layerpro 3.1.1 → 3.2.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/FUNDING.yml +12 -0
- package/README.md +35 -3
- package/index.cjs +329 -302
- package/index.css +2 -1
- package/index.js +329 -304
- package/package.json +40 -12
- package/react.cjs +404 -0
- package/react.js +400 -0
- package/types/layerpro.d.ts +133 -132
package/package.json
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "layerpro",
|
|
3
3
|
"codeName": "layerpro",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.2.0",
|
|
5
5
|
"description": "The real custom modals, alert, confirm, prompt... for your browser",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
|
-
"
|
|
7
|
+
"module": "./index.js",
|
|
8
|
+
"browser": "./dist/index.js",
|
|
8
9
|
"types": "./index.d.ts",
|
|
9
|
-
"
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./index.js",
|
|
13
|
+
"require": "./index.cjs",
|
|
14
|
+
"types": "./index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./react": {
|
|
17
|
+
"import": "./react.js",
|
|
18
|
+
"require": "./react.cjs",
|
|
19
|
+
"types": "./react.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./types/*": "./types/*"
|
|
22
|
+
},
|
|
10
23
|
"license": "MIT",
|
|
11
24
|
"copyright": "Dario Passariello",
|
|
12
25
|
"author": "Dario Passariello",
|
|
@@ -41,21 +54,36 @@
|
|
|
41
54
|
"node": ">=18.0.0"
|
|
42
55
|
},
|
|
43
56
|
"files": [
|
|
44
|
-
"
|
|
57
|
+
"markdown/**/*",
|
|
58
|
+
"types/**/*",
|
|
59
|
+
"COPYRIGHT.md",
|
|
60
|
+
"FUNDING.yml",
|
|
61
|
+
"index.cjs",
|
|
62
|
+
"index.css",
|
|
63
|
+
"index.d.ts",
|
|
64
|
+
"index.js",
|
|
65
|
+
"LICENSE.md",
|
|
66
|
+
"llms.txt",
|
|
67
|
+
"package.json",
|
|
68
|
+
"react.cjs",
|
|
69
|
+
"react.js",
|
|
70
|
+
"README.md",
|
|
71
|
+
"SECURITY.md"
|
|
45
72
|
],
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"react": ">=18",
|
|
75
|
+
"react-dom": ">=18"
|
|
76
|
+
},
|
|
46
77
|
"support": {
|
|
47
78
|
"name": "Dario Passariello",
|
|
48
79
|
"url": "https://dario.passariello.ca/",
|
|
49
80
|
"email": "dariopassariello@gmail.com"
|
|
50
81
|
},
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"types": "./index.d.ts"
|
|
57
|
-
},
|
|
58
|
-
"./types/*": "./types/*"
|
|
82
|
+
"resolutions": {
|
|
83
|
+
"esbuild": "^0.25.0"
|
|
84
|
+
},
|
|
85
|
+
"overrides": {
|
|
86
|
+
"esbuild": "^0.28.2"
|
|
59
87
|
},
|
|
60
88
|
"typings": "./index.d.ts"
|
|
61
89
|
}
|
package/react.cjs
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var e = require("react"), t = require("react-dom/client"), n = require("react-dom");
|
|
4
|
+
|
|
5
|
+
function r(e) {
|
|
6
|
+
return e && e.__esModule ? e : {
|
|
7
|
+
default: e
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
var o = r(e), i = Object.defineProperty, s = (e, t, n) => {
|
|
12
|
+
return s = n, (o = "symbol" != typeof t ? t + "" : t) in (r = e) ? i(r, o, {
|
|
13
|
+
enumerable: !0,
|
|
14
|
+
configurable: !0,
|
|
15
|
+
writable: !0,
|
|
16
|
+
value: s
|
|
17
|
+
}) : r[o] = s;
|
|
18
|
+
var r, o, s;
|
|
19
|
+
}, l = class extends Error {
|
|
20
|
+
constructor(e, t, n) {
|
|
21
|
+
super(`[reattach:${t}] ${e}`), s(this, "code"), s(this, "details"), this.name = "ReattachError",
|
|
22
|
+
this.code = t, void 0 !== n && (this.details = n);
|
|
23
|
+
}
|
|
24
|
+
}, a = new WeakMap, c = new Set;
|
|
25
|
+
|
|
26
|
+
function d() {
|
|
27
|
+
if ("undefined" == typeof document || "undefined" == typeof window) throw new l("reattach requires a browser environment (document is not available)", "ENVIRONMENT_ERROR");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function u(e) {
|
|
31
|
+
if (d(), "string" != typeof e || 0 === e.length) throw new l("Invalid selector received: " + typeof e, "INVALID_SELECTOR");
|
|
32
|
+
const t = document.querySelector(e);
|
|
33
|
+
if (!t) throw new l(`No element found matching selector "${e}"`, "PARENT_NOT_FOUND");
|
|
34
|
+
return t;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function f(e, t) {
|
|
38
|
+
if (t) {
|
|
39
|
+
const n = Array.from(e.children).filter(e => e.id === t);
|
|
40
|
+
if (n.length, n.length > 0) return {
|
|
41
|
+
element: n[0],
|
|
42
|
+
created: !1
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const n = document.createElement("div");
|
|
46
|
+
return t && (n.id = t), e.appendChild(n), c.add(n), {
|
|
47
|
+
element: n,
|
|
48
|
+
created: !0
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function m(e, t) {
|
|
53
|
+
if (!t) return e;
|
|
54
|
+
const n = document.createElement("div");
|
|
55
|
+
return n.className = "reattach-overlay", t.zIndex ? n.style.zIndex = String(t.zIndex) : t.stackingOrder && (n.style.zIndex = String("top" === t.stackingOrder ? 9999 : "bottom" === t.stackingOrder ? 0 : 5e3)),
|
|
56
|
+
n.style.position = "fixed", n.style.top = "0", n.style.left = "0", n.style.width = "100vw",
|
|
57
|
+
n.style.height = "100vh", n.style.display = "flex", n.style.alignItems = "center",
|
|
58
|
+
n.style.justifyContent = "center", n.style.pointerEvents = "auto", e.appendChild(n),
|
|
59
|
+
n;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function h(e, t) {
|
|
63
|
+
const n = w.get(e) ?? {
|
|
64
|
+
zIndex: 0,
|
|
65
|
+
scrollLocked: !1
|
|
66
|
+
};
|
|
67
|
+
n.scrollLocked = !0, n.originalOverflow = document.body.style.overflow, document.body.style.overflow = "hidden",
|
|
68
|
+
w.set(e, n);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function y(e) {
|
|
72
|
+
const t = w.get(e);
|
|
73
|
+
t && (t.scrollLocked && (document.body.style.overflow = t.originalOverflow ?? ""),
|
|
74
|
+
t.focusTrapCleanup && t.focusTrapCleanup(), t.scrollLocked = !1, t.originalOverflow = void 0,
|
|
75
|
+
t.focusTrapCleanup = void 0, w.set(e, t));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function p(e, t) {
|
|
79
|
+
const n = [ "a[href]", "button:not([disabled])", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", '[tabindex]:not([tabindex="-1"])' ].join(", "), r = Array.from(e.querySelectorAll(n));
|
|
80
|
+
if (0 === r.length) return;
|
|
81
|
+
const o = r[0], i = r[r.length - 1], s = e => {
|
|
82
|
+
"Tab" === e.key && (e.shiftKey && document.activeElement === o ? (e.preventDefault(),
|
|
83
|
+
i.focus()) : e.shiftKey || document.activeElement !== i || (e.preventDefault(),
|
|
84
|
+
o.focus()));
|
|
85
|
+
}, l = t => {
|
|
86
|
+
if ("Escape" === t.key && e.parentElement) {
|
|
87
|
+
e.parentElement.removeChild(e);
|
|
88
|
+
const t = a.get(e);
|
|
89
|
+
t && (t.unmount(), a.delete(e)), c.delete(e), w.delete(e), y(e);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return e.addEventListener("keydown", s), document.addEventListener("keydown", l),
|
|
93
|
+
() => {
|
|
94
|
+
e.removeEventListener("keydown", s), document.removeEventListener("keydown", l);
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function v(n, r, i) {
|
|
99
|
+
let s = i ?? a.get(n);
|
|
100
|
+
return s || (s = t.createRoot(n), a.set(n, s)), s.render(e.isValidElement(r) ? r : o.default.createElement(o.default.Fragment, null, r)),
|
|
101
|
+
s;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function E(e) {
|
|
105
|
+
const t = L.get(e);
|
|
106
|
+
t && t.destroy();
|
|
107
|
+
const n = a.get(e);
|
|
108
|
+
return n && (n.unmount(), a.delete(e)), c.delete(e), k(e), y(e), w.delete(e), e.remove(),
|
|
109
|
+
!0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function b(e, t) {
|
|
113
|
+
if (!t) return;
|
|
114
|
+
t.id && (e.id = t.id), t.class && (e.className = t.class), t.name && (e.name = t.name),
|
|
115
|
+
t.dataset && Object.entries(t.dataset).forEach(([t, n]) => {
|
|
116
|
+
e.dataset[t] = n;
|
|
117
|
+
}), t.style && ("string" == typeof t.style ? e.setAttribute("style", t.style) : Object.assign(e.style, t.style));
|
|
118
|
+
const n = new Set([ "id", "class", "name", "dataset", "style", "root", "inheritContext", "resilient", "overlay", "bubbleEvents", "isolateNativeEvents", "layout", "hydrate" ]);
|
|
119
|
+
Object.entries(t).forEach(([t, r]) => {
|
|
120
|
+
n.has(t) || "string" != typeof r && "number" != typeof r && "boolean" != typeof r || e.setAttribute(t, String(r));
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
var g = new Map, w = new Map, L = new WeakMap, C = new WeakMap;
|
|
125
|
+
|
|
126
|
+
function x(e = null) {
|
|
127
|
+
let t = e;
|
|
128
|
+
for (const [e, n] of g) t = o.default.createElement(e.Provider, {
|
|
129
|
+
value: n
|
|
130
|
+
}, t);
|
|
131
|
+
return t ? o.default.isValidElement(t) ? t : o.default.createElement(o.default.Fragment, null, t) : o.default.createElement(o.default.Fragment, null);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function I(e, t) {
|
|
135
|
+
const n = new MutationObserver(r => {
|
|
136
|
+
if (!document.contains(e)) {
|
|
137
|
+
n.disconnect();
|
|
138
|
+
let r = null;
|
|
139
|
+
try {
|
|
140
|
+
r = t();
|
|
141
|
+
} catch {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
if (r && r !== e) {
|
|
145
|
+
const n = a.get(e);
|
|
146
|
+
n && (n.unmount(), a.delete(e)), c.delete(e);
|
|
147
|
+
const r = t();
|
|
148
|
+
v(r, e.innerHTML ? o.default.createElement("div", {
|
|
149
|
+
dangerouslySetInnerHTML: {
|
|
150
|
+
__html: e.innerHTML
|
|
151
|
+
}
|
|
152
|
+
}) : null), I(r, t);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
n.observe(document.documentElement, {
|
|
157
|
+
childList: !0,
|
|
158
|
+
subtree: !0
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function T(e, t, n) {
|
|
163
|
+
const r = new Map;
|
|
164
|
+
C.set(e, r), n && (e.addEventListener("click", e => e.stopPropagation(), {
|
|
165
|
+
capture: !0
|
|
166
|
+
}), e.addEventListener("keydown", e => e.stopPropagation(), {
|
|
167
|
+
capture: !0
|
|
168
|
+
}), e.addEventListener("keyup", e => e.stopPropagation(), {
|
|
169
|
+
capture: !0
|
|
170
|
+
}));
|
|
171
|
+
const o = e.parentElement;
|
|
172
|
+
o && t.forEach(t => {
|
|
173
|
+
const n = t.slice(2).toLowerCase(), i = e => {
|
|
174
|
+
if (e.target === o) return;
|
|
175
|
+
const t = new CustomEvent(e.type, {
|
|
176
|
+
detail: {
|
|
177
|
+
originalEvent: e
|
|
178
|
+
},
|
|
179
|
+
bubbles: !0
|
|
180
|
+
});
|
|
181
|
+
o.dispatchEvent(t);
|
|
182
|
+
};
|
|
183
|
+
r.set(t, i), e.addEventListener(n, i, !0);
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function k(e) {
|
|
188
|
+
const t = C.get(e);
|
|
189
|
+
t && (t.forEach((t, n) => {
|
|
190
|
+
const r = n.slice(2).toLowerCase();
|
|
191
|
+
e.removeEventListener(r, t, !0);
|
|
192
|
+
}), C.delete(e));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function R(e, t) {
|
|
196
|
+
const n = L.get(e);
|
|
197
|
+
if (n) return n;
|
|
198
|
+
const r = {
|
|
199
|
+
updateProps: e => {
|
|
200
|
+
const n = o.default.createElement("div", e);
|
|
201
|
+
t.render(n);
|
|
202
|
+
},
|
|
203
|
+
getContainer: () => e,
|
|
204
|
+
destroy: () => {
|
|
205
|
+
t.unmount(), a.delete(e), c.delete(e), k(e), y(e), w.delete(e), L.delete(e);
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
return L.set(e, r), r;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function M(e, t) {
|
|
212
|
+
if (!t.anchor) return;
|
|
213
|
+
const n = () => {
|
|
214
|
+
const n = document.querySelector(t.anchor);
|
|
215
|
+
if (!n || !e.parentElement) return;
|
|
216
|
+
const r = n.getBoundingClientRect(), o = e.getBoundingClientRect(), i = t.placement || "bottom", s = t.offset || 0;
|
|
217
|
+
let l = 0, a = 0;
|
|
218
|
+
const c = window.innerWidth, d = window.innerHeight;
|
|
219
|
+
i.startsWith("top") || i.startsWith("bottom") ? (l = i.startsWith("top") ? r.top - o.height - s : r.bottom + s,
|
|
220
|
+
a = i.endsWith("-start") ? r.left : i.endsWith("-end") ? r.right - o.width : r.left + (r.width - o.width) / 2) : (a = i.startsWith("left") ? r.left - o.width - s : r.right + s,
|
|
221
|
+
l = i.endsWith("-start") ? r.top : i.endsWith("-end") ? r.bottom - o.height : r.top + (r.height - o.height) / 2),
|
|
222
|
+
i.startsWith("bottom") && l + o.height > d && (l = r.top - o.height - s), i.startsWith("top") && l < 0 && (l = r.bottom + s),
|
|
223
|
+
i.startsWith("left") && a < 0 && (a = r.right + s), i.startsWith("right") && a + o.width > c && (a = r.left - o.width - s),
|
|
224
|
+
e.style.position = "fixed", e.style.top = `${Math.max(0, l)}px`, e.style.left = `${Math.max(0, a)}px`;
|
|
225
|
+
};
|
|
226
|
+
n();
|
|
227
|
+
const r = () => n(), o = () => n();
|
|
228
|
+
return window.addEventListener("resize", r), window.addEventListener("scroll", o, !0),
|
|
229
|
+
() => {
|
|
230
|
+
window.removeEventListener("resize", r), window.removeEventListener("scroll", o, !0);
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
var N = function(t, ...n) {
|
|
235
|
+
if (0 === n.length) {
|
|
236
|
+
if (d(), "string" != typeof t || 0 === t.length) throw new l("Invalid id argument", "INVALID_ID");
|
|
237
|
+
return document.getElementById(t) ?? null;
|
|
238
|
+
}
|
|
239
|
+
let r, o, i, s = {};
|
|
240
|
+
const [a, c, y] = n;
|
|
241
|
+
if ("string" == typeof a) {
|
|
242
|
+
if (r = a, o = c, y && "object" == typeof y && !Array.isArray(y)) {
|
|
243
|
+
const e = y;
|
|
244
|
+
s.inheritContext = !0 === e.inheritContext, s.resilient = !0 === e.resilient, i = e;
|
|
245
|
+
}
|
|
246
|
+
} else if (e.isValidElement(a)) {
|
|
247
|
+
if (o = a, c && "object" == typeof c && !Array.isArray(c)) {
|
|
248
|
+
const e = c;
|
|
249
|
+
s.inheritContext = !0 === e.inheritContext, s.resilient = !0 === e.resilient, i = e;
|
|
250
|
+
}
|
|
251
|
+
} else if (a && "object" == typeof a && !Array.isArray(a)) {
|
|
252
|
+
if (s = a, r = s.id, o = c, y && "object" == typeof y && !Array.isArray(y)) {
|
|
253
|
+
const e = y;
|
|
254
|
+
s.inheritContext = !0 === e.inheritContext, s.resilient = !0 === e.resilient, i = e;
|
|
255
|
+
}
|
|
256
|
+
} else null != a && (o = a);
|
|
257
|
+
if (null == o) throw new l("children is required", "CHILDREN_REQUIRED");
|
|
258
|
+
const E = u(t), g = f(E, r).element;
|
|
259
|
+
b(g, {
|
|
260
|
+
id: r,
|
|
261
|
+
class: s.class,
|
|
262
|
+
name: s.name,
|
|
263
|
+
dataset: s.dataset,
|
|
264
|
+
style: s.style,
|
|
265
|
+
...Object.fromEntries(Object.entries(s).filter(([e]) => ![ "id", "class", "name", "dataset", "style", "inheritContext", "resilient" ].includes(e)))
|
|
266
|
+
});
|
|
267
|
+
let L = o;
|
|
268
|
+
if ((i?.inheritContext || s.inheritContext) && (L = x(o)), (i?.resilient || s.resilient) && I(g, () => f(E, r).element),
|
|
269
|
+
(i?.bubbleEvents || i?.isolateNativeEvents) && T(g, i.bubbleEvents || [], !0 === i.isolateNativeEvents),
|
|
270
|
+
i?.layout && M(g, i.layout), i?.overlay) {
|
|
271
|
+
const e = m(g, i.overlay);
|
|
272
|
+
if (i.overlay.lockScroll && h(g), i.overlay.trapFocus) {
|
|
273
|
+
const t = p(e);
|
|
274
|
+
if (t) {
|
|
275
|
+
const e = w.get(g) ?? {
|
|
276
|
+
zIndex: 0,
|
|
277
|
+
scrollLocked: !1
|
|
278
|
+
};
|
|
279
|
+
e.focusTrapCleanup = t, w.set(g, e);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
R(g, v(e, L));
|
|
283
|
+
} else R(g, v(g, L));
|
|
284
|
+
return g;
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
N.mount = function(e, r, o) {
|
|
288
|
+
if (d(), !(e instanceof HTMLElement)) throw new l("container must be an HTMLElement", "INVALID_CONTAINER");
|
|
289
|
+
if (null == r) throw new l("children is required for mount()", "CHILDREN_REQUIRED");
|
|
290
|
+
b(e, o);
|
|
291
|
+
let i, s = e;
|
|
292
|
+
if (o?.overlay && (s = m(e, o.overlay)), o?.overlay?.lockScroll && h(e), o?.overlay?.trapFocus) {
|
|
293
|
+
const e = p(s);
|
|
294
|
+
if (e) {
|
|
295
|
+
const t = w.get(s) ?? {
|
|
296
|
+
zIndex: 0,
|
|
297
|
+
scrollLocked: !1
|
|
298
|
+
};
|
|
299
|
+
t.focusTrapCleanup = e, w.set(s, t);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
if (o?.bubbleEvents || o?.isolateNativeEvents) {
|
|
303
|
+
let t = [];
|
|
304
|
+
o?.bubbleEvents && (t = o.bubbleEvents), T(e, t, !0 === o?.isolateNativeEvents);
|
|
305
|
+
}
|
|
306
|
+
if (o?.layout && M(e, o.layout), o?.root) {
|
|
307
|
+
let t = r;
|
|
308
|
+
o.inheritContext && (t = x(r)), o.root.render(n.createPortal(t, s)), c.add(e), i = o.root;
|
|
309
|
+
} else {
|
|
310
|
+
c.add(e);
|
|
311
|
+
let n = r;
|
|
312
|
+
o?.inheritContext && (n = x(r)), i = o?.hydrate ? function(e) {
|
|
313
|
+
if (e.innerHTML && e.innerHTML.trim() === "".trim()) {
|
|
314
|
+
const n = t.createRoot(e);
|
|
315
|
+
return a.set(e, n), n;
|
|
316
|
+
}
|
|
317
|
+
e.innerHTML = "";
|
|
318
|
+
const n = t.createRoot(e);
|
|
319
|
+
return a.set(e, n), n;
|
|
320
|
+
}(s) : v(s, n);
|
|
321
|
+
}
|
|
322
|
+
return i && R(e, i), o?.resilient && I(e, () => e), e;
|
|
323
|
+
}, N.unmount = function(e, t) {
|
|
324
|
+
if (d(), void 0 === e && void 0 === t) {
|
|
325
|
+
if (0 === c.size) return !1;
|
|
326
|
+
const e = Array.from(c);
|
|
327
|
+
for (const t of e) E(t);
|
|
328
|
+
return !0;
|
|
329
|
+
}
|
|
330
|
+
if (e && !t) {
|
|
331
|
+
const t = document.getElementById(e);
|
|
332
|
+
return !(!t || !c.has(t)) && E(t);
|
|
333
|
+
}
|
|
334
|
+
const n = u(e), r = t ? Array.from(n.children).find(e => e.id === t) : void 0;
|
|
335
|
+
return !(!r || !c.has(r)) && E(r);
|
|
336
|
+
}, N.clear = function(e) {
|
|
337
|
+
if (d(), !e) {
|
|
338
|
+
const e = c.size, t = Array.from(c);
|
|
339
|
+
for (const e of t) E(e);
|
|
340
|
+
return e;
|
|
341
|
+
}
|
|
342
|
+
const t = u(e);
|
|
343
|
+
let n = 0;
|
|
344
|
+
const r = Array.from(c);
|
|
345
|
+
for (const e of r) t.contains(e) && (E(e), n++);
|
|
346
|
+
return n;
|
|
347
|
+
}, N.has = function(e, t) {
|
|
348
|
+
if (e && t) {
|
|
349
|
+
const n = document.querySelector(e);
|
|
350
|
+
return !!n && Array.from(n.children).some(e => e.id === t && a.has(e));
|
|
351
|
+
}
|
|
352
|
+
if (e && !t) {
|
|
353
|
+
const t = document.getElementById(e);
|
|
354
|
+
return !!t && a.has(t);
|
|
355
|
+
}
|
|
356
|
+
return c.size > 0;
|
|
357
|
+
}, N.when = function(e, t = 0) {
|
|
358
|
+
if ("undefined" == typeof document) return Promise.reject(new l("reattach requires a browser environment", "ENVIRONMENT_ERROR"));
|
|
359
|
+
const n = document.querySelector(e);
|
|
360
|
+
return n ? Promise.resolve(n) : new Promise((n, r) => {
|
|
361
|
+
let o;
|
|
362
|
+
const i = new MutationObserver(() => {
|
|
363
|
+
const t = document.querySelector(e);
|
|
364
|
+
t && (o && clearTimeout(o), i.disconnect(), n(t));
|
|
365
|
+
});
|
|
366
|
+
i.observe(document.documentElement, {
|
|
367
|
+
childList: !0,
|
|
368
|
+
subtree: !0
|
|
369
|
+
}), t > 0 && (o = setTimeout(() => {
|
|
370
|
+
i.disconnect(), r(new l(`Timeout: "${e}" not found within ${t}ms`, "TIMEOUT"));
|
|
371
|
+
}, t));
|
|
372
|
+
});
|
|
373
|
+
}, N.global = function() {
|
|
374
|
+
d();
|
|
375
|
+
const e = globalThis;
|
|
376
|
+
return e.reattach || Object.defineProperty(e, "reattach", {
|
|
377
|
+
value: N,
|
|
378
|
+
configurable: !0,
|
|
379
|
+
enumerable: !1,
|
|
380
|
+
writable: !1
|
|
381
|
+
}), N;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
var O = (e, t) => {
|
|
385
|
+
const n = String(e.id);
|
|
386
|
+
try {
|
|
387
|
+
N.mount(t, e.body, {
|
|
388
|
+
id: `layerpro_body_${n}`,
|
|
389
|
+
inheritContext: e.inheritContext ?? !1,
|
|
390
|
+
resilient: e.resilient ?? !1
|
|
391
|
+
});
|
|
392
|
+
} catch (e) {
|
|
393
|
+
const t = e instanceof Error ? e.message : String(e);
|
|
394
|
+
t.includes("Invalid hook call") || t.includes("hooks") ? console.error("LayerPro Error: React hooks error detected. This usually happens when:\n1. Multiple copies of React are loaded on the page\n2. The component is called as a function instead of being passed as JSX\n3. React version mismatch between the app and LayerPro\n\nMake sure body is passed as <Component /> not <Component />()") : console.error("Error rendering React component:", e);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
O.unmount = e => {
|
|
399
|
+
N.unmount(`layerpro_body_${e}`);
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
var A = O;
|
|
403
|
+
|
|
404
|
+
module.exports = A;
|