@andoniaina/react-modal 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.es.js +133 -106
- package/package.json +2 -1
- package/dist/react-modal.css +0 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const N=require("react");var w={exports:{}},_={};var L;function te(){if(L)return _;L=1;var s=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function i(f,o,l){var d=null;if(l!==void 0&&(d=""+l),o.key!==void 0&&(d=""+o.key),"key"in o){l={};for(var m in o)m!=="key"&&(l[m]=o[m])}else l=o;return o=l.ref,{$$typeof:s,type:f,key:d,ref:o!==void 0?o:null,props:l}}return _.Fragment=u,_.jsx=i,_.jsxs=i,_}var R={};var M;function ne(){return M||(M=1,process.env.NODE_ENV!=="production"&&(function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===K?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case g:return"Fragment";case z:return"Profiler";case q:return"StrictMode";case H:return"Suspense";case Z:return"SuspenseList";case Q:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case V:return"Portal";case G:return e.displayName||"Context";case J:return(e._context.displayName||"Context")+".Consumer";case X:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case B:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case A:r=e._payload,e=e._init;try{return s(e(r))}catch{}}return null}function u(e){return""+e}function i(e){try{u(e);var r=!1}catch{r=!0}if(r){r=console;var t=r.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t.call(r,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),u(e)}}function f(e){if(e===g)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===A)return"<...>";try{var r=s(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function o(){var e=j.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function d(e){if(C.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function m(e,r){function t(){Y||(Y=!0,console.error("%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://react.dev/link/special-props)",r))}t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}function h(){var e=s(this.type);return $[e]||($[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function T(e,r,t,n,y,S){var a=t.ref;return e={$$typeof:x,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:h}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:y}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:S}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function v(e,r,t,n,y,S){var a=r.children;if(a!==void 0)if(n)if(ee(a)){for(n=0;n<a.length;n++)k(a[n]);Object.freeze&&Object.freeze(a)}else console.error("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 k(a);if(C.call(r,"key")){a=s(e);var E=Object.keys(r).filter(function(re){return re!=="key"});n=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",F[a+n]||(E=0<E.length?"{"+E.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,n,a,E,a),
|
|
6
|
+
<%s key={someKey} {...props} />`,n,a,E,a),F[a+n]=!0)}if(a=null,t!==void 0&&(i(t),a=""+t),d(r)&&(i(r.key),a=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return a&&m(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,a,t,o(),y,S)}function k(e){b(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===A&&(e._payload.status==="fulfilled"?b(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function b(e){return typeof e=="object"&&e!==null&&e.$$typeof===x}var c=N,x=Symbol.for("react.transitional.element"),V=Symbol.for("react.portal"),g=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),J=Symbol.for("react.consumer"),G=Symbol.for("react.context"),X=Symbol.for("react.forward_ref"),H=Symbol.for("react.suspense"),Z=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),A=Symbol.for("react.lazy"),Q=Symbol.for("react.activity"),K=Symbol.for("react.client.reference"),j=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,ee=Array.isArray,O=console.createTask?console.createTask:function(){return null};c={react_stack_bottom_frame:function(e){return e()}};var Y,$={},I=c.react_stack_bottom_frame.bind(c,l)(),D=O(f(l)),F={};R.Fragment=g,R.jsx=function(e,r,t){var n=1e4>j.recentlyCreatedOwnerStacks++;return v(e,r,t,!1,n?Error("react-stack-top-frame"):I,n?O(f(e)):D)},R.jsxs=function(e,r,t){var n=1e4>j.recentlyCreatedOwnerStacks++;return v(e,r,t,!0,n?Error("react-stack-top-frame"):I,n?O(f(e)):D)}})()),R}var W;function ae(){return W||(W=1,process.env.NODE_ENV==="production"?w.exports=te():w.exports=ne()),w.exports}var p=ae();const U={default:{border:"border-gray-200",icon:null},success:{border:"border-green-500",title:"text-green-600"},error:{border:"border-red-500",title:"text-red-600"}};function oe({isOpen:s,onClose:u,children:i,variant:f="default",closeOnEsc:o=!0,closeOnOverlayClick:l=!0,animationDuration:d=300,onBeforeOpen:m,onAfterOpen:h,onBeforeClose:T,onAfterClose:v}){if(N.useEffect(()=>(s?(m?.(),h?.(),document.body.style.overflow="hidden"):document.body.style.overflow="",()=>{document.body.style.overflow=""}),[s]),N.useEffect(()=>{if(!o)return;const c=x=>{x.key==="Escape"&&(T?.(),u(),v?.())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[o,u]),!s)return null;const k=()=>{l&&(T?.(),u(),v?.())},b=U[f]||U.default;return p.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 transition-opacity",style:{transitionDuration:`${d}ms`},onClick:k,role:"dialog","aria-modal":"true",children:p.jsxs("div",{className:`relative w-[90%] max-w-md rounded-xl bg-white px-10 py-8 text-center shadow-xl border-2 ${b.border} animate-fadeIn`,onClick:c=>c.stopPropagation(),children:[b.icon&&p.jsx("div",{className:"mb-4 text-4xl",children:b.icon}),p.jsx("button",{className:"absolute top-3 right-3 text-2xl font-bold text-gray-500 hover:text-black",onClick:u,"aria-label":"Close modal",children:"×"}),p.jsx("div",{className:b.title,children:i})]})})}module.exports=oe;
|
package/dist/index.es.js
CHANGED
|
@@ -1,64 +1,64 @@
|
|
|
1
|
-
import
|
|
1
|
+
import te, { useEffect as F } from "react";
|
|
2
2
|
var w = { exports: {} }, _ = {};
|
|
3
|
-
var
|
|
4
|
-
function
|
|
5
|
-
if (
|
|
6
|
-
|
|
3
|
+
var L;
|
|
4
|
+
function ne() {
|
|
5
|
+
if (L) return _;
|
|
6
|
+
L = 1;
|
|
7
7
|
var s = /* @__PURE__ */ Symbol.for("react.transitional.element"), u = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
-
function i(
|
|
9
|
-
var
|
|
10
|
-
if (l !== void 0 && (
|
|
8
|
+
function i(f, o, l) {
|
|
9
|
+
var d = null;
|
|
10
|
+
if (l !== void 0 && (d = "" + l), o.key !== void 0 && (d = "" + o.key), "key" in o) {
|
|
11
11
|
l = {};
|
|
12
|
-
for (var
|
|
13
|
-
|
|
12
|
+
for (var m in o)
|
|
13
|
+
m !== "key" && (l[m] = o[m]);
|
|
14
14
|
} else l = o;
|
|
15
15
|
return o = l.ref, {
|
|
16
16
|
$$typeof: s,
|
|
17
|
-
type:
|
|
18
|
-
key:
|
|
17
|
+
type: f,
|
|
18
|
+
key: d,
|
|
19
19
|
ref: o !== void 0 ? o : null,
|
|
20
20
|
props: l
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
return _.Fragment = u, _.jsx = i, _.jsxs = i, _;
|
|
24
24
|
}
|
|
25
|
-
var
|
|
26
|
-
var
|
|
27
|
-
function
|
|
28
|
-
return
|
|
25
|
+
var R = {};
|
|
26
|
+
var M;
|
|
27
|
+
function ae() {
|
|
28
|
+
return M || (M = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
29
|
function s(e) {
|
|
30
30
|
if (e == null) return null;
|
|
31
31
|
if (typeof e == "function")
|
|
32
|
-
return e.$$typeof ===
|
|
32
|
+
return e.$$typeof === K ? null : e.displayName || e.name || null;
|
|
33
33
|
if (typeof e == "string") return e;
|
|
34
34
|
switch (e) {
|
|
35
|
-
case
|
|
35
|
+
case g:
|
|
36
36
|
return "Fragment";
|
|
37
|
-
case
|
|
37
|
+
case z:
|
|
38
38
|
return "Profiler";
|
|
39
39
|
case q:
|
|
40
40
|
return "StrictMode";
|
|
41
|
-
case X:
|
|
42
|
-
return "Suspense";
|
|
43
41
|
case H:
|
|
42
|
+
return "Suspense";
|
|
43
|
+
case Z:
|
|
44
44
|
return "SuspenseList";
|
|
45
|
-
case
|
|
45
|
+
case Q:
|
|
46
46
|
return "Activity";
|
|
47
47
|
}
|
|
48
48
|
if (typeof e == "object")
|
|
49
49
|
switch (typeof e.tag == "number" && console.error(
|
|
50
50
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
51
51
|
), e.$$typeof) {
|
|
52
|
-
case
|
|
52
|
+
case V:
|
|
53
53
|
return "Portal";
|
|
54
|
-
case
|
|
54
|
+
case G:
|
|
55
55
|
return e.displayName || "Context";
|
|
56
|
-
case
|
|
56
|
+
case J:
|
|
57
57
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
58
|
-
case
|
|
58
|
+
case X:
|
|
59
59
|
var r = e.render;
|
|
60
60
|
return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
61
|
-
case
|
|
61
|
+
case B:
|
|
62
62
|
return r = e.displayName || null, r !== null ? r : s(e.type) || "Memo";
|
|
63
63
|
case A:
|
|
64
64
|
r = e._payload, e = e._init;
|
|
@@ -89,8 +89,8 @@ function ne() {
|
|
|
89
89
|
), u(e);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
function
|
|
93
|
-
if (e ===
|
|
92
|
+
function f(e) {
|
|
93
|
+
if (e === g) return "<>";
|
|
94
94
|
if (typeof e == "object" && e !== null && e.$$typeof === A)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
@@ -101,22 +101,22 @@ function ne() {
|
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
function o() {
|
|
104
|
-
var e =
|
|
104
|
+
var e = j.A;
|
|
105
105
|
return e === null ? null : e.getOwner();
|
|
106
106
|
}
|
|
107
107
|
function l() {
|
|
108
108
|
return Error("react-stack-top-frame");
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (
|
|
110
|
+
function d(e) {
|
|
111
|
+
if (N.call(e, "key")) {
|
|
112
112
|
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
113
113
|
if (r && r.isReactWarning) return !1;
|
|
114
114
|
}
|
|
115
115
|
return e.key !== void 0;
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function m(e, r) {
|
|
118
118
|
function t() {
|
|
119
|
-
|
|
119
|
+
C || (C = !0, console.error(
|
|
120
120
|
"%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://react.dev/link/special-props)",
|
|
121
121
|
r
|
|
122
122
|
));
|
|
@@ -126,23 +126,23 @@ function ne() {
|
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function h() {
|
|
130
130
|
var e = s(this.type);
|
|
131
|
-
return
|
|
131
|
+
return Y[e] || (Y[e] = !0, console.error(
|
|
132
132
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
133
133
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function T(e, r, t, n, y, S) {
|
|
136
136
|
var a = t.ref;
|
|
137
137
|
return e = {
|
|
138
|
-
$$typeof:
|
|
138
|
+
$$typeof: x,
|
|
139
139
|
type: e,
|
|
140
140
|
key: r,
|
|
141
141
|
props: t,
|
|
142
142
|
_owner: n
|
|
143
143
|
}, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
|
-
get:
|
|
145
|
+
get: h
|
|
146
146
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
147
147
|
configurable: !1,
|
|
148
148
|
enumerable: !1,
|
|
@@ -162,28 +162,28 @@ function ne() {
|
|
|
162
162
|
configurable: !1,
|
|
163
163
|
enumerable: !1,
|
|
164
164
|
writable: !0,
|
|
165
|
-
value:
|
|
165
|
+
value: S
|
|
166
166
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function v(e, r, t, n, y, S) {
|
|
169
169
|
var a = r.children;
|
|
170
170
|
if (a !== void 0)
|
|
171
171
|
if (n)
|
|
172
|
-
if (
|
|
172
|
+
if (ee(a)) {
|
|
173
173
|
for (n = 0; n < a.length; n++)
|
|
174
|
-
|
|
174
|
+
k(a[n]);
|
|
175
175
|
Object.freeze && Object.freeze(a);
|
|
176
176
|
} else
|
|
177
177
|
console.error(
|
|
178
178
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
179
179
|
);
|
|
180
|
-
else
|
|
181
|
-
if (
|
|
180
|
+
else k(a);
|
|
181
|
+
if (N.call(r, "key")) {
|
|
182
182
|
a = s(e);
|
|
183
|
-
var E = Object.keys(r).filter(function(
|
|
184
|
-
return
|
|
183
|
+
var E = Object.keys(r).filter(function(re) {
|
|
184
|
+
return re !== "key";
|
|
185
185
|
});
|
|
186
|
-
n = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}",
|
|
186
|
+
n = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", D[a + n] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
187
187
|
`A props object containing a "key" prop is being spread into JSX:
|
|
188
188
|
let props = %s;
|
|
189
189
|
<%s {...props} />
|
|
@@ -194,114 +194,141 @@ React keys must be passed directly to JSX without using spread:
|
|
|
194
194
|
a,
|
|
195
195
|
E,
|
|
196
196
|
a
|
|
197
|
-
),
|
|
197
|
+
), D[a + n] = !0);
|
|
198
198
|
}
|
|
199
|
-
if (a = null, t !== void 0 && (i(t), a = "" + t),
|
|
199
|
+
if (a = null, t !== void 0 && (i(t), a = "" + t), d(r) && (i(r.key), a = "" + r.key), "key" in r) {
|
|
200
200
|
t = {};
|
|
201
|
-
for (var
|
|
202
|
-
|
|
201
|
+
for (var P in r)
|
|
202
|
+
P !== "key" && (t[P] = r[P]);
|
|
203
203
|
} else t = r;
|
|
204
|
-
return a &&
|
|
204
|
+
return a && m(
|
|
205
205
|
t,
|
|
206
206
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
|
-
),
|
|
207
|
+
), T(
|
|
208
208
|
e,
|
|
209
209
|
a,
|
|
210
210
|
t,
|
|
211
211
|
o(),
|
|
212
212
|
y,
|
|
213
|
-
|
|
213
|
+
S
|
|
214
214
|
);
|
|
215
215
|
}
|
|
216
|
-
function
|
|
217
|
-
|
|
216
|
+
function k(e) {
|
|
217
|
+
b(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === A && (e._payload.status === "fulfilled" ? b(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
218
|
}
|
|
219
|
-
function
|
|
220
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
219
|
+
function b(e) {
|
|
220
|
+
return typeof e == "object" && e !== null && e.$$typeof === x;
|
|
221
221
|
}
|
|
222
|
-
var
|
|
222
|
+
var c = te, x = /* @__PURE__ */ Symbol.for("react.transitional.element"), V = /* @__PURE__ */ Symbol.for("react.portal"), g = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), z = /* @__PURE__ */ Symbol.for("react.profiler"), J = /* @__PURE__ */ Symbol.for("react.consumer"), G = /* @__PURE__ */ Symbol.for("react.context"), X = /* @__PURE__ */ Symbol.for("react.forward_ref"), H = /* @__PURE__ */ Symbol.for("react.suspense"), Z = /* @__PURE__ */ Symbol.for("react.suspense_list"), B = /* @__PURE__ */ Symbol.for("react.memo"), A = /* @__PURE__ */ Symbol.for("react.lazy"), Q = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), j = c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, ee = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
223
223
|
return null;
|
|
224
224
|
};
|
|
225
|
-
|
|
225
|
+
c = {
|
|
226
226
|
react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
}
|
|
229
229
|
};
|
|
230
|
-
var
|
|
231
|
-
|
|
230
|
+
var C, Y = {}, $ = c.react_stack_bottom_frame.bind(
|
|
231
|
+
c,
|
|
232
232
|
l
|
|
233
|
-
)(),
|
|
234
|
-
|
|
235
|
-
var n = 1e4 >
|
|
236
|
-
return
|
|
233
|
+
)(), I = O(f(l)), D = {};
|
|
234
|
+
R.Fragment = g, R.jsx = function(e, r, t) {
|
|
235
|
+
var n = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return v(
|
|
237
237
|
e,
|
|
238
238
|
r,
|
|
239
239
|
t,
|
|
240
240
|
!1,
|
|
241
|
-
n ? Error("react-stack-top-frame") :
|
|
242
|
-
n ?
|
|
241
|
+
n ? Error("react-stack-top-frame") : $,
|
|
242
|
+
n ? O(f(e)) : I
|
|
243
243
|
);
|
|
244
|
-
},
|
|
245
|
-
var n = 1e4 >
|
|
246
|
-
return
|
|
244
|
+
}, R.jsxs = function(e, r, t) {
|
|
245
|
+
var n = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return v(
|
|
247
247
|
e,
|
|
248
248
|
r,
|
|
249
249
|
t,
|
|
250
250
|
!0,
|
|
251
|
-
n ? Error("react-stack-top-frame") :
|
|
252
|
-
n ?
|
|
251
|
+
n ? Error("react-stack-top-frame") : $,
|
|
252
|
+
n ? O(f(e)) : I
|
|
253
253
|
);
|
|
254
254
|
};
|
|
255
|
-
})()),
|
|
255
|
+
})()), R;
|
|
256
256
|
}
|
|
257
|
-
var
|
|
258
|
-
function
|
|
259
|
-
return
|
|
257
|
+
var W;
|
|
258
|
+
function oe() {
|
|
259
|
+
return W || (W = 1, process.env.NODE_ENV === "production" ? w.exports = ne() : w.exports = ae()), w.exports;
|
|
260
260
|
}
|
|
261
|
-
var
|
|
262
|
-
|
|
261
|
+
var p = oe();
|
|
262
|
+
const U = {
|
|
263
|
+
default: {
|
|
264
|
+
border: "border-gray-200",
|
|
265
|
+
icon: null
|
|
266
|
+
},
|
|
267
|
+
success: {
|
|
268
|
+
border: "border-green-500",
|
|
269
|
+
title: "text-green-600"
|
|
270
|
+
},
|
|
271
|
+
error: {
|
|
272
|
+
border: "border-red-500",
|
|
273
|
+
title: "text-red-600"
|
|
274
|
+
}
|
|
275
|
+
};
|
|
276
|
+
function se({
|
|
263
277
|
isOpen: s,
|
|
264
278
|
onClose: u,
|
|
265
279
|
children: i,
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
280
|
+
variant: f = "default",
|
|
281
|
+
closeOnEsc: o = !0,
|
|
282
|
+
closeOnOverlayClick: l = !0,
|
|
283
|
+
animationDuration: d = 300,
|
|
284
|
+
onBeforeOpen: m,
|
|
285
|
+
onAfterOpen: h,
|
|
286
|
+
onBeforeClose: T,
|
|
287
|
+
onAfterClose: v
|
|
273
288
|
}) {
|
|
274
|
-
if (
|
|
289
|
+
if (F(() => (s ? (m?.(), h?.(), document.body.style.overflow = "hidden") : document.body.style.overflow = "", () => {
|
|
275
290
|
document.body.style.overflow = "";
|
|
276
|
-
}), [s]),
|
|
277
|
-
if (!
|
|
278
|
-
const
|
|
279
|
-
|
|
291
|
+
}), [s]), F(() => {
|
|
292
|
+
if (!o) return;
|
|
293
|
+
const c = (x) => {
|
|
294
|
+
x.key === "Escape" && (T?.(), u(), v?.());
|
|
280
295
|
};
|
|
281
|
-
return document.addEventListener("keydown",
|
|
282
|
-
}, [
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
};
|
|
286
|
-
return /* @__PURE__ */
|
|
296
|
+
return document.addEventListener("keydown", c), () => document.removeEventListener("keydown", c);
|
|
297
|
+
}, [o, u]), !s) return null;
|
|
298
|
+
const k = () => {
|
|
299
|
+
l && (T?.(), u(), v?.());
|
|
300
|
+
}, b = U[f] || U.default;
|
|
301
|
+
return /* @__PURE__ */ p.jsx(
|
|
287
302
|
"div",
|
|
288
303
|
{
|
|
289
|
-
className: "
|
|
290
|
-
style: { transitionDuration: `${
|
|
291
|
-
onClick:
|
|
304
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 transition-opacity",
|
|
305
|
+
style: { transitionDuration: `${d}ms` },
|
|
306
|
+
onClick: k,
|
|
292
307
|
role: "dialog",
|
|
293
308
|
"aria-modal": "true",
|
|
294
|
-
children: /* @__PURE__ */
|
|
309
|
+
children: /* @__PURE__ */ p.jsxs(
|
|
295
310
|
"div",
|
|
296
311
|
{
|
|
297
|
-
className:
|
|
298
|
-
onClick: (
|
|
299
|
-
children:
|
|
312
|
+
className: `relative w-[90%] max-w-md rounded-xl bg-white px-10 py-8 text-center shadow-xl border-2 ${b.border} animate-fadeIn`,
|
|
313
|
+
onClick: (c) => c.stopPropagation(),
|
|
314
|
+
children: [
|
|
315
|
+
b.icon && /* @__PURE__ */ p.jsx("div", { className: "mb-4 text-4xl", children: b.icon }),
|
|
316
|
+
/* @__PURE__ */ p.jsx(
|
|
317
|
+
"button",
|
|
318
|
+
{
|
|
319
|
+
className: "absolute top-3 right-3 text-2xl font-bold text-gray-500 hover:text-black",
|
|
320
|
+
onClick: u,
|
|
321
|
+
"aria-label": "Close modal",
|
|
322
|
+
children: "×"
|
|
323
|
+
}
|
|
324
|
+
),
|
|
325
|
+
/* @__PURE__ */ p.jsx("div", { className: b.title, children: i })
|
|
326
|
+
]
|
|
300
327
|
}
|
|
301
328
|
)
|
|
302
329
|
}
|
|
303
330
|
);
|
|
304
331
|
}
|
|
305
332
|
export {
|
|
306
|
-
|
|
333
|
+
se as default
|
|
307
334
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andoniaina/react-modal",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "Reusable, accessible and customizable React modal component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
"files": [
|
|
10
10
|
"dist"
|
|
11
11
|
],
|
|
12
|
+
"style": "dist/react-modal.css",
|
|
12
13
|
"exports": {
|
|
13
14
|
".": {
|
|
14
15
|
"types": "./dist/index.d.ts",
|
package/dist/react-modal.css
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.modal-overlay{position:fixed;inset:0;background:#0009;opacity:0;display:flex;align-items:center;justify-content:center;transition:opacity ease-in-out;z-index:1000}.modal-overlay.show{opacity:1}.modal-content{background:#fff;padding:24px;border-radius:6px;min-width:300px;max-width:90%}
|