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/react.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import e, { isValidElement as t } from "react";
|
|
2
|
+
|
|
3
|
+
import { createRoot as n } from "react-dom/client";
|
|
4
|
+
|
|
5
|
+
import { createPortal as o } from "react-dom";
|
|
6
|
+
|
|
7
|
+
var r = Object.defineProperty, i = (e, t, n) => {
|
|
8
|
+
return s = n, (i = "symbol" != typeof t ? t + "" : t) in (o = e) ? r(o, i, {
|
|
9
|
+
enumerable: !0,
|
|
10
|
+
configurable: !0,
|
|
11
|
+
writable: !0,
|
|
12
|
+
value: s
|
|
13
|
+
}) : o[i] = s;
|
|
14
|
+
var o, i, s;
|
|
15
|
+
}, s = class extends Error {
|
|
16
|
+
constructor(e, t, n) {
|
|
17
|
+
super(`[reattach:${t}] ${e}`), i(this, "code"), i(this, "details"), this.name = "ReattachError",
|
|
18
|
+
this.code = t, void 0 !== n && (this.details = n);
|
|
19
|
+
}
|
|
20
|
+
}, l = new WeakMap, a = new Set;
|
|
21
|
+
|
|
22
|
+
function c() {
|
|
23
|
+
if ("undefined" == typeof document || "undefined" == typeof window) throw new s("reattach requires a browser environment (document is not available)", "ENVIRONMENT_ERROR");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function d(e) {
|
|
27
|
+
if (c(), "string" != typeof e || 0 === e.length) throw new s("Invalid selector received: " + typeof e, "INVALID_SELECTOR");
|
|
28
|
+
const t = document.querySelector(e);
|
|
29
|
+
if (!t) throw new s(`No element found matching selector "${e}"`, "PARENT_NOT_FOUND");
|
|
30
|
+
return t;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function u(e, t) {
|
|
34
|
+
if (t) {
|
|
35
|
+
const n = Array.from(e.children).filter(e => e.id === t);
|
|
36
|
+
if (n.length, n.length > 0) return {
|
|
37
|
+
element: n[0],
|
|
38
|
+
created: !1
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const n = document.createElement("div");
|
|
42
|
+
return t && (n.id = t), e.appendChild(n), a.add(n), {
|
|
43
|
+
element: n,
|
|
44
|
+
created: !0
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function f(e, t) {
|
|
49
|
+
if (!t) return e;
|
|
50
|
+
const n = document.createElement("div");
|
|
51
|
+
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)),
|
|
52
|
+
n.style.position = "fixed", n.style.top = "0", n.style.left = "0", n.style.width = "100vw",
|
|
53
|
+
n.style.height = "100vh", n.style.display = "flex", n.style.alignItems = "center",
|
|
54
|
+
n.style.justifyContent = "center", n.style.pointerEvents = "auto", e.appendChild(n),
|
|
55
|
+
n;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function m(e, t) {
|
|
59
|
+
const n = g.get(e) ?? {
|
|
60
|
+
zIndex: 0,
|
|
61
|
+
scrollLocked: !1
|
|
62
|
+
};
|
|
63
|
+
n.scrollLocked = !0, n.originalOverflow = document.body.style.overflow, document.body.style.overflow = "hidden",
|
|
64
|
+
g.set(e, n);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function h(e) {
|
|
68
|
+
const t = g.get(e);
|
|
69
|
+
t && (t.scrollLocked && (document.body.style.overflow = t.originalOverflow ?? ""),
|
|
70
|
+
t.focusTrapCleanup && t.focusTrapCleanup(), t.scrollLocked = !1, t.originalOverflow = void 0,
|
|
71
|
+
t.focusTrapCleanup = void 0, g.set(e, t));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function y(e, t) {
|
|
75
|
+
const n = [ "a[href]", "button:not([disabled])", "input:not([disabled])", "select:not([disabled])", "textarea:not([disabled])", '[tabindex]:not([tabindex="-1"])' ].join(", "), o = Array.from(e.querySelectorAll(n));
|
|
76
|
+
if (0 === o.length) return;
|
|
77
|
+
const r = o[0], i = o[o.length - 1], s = e => {
|
|
78
|
+
"Tab" === e.key && (e.shiftKey && document.activeElement === r ? (e.preventDefault(),
|
|
79
|
+
i.focus()) : e.shiftKey || document.activeElement !== i || (e.preventDefault(),
|
|
80
|
+
r.focus()));
|
|
81
|
+
}, c = t => {
|
|
82
|
+
if ("Escape" === t.key && e.parentElement) {
|
|
83
|
+
e.parentElement.removeChild(e);
|
|
84
|
+
const t = l.get(e);
|
|
85
|
+
t && (t.unmount(), l.delete(e)), a.delete(e), g.delete(e), h(e);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
return e.addEventListener("keydown", s), document.addEventListener("keydown", c),
|
|
89
|
+
() => {
|
|
90
|
+
e.removeEventListener("keydown", s), document.removeEventListener("keydown", c);
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function p(o, r, i) {
|
|
95
|
+
let s = i ?? l.get(o);
|
|
96
|
+
return s || (s = n(o), l.set(o, s)), s.render(t(r) ? r : e.createElement(e.Fragment, null, r)),
|
|
97
|
+
s;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function v(e) {
|
|
101
|
+
const t = w.get(e);
|
|
102
|
+
t && t.destroy();
|
|
103
|
+
const n = l.get(e);
|
|
104
|
+
return n && (n.unmount(), l.delete(e)), a.delete(e), T(e), h(e), g.delete(e), e.remove(),
|
|
105
|
+
!0;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function b(e, t) {
|
|
109
|
+
if (!t) return;
|
|
110
|
+
t.id && (e.id = t.id), t.class && (e.className = t.class), t.name && (e.name = t.name),
|
|
111
|
+
t.dataset && Object.entries(t.dataset).forEach(([t, n]) => {
|
|
112
|
+
e.dataset[t] = n;
|
|
113
|
+
}), t.style && ("string" == typeof t.style ? e.setAttribute("style", t.style) : Object.assign(e.style, t.style));
|
|
114
|
+
const n = new Set([ "id", "class", "name", "dataset", "style", "root", "inheritContext", "resilient", "overlay", "bubbleEvents", "isolateNativeEvents", "layout", "hydrate" ]);
|
|
115
|
+
Object.entries(t).forEach(([t, o]) => {
|
|
116
|
+
n.has(t) || "string" != typeof o && "number" != typeof o && "boolean" != typeof o || e.setAttribute(t, String(o));
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var E = new Map, g = new Map, w = new WeakMap, L = new WeakMap;
|
|
121
|
+
|
|
122
|
+
function C(t = null) {
|
|
123
|
+
let n = t;
|
|
124
|
+
for (const [t, o] of E) n = e.createElement(t.Provider, {
|
|
125
|
+
value: o
|
|
126
|
+
}, n);
|
|
127
|
+
return n ? e.isValidElement(n) ? n : e.createElement(e.Fragment, null, n) : e.createElement(e.Fragment, null);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function x(t, n) {
|
|
131
|
+
const o = new MutationObserver(r => {
|
|
132
|
+
if (!document.contains(t)) {
|
|
133
|
+
o.disconnect();
|
|
134
|
+
let r = null;
|
|
135
|
+
try {
|
|
136
|
+
r = n();
|
|
137
|
+
} catch {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
if (r && r !== t) {
|
|
141
|
+
const o = l.get(t);
|
|
142
|
+
o && (o.unmount(), l.delete(t)), a.delete(t);
|
|
143
|
+
const r = n();
|
|
144
|
+
p(r, t.innerHTML ? e.createElement("div", {
|
|
145
|
+
dangerouslySetInnerHTML: {
|
|
146
|
+
__html: t.innerHTML
|
|
147
|
+
}
|
|
148
|
+
}) : null), x(r, n);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
o.observe(document.documentElement, {
|
|
153
|
+
childList: !0,
|
|
154
|
+
subtree: !0
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function I(e, t, n) {
|
|
159
|
+
const o = new Map;
|
|
160
|
+
L.set(e, o), n && (e.addEventListener("click", e => e.stopPropagation(), {
|
|
161
|
+
capture: !0
|
|
162
|
+
}), e.addEventListener("keydown", e => e.stopPropagation(), {
|
|
163
|
+
capture: !0
|
|
164
|
+
}), e.addEventListener("keyup", e => e.stopPropagation(), {
|
|
165
|
+
capture: !0
|
|
166
|
+
}));
|
|
167
|
+
const r = e.parentElement;
|
|
168
|
+
r && t.forEach(t => {
|
|
169
|
+
const n = t.slice(2).toLowerCase(), i = e => {
|
|
170
|
+
if (e.target === r) return;
|
|
171
|
+
const t = new CustomEvent(e.type, {
|
|
172
|
+
detail: {
|
|
173
|
+
originalEvent: e
|
|
174
|
+
},
|
|
175
|
+
bubbles: !0
|
|
176
|
+
});
|
|
177
|
+
r.dispatchEvent(t);
|
|
178
|
+
};
|
|
179
|
+
o.set(t, i), e.addEventListener(n, i, !0);
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function T(e) {
|
|
184
|
+
const t = L.get(e);
|
|
185
|
+
t && (t.forEach((t, n) => {
|
|
186
|
+
const o = n.slice(2).toLowerCase();
|
|
187
|
+
e.removeEventListener(o, t, !0);
|
|
188
|
+
}), L.delete(e));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function k(t, n) {
|
|
192
|
+
const o = w.get(t);
|
|
193
|
+
if (o) return o;
|
|
194
|
+
const r = {
|
|
195
|
+
updateProps: t => {
|
|
196
|
+
const o = e.createElement("div", t);
|
|
197
|
+
n.render(o);
|
|
198
|
+
},
|
|
199
|
+
getContainer: () => t,
|
|
200
|
+
destroy: () => {
|
|
201
|
+
n.unmount(), l.delete(t), a.delete(t), T(t), h(t), g.delete(t), w.delete(t);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
return w.set(t, r), r;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function N(e, t) {
|
|
208
|
+
if (!t.anchor) return;
|
|
209
|
+
const n = () => {
|
|
210
|
+
const n = document.querySelector(t.anchor);
|
|
211
|
+
if (!n || !e.parentElement) return;
|
|
212
|
+
const o = n.getBoundingClientRect(), r = e.getBoundingClientRect(), i = t.placement || "bottom", s = t.offset || 0;
|
|
213
|
+
let l = 0, a = 0;
|
|
214
|
+
const c = window.innerWidth, d = window.innerHeight;
|
|
215
|
+
i.startsWith("top") || i.startsWith("bottom") ? (l = i.startsWith("top") ? o.top - r.height - s : o.bottom + s,
|
|
216
|
+
a = i.endsWith("-start") ? o.left : i.endsWith("-end") ? o.right - r.width : o.left + (o.width - r.width) / 2) : (a = i.startsWith("left") ? o.left - r.width - s : o.right + s,
|
|
217
|
+
l = i.endsWith("-start") ? o.top : i.endsWith("-end") ? o.bottom - r.height : o.top + (o.height - r.height) / 2),
|
|
218
|
+
i.startsWith("bottom") && l + r.height > d && (l = o.top - r.height - s), i.startsWith("top") && l < 0 && (l = o.bottom + s),
|
|
219
|
+
i.startsWith("left") && a < 0 && (a = o.right + s), i.startsWith("right") && a + r.width > c && (a = o.left - r.width - s),
|
|
220
|
+
e.style.position = "fixed", e.style.top = `${Math.max(0, l)}px`, e.style.left = `${Math.max(0, a)}px`;
|
|
221
|
+
};
|
|
222
|
+
n();
|
|
223
|
+
const o = () => n(), r = () => n();
|
|
224
|
+
return window.addEventListener("resize", o), window.addEventListener("scroll", r, !0),
|
|
225
|
+
() => {
|
|
226
|
+
window.removeEventListener("resize", o), window.removeEventListener("scroll", r, !0);
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
var O = function(e, ...n) {
|
|
231
|
+
if (0 === n.length) {
|
|
232
|
+
if (c(), "string" != typeof e || 0 === e.length) throw new s("Invalid id argument", "INVALID_ID");
|
|
233
|
+
return document.getElementById(e) ?? null;
|
|
234
|
+
}
|
|
235
|
+
let o, r, i, l = {};
|
|
236
|
+
const [a, h, v] = n;
|
|
237
|
+
if ("string" == typeof a) {
|
|
238
|
+
if (o = a, r = h, v && "object" == typeof v && !Array.isArray(v)) {
|
|
239
|
+
const e = v;
|
|
240
|
+
l.inheritContext = !0 === e.inheritContext, l.resilient = !0 === e.resilient, i = e;
|
|
241
|
+
}
|
|
242
|
+
} else if (t(a)) {
|
|
243
|
+
if (r = a, h && "object" == typeof h && !Array.isArray(h)) {
|
|
244
|
+
const e = h;
|
|
245
|
+
l.inheritContext = !0 === e.inheritContext, l.resilient = !0 === e.resilient, i = e;
|
|
246
|
+
}
|
|
247
|
+
} else if (a && "object" == typeof a && !Array.isArray(a)) {
|
|
248
|
+
if (l = a, o = l.id, r = h, v && "object" == typeof v && !Array.isArray(v)) {
|
|
249
|
+
const e = v;
|
|
250
|
+
l.inheritContext = !0 === e.inheritContext, l.resilient = !0 === e.resilient, i = e;
|
|
251
|
+
}
|
|
252
|
+
} else null != a && (r = a);
|
|
253
|
+
if (null == r) throw new s("children is required", "CHILDREN_REQUIRED");
|
|
254
|
+
const E = d(e), w = u(E, o).element;
|
|
255
|
+
b(w, {
|
|
256
|
+
id: o,
|
|
257
|
+
class: l.class,
|
|
258
|
+
name: l.name,
|
|
259
|
+
dataset: l.dataset,
|
|
260
|
+
style: l.style,
|
|
261
|
+
...Object.fromEntries(Object.entries(l).filter(([e]) => ![ "id", "class", "name", "dataset", "style", "inheritContext", "resilient" ].includes(e)))
|
|
262
|
+
});
|
|
263
|
+
let L = r;
|
|
264
|
+
if ((i?.inheritContext || l.inheritContext) && (L = C(r)), (i?.resilient || l.resilient) && x(w, () => u(E, o).element),
|
|
265
|
+
(i?.bubbleEvents || i?.isolateNativeEvents) && I(w, i.bubbleEvents || [], !0 === i.isolateNativeEvents),
|
|
266
|
+
i?.layout && N(w, i.layout), i?.overlay) {
|
|
267
|
+
const e = f(w, i.overlay);
|
|
268
|
+
if (i.overlay.lockScroll && m(w), i.overlay.trapFocus) {
|
|
269
|
+
const t = y(e);
|
|
270
|
+
if (t) {
|
|
271
|
+
const e = g.get(w) ?? {
|
|
272
|
+
zIndex: 0,
|
|
273
|
+
scrollLocked: !1
|
|
274
|
+
};
|
|
275
|
+
e.focusTrapCleanup = t, g.set(w, e);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
k(w, p(e, L));
|
|
279
|
+
} else k(w, p(w, L));
|
|
280
|
+
return w;
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
O.mount = function(e, t, r) {
|
|
284
|
+
if (c(), !(e instanceof HTMLElement)) throw new s("container must be an HTMLElement", "INVALID_CONTAINER");
|
|
285
|
+
if (null == t) throw new s("children is required for mount()", "CHILDREN_REQUIRED");
|
|
286
|
+
b(e, r);
|
|
287
|
+
let i, d = e;
|
|
288
|
+
if (r?.overlay && (d = f(e, r.overlay)), r?.overlay?.lockScroll && m(e), r?.overlay?.trapFocus) {
|
|
289
|
+
const e = y(d);
|
|
290
|
+
if (e) {
|
|
291
|
+
const t = g.get(d) ?? {
|
|
292
|
+
zIndex: 0,
|
|
293
|
+
scrollLocked: !1
|
|
294
|
+
};
|
|
295
|
+
t.focusTrapCleanup = e, g.set(d, t);
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (r?.bubbleEvents || r?.isolateNativeEvents) {
|
|
299
|
+
let t = [];
|
|
300
|
+
r?.bubbleEvents && (t = r.bubbleEvents), I(e, t, !0 === r?.isolateNativeEvents);
|
|
301
|
+
}
|
|
302
|
+
if (r?.layout && N(e, r.layout), r?.root) {
|
|
303
|
+
let n = t;
|
|
304
|
+
r.inheritContext && (n = C(t)), r.root.render(o(n, d)), a.add(e), i = r.root;
|
|
305
|
+
} else {
|
|
306
|
+
a.add(e);
|
|
307
|
+
let o = t;
|
|
308
|
+
r?.inheritContext && (o = C(t)), i = r?.hydrate ? function(e) {
|
|
309
|
+
if (e.innerHTML && e.innerHTML.trim() === "".trim()) {
|
|
310
|
+
const t = n(e);
|
|
311
|
+
return l.set(e, t), t;
|
|
312
|
+
}
|
|
313
|
+
e.innerHTML = "";
|
|
314
|
+
const t = n(e);
|
|
315
|
+
return l.set(e, t), t;
|
|
316
|
+
}(d) : p(d, o);
|
|
317
|
+
}
|
|
318
|
+
return i && k(e, i), r?.resilient && x(e, () => e), e;
|
|
319
|
+
}, O.unmount = function(e, t) {
|
|
320
|
+
if (c(), void 0 === e && void 0 === t) {
|
|
321
|
+
if (0 === a.size) return !1;
|
|
322
|
+
const e = Array.from(a);
|
|
323
|
+
for (const t of e) v(t);
|
|
324
|
+
return !0;
|
|
325
|
+
}
|
|
326
|
+
if (e && !t) {
|
|
327
|
+
const t = document.getElementById(e);
|
|
328
|
+
return !(!t || !a.has(t)) && v(t);
|
|
329
|
+
}
|
|
330
|
+
const n = d(e), o = t ? Array.from(n.children).find(e => e.id === t) : void 0;
|
|
331
|
+
return !(!o || !a.has(o)) && v(o);
|
|
332
|
+
}, O.clear = function(e) {
|
|
333
|
+
if (c(), !e) {
|
|
334
|
+
const e = a.size, t = Array.from(a);
|
|
335
|
+
for (const e of t) v(e);
|
|
336
|
+
return e;
|
|
337
|
+
}
|
|
338
|
+
const t = d(e);
|
|
339
|
+
let n = 0;
|
|
340
|
+
const o = Array.from(a);
|
|
341
|
+
for (const e of o) t.contains(e) && (v(e), n++);
|
|
342
|
+
return n;
|
|
343
|
+
}, O.has = function(e, t) {
|
|
344
|
+
if (e && t) {
|
|
345
|
+
const n = document.querySelector(e);
|
|
346
|
+
return !!n && Array.from(n.children).some(e => e.id === t && l.has(e));
|
|
347
|
+
}
|
|
348
|
+
if (e && !t) {
|
|
349
|
+
const t = document.getElementById(e);
|
|
350
|
+
return !!t && l.has(t);
|
|
351
|
+
}
|
|
352
|
+
return a.size > 0;
|
|
353
|
+
}, O.when = function(e, t = 0) {
|
|
354
|
+
if ("undefined" == typeof document) return Promise.reject(new s("reattach requires a browser environment", "ENVIRONMENT_ERROR"));
|
|
355
|
+
const n = document.querySelector(e);
|
|
356
|
+
return n ? Promise.resolve(n) : new Promise((n, o) => {
|
|
357
|
+
let r;
|
|
358
|
+
const i = new MutationObserver(() => {
|
|
359
|
+
const t = document.querySelector(e);
|
|
360
|
+
t && (r && clearTimeout(r), i.disconnect(), n(t));
|
|
361
|
+
});
|
|
362
|
+
i.observe(document.documentElement, {
|
|
363
|
+
childList: !0,
|
|
364
|
+
subtree: !0
|
|
365
|
+
}), t > 0 && (r = setTimeout(() => {
|
|
366
|
+
i.disconnect(), o(new s(`Timeout: "${e}" not found within ${t}ms`, "TIMEOUT"));
|
|
367
|
+
}, t));
|
|
368
|
+
});
|
|
369
|
+
}, O.global = function() {
|
|
370
|
+
c();
|
|
371
|
+
const e = globalThis;
|
|
372
|
+
return e.reattach || Object.defineProperty(e, "reattach", {
|
|
373
|
+
value: O,
|
|
374
|
+
configurable: !0,
|
|
375
|
+
enumerable: !1,
|
|
376
|
+
writable: !1
|
|
377
|
+
}), O;
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
var R = (e, t) => {
|
|
381
|
+
const n = String(e.id);
|
|
382
|
+
try {
|
|
383
|
+
O.mount(t, e.body, {
|
|
384
|
+
id: `layerpro_body_${n}`,
|
|
385
|
+
inheritContext: e.inheritContext ?? !1,
|
|
386
|
+
resilient: e.resilient ?? !1
|
|
387
|
+
});
|
|
388
|
+
} catch (e) {
|
|
389
|
+
const t = e instanceof Error ? e.message : String(e);
|
|
390
|
+
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);
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
|
|
394
|
+
R.unmount = e => {
|
|
395
|
+
O.unmount(`layerpro_body_${e}`);
|
|
396
|
+
};
|
|
397
|
+
|
|
398
|
+
var A = R;
|
|
399
|
+
|
|
400
|
+
export { A as default };
|
package/types/layerpro.d.ts
CHANGED
|
@@ -1,132 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
/** Generate custom
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
declare function
|
|
14
|
-
|
|
15
|
-
/** Generate custom
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
readonly
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
*
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
/** Generate custom alert using alert([text]) */
|
|
4
|
+
declare function alert(f1?: string): void
|
|
5
|
+
|
|
6
|
+
/** Generate custom confirm using confirm([text],[callback for YES],[optional callback for NO])
|
|
7
|
+
* WARNING: This overrides the native confirm(). The return value is NOT a usable
|
|
8
|
+
* boolean — callbacks are invoked asynchronously instead. Never rely on the
|
|
9
|
+
* return value; use the yes/no callbacks. */
|
|
10
|
+
declare function confirm(message: string, func1: (yes: boolean) => void, func2?: (no: boolean) => void): void
|
|
11
|
+
|
|
12
|
+
/** Generate custom message using message([text],[callback]) and option callback */
|
|
13
|
+
declare function message(f1?: string, func1?: () => void): void
|
|
14
|
+
|
|
15
|
+
/** Generate custom prompt using prompt([text],[callback]) and option callback
|
|
16
|
+
* WARNING: This overrides the native prompt(). The return value is NOT a usable
|
|
17
|
+
* string — use the callback to receive the input. */
|
|
18
|
+
declare function prompt(f1?: string, func1?: (input: string) => void): void
|
|
19
|
+
|
|
20
|
+
///
|
|
21
|
+
|
|
22
|
+
interface LayerButtonConfig {
|
|
23
|
+
text: string
|
|
24
|
+
cb?: () => void
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface LayerButtonsConfig {
|
|
28
|
+
confirm?: LayerButtonConfig
|
|
29
|
+
cancel?: LayerButtonConfig
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface GenLayerProps {
|
|
33
|
+
id: string | number
|
|
34
|
+
body?: React.ReactElement | string | HTMLElement
|
|
35
|
+
name?: string
|
|
36
|
+
style?: Record<string, string | number>
|
|
37
|
+
class?: string
|
|
38
|
+
icon?: string
|
|
39
|
+
|
|
40
|
+
buttons?: LayerButtonsConfig
|
|
41
|
+
|
|
42
|
+
top?: number | string
|
|
43
|
+
left?: number | string
|
|
44
|
+
right?: number | string
|
|
45
|
+
bottom?: number | string
|
|
46
|
+
|
|
47
|
+
width?: number | string
|
|
48
|
+
height?: number | string
|
|
49
|
+
|
|
50
|
+
minWidth?: number
|
|
51
|
+
minHeight?: number
|
|
52
|
+
maxWidth?: number
|
|
53
|
+
maxHeight?: number
|
|
54
|
+
|
|
55
|
+
fadeIn?: number
|
|
56
|
+
fadeOut?: number
|
|
57
|
+
timer?: number
|
|
58
|
+
|
|
59
|
+
maximize?: boolean
|
|
60
|
+
isMaximize?: boolean
|
|
61
|
+
dockable?: boolean
|
|
62
|
+
movable?: boolean
|
|
63
|
+
|
|
64
|
+
resizable?: boolean
|
|
65
|
+
close?: boolean
|
|
66
|
+
raised?: boolean
|
|
67
|
+
modal?: boolean
|
|
68
|
+
iconize?: boolean
|
|
69
|
+
center?: boolean
|
|
70
|
+
|
|
71
|
+
source?: string
|
|
72
|
+
store?: unknown
|
|
73
|
+
inheritContext?: boolean
|
|
74
|
+
resilient?: boolean
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Interface for the layerpro object
|
|
79
|
+
*/
|
|
80
|
+
interface _layerpro {
|
|
81
|
+
|
|
82
|
+
readonly alert: (txt: string) => void
|
|
83
|
+
readonly prompt: (txt: string, callback: (input: string) => void) => void
|
|
84
|
+
readonly message: (txt: string, callback: () => void) => void
|
|
85
|
+
readonly confirm: (txt: string, yesCallback: () => void, noCallback?: () => void) => void
|
|
86
|
+
readonly credits: (props: { name: string, version: string, description: string, license: string, author: { name: string, email: string } }) => void
|
|
87
|
+
|
|
88
|
+
setProps: (obj: Record<string, unknown>, options?: { enumerable?: boolean, writable?: boolean }) => void
|
|
89
|
+
|
|
90
|
+
/** Remove the global alert/confirm/prompt/message overrides and restore
|
|
91
|
+
* the native browser implementations. Call this right after importing
|
|
92
|
+
* LayerPro if your codebase depends on synchronous native globals. */
|
|
93
|
+
readonly noGlobals: () => void
|
|
94
|
+
|
|
95
|
+
/** Opt-in to override the browser's native alert/confirm/prompt/message
|
|
96
|
+
* globals with LayerPro's callback-based versions. This is opt-in so
|
|
97
|
+
* libraries embedded in other applications do not silently change
|
|
98
|
+
* global behavior. */
|
|
99
|
+
readonly installGlobals: () => void
|
|
100
|
+
|
|
101
|
+
readonly popup: {
|
|
102
|
+
open: (props: GenLayerProps) => GenLayerProps
|
|
103
|
+
center: (id: string | number | GenLayerProps, offset?: number) => void
|
|
104
|
+
maximize: (props: GenLayerProps) => void
|
|
105
|
+
iconize: (id: string | number | GenLayerProps) => void
|
|
106
|
+
movable: (props: GenLayerProps) => void
|
|
107
|
+
resizable: (props: GenLayerProps) => void
|
|
108
|
+
store: (element: unknown) => void
|
|
109
|
+
index: (id: string | number | GenLayerProps) => void
|
|
110
|
+
zIndex: (props?: GenLayerProps) => number
|
|
111
|
+
close: (id: string | number | GenLayerProps | null | undefined) => void
|
|
112
|
+
unmount: (id: string) => void
|
|
113
|
+
cleanupEvents: (id: string) => void
|
|
114
|
+
abortSource: (id: string) => void
|
|
115
|
+
useReactAdapter?: (props: GenLayerProps, container: HTMLElement) => void
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* LayerPro overrides the native alert/confirm/prompt globals and adds a
|
|
122
|
+
* `message` global. They are callback-based and do NOT return native values.
|
|
123
|
+
* Call `layerpro.noGlobals()` to restore the synchronous natives.
|
|
124
|
+
*/
|
|
125
|
+
interface Window {
|
|
126
|
+
layerpro: _layerpro
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
declare var layerpro: _layerpro
|
|
130
|
+
type layerpro = _layerpro
|
|
131
|
+
|
|
132
|
+
declare var popup: layerpro
|
|
133
|
+
type popup = layerpro
|