@andoniaina/react-modal 1.0.8 → 1.1.0
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 +12 -11
- package/package.json +1 -3
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
"use strict";Object.
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const N=require("react");var g={exports:{}},_={};var F;function ne(){if(F)return _;F=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 L;function ae(){return L||(L=1,process.env.NODE_ENV!=="production"&&(function(){function s(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ee?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case h:return"Fragment";case J:return"Profiler";case z:return"StrictMode";case Z:return"Suspense";case B:return"SuspenseList";case K: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 q:return"Portal";case X:return e.displayName||"Context";case G:return(e._context.displayName||"Context")+".Consumer";case H:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Q:return r=e.displayName||null,r!==null?r:s(e.type)||"Memo";case S: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===h)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===S)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 w(){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,O){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:w}):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:O}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function v(e,r,t,n,y,O){var a=r.children;if(a!==void 0)if(n)if(re(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(te){return te!=="key"});n=0<E.length?"{key: someKey, "+E.join(": ..., ")+": ...}":"{key: someKey}",D[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),D[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,O)}function k(e){b(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===S&&(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"),q=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),z=Symbol.for("react.strict_mode"),J=Symbol.for("react.profiler"),G=Symbol.for("react.consumer"),X=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),Z=Symbol.for("react.suspense"),B=Symbol.for("react.suspense_list"),Q=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),K=Symbol.for("react.activity"),ee=Symbol.for("react.client.reference"),j=c.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,C=Object.prototype.hasOwnProperty,re=Array.isArray,A=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)(),M=A(f(l)),D={};R.Fragment=h,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?A(f(e)):M)},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?A(f(e)):M)}})()),R}var W;function oe(){return W||(W=1,process.env.NODE_ENV==="production"?g.exports=ne():g.exports=ae()),g.exports}var p=oe();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 V({isOpen:s,onClose:u,children:i,variant:f="default",closeOnEsc:o=!0,closeOnOverlayClick:l=!0,animationDuration:d=300,onBeforeOpen:m,onAfterOpen:w,onBeforeClose:T,onAfterClose:v}){if(N.useEffect(()=>(s?(m?.(),w?.(),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 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-blue 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})]})})}exports.Modal=V;exports.default=V;
|
package/dist/index.es.js
CHANGED
|
@@ -32,7 +32,7 @@ function ae() {
|
|
|
32
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 h:
|
|
36
36
|
return "Fragment";
|
|
37
37
|
case z:
|
|
38
38
|
return "Profiler";
|
|
@@ -90,7 +90,7 @@ function ae() {
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
function f(e) {
|
|
93
|
-
if (e ===
|
|
93
|
+
if (e === h) return "<>";
|
|
94
94
|
if (typeof e == "object" && e !== null && e.$$typeof === A)
|
|
95
95
|
return "<...>";
|
|
96
96
|
try {
|
|
@@ -126,7 +126,7 @@ function ae() {
|
|
|
126
126
|
configurable: !0
|
|
127
127
|
});
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function g() {
|
|
130
130
|
var e = s(this.type);
|
|
131
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."
|
|
@@ -142,7 +142,7 @@ function ae() {
|
|
|
142
142
|
_owner: n
|
|
143
143
|
}, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
|
|
144
144
|
enumerable: !1,
|
|
145
|
-
get:
|
|
145
|
+
get: g
|
|
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,
|
|
@@ -219,7 +219,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
219
219
|
function b(e) {
|
|
220
220
|
return typeof e == "object" && e !== null && e.$$typeof === x;
|
|
221
221
|
}
|
|
222
|
-
var c = te, x = /* @__PURE__ */ Symbol.for("react.transitional.element"), V = /* @__PURE__ */ Symbol.for("react.portal"),
|
|
222
|
+
var c = te, x = /* @__PURE__ */ Symbol.for("react.transitional.element"), V = /* @__PURE__ */ Symbol.for("react.portal"), h = /* @__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 = {
|
|
@@ -231,7 +231,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
231
231
|
c,
|
|
232
232
|
l
|
|
233
233
|
)(), I = O(f(l)), D = {};
|
|
234
|
-
R.Fragment =
|
|
234
|
+
R.Fragment = h, R.jsx = function(e, r, t) {
|
|
235
235
|
var n = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
236
236
|
return v(
|
|
237
237
|
e,
|
|
@@ -282,11 +282,11 @@ function se({
|
|
|
282
282
|
closeOnOverlayClick: l = !0,
|
|
283
283
|
animationDuration: d = 300,
|
|
284
284
|
onBeforeOpen: m,
|
|
285
|
-
onAfterOpen:
|
|
285
|
+
onAfterOpen: g,
|
|
286
286
|
onBeforeClose: T,
|
|
287
287
|
onAfterClose: v
|
|
288
288
|
}) {
|
|
289
|
-
if (F(() => (s ? (m?.(),
|
|
289
|
+
if (F(() => (s ? (m?.(), g?.(), document.body.style.overflow = "hidden") : document.body.style.overflow = "", () => {
|
|
290
290
|
document.body.style.overflow = "";
|
|
291
291
|
}), [s]), F(() => {
|
|
292
292
|
if (!o) return;
|
|
@@ -301,7 +301,7 @@ function se({
|
|
|
301
301
|
return /* @__PURE__ */ p.jsx(
|
|
302
302
|
"div",
|
|
303
303
|
{
|
|
304
|
-
className: "fixed inset-0 z-50 flex items-center justify-center bg-black
|
|
304
|
+
className: "fixed inset-0 z-50 flex items-center justify-center bg-black transition-opacity",
|
|
305
305
|
style: { transitionDuration: `${d}ms` },
|
|
306
306
|
onClick: k,
|
|
307
307
|
role: "dialog",
|
|
@@ -309,7 +309,7 @@ function se({
|
|
|
309
309
|
children: /* @__PURE__ */ p.jsxs(
|
|
310
310
|
"div",
|
|
311
311
|
{
|
|
312
|
-
className: `relative w-[90%] max-w-md rounded-xl bg-
|
|
312
|
+
className: `relative w-[90%] max-w-md rounded-xl bg-blue px-10 py-8 text-center shadow-xl border-2 ${b.border} animate-fadeIn`,
|
|
313
313
|
onClick: (c) => c.stopPropagation(),
|
|
314
314
|
children: [
|
|
315
315
|
b.icon && /* @__PURE__ */ p.jsx("div", { className: "mb-4 text-4xl", children: b.icon }),
|
|
@@ -330,5 +330,6 @@ function se({
|
|
|
330
330
|
);
|
|
331
331
|
}
|
|
332
332
|
export {
|
|
333
|
-
se as Modal
|
|
333
|
+
se as Modal,
|
|
334
|
+
se as default
|
|
334
335
|
};
|
package/package.json
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@andoniaina/react-modal",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Reusable, accessible and customizable React modal component",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs.js",
|
|
7
7
|
"module": "dist/index.es.js",
|
|
8
|
-
"types": "dist/index.d.ts",
|
|
9
8
|
"files": [
|
|
10
9
|
"dist"
|
|
11
10
|
],
|
|
12
11
|
"style": "dist/react-modal.css",
|
|
13
12
|
"exports": {
|
|
14
13
|
".": {
|
|
15
|
-
"types": "./dist/index.d.ts",
|
|
16
14
|
"import": "./dist/index.es.js",
|
|
17
15
|
"require": "./dist/index.cjs.js"
|
|
18
16
|
}
|