@andoniaina/react-modal 1.0.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/README.md ADDED
@@ -0,0 +1,96 @@
1
+ đŸ§© ProblĂ©matique initiale
2
+ Limites de la solution jQuery
3
+
4
+ Manipulation directe du DOM
5
+
6
+ Couplage fort entre HTML et JavaScript
7
+
8
+ Difficulté de maintenance à grande échelle
9
+
10
+ Dépendance à une librairie externe (jQuery)
11
+
12
+ Intégration complexe dans une application React
13
+
14
+ 👉 Dans une application React, l’utilisation de jQuery va à l’encontre du Virtual DOM et des bonnes pratiques React.
15
+
16
+ 🔄 Solution mise en place
17
+
18
+ Le plugin jquery-modal a Ă©tĂ© remplacĂ© par un composant React contrĂŽlĂ© par l’état (state), respectant :
19
+
20
+ le flux de données unidirectionnel
21
+
22
+ la logique déclarative de React
23
+
24
+ la réutilisabilité des composants
25
+
26
+ 🔍 Comparaison fonctionnelle
27
+ Fonctionnalité jquery-modal React Modal
28
+ Ouverture / fermeture Attribut HTML + JS State React
29
+ Overlay Oui Oui
30
+ Fermeture par ESC Oui Oui
31
+ Fermeture par clic Oui Oui
32
+ Animation jQuery CSS
33
+ ÉvĂ©nements jQuery events Props & callbacks
34
+ Accessibilité Limitée aria-modal, role="dialog"
35
+ Dépendance externe jQuery Aucune
36
+
37
+ 🧠 DiffĂ©rence de paradigme
38
+ Approche jQuery (impérative)
39
+ <a href="#modal" rel="modal:open">Open</a>
40
+
41
+ $('#modal').modal({ escapeClose: true });
42
+
43
+ - Le DOM est modifié directement
44
+ - Le comportement dépend de sélecteurs
45
+ - La logique est dispersée
46
+
47
+ Approche React (déclarative)
48
+ const [isOpen, setIsOpen] = useState(false);
49
+
50
+ <Modal isOpen={isOpen} onClose={() => setIsOpen(false)}>
51
+ Contenu du modal
52
+ </Modal>
53
+
54
+ - L’UI dĂ©pend de l’état
55
+ - La logique est centralisée
56
+ - Le composant est réutilisable
57
+
58
+ 🔁 Correspondance des API
59
+ jquery-modal Implémentation React
60
+ rel="modal:open" <ModalTrigger />
61
+ $.modal.close() setIsOpen(false)
62
+ escapeClose closeOnEsc
63
+ clickClose closeOnOverlayClick
64
+ fadeDuration animationDuration
65
+ modal:open onAfterOpen
66
+ modal:close onAfterClose
67
+
68
+ đŸ§± Architecture du composant
69
+ src/
70
+ ├── components/
71
+ │ ├── Modal/
72
+ │ │ ├── Modal.jsx
73
+ │ │ └── Modal.css
74
+ │ └── ModalTrigger.jsx
75
+ ├── App.jsx
76
+
77
+ - Modal.jsx : gestion de l’ouverture, fermeture et Ă©vĂ©nements
78
+ - Modal.css : styles et animations
79
+ - ModalTrigger.jsx : remplacement du déclenchement jQuery
80
+
81
+ ♿ AccessibilitĂ©
82
+ Le composant React respecte les bonnes pratiques d’accessibilitĂ© :
83
+ * role="dialog"
84
+ * aria-modal="true"
85
+ * Fermeture via la touche Escape
86
+ * Blocage du scroll du body lors de l’ouverture
87
+
88
+ Ces Ă©lĂ©ments amĂ©liorent l’expĂ©rience utilisateur par rapport Ă  la version jQuery.
89
+
90
+ ✅ BĂ©nĂ©fices de la migration
91
+
92
+ ❌ Suppression complùte de jQuery
93
+ ♻ Code plus maintenable
94
+ 🧠 Logique centralisĂ©e
95
+ 🚀 IntĂ©gration native dans React
96
+ 📈 Performance et lisibilitĂ© amĂ©liorĂ©es
@@ -0,0 +1 @@
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%}
@@ -0,0 +1,307 @@
1
+ import re, { useEffect as D } from "react";
2
+ var w = { exports: {} }, _ = {};
3
+ var F;
4
+ function te() {
5
+ if (F) return _;
6
+ F = 1;
7
+ var s = /* @__PURE__ */ Symbol.for("react.transitional.element"), u = /* @__PURE__ */ Symbol.for("react.fragment");
8
+ function i(c, o, l) {
9
+ var f = null;
10
+ if (l !== void 0 && (f = "" + l), o.key !== void 0 && (f = "" + o.key), "key" in o) {
11
+ l = {};
12
+ for (var d in o)
13
+ d !== "key" && (l[d] = o[d]);
14
+ } else l = o;
15
+ return o = l.ref, {
16
+ $$typeof: s,
17
+ type: c,
18
+ key: f,
19
+ ref: o !== void 0 ? o : null,
20
+ props: l
21
+ };
22
+ }
23
+ return _.Fragment = u, _.jsx = i, _.jsxs = i, _;
24
+ }
25
+ var v = {};
26
+ var L;
27
+ function ne() {
28
+ return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
29
+ function s(e) {
30
+ if (e == null) return null;
31
+ if (typeof e == "function")
32
+ return e.$$typeof === Q ? null : e.displayName || e.name || null;
33
+ if (typeof e == "string") return e;
34
+ switch (e) {
35
+ case O:
36
+ return "Fragment";
37
+ case J:
38
+ return "Profiler";
39
+ case q:
40
+ return "StrictMode";
41
+ case X:
42
+ return "Suspense";
43
+ case H:
44
+ return "SuspenseList";
45
+ case B:
46
+ return "Activity";
47
+ }
48
+ if (typeof e == "object")
49
+ switch (typeof e.tag == "number" && console.error(
50
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
51
+ ), e.$$typeof) {
52
+ case U:
53
+ return "Portal";
54
+ case z:
55
+ return e.displayName || "Context";
56
+ case V:
57
+ return (e._context.displayName || "Context") + ".Consumer";
58
+ case G:
59
+ var r = e.render;
60
+ return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
61
+ case Z:
62
+ return r = e.displayName || null, r !== null ? r : s(e.type) || "Memo";
63
+ case A:
64
+ r = e._payload, e = e._init;
65
+ try {
66
+ return s(e(r));
67
+ } catch {
68
+ }
69
+ }
70
+ return null;
71
+ }
72
+ function u(e) {
73
+ return "" + e;
74
+ }
75
+ function i(e) {
76
+ try {
77
+ u(e);
78
+ var r = !1;
79
+ } catch {
80
+ r = !0;
81
+ }
82
+ if (r) {
83
+ r = console;
84
+ var t = r.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
85
+ return t.call(
86
+ r,
87
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
88
+ n
89
+ ), u(e);
90
+ }
91
+ }
92
+ function c(e) {
93
+ if (e === O) return "<>";
94
+ if (typeof e == "object" && e !== null && e.$$typeof === A)
95
+ return "<...>";
96
+ try {
97
+ var r = s(e);
98
+ return r ? "<" + r + ">" : "<...>";
99
+ } catch {
100
+ return "<...>";
101
+ }
102
+ }
103
+ function o() {
104
+ var e = P.A;
105
+ return e === null ? null : e.getOwner();
106
+ }
107
+ function l() {
108
+ return Error("react-stack-top-frame");
109
+ }
110
+ function f(e) {
111
+ if (g.call(e, "key")) {
112
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
113
+ if (r && r.isReactWarning) return !1;
114
+ }
115
+ return e.key !== void 0;
116
+ }
117
+ function d(e, r) {
118
+ function t() {
119
+ N || (N = !0, console.error(
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
+ r
122
+ ));
123
+ }
124
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
125
+ get: t,
126
+ configurable: !0
127
+ });
128
+ }
129
+ function R() {
130
+ var e = s(this.type);
131
+ return C[e] || (C[e] = !0, console.error(
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
+ )), e = this.props.ref, e !== void 0 ? e : null;
134
+ }
135
+ function b(e, r, t, n, y, h) {
136
+ var a = t.ref;
137
+ return e = {
138
+ $$typeof: j,
139
+ type: e,
140
+ key: r,
141
+ props: t,
142
+ _owner: n
143
+ }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
144
+ enumerable: !1,
145
+ get: R
146
+ }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
147
+ configurable: !1,
148
+ enumerable: !1,
149
+ writable: !0,
150
+ value: 0
151
+ }), Object.defineProperty(e, "_debugInfo", {
152
+ configurable: !1,
153
+ enumerable: !1,
154
+ writable: !0,
155
+ value: null
156
+ }), Object.defineProperty(e, "_debugStack", {
157
+ configurable: !1,
158
+ enumerable: !1,
159
+ writable: !0,
160
+ value: y
161
+ }), Object.defineProperty(e, "_debugTask", {
162
+ configurable: !1,
163
+ enumerable: !1,
164
+ writable: !0,
165
+ value: h
166
+ }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
167
+ }
168
+ function p(e, r, t, n, y, h) {
169
+ var a = r.children;
170
+ if (a !== void 0)
171
+ if (n)
172
+ if (K(a)) {
173
+ for (n = 0; n < a.length; n++)
174
+ m(a[n]);
175
+ Object.freeze && Object.freeze(a);
176
+ } else
177
+ console.error(
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
+ );
180
+ else m(a);
181
+ if (g.call(r, "key")) {
182
+ a = s(e);
183
+ var E = Object.keys(r).filter(function(ee) {
184
+ return ee !== "key";
185
+ });
186
+ n = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", I[a + n] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ `A props object containing a "key" prop is being spread into JSX:
188
+ let props = %s;
189
+ <%s {...props} />
190
+ React keys must be passed directly to JSX without using spread:
191
+ let props = %s;
192
+ <%s key={someKey} {...props} />`,
193
+ n,
194
+ a,
195
+ E,
196
+ a
197
+ ), I[a + n] = !0);
198
+ }
199
+ if (a = null, t !== void 0 && (i(t), a = "" + t), f(r) && (i(r.key), a = "" + r.key), "key" in r) {
200
+ t = {};
201
+ for (var x in r)
202
+ x !== "key" && (t[x] = r[x]);
203
+ } else t = r;
204
+ return a && d(
205
+ t,
206
+ typeof e == "function" ? e.displayName || e.name || "Unknown" : e
207
+ ), b(
208
+ e,
209
+ a,
210
+ t,
211
+ o(),
212
+ y,
213
+ h
214
+ );
215
+ }
216
+ function m(e) {
217
+ T(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === A && (e._payload.status === "fulfilled" ? T(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
218
+ }
219
+ function T(e) {
220
+ return typeof e == "object" && e !== null && e.$$typeof === j;
221
+ }
222
+ var k = re, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), U = /* @__PURE__ */ Symbol.for("react.portal"), O = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), J = /* @__PURE__ */ Symbol.for("react.profiler"), V = /* @__PURE__ */ Symbol.for("react.consumer"), z = /* @__PURE__ */ Symbol.for("react.context"), G = /* @__PURE__ */ Symbol.for("react.forward_ref"), X = /* @__PURE__ */ Symbol.for("react.suspense"), H = /* @__PURE__ */ Symbol.for("react.suspense_list"), Z = /* @__PURE__ */ Symbol.for("react.memo"), A = /* @__PURE__ */ Symbol.for("react.lazy"), B = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), P = k.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, g = Object.prototype.hasOwnProperty, K = Array.isArray, S = console.createTask ? console.createTask : function() {
223
+ return null;
224
+ };
225
+ k = {
226
+ react_stack_bottom_frame: function(e) {
227
+ return e();
228
+ }
229
+ };
230
+ var N, C = {}, Y = k.react_stack_bottom_frame.bind(
231
+ k,
232
+ l
233
+ )(), $ = S(c(l)), I = {};
234
+ v.Fragment = O, v.jsx = function(e, r, t) {
235
+ var n = 1e4 > P.recentlyCreatedOwnerStacks++;
236
+ return p(
237
+ e,
238
+ r,
239
+ t,
240
+ !1,
241
+ n ? Error("react-stack-top-frame") : Y,
242
+ n ? S(c(e)) : $
243
+ );
244
+ }, v.jsxs = function(e, r, t) {
245
+ var n = 1e4 > P.recentlyCreatedOwnerStacks++;
246
+ return p(
247
+ e,
248
+ r,
249
+ t,
250
+ !0,
251
+ n ? Error("react-stack-top-frame") : Y,
252
+ n ? S(c(e)) : $
253
+ );
254
+ };
255
+ })()), v;
256
+ }
257
+ var M;
258
+ function ae() {
259
+ return M || (M = 1, process.env.NODE_ENV === "production" ? w.exports = te() : w.exports = ne()), w.exports;
260
+ }
261
+ var W = ae();
262
+ function le({
263
+ isOpen: s,
264
+ onClose: u,
265
+ children: i,
266
+ closeOnEsc: c = !0,
267
+ closeOnOverlayClick: o = !0,
268
+ animationDuration: l = 300,
269
+ onBeforeOpen: f,
270
+ onAfterOpen: d,
271
+ onBeforeClose: R,
272
+ onAfterClose: b
273
+ }) {
274
+ if (D(() => (s ? (f?.(), d?.(), document.body.style.overflow = "hidden") : document.body.style.overflow = "", () => {
275
+ document.body.style.overflow = "";
276
+ }), [s]), D(() => {
277
+ if (!c) return;
278
+ const m = (T) => {
279
+ T.key === "Escape" && (R?.(), u(), b?.());
280
+ };
281
+ return document.addEventListener("keydown", m), () => document.removeEventListener("keydown", m);
282
+ }, [c, u]), !s) return null;
283
+ const p = () => {
284
+ o && (R?.(), u(), b?.());
285
+ };
286
+ return /* @__PURE__ */ W.jsx(
287
+ "div",
288
+ {
289
+ className: "modal-overlay show",
290
+ style: { transitionDuration: `${l}ms` },
291
+ onClick: p,
292
+ role: "dialog",
293
+ "aria-modal": "true",
294
+ children: /* @__PURE__ */ W.jsx(
295
+ "div",
296
+ {
297
+ className: "modal-content",
298
+ onClick: (m) => m.stopPropagation(),
299
+ children: i
300
+ }
301
+ )
302
+ }
303
+ );
304
+ }
305
+ export {
306
+ le as default
307
+ };
@@ -0,0 +1,6 @@
1
+ (function(l,c){typeof exports=="object"&&typeof module<"u"?module.exports=c(require("react")):typeof define=="function"&&define.amd?define(["react"],c):(l=typeof globalThis<"u"?globalThis:l||self,l.ReactSimpleModal=c(l.React))})(this,(function(l){"use strict";var c={exports:{}},R={};var g;function U(){if(g)return R;g=1;var u=Symbol.for("react.transitional.element"),i=Symbol.for("react.fragment");function d(f,o,s){var m=null;if(s!==void 0&&(m=""+s),o.key!==void 0&&(m=""+o.key),"key"in o){s={};for(var E in o)E!=="key"&&(s[E]=o[E])}else s=o;return o=s.ref,{$$typeof:u,type:f,key:m,ref:o!==void 0?o:null,props:s}}return R.Fragment=i,R.jsx=d,R.jsxs=d,R}var b={};var N;function J(){return N||(N=1,process.env.NODE_ENV!=="production"&&(function(){function u(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===te?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case X:return"Profiler";case G:return"StrictMode";case Q:return"Suspense";case K:return"SuspenseList";case re: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 Z:return e.displayName||"Context";case H:return(e._context.displayName||"Context")+".Consumer";case B:var r=e.render;return e=e.displayName,e||(e=r.displayName||r.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ee:return r=e.displayName||null,r!==null?r:u(e.type)||"Memo";case S:r=e._payload,e=e._init;try{return u(e(r))}catch{}}return null}function i(e){return""+e}function d(e){try{i(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),i(e)}}function f(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===S)return"<...>";try{var r=u(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function o(){var e=A.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function m(e){if(D.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function E(e,r){function t(){F||(F=!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 p(){var e=u(this.type);return L[e]||(L[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,h,x){var a=t.ref;return e={$$typeof:I,type:e,key:r,props:t,_owner:n},(a!==void 0?a:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:p}):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:h}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function k(e,r,t,n,h,x){var a=r.children;if(a!==void 0)if(n)if(ne(a)){for(n=0;n<a.length;n++)_(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 _(a);if(D.call(r,"key")){a=u(e);var v=Object.keys(r).filter(function(ae){return ae!=="key"});n=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",W[a+n]||(v=0<v.length?"{"+v.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,n,a,v,a),W[a+n]=!0)}if(a=null,t!==void 0&&(d(t),a=""+t),m(r)&&(d(r.key),a=""+r.key),"key"in r){t={};for(var j in r)j!=="key"&&(t[j]=r[j])}else t=r;return a&&E(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),T(e,a,t,o(),h,x)}function _(e){y(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===S&&(e._payload.status==="fulfilled"?y(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function y(e){return typeof e=="object"&&e!==null&&e.$$typeof===I}var w=l,I=Symbol.for("react.transitional.element"),q=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),G=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),Z=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),A=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,ne=Array.isArray,P=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(e){return e()}};var F,L={},M=w.react_stack_bottom_frame.bind(w,s)(),$=P(f(s)),W={};b.Fragment=O,b.jsx=function(e,r,t){var n=1e4>A.recentlyCreatedOwnerStacks++;return k(e,r,t,!1,n?Error("react-stack-top-frame"):M,n?P(f(e)):$)},b.jsxs=function(e,r,t){var n=1e4>A.recentlyCreatedOwnerStacks++;return k(e,r,t,!0,n?Error("react-stack-top-frame"):M,n?P(f(e)):$)}})()),b}var C;function V(){return C||(C=1,process.env.NODE_ENV==="production"?c.exports=U():c.exports=J()),c.exports}var Y=V();function z({isOpen:u,onClose:i,children:d,closeOnEsc:f=!0,closeOnOverlayClick:o=!0,animationDuration:s=300,onBeforeOpen:m,onAfterOpen:E,onBeforeClose:p,onAfterClose:T}){if(l.useEffect(()=>(u?(m?.(),E?.(),document.body.style.overflow="hidden"):document.body.style.overflow="",()=>{document.body.style.overflow=""}),[u]),l.useEffect(()=>{if(!f)return;const _=y=>{y.key==="Escape"&&(p?.(),i(),T?.())};return document.addEventListener("keydown",_),()=>document.removeEventListener("keydown",_)},[f,i]),!u)return null;const k=()=>{o&&(p?.(),i(),T?.())};return Y.jsx("div",{className:"modal-overlay show",style:{transitionDuration:`${s}ms`},onClick:k,role:"dialog","aria-modal":"true",children:Y.jsx("div",{className:"modal-content",onClick:_=>_.stopPropagation(),children:d})})}return z}));
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@andoniaina/react-modal",
3
+ "version": "1.0.0",
4
+ "description": "Reusable, accessible and customizable React modal component",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "module": "dist/index.esm.js",
8
+ "types": "dist/index.d.ts",
9
+ "files": [
10
+ "dist"
11
+ ],
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.esm.js",
16
+ "require": "./dist/index.js"
17
+ }
18
+ },
19
+ "scripts": {
20
+ "dev": "vite",
21
+ "build": "vite build",
22
+ "lint": "eslint .",
23
+ "preview": "vite preview"
24
+ },
25
+ "keywords": [
26
+ "react",
27
+ "modal",
28
+ "dialog",
29
+ "accessible",
30
+ "ui",
31
+ "component"
32
+ ],
33
+ "author": "Ton Nom",
34
+ "license": "MIT",
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "https://github.com/andoniaina/react-modal"
38
+ },
39
+ "bugs": {
40
+ "url": "https://github.com/andoniaina/react-modal/issues"
41
+ },
42
+ "homepage": "https://github.com/andoniaina/react-modal#readme",
43
+ "peerDependencies": {
44
+ "react": ">=18",
45
+ "react-dom": ">=18"
46
+ },
47
+ "devDependencies": {
48
+ "@eslint/js": "^9.39.1",
49
+ "@types/react": "^19.2.5",
50
+ "@types/react-dom": "^19.2.3",
51
+ "@vitejs/plugin-react": "^5.1.1",
52
+ "eslint": "^9.39.1",
53
+ "eslint-plugin-react-hooks": "^7.0.1",
54
+ "eslint-plugin-react-refresh": "^0.4.24",
55
+ "globals": "^16.5.0",
56
+ "vite": "^7.2.4"
57
+ }
58
+ }