@encatch/ws-react 0.0.36 → 0.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/EncatchPreview.d.ts +1 -1
- package/dist/ws-react.es.js +123 -133
- package/dist/ws-react.umd.js +4 -264
- package/package.json +1 -1
- package/dist/web-form-engine-core.umd-DWVcgyyq.js +0 -18025
package/dist/EncatchPreview.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { OnFormEventHandler } from "./types";
|
|
|
4
4
|
declare module "react" {
|
|
5
5
|
namespace JSX {
|
|
6
6
|
interface IntrinsicElements {
|
|
7
|
-
"encatch-app
|
|
7
|
+
"encatch-app": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
|
|
8
8
|
theme?: AppProps["theme"];
|
|
9
9
|
currentMode?: "light" | "dark";
|
|
10
10
|
currentLanguage?: AppProps["currentLanguage"];
|
package/dist/ws-react.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import I, { useState as
|
|
2
|
-
var
|
|
1
|
+
import I, { useState as V, useRef as oe, useEffect as S, useCallback as se } from "react";
|
|
2
|
+
var A = { exports: {} }, P = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -9,12 +9,12 @@ var k = { exports: {} }, A = {};
|
|
|
9
9
|
* This source code is licensed under the MIT license found in the
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
15
|
-
|
|
16
|
-
var
|
|
17
|
-
function
|
|
12
|
+
var U;
|
|
13
|
+
function ie() {
|
|
14
|
+
if (U) return P;
|
|
15
|
+
U = 1;
|
|
16
|
+
var o = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
17
|
+
function t(u, s, c) {
|
|
18
18
|
var m = null;
|
|
19
19
|
if (c !== void 0 && (m = "" + c), s.key !== void 0 && (m = "" + s.key), "key" in s) {
|
|
20
20
|
c = {};
|
|
@@ -22,16 +22,16 @@ function ue() {
|
|
|
22
22
|
p !== "key" && (c[p] = s[p]);
|
|
23
23
|
} else c = s;
|
|
24
24
|
return s = c.ref, {
|
|
25
|
-
$$typeof:
|
|
25
|
+
$$typeof: o,
|
|
26
26
|
type: u,
|
|
27
27
|
key: m,
|
|
28
28
|
ref: s !== void 0 ? s : null,
|
|
29
29
|
props: c
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return P.Fragment = r, P.jsx = t, P.jsxs = t, P;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var k = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -41,26 +41,26 @@ var P = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
45
|
-
function
|
|
46
|
-
return
|
|
47
|
-
function
|
|
44
|
+
var J;
|
|
45
|
+
function ue() {
|
|
46
|
+
return J || (J = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
|
+
function o(e) {
|
|
48
48
|
if (e == null) return null;
|
|
49
49
|
if (typeof e == "function")
|
|
50
|
-
return e.$$typeof ===
|
|
50
|
+
return e.$$typeof === re ? null : e.displayName || e.name || null;
|
|
51
51
|
if (typeof e == "string") return e;
|
|
52
52
|
switch (e) {
|
|
53
53
|
case f:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case X:
|
|
56
|
-
return "Profiler";
|
|
57
55
|
case Q:
|
|
56
|
+
return "Profiler";
|
|
57
|
+
case G:
|
|
58
58
|
return "StrictMode";
|
|
59
|
-
case
|
|
59
|
+
case Z:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case K:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case ee:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof e == "object")
|
|
@@ -69,19 +69,19 @@ function ce() {
|
|
|
69
69
|
), e.$$typeof) {
|
|
70
70
|
case i:
|
|
71
71
|
return "Portal";
|
|
72
|
-
case H:
|
|
73
|
-
return (e.displayName || "Context") + ".Provider";
|
|
74
72
|
case B:
|
|
73
|
+
return (e.displayName || "Context") + ".Provider";
|
|
74
|
+
case X:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
77
|
-
var
|
|
78
|
-
return e = e.displayName, e || (e =
|
|
79
|
-
case
|
|
80
|
-
return
|
|
81
|
-
case
|
|
82
|
-
|
|
76
|
+
case H:
|
|
77
|
+
var n = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case D:
|
|
80
|
+
return n = e.displayName || null, n !== null ? n : o(e.type) || "Memo";
|
|
81
|
+
case M:
|
|
82
|
+
n = e._payload, e = e._init;
|
|
83
83
|
try {
|
|
84
|
-
return
|
|
84
|
+
return o(e(n));
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -90,18 +90,18 @@ function ce() {
|
|
|
90
90
|
function r(e) {
|
|
91
91
|
return "" + e;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function t(e) {
|
|
94
94
|
try {
|
|
95
95
|
r(e);
|
|
96
|
-
var
|
|
96
|
+
var n = !1;
|
|
97
97
|
} catch {
|
|
98
|
-
|
|
98
|
+
n = !0;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
var l =
|
|
100
|
+
if (n) {
|
|
101
|
+
n = console;
|
|
102
|
+
var l = n.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
103
|
return l.call(
|
|
104
|
-
|
|
104
|
+
n,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
106
|
d
|
|
107
107
|
), r(e);
|
|
@@ -109,11 +109,11 @@ function ce() {
|
|
|
109
109
|
}
|
|
110
110
|
function u(e) {
|
|
111
111
|
if (e === f) return "<>";
|
|
112
|
-
if (typeof e == "object" && e !== null && e.$$typeof ===
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === M)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
|
-
var
|
|
116
|
-
return
|
|
115
|
+
var n = o(e);
|
|
116
|
+
return n ? "<" + n + ">" : "<...>";
|
|
117
117
|
} catch {
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
@@ -126,17 +126,17 @@ function ce() {
|
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
128
|
function m(e) {
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
129
|
+
if (F.call(e, "key")) {
|
|
130
|
+
var n = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (n && n.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function p(e,
|
|
135
|
+
function p(e, n) {
|
|
136
136
|
function l() {
|
|
137
|
-
|
|
137
|
+
Y || (Y = !0, console.error(
|
|
138
138
|
"%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)",
|
|
139
|
-
|
|
139
|
+
n
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
142
|
l.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
@@ -145,18 +145,18 @@ function ce() {
|
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
function R() {
|
|
148
|
-
var e =
|
|
149
|
-
return
|
|
148
|
+
var e = o(this.type);
|
|
149
|
+
return L[e] || (L[e] = !0, console.error(
|
|
150
150
|
"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."
|
|
151
151
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
152
|
}
|
|
153
|
-
function T(e,
|
|
153
|
+
function T(e, n, l, d, w, E, x, j) {
|
|
154
154
|
return l = E.ref, e = {
|
|
155
155
|
$$typeof: y,
|
|
156
156
|
type: e,
|
|
157
|
-
key:
|
|
157
|
+
key: n,
|
|
158
158
|
props: E,
|
|
159
|
-
_owner:
|
|
159
|
+
_owner: w
|
|
160
160
|
}, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
161
|
enumerable: !1,
|
|
162
162
|
get: R
|
|
@@ -182,25 +182,25 @@ function ce() {
|
|
|
182
182
|
value: j
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function h(e,
|
|
186
|
-
var b =
|
|
185
|
+
function h(e, n, l, d, w, E, x, j) {
|
|
186
|
+
var b = n.children;
|
|
187
187
|
if (b !== void 0)
|
|
188
188
|
if (d)
|
|
189
|
-
if (
|
|
189
|
+
if (te(b)) {
|
|
190
190
|
for (d = 0; d < b.length; d++)
|
|
191
|
-
|
|
191
|
+
g(b[d]);
|
|
192
192
|
Object.freeze && Object.freeze(b);
|
|
193
193
|
} else
|
|
194
194
|
console.error(
|
|
195
195
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
196
|
);
|
|
197
|
-
else
|
|
198
|
-
if (
|
|
199
|
-
b =
|
|
200
|
-
var _ = Object.keys(
|
|
201
|
-
return
|
|
197
|
+
else g(b);
|
|
198
|
+
if (F.call(n, "key")) {
|
|
199
|
+
b = o(e);
|
|
200
|
+
var _ = Object.keys(n).filter(function(ne) {
|
|
201
|
+
return ne !== "key";
|
|
202
202
|
});
|
|
203
|
-
d = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}",
|
|
203
|
+
d = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", q[b + d] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
204
|
`A props object containing a "key" prop is being spread into JSX:
|
|
205
205
|
let props = %s;
|
|
206
206
|
<%s {...props} />
|
|
@@ -211,13 +211,13 @@ React keys must be passed directly to JSX without using spread:
|
|
|
211
211
|
b,
|
|
212
212
|
_,
|
|
213
213
|
b
|
|
214
|
-
),
|
|
214
|
+
), q[b + d] = !0);
|
|
215
215
|
}
|
|
216
|
-
if (b = null, l !== void 0 && (
|
|
216
|
+
if (b = null, l !== void 0 && (t(l), b = "" + l), m(n) && (t(n.key), b = "" + n.key), "key" in n) {
|
|
217
217
|
l = {};
|
|
218
|
-
for (var N in
|
|
219
|
-
N !== "key" && (l[N] =
|
|
220
|
-
} else l =
|
|
218
|
+
for (var N in n)
|
|
219
|
+
N !== "key" && (l[N] = n[N]);
|
|
220
|
+
} else l = n;
|
|
221
221
|
return b && p(
|
|
222
222
|
l,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
@@ -225,17 +225,17 @@ React keys must be passed directly to JSX without using spread:
|
|
|
225
225
|
e,
|
|
226
226
|
b,
|
|
227
227
|
E,
|
|
228
|
-
|
|
228
|
+
w,
|
|
229
229
|
s(),
|
|
230
230
|
l,
|
|
231
231
|
x,
|
|
232
232
|
j
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
|
-
function
|
|
235
|
+
function g(e) {
|
|
236
236
|
typeof e == "object" && e !== null && e.$$typeof === y && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var a = I, y = Symbol.for("react.transitional.element"), i = Symbol.for("react.portal"), f = Symbol.for("react.fragment"),
|
|
238
|
+
var a = I, y = Symbol.for("react.transitional.element"), i = Symbol.for("react.portal"), f = Symbol.for("react.fragment"), G = Symbol.for("react.strict_mode"), Q = Symbol.for("react.profiler"), X = Symbol.for("react.consumer"), B = Symbol.for("react.context"), H = Symbol.for("react.forward_ref"), Z = Symbol.for("react.suspense"), K = Symbol.for("react.suspense_list"), D = Symbol.for("react.memo"), M = Symbol.for("react.lazy"), ee = Symbol.for("react.activity"), re = Symbol.for("react.client.reference"), C = a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, F = Object.prototype.hasOwnProperty, te = Array.isArray, O = console.createTask ? console.createTask : function() {
|
|
239
239
|
return null;
|
|
240
240
|
};
|
|
241
241
|
a = {
|
|
@@ -243,50 +243,50 @@ React keys must be passed directly to JSX without using spread:
|
|
|
243
243
|
return e();
|
|
244
244
|
}
|
|
245
245
|
};
|
|
246
|
-
var
|
|
246
|
+
var Y, L = {}, W = a.react_stack_bottom_frame.bind(
|
|
247
247
|
a,
|
|
248
248
|
c
|
|
249
|
-
)(), $ = O(u(c)),
|
|
250
|
-
|
|
249
|
+
)(), $ = O(u(c)), q = {};
|
|
250
|
+
k.Fragment = f, k.jsx = function(e, n, l, d, w) {
|
|
251
251
|
var E = 1e4 > C.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return h(
|
|
253
253
|
e,
|
|
254
|
-
|
|
254
|
+
n,
|
|
255
255
|
l,
|
|
256
256
|
!1,
|
|
257
257
|
d,
|
|
258
|
-
|
|
258
|
+
w,
|
|
259
259
|
E ? Error("react-stack-top-frame") : W,
|
|
260
260
|
E ? O(u(e)) : $
|
|
261
261
|
);
|
|
262
|
-
},
|
|
262
|
+
}, k.jsxs = function(e, n, l, d, w) {
|
|
263
263
|
var E = 1e4 > C.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return h(
|
|
265
265
|
e,
|
|
266
|
-
|
|
266
|
+
n,
|
|
267
267
|
l,
|
|
268
268
|
!0,
|
|
269
269
|
d,
|
|
270
|
-
|
|
270
|
+
w,
|
|
271
271
|
E ? Error("react-stack-top-frame") : W,
|
|
272
272
|
E ? O(u(e)) : $
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
|
-
})()),
|
|
275
|
+
})()), k;
|
|
276
276
|
}
|
|
277
|
-
var
|
|
278
|
-
function
|
|
279
|
-
return
|
|
277
|
+
var z;
|
|
278
|
+
function ce() {
|
|
279
|
+
return z || (z = 1, process.env.NODE_ENV === "production" ? A.exports = ie() : A.exports = ue()), A.exports;
|
|
280
280
|
}
|
|
281
|
-
var
|
|
282
|
-
class
|
|
281
|
+
var ae = ce();
|
|
282
|
+
class le extends EventTarget {
|
|
283
283
|
subscriptions = /* @__PURE__ */ new Map();
|
|
284
284
|
targetOrigin = "*";
|
|
285
285
|
/**
|
|
286
286
|
* Check if a form ID matches the filter
|
|
287
287
|
*/
|
|
288
|
-
matchesFilter(r,
|
|
289
|
-
return !
|
|
288
|
+
matchesFilter(r, t) {
|
|
289
|
+
return !t || t === "*" || t === null || t === void 0 ? !0 : typeof t == "string" ? r === t : Array.isArray(t) ? t.includes(r || "") : typeof t == "function" ? t(r || "") : !1;
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
292
|
* Get form ID from payload
|
|
@@ -297,21 +297,21 @@ class fe extends EventTarget {
|
|
|
297
297
|
/**
|
|
298
298
|
* Publish an event to all matching subscribers
|
|
299
299
|
*/
|
|
300
|
-
publish(r,
|
|
300
|
+
publish(r, t, u) {
|
|
301
301
|
typeof window < "u" && window.dispatchEvent(
|
|
302
302
|
new CustomEvent(r, {
|
|
303
|
-
detail:
|
|
303
|
+
detail: t,
|
|
304
304
|
bubbles: !0
|
|
305
305
|
})
|
|
306
|
-
), u?.usePostMessage !== !1 && this.sendPostMessage(r,
|
|
306
|
+
), u?.usePostMessage !== !1 && this.sendPostMessage(r, t);
|
|
307
307
|
}
|
|
308
308
|
/**
|
|
309
309
|
* Subscribe to form events with optional form ID filtering
|
|
310
310
|
*/
|
|
311
|
-
subscribe(r,
|
|
311
|
+
subscribe(r, t, u) {
|
|
312
312
|
const s = Symbol("subscription"), c = {
|
|
313
313
|
eventType: r,
|
|
314
|
-
handler:
|
|
314
|
+
handler: t,
|
|
315
315
|
filter: u?.formId,
|
|
316
316
|
id: s,
|
|
317
317
|
once: u?.once
|
|
@@ -319,7 +319,7 @@ class fe extends EventTarget {
|
|
|
319
319
|
this.subscriptions.has(r) || this.subscriptions.set(r, []), this.subscriptions.get(r).push(c);
|
|
320
320
|
const m = (p) => {
|
|
321
321
|
const R = p, T = this.getFormIdFromPayload(R.detail);
|
|
322
|
-
this.matchesFilter(T, u?.formId) && (
|
|
322
|
+
this.matchesFilter(T, u?.formId) && (t(R.detail), u?.once && typeof window < "u" && window.removeEventListener(r, m));
|
|
323
323
|
};
|
|
324
324
|
return typeof window < "u" && window.addEventListener(r, m), () => {
|
|
325
325
|
this.unsubscribe(s), typeof window < "u" && window.removeEventListener(r, m);
|
|
@@ -329,10 +329,10 @@ class fe extends EventTarget {
|
|
|
329
329
|
* Unsubscribe by subscription ID
|
|
330
330
|
*/
|
|
331
331
|
unsubscribe(r) {
|
|
332
|
-
for (const [
|
|
332
|
+
for (const [t, u] of this.subscriptions.entries()) {
|
|
333
333
|
const s = u.findIndex((c) => c.id === r);
|
|
334
334
|
if (s !== -1) {
|
|
335
|
-
u.splice(s, 1), u.length === 0 && this.subscriptions.delete(
|
|
335
|
+
u.splice(s, 1), u.length === 0 && this.subscriptions.delete(t);
|
|
336
336
|
break;
|
|
337
337
|
}
|
|
338
338
|
}
|
|
@@ -340,7 +340,7 @@ class fe extends EventTarget {
|
|
|
340
340
|
/**
|
|
341
341
|
* Subscribe to all form events with optional filtering
|
|
342
342
|
*/
|
|
343
|
-
subscribeAll(r,
|
|
343
|
+
subscribeAll(r, t) {
|
|
344
344
|
const u = [
|
|
345
345
|
"form:view",
|
|
346
346
|
"form:submit",
|
|
@@ -353,7 +353,7 @@ class fe extends EventTarget {
|
|
|
353
353
|
const m = this.subscribe(
|
|
354
354
|
c,
|
|
355
355
|
(p) => r(c, p),
|
|
356
|
-
|
|
356
|
+
t
|
|
357
357
|
);
|
|
358
358
|
s.push(m);
|
|
359
359
|
}), () => {
|
|
@@ -364,7 +364,7 @@ class fe extends EventTarget {
|
|
|
364
364
|
* Get active subscriptions count (for debugging)
|
|
365
365
|
*/
|
|
366
366
|
getSubscriptionCount(r) {
|
|
367
|
-
return r ? this.subscriptions.get(r)?.length || 0 : Array.from(this.subscriptions.values()).reduce((
|
|
367
|
+
return r ? this.subscriptions.get(r)?.length || 0 : Array.from(this.subscriptions.values()).reduce((t, u) => t + u.length, 0);
|
|
368
368
|
}
|
|
369
369
|
/**
|
|
370
370
|
* Clear all subscriptions for an event type (or all events)
|
|
@@ -372,39 +372,31 @@ class fe extends EventTarget {
|
|
|
372
372
|
clearSubscriptions(r) {
|
|
373
373
|
r ? this.subscriptions.delete(r) : this.subscriptions.clear();
|
|
374
374
|
}
|
|
375
|
-
sendPostMessage(r,
|
|
375
|
+
sendPostMessage(r, t) {
|
|
376
376
|
const u = {
|
|
377
377
|
type: `encatch:${r}`,
|
|
378
|
-
payload:
|
|
378
|
+
payload: t,
|
|
379
379
|
source: "encatch-form-engine"
|
|
380
380
|
};
|
|
381
381
|
window.parent && window.parent !== window && window.parent.postMessage(u, this.targetOrigin), document.querySelectorAll("iframe").forEach((s) => {
|
|
382
382
|
s.contentWindow && s.contentWindow.postMessage(u, this.targetOrigin);
|
|
383
383
|
}), typeof window.ReactNativeWebView < "u" && window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
384
384
|
action: r.replace("form:", ""),
|
|
385
|
-
data: JSON.stringify(
|
|
385
|
+
data: JSON.stringify(t)
|
|
386
386
|
}));
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
|
-
const v = new
|
|
390
|
-
|
|
391
|
-
try {
|
|
392
|
-
customElements.get(M) || customElements.define(M, t);
|
|
393
|
-
} catch (r) {
|
|
394
|
-
console.debug("Custom element registration:", r);
|
|
395
|
-
}
|
|
396
|
-
});
|
|
397
|
-
const be = ({
|
|
398
|
-
formData: t,
|
|
389
|
+
const v = new le(), de = ({
|
|
390
|
+
formData: o,
|
|
399
391
|
cssLink: r,
|
|
400
|
-
scale:
|
|
392
|
+
scale: t = 100,
|
|
401
393
|
persistMode: u = "none",
|
|
402
394
|
instanceId: s,
|
|
403
395
|
onFormEvent: c
|
|
404
396
|
}) => {
|
|
405
|
-
const [m, p] =
|
|
397
|
+
const [m, p] = V(!1), [R, T] = V(!0), h = I.useRef(null), g = I.useRef(
|
|
406
398
|
null
|
|
407
|
-
), a =
|
|
399
|
+
), a = oe({});
|
|
408
400
|
S(() => {
|
|
409
401
|
if (!c) return;
|
|
410
402
|
c({
|
|
@@ -472,40 +464,38 @@ const be = ({
|
|
|
472
464
|
}, [s]), S(() => {
|
|
473
465
|
(() => {
|
|
474
466
|
try {
|
|
475
|
-
return
|
|
467
|
+
return o ? !0 : (console.warn("[EncatchPreview] formData is not defined"), !1);
|
|
476
468
|
} catch (f) {
|
|
477
469
|
return console.error("[EncatchPreview] Error during data validation:", f), !1;
|
|
478
470
|
}
|
|
479
471
|
})() ? p(!0) : console.warn(
|
|
480
472
|
"[EncatchPreview] Data validation failed, retrying in 100ms..."
|
|
481
473
|
);
|
|
482
|
-
}, [
|
|
483
|
-
const y =
|
|
484
|
-
|
|
485
|
-
}, [
|
|
474
|
+
}, [o]);
|
|
475
|
+
const y = se(() => {
|
|
476
|
+
o.onClose && o.onClose(), T(!1);
|
|
477
|
+
}, [o.onClose]);
|
|
486
478
|
return S(() => {
|
|
487
479
|
if (!m || !h.current)
|
|
488
480
|
return;
|
|
489
|
-
const i = document.createElement(
|
|
490
|
-
return
|
|
491
|
-
|
|
492
|
-
}), () => {
|
|
493
|
-
h.current && w.current && h.current.removeChild(w.current), w.current = null;
|
|
481
|
+
const i = document.createElement("encatch-app");
|
|
482
|
+
return i.theme = o.theme, i.currentMode = o.currentMode, i.currentLanguage = o.currentLanguage, i.questions = o.questions, i.questionLanguages = o.questionLanguages, i.otherConfigurationProperties = o.otherConfigurationProperties, i.welcomeScreenProperties = o.welcomeScreenProperties, i.endScreenProperties = o.endScreenProperties, i.translations = o.translations, i.sections = o.sections, i.themeSettings = o.themeSettings, i.onClose = y, i.onSectionChange = o.onSectionChange, i.apiKey = o.apiKey, i.hostUrl = o.hostUrl, i.feedbackConfigId = o.feedbackConfigId, i.identifier = o.identifier, r && (i.cssLink = r), i.scale = t, i.persistMode = u, s && (i.instanceId = s), g.current = i, h.current.appendChild(i), () => {
|
|
483
|
+
h.current && g.current && h.current.removeChild(g.current), g.current = null;
|
|
494
484
|
};
|
|
495
|
-
}, [m,
|
|
485
|
+
}, [m, o, r, t, y, u, s]), R ? /* @__PURE__ */ ae.jsx("div", { ref: h }) : null;
|
|
496
486
|
};
|
|
497
|
-
function
|
|
487
|
+
function be(o, r, t) {
|
|
498
488
|
S(() => v.subscribe(
|
|
499
|
-
|
|
489
|
+
o,
|
|
500
490
|
r,
|
|
501
|
-
|
|
502
|
-
), [
|
|
491
|
+
t
|
|
492
|
+
), [o, t?.formId, r]);
|
|
503
493
|
}
|
|
504
|
-
function
|
|
505
|
-
S(() => v.subscribeAll(
|
|
494
|
+
function me(o, r) {
|
|
495
|
+
S(() => v.subscribeAll(o, r), [r?.formId, o]);
|
|
506
496
|
}
|
|
507
497
|
export {
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
498
|
+
de as EncatchPreview,
|
|
499
|
+
be as useEncatchFormEvent,
|
|
500
|
+
me as useEncatchFormEventAll
|
|
511
501
|
};
|