@geoffreybunel/react-hrnet-modal 0.4.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 +74 -0
- package/dist/react-hrnet-modal.es.js +285 -0
- package/dist/react-hrnet-modal.umd.js +6 -0
- package/dist/style.css +46 -0
- package/dist/vite.svg +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# react-hrnet-modal
|
|
2
|
+
|
|
3
|
+
A lightweight and controlled React modal component, created as part of the HRNet application modernization.
|
|
4
|
+
This component replaces a legacy jQuery modal plugin with a fully React-based, reusable solution.
|
|
5
|
+
The modal is designed to be simple, predictable, accessible, and easy to integrate into any React application.
|
|
6
|
+
|
|
7
|
+
## ✨ Features
|
|
8
|
+
|
|
9
|
+
- Controlled component (isOpen / onClose)
|
|
10
|
+
- Overlay click to close (optional)
|
|
11
|
+
- Escape key support (optional)
|
|
12
|
+
- Scroll locking when the modal is open
|
|
13
|
+
- Optional close button
|
|
14
|
+
- Basic accessibility support (role="dialog", aria-modal)
|
|
15
|
+
- Styles provided via a dedicated CSS file
|
|
16
|
+
- Published as an npm package via GitHub Packages
|
|
17
|
+
|
|
18
|
+
## 📦 Installation
|
|
19
|
+
|
|
20
|
+
This package is published on GitHub Packages.
|
|
21
|
+
|
|
22
|
+
### 1. Configure npm (once per project)
|
|
23
|
+
Create or edit a .npmrc file at the root of your project:
|
|
24
|
+
```ini
|
|
25
|
+
@geoffreybunel:registry=https://npm.pkg.github.com
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Install the package
|
|
29
|
+
```ini
|
|
30
|
+
npm install @geoffreybunel/react-hrnet-modal
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## 🚀 Usage
|
|
34
|
+
|
|
35
|
+
Import the component and its styles
|
|
36
|
+
```ini
|
|
37
|
+
import Modal from "@geoffreybunel/react-hrnet-modal";
|
|
38
|
+
import "@geoffreybunel/react-hrnet-modal/style.css";
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## 🔧 Props
|
|
42
|
+
|
|
43
|
+
| Prop | Type | Required | Default | Description |
|
|
44
|
+
|------|------|----------|---------|-------------|
|
|
45
|
+
| `isOpen` | boolean | ✅ | — | Controls whether the modal is displayed |
|
|
46
|
+
| `onClose` | function | ✅ | — | Callback triggered when the modal requests to close |
|
|
47
|
+
| `children` | ReactNode | ✅ | — | Content displayed inside the modal |
|
|
48
|
+
| `title` | ReactNode | ❌ | — | Optional title displayed at the top of the modal |
|
|
49
|
+
| `closeOnOverlayClick` | boolean | ❌ | `true` | Allows closing the modal by clicking the overlay |
|
|
50
|
+
| `closeOnEsc` | boolean | ❌ | `true` | Allows closing the modal using the Escape key |
|
|
51
|
+
| `showCloseButton` | boolean | ❌ | `true` | Displays a close button inside the modal |
|
|
52
|
+
|
|
53
|
+
## ♿ Accessibility
|
|
54
|
+
|
|
55
|
+
This modal includes basic accessibility features:
|
|
56
|
+
- role="dialog"
|
|
57
|
+
- aria-modal="true"
|
|
58
|
+
- aria-labelledby when a title is provided
|
|
59
|
+
The component follows common accessibility conventions for modal dialogs.
|
|
60
|
+
|
|
61
|
+
## 🧱 Styling
|
|
62
|
+
|
|
63
|
+
The component ships with a standalone CSS file:
|
|
64
|
+
```ini
|
|
65
|
+
import "@geoffreybunel/react-hrnet-modal/style.css";
|
|
66
|
+
```
|
|
67
|
+
Styles are namespaced to avoid collisions with host applications.
|
|
68
|
+
|
|
69
|
+
## 🛠️ Development notes
|
|
70
|
+
|
|
71
|
+
- Built with React and Vite
|
|
72
|
+
- React and React DOM are declared as peerDependencies
|
|
73
|
+
- Distributed as compiled ES and UMD builds
|
|
74
|
+
- Intended to be reusable outside of the HRNet application
|
|
@@ -0,0 +1,285 @@
|
|
|
1
|
+
import re, { useId as te, useEffect as F } from "react";
|
|
2
|
+
var p = { exports: {} }, _ = {};
|
|
3
|
+
var L;
|
|
4
|
+
function ne() {
|
|
5
|
+
if (L) return _;
|
|
6
|
+
L = 1;
|
|
7
|
+
var o = /* @__PURE__ */ Symbol.for("react.transitional.element"), s = /* @__PURE__ */ Symbol.for("react.fragment");
|
|
8
|
+
function m(c, l, u) {
|
|
9
|
+
var i = null;
|
|
10
|
+
if (u !== void 0 && (i = "" + u), l.key !== void 0 && (i = "" + l.key), "key" in l) {
|
|
11
|
+
u = {};
|
|
12
|
+
for (var f in l)
|
|
13
|
+
f !== "key" && (u[f] = l[f]);
|
|
14
|
+
} else u = l;
|
|
15
|
+
return l = u.ref, {
|
|
16
|
+
$$typeof: o,
|
|
17
|
+
type: c,
|
|
18
|
+
key: i,
|
|
19
|
+
ref: l !== void 0 ? l : null,
|
|
20
|
+
props: u
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return _.Fragment = s, _.jsx = m, _.jsxs = m, _;
|
|
24
|
+
}
|
|
25
|
+
var v = {};
|
|
26
|
+
var M;
|
|
27
|
+
function ae() {
|
|
28
|
+
return M || (M = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
29
|
+
function o(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 y:
|
|
36
|
+
return "Fragment";
|
|
37
|
+
case J:
|
|
38
|
+
return "Profiler";
|
|
39
|
+
case q:
|
|
40
|
+
return "StrictMode";
|
|
41
|
+
case X:
|
|
42
|
+
return "Suspense";
|
|
43
|
+
case B:
|
|
44
|
+
return "SuspenseList";
|
|
45
|
+
case Z:
|
|
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 H:
|
|
62
|
+
return r = e.displayName || null, r !== null ? r : o(e.type) || "Memo";
|
|
63
|
+
case w:
|
|
64
|
+
r = e._payload, e = e._init;
|
|
65
|
+
try {
|
|
66
|
+
return o(e(r));
|
|
67
|
+
} catch {
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
function s(e) {
|
|
73
|
+
return "" + e;
|
|
74
|
+
}
|
|
75
|
+
function m(e) {
|
|
76
|
+
try {
|
|
77
|
+
s(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
|
+
), s(e);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function c(e) {
|
|
93
|
+
if (e === y) return "<>";
|
|
94
|
+
if (typeof e == "object" && e !== null && e.$$typeof === w)
|
|
95
|
+
return "<...>";
|
|
96
|
+
try {
|
|
97
|
+
var r = o(e);
|
|
98
|
+
return r ? "<" + r + ">" : "<...>";
|
|
99
|
+
} catch {
|
|
100
|
+
return "<...>";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
function l() {
|
|
104
|
+
var e = h.A;
|
|
105
|
+
return e === null ? null : e.getOwner();
|
|
106
|
+
}
|
|
107
|
+
function u() {
|
|
108
|
+
return Error("react-stack-top-frame");
|
|
109
|
+
}
|
|
110
|
+
function i(e) {
|
|
111
|
+
if (N.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 f(e, r) {
|
|
118
|
+
function t() {
|
|
119
|
+
C || (C = !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 d() {
|
|
130
|
+
var e = o(this.type);
|
|
131
|
+
return Y[e] || (Y[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 k(e, r, t, n, R, x) {
|
|
136
|
+
var a = t.ref;
|
|
137
|
+
return e = {
|
|
138
|
+
$$typeof: g,
|
|
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: d
|
|
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: R
|
|
161
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
162
|
+
configurable: !1,
|
|
163
|
+
enumerable: !1,
|
|
164
|
+
writable: !0,
|
|
165
|
+
value: x
|
|
166
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
167
|
+
}
|
|
168
|
+
function S(e, r, t, n, R, x) {
|
|
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
|
+
j(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 j(a);
|
|
181
|
+
if (N.call(r, "key")) {
|
|
182
|
+
a = o(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}", D[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
|
+
), D[a + n] = !0);
|
|
198
|
+
}
|
|
199
|
+
if (a = null, t !== void 0 && (m(t), a = "" + t), i(r) && (m(r.key), a = "" + r.key), "key" in r) {
|
|
200
|
+
t = {};
|
|
201
|
+
for (var P in r)
|
|
202
|
+
P !== "key" && (t[P] = r[P]);
|
|
203
|
+
} else t = r;
|
|
204
|
+
return a && f(
|
|
205
|
+
t,
|
|
206
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
207
|
+
), k(
|
|
208
|
+
e,
|
|
209
|
+
a,
|
|
210
|
+
t,
|
|
211
|
+
l(),
|
|
212
|
+
R,
|
|
213
|
+
x
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function j(e) {
|
|
217
|
+
O(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === w && (e._payload.status === "fulfilled" ? O(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
218
|
+
}
|
|
219
|
+
function O(e) {
|
|
220
|
+
return typeof e == "object" && e !== null && e.$$typeof === g;
|
|
221
|
+
}
|
|
222
|
+
var b = re, g = /* @__PURE__ */ Symbol.for("react.transitional.element"), U = /* @__PURE__ */ Symbol.for("react.portal"), y = /* @__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"), B = /* @__PURE__ */ Symbol.for("react.suspense_list"), H = /* @__PURE__ */ Symbol.for("react.memo"), w = /* @__PURE__ */ Symbol.for("react.lazy"), Z = /* @__PURE__ */ Symbol.for("react.activity"), Q = /* @__PURE__ */ Symbol.for("react.client.reference"), h = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, K = Array.isArray, A = console.createTask ? console.createTask : function() {
|
|
223
|
+
return null;
|
|
224
|
+
};
|
|
225
|
+
b = {
|
|
226
|
+
react_stack_bottom_frame: function(e) {
|
|
227
|
+
return e();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
var C, Y = {}, I = b.react_stack_bottom_frame.bind(
|
|
231
|
+
b,
|
|
232
|
+
u
|
|
233
|
+
)(), $ = A(c(u)), D = {};
|
|
234
|
+
v.Fragment = y, v.jsx = function(e, r, t) {
|
|
235
|
+
var n = 1e4 > h.recentlyCreatedOwnerStacks++;
|
|
236
|
+
return S(
|
|
237
|
+
e,
|
|
238
|
+
r,
|
|
239
|
+
t,
|
|
240
|
+
!1,
|
|
241
|
+
n ? Error("react-stack-top-frame") : I,
|
|
242
|
+
n ? A(c(e)) : $
|
|
243
|
+
);
|
|
244
|
+
}, v.jsxs = function(e, r, t) {
|
|
245
|
+
var n = 1e4 > h.recentlyCreatedOwnerStacks++;
|
|
246
|
+
return S(
|
|
247
|
+
e,
|
|
248
|
+
r,
|
|
249
|
+
t,
|
|
250
|
+
!0,
|
|
251
|
+
n ? Error("react-stack-top-frame") : I,
|
|
252
|
+
n ? A(c(e)) : $
|
|
253
|
+
);
|
|
254
|
+
};
|
|
255
|
+
})()), v;
|
|
256
|
+
}
|
|
257
|
+
var W;
|
|
258
|
+
function oe() {
|
|
259
|
+
return W || (W = 1, process.env.NODE_ENV === "production" ? p.exports = ne() : p.exports = ae()), p.exports;
|
|
260
|
+
}
|
|
261
|
+
var T = oe();
|
|
262
|
+
function ue({ isOpen: o, onClose: s, children: m, title: c, closeOnOverlayClick: l = !0, showCloseButton: u = !0, closeOnEsc: i = !0 }) {
|
|
263
|
+
const f = te();
|
|
264
|
+
return F(() => {
|
|
265
|
+
const d = document.body.style.overflow;
|
|
266
|
+
return o === !0 && (document.body.style.overflow = "hidden"), () => {
|
|
267
|
+
document.body.style.overflow = d;
|
|
268
|
+
};
|
|
269
|
+
}, [o]), F(() => {
|
|
270
|
+
if (!o || !i) return;
|
|
271
|
+
const d = (k) => {
|
|
272
|
+
k.key === "Escape" && s();
|
|
273
|
+
};
|
|
274
|
+
return document.addEventListener("keydown", d), () => {
|
|
275
|
+
document.removeEventListener("keydown", d);
|
|
276
|
+
};
|
|
277
|
+
}, [o, i, s]), o ? /* @__PURE__ */ T.jsx("div", { className: "hrnet-modal-overlay", onClick: l ? s : void 0, "aria-modal": "true", role: "dialog", "aria-labelledby": c ? f : void 0, children: /* @__PURE__ */ T.jsxs("div", { className: "hrnet-modal-content", onClick: (d) => d.stopPropagation(), children: [
|
|
278
|
+
c && /* @__PURE__ */ T.jsx("h2", { id: f, children: c }),
|
|
279
|
+
m,
|
|
280
|
+
u && /* @__PURE__ */ T.jsx("button", { type: "button", className: "hrnet-modal-close", onClick: s, children: "×" })
|
|
281
|
+
] }) }) : null;
|
|
282
|
+
}
|
|
283
|
+
export {
|
|
284
|
+
ue as default
|
|
285
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
(function(u,f){typeof exports=="object"&&typeof module<"u"?module.exports=f(require("react")):typeof define=="function"&&define.amd?define(["react"],f):(u=typeof globalThis<"u"?globalThis:u||self,u.ReactHrnetModal=f(u.React))})(this,(function(u){"use strict";var f={exports:{}},b={};var S;function $(){if(S)return b;S=1;var a=Symbol.for("react.transitional.element"),c=Symbol.for("react.fragment");function _(i,l,s){var d=null;if(s!==void 0&&(d=""+s),l.key!==void 0&&(d=""+l.key),"key"in l){s={};for(var m in l)m!=="key"&&(s[m]=l[m])}else s=l;return l=s.ref,{$$typeof:a,type:i,key:d,ref:l!==void 0?l:null,props:s}}return b.Fragment=c,b.jsx=_,b.jsxs=_,b}var R={};var O;function J(){return O||(O=1,process.env.NODE_ENV!=="production"&&(function(){function a(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 h:return"Fragment";case X:return"Profiler";case q: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 G:return"Portal";case B:return e.displayName||"Context";case H:return(e._context.displayName||"Context")+".Consumer";case Z: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:a(e.type)||"Memo";case w:r=e._payload,e=e._init;try{return a(e(r))}catch{}}return null}function c(e){return""+e}function _(e){try{c(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),c(e)}}function i(e){if(e===h)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===w)return"<...>";try{var r=a(e);return r?"<"+r+">":"<...>"}catch{return"<...>"}}function l(){var e=x.A;return e===null?null:e.getOwner()}function s(){return Error("react-stack-top-frame")}function d(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 m(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 E(){var e=a(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 y(e,r,t,n,k,j){var o=t.ref;return e={$$typeof:I,type:e,key:r,props:t,_owner:n},(o!==void 0?o:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:E}):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:k}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:j}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function N(e,r,t,n,k,j){var o=r.children;if(o!==void 0)if(n)if(ne(o)){for(n=0;n<o.length;n++)C(o[n]);Object.freeze&&Object.freeze(o)}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 C(o);if(D.call(r,"key")){o=a(e);var v=Object.keys(r).filter(function(oe){return oe!=="key"});n=0<v.length?"{key: someKey, "+v.join(": ..., ")+": ...}":"{key: someKey}",U[o+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,o,v,o),U[o+n]=!0)}if(o=null,t!==void 0&&(_(t),o=""+t),d(r)&&(_(r.key),o=""+r.key),"key"in r){t={};for(var P in r)P!=="key"&&(t[P]=r[P])}else t=r;return o&&m(t,typeof e=="function"?e.displayName||e.name||"Unknown":e),y(e,o,t,l(),k,j)}function C(e){Y(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===w&&(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 T=u,I=Symbol.for("react.transitional.element"),G=Symbol.for("react.portal"),h=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),X=Symbol.for("react.profiler"),H=Symbol.for("react.consumer"),B=Symbol.for("react.context"),Z=Symbol.for("react.forward_ref"),Q=Symbol.for("react.suspense"),K=Symbol.for("react.suspense_list"),ee=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),re=Symbol.for("react.activity"),te=Symbol.for("react.client.reference"),x=T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,D=Object.prototype.hasOwnProperty,ne=Array.isArray,A=console.createTask?console.createTask:function(){return null};T={react_stack_bottom_frame:function(e){return e()}};var F,L={},M=T.react_stack_bottom_frame.bind(T,s)(),W=A(i(s)),U={};R.Fragment=h,R.jsx=function(e,r,t){var n=1e4>x.recentlyCreatedOwnerStacks++;return N(e,r,t,!1,n?Error("react-stack-top-frame"):M,n?A(i(e)):W)},R.jsxs=function(e,r,t){var n=1e4>x.recentlyCreatedOwnerStacks++;return N(e,r,t,!0,n?Error("react-stack-top-frame"):M,n?A(i(e)):W)}})()),R}var g;function V(){return g||(g=1,process.env.NODE_ENV==="production"?f.exports=$():f.exports=J()),f.exports}var p=V();function z({isOpen:a,onClose:c,children:_,title:i,closeOnOverlayClick:l=!0,showCloseButton:s=!0,closeOnEsc:d=!0}){const m=u.useId();return u.useEffect(()=>{const E=document.body.style.overflow;return a===!0&&(document.body.style.overflow="hidden"),()=>{document.body.style.overflow=E}},[a]),u.useEffect(()=>{if(!a||!d)return;const E=y=>{y.key==="Escape"&&c()};return document.addEventListener("keydown",E),()=>{document.removeEventListener("keydown",E)}},[a,d,c]),a?p.jsx("div",{className:"hrnet-modal-overlay",onClick:l?c:void 0,"aria-modal":"true",role:"dialog","aria-labelledby":i?m:void 0,children:p.jsxs("div",{className:"hrnet-modal-content",onClick:E=>E.stopPropagation(),children:[i&&p.jsx("h2",{id:m,children:i}),_,s&&p.jsx("button",{type:"button",className:"hrnet-modal-close",onClick:c,children:"×"})]})}):null}return z}));
|
package/dist/style.css
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
.hrnet-modal-overlay {
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
right: 0;
|
|
5
|
+
bottom: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 100%;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
z-index: 1;
|
|
11
|
+
padding: 20px;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
background-color: rgba(0, 0, 0, 0.75);
|
|
14
|
+
text-align: center;
|
|
15
|
+
margin: auto;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.hrnet-modal-content {
|
|
19
|
+
vertical-align: middle;
|
|
20
|
+
position: relative;
|
|
21
|
+
z-index: 2;
|
|
22
|
+
max-width: 500px;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
width: 90%;
|
|
25
|
+
background: #fff;
|
|
26
|
+
padding: 15px 30px;
|
|
27
|
+
border-radius: 8px;
|
|
28
|
+
box-shadow: 0 0 10px #000;
|
|
29
|
+
text-align: left;
|
|
30
|
+
margin: auto;
|
|
31
|
+
top: 50%
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hrnet-modal-close {
|
|
35
|
+
position: absolute;
|
|
36
|
+
top: -12.5px;
|
|
37
|
+
right: -12.5px;
|
|
38
|
+
display: block;
|
|
39
|
+
width: 30px;
|
|
40
|
+
height: 30px;
|
|
41
|
+
border: none;
|
|
42
|
+
border-radius: 50px;
|
|
43
|
+
cursor: pointer;
|
|
44
|
+
background-color: #000;
|
|
45
|
+
color: white;
|
|
46
|
+
}
|
package/dist/vite.svg
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@geoffreybunel/react-hrnet-modal",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "0.4.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"main": "./dist/react-hrnet-modal.umd.js",
|
|
8
|
+
"module": "./dist/react-hrnet-modal.es.js",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/geoffreybunel/react-hrnet-modal.git"
|
|
12
|
+
},
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./dist/react-hrnet-modal.es.js",
|
|
16
|
+
"require": "./dist/react-hrnet-modal.umd.js"
|
|
17
|
+
},
|
|
18
|
+
"./style.css": "./dist/style.css"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"dev": "vite",
|
|
26
|
+
"build": "vite build",
|
|
27
|
+
"postbuild": "node scripts/copy-css.mjs",
|
|
28
|
+
"lint": "eslint .",
|
|
29
|
+
"preview": "vite preview",
|
|
30
|
+
"prepare": "npm run build"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"react": ">=18",
|
|
34
|
+
"react-dom": ">=18"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@eslint/js": "^9.39.1",
|
|
38
|
+
"@types/react": "^19.2.5",
|
|
39
|
+
"@types/react-dom": "^19.2.3",
|
|
40
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
41
|
+
"cpx": "^1.5.0",
|
|
42
|
+
"eslint": "^9.39.1",
|
|
43
|
+
"eslint-plugin-react-hooks": "^7.0.1",
|
|
44
|
+
"eslint-plugin-react-refresh": "^0.4.24",
|
|
45
|
+
"globals": "^16.5.0",
|
|
46
|
+
"vite": "^7.2.4"
|
|
47
|
+
}
|
|
48
|
+
}
|