@encatch/ws-react 0.0.19 → 0.0.21
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/ws-react.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
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,10 +9,10 @@ var k = { exports: {} }, y = {};
|
|
|
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
|
|
12
|
+
var U;
|
|
13
13
|
function ie() {
|
|
14
|
-
if (
|
|
15
|
-
|
|
14
|
+
if (U) return P;
|
|
15
|
+
U = 1;
|
|
16
16
|
var t = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
|
|
17
17
|
function n(u, s, c) {
|
|
18
18
|
var m = null;
|
|
@@ -29,9 +29,9 @@ function ie() {
|
|
|
29
29
|
props: c
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return P.Fragment = r, P.jsx = n, P.jsxs = n, P;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var k = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -78,7 +78,7 @@ function ue() {
|
|
|
78
78
|
return e = e.displayName, e || (e = o.displayName || o.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
79
|
case D:
|
|
80
80
|
return o = e.displayName || null, o !== null ? o : t(e.type) || "Memo";
|
|
81
|
-
case
|
|
81
|
+
case M:
|
|
82
82
|
o = e._payload, e = e._init;
|
|
83
83
|
try {
|
|
84
84
|
return t(e(o));
|
|
@@ -109,7 +109,7 @@ function ue() {
|
|
|
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
115
|
var o = t(e);
|
|
@@ -126,7 +126,7 @@ function ue() {
|
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
128
|
function m(e) {
|
|
129
|
-
if (
|
|
129
|
+
if (F.call(e, "key")) {
|
|
130
130
|
var o = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
131
|
if (o && o.isReactWarning) return !1;
|
|
132
132
|
}
|
|
@@ -134,7 +134,7 @@ function ue() {
|
|
|
134
134
|
}
|
|
135
135
|
function p(e, o) {
|
|
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
|
o
|
|
140
140
|
));
|
|
@@ -146,17 +146,17 @@ function ue() {
|
|
|
146
146
|
}
|
|
147
147
|
function R() {
|
|
148
148
|
var e = t(this.type);
|
|
149
|
-
return
|
|
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
|
|
153
|
+
function T(e, o, l, d, w, h, x, j) {
|
|
154
154
|
return l = h.ref, e = {
|
|
155
|
-
$$typeof:
|
|
155
|
+
$$typeof: y,
|
|
156
156
|
type: e,
|
|
157
157
|
key: o,
|
|
158
158
|
props: h,
|
|
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,11 +182,11 @@ function ue() {
|
|
|
182
182
|
value: j
|
|
183
183
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
184
|
}
|
|
185
|
-
function E(e, o, l, d,
|
|
185
|
+
function E(e, o, l, d, w, h, x, j) {
|
|
186
186
|
var b = o.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
|
v(b[d]);
|
|
192
192
|
Object.freeze && Object.freeze(b);
|
|
@@ -195,10 +195,10 @@ function ue() {
|
|
|
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
197
|
else v(b);
|
|
198
|
-
if (
|
|
198
|
+
if (F.call(o, "key")) {
|
|
199
199
|
b = t(e);
|
|
200
|
-
var _ = Object.keys(o).filter(function(
|
|
201
|
-
return
|
|
200
|
+
var _ = Object.keys(o).filter(function(ne) {
|
|
201
|
+
return ne !== "key";
|
|
202
202
|
});
|
|
203
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:
|
|
@@ -215,17 +215,17 @@ React keys must be passed directly to JSX without using spread:
|
|
|
215
215
|
}
|
|
216
216
|
if (b = null, l !== void 0 && (n(l), b = "" + l), m(o) && (n(o.key), b = "" + o.key), "key" in o) {
|
|
217
217
|
l = {};
|
|
218
|
-
for (var
|
|
219
|
-
|
|
218
|
+
for (var N in o)
|
|
219
|
+
N !== "key" && (l[N] = o[N]);
|
|
220
220
|
} else l = o;
|
|
221
221
|
return b && p(
|
|
222
222
|
l,
|
|
223
223
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
-
),
|
|
224
|
+
), T(
|
|
225
225
|
e,
|
|
226
226
|
b,
|
|
227
227
|
h,
|
|
228
|
-
|
|
228
|
+
w,
|
|
229
229
|
s(),
|
|
230
230
|
l,
|
|
231
231
|
x,
|
|
@@ -233,9 +233,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
233
233
|
);
|
|
234
234
|
}
|
|
235
235
|
function v(e) {
|
|
236
|
-
typeof e == "object" && e !== null && e.$$typeof ===
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === y && e._store && (e._store.validated = 1);
|
|
237
237
|
}
|
|
238
|
-
var a =
|
|
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,11 +243,11 @@ 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
|
-
)(),
|
|
250
|
-
|
|
249
|
+
)(), $ = O(u(c)), q = {};
|
|
250
|
+
k.Fragment = f, k.jsx = function(e, o, l, d, w) {
|
|
251
251
|
var h = 1e4 > C.recentlyCreatedOwnerStacks++;
|
|
252
252
|
return E(
|
|
253
253
|
e,
|
|
@@ -255,11 +255,11 @@ React keys must be passed directly to JSX without using spread:
|
|
|
255
255
|
l,
|
|
256
256
|
!1,
|
|
257
257
|
d,
|
|
258
|
-
|
|
259
|
-
h ? Error("react-stack-top-frame") :
|
|
260
|
-
h ? O(u(e)) :
|
|
258
|
+
w,
|
|
259
|
+
h ? Error("react-stack-top-frame") : W,
|
|
260
|
+
h ? O(u(e)) : $
|
|
261
261
|
);
|
|
262
|
-
},
|
|
262
|
+
}, k.jsxs = function(e, o, l, d, w) {
|
|
263
263
|
var h = 1e4 > C.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return E(
|
|
265
265
|
e,
|
|
@@ -267,16 +267,16 @@ React keys must be passed directly to JSX without using spread:
|
|
|
267
267
|
l,
|
|
268
268
|
!0,
|
|
269
269
|
d,
|
|
270
|
-
|
|
271
|
-
h ? Error("react-stack-top-frame") :
|
|
272
|
-
h ? O(u(e)) :
|
|
270
|
+
w,
|
|
271
|
+
h ? Error("react-stack-top-frame") : W,
|
|
272
|
+
h ? O(u(e)) : $
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
|
-
})()),
|
|
275
|
+
})()), k;
|
|
276
276
|
}
|
|
277
277
|
var z;
|
|
278
278
|
function ce() {
|
|
279
|
-
return z || (z = 1, process.env.NODE_ENV === "production" ?
|
|
279
|
+
return z || (z = 1, process.env.NODE_ENV === "production" ? A.exports = ie() : A.exports = ue()), A.exports;
|
|
280
280
|
}
|
|
281
281
|
var ae = ce();
|
|
282
282
|
class le extends EventTarget {
|
|
@@ -298,16 +298,12 @@ class le extends EventTarget {
|
|
|
298
298
|
* Publish an event to all matching subscribers
|
|
299
299
|
*/
|
|
300
300
|
publish(r, n, u) {
|
|
301
|
-
|
|
302
|
-
console.log(`[FormEventPublisher] 📢 Publishing "${r}"`, {
|
|
303
|
-
formId: s,
|
|
304
|
-
payload: n
|
|
305
|
-
}), typeof window < "u" && (window.dispatchEvent(
|
|
301
|
+
typeof window < "u" && window.dispatchEvent(
|
|
306
302
|
new CustomEvent(r, {
|
|
307
303
|
detail: n,
|
|
308
304
|
bubbles: !0
|
|
309
305
|
})
|
|
310
|
-
),
|
|
306
|
+
), u?.usePostMessage !== !1 && this.sendPostMessage(r, n);
|
|
311
307
|
}
|
|
312
308
|
/**
|
|
313
309
|
* Subscribe to form events with optional form ID filtering
|
|
@@ -320,20 +316,13 @@ class le extends EventTarget {
|
|
|
320
316
|
id: s,
|
|
321
317
|
once: u?.once
|
|
322
318
|
};
|
|
323
|
-
this.subscriptions.has(r) || this.subscriptions.set(r, []), this.subscriptions.get(r).push(c)
|
|
324
|
-
formId: u?.formId,
|
|
325
|
-
once: u?.once,
|
|
326
|
-
totalSubscriptions: this.subscriptions.get(r).length
|
|
327
|
-
});
|
|
319
|
+
this.subscriptions.has(r) || this.subscriptions.set(r, []), this.subscriptions.get(r).push(c);
|
|
328
320
|
const m = (p) => {
|
|
329
|
-
const R = p,
|
|
330
|
-
this.matchesFilter(
|
|
321
|
+
const R = p, T = this.getFormIdFromPayload(R.detail);
|
|
322
|
+
this.matchesFilter(T, u?.formId) && (n(R.detail), u?.once && typeof window < "u" && window.removeEventListener(r, m));
|
|
331
323
|
};
|
|
332
324
|
return typeof window < "u" && window.addEventListener(r, m), () => {
|
|
333
|
-
|
|
334
|
-
formId: u?.formId,
|
|
335
|
-
remainingSubscriptions: (this.subscriptions.get(r)?.length || 1) - 1
|
|
336
|
-
}), this.unsubscribe(s), typeof window < "u" && window.removeEventListener(r, m);
|
|
325
|
+
this.unsubscribe(s), typeof window < "u" && window.removeEventListener(r, m);
|
|
337
326
|
};
|
|
338
327
|
}
|
|
339
328
|
/**
|
|
@@ -352,10 +341,6 @@ class le extends EventTarget {
|
|
|
352
341
|
* Subscribe to all form events with optional filtering
|
|
353
342
|
*/
|
|
354
343
|
subscribeAll(r, n) {
|
|
355
|
-
console.log("[FormEventPublisher] Subscribing to ALL events", {
|
|
356
|
-
formId: n?.formId,
|
|
357
|
-
once: n?.once
|
|
358
|
-
});
|
|
359
344
|
const u = [
|
|
360
345
|
"form:view",
|
|
361
346
|
"form:submit",
|
|
@@ -372,9 +357,7 @@ class le extends EventTarget {
|
|
|
372
357
|
);
|
|
373
358
|
s.push(m);
|
|
374
359
|
}), () => {
|
|
375
|
-
|
|
376
|
-
formId: n?.formId
|
|
377
|
-
}), s.forEach((c) => c());
|
|
360
|
+
s.forEach((c) => c());
|
|
378
361
|
};
|
|
379
362
|
}
|
|
380
363
|
/**
|
|
@@ -403,9 +386,8 @@ class le extends EventTarget {
|
|
|
403
386
|
}));
|
|
404
387
|
}
|
|
405
388
|
}
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
typeof window < "u" && import("./web-form-engine-core.umd-Z21xRWf8.js").then((t) => t.w).then(({ EncatchAppElement: t }) => {
|
|
389
|
+
const g = new le();
|
|
390
|
+
typeof window < "u" && import("./web-form-engine-core.umd-DaNIE3D9.js").then((t) => t.w).then(({ EncatchAppElement: t }) => {
|
|
409
391
|
try {
|
|
410
392
|
customElements.get("encatch-app") || customElements.define("encatch-app", t);
|
|
411
393
|
} catch (r) {
|
|
@@ -420,7 +402,7 @@ const de = ({
|
|
|
420
402
|
instanceId: s,
|
|
421
403
|
onFormEvent: c
|
|
422
404
|
}) => {
|
|
423
|
-
const [m, p] =
|
|
405
|
+
const [m, p] = V(!1), [R, T] = V(!0), E = I.useRef(null), v = I.useRef(
|
|
424
406
|
null
|
|
425
407
|
), a = oe({});
|
|
426
408
|
S(() => {
|
|
@@ -449,37 +431,37 @@ const de = ({
|
|
|
449
431
|
if (!s) return;
|
|
450
432
|
const i = [];
|
|
451
433
|
return a.current.onSubmit && i.push(
|
|
452
|
-
|
|
434
|
+
g.subscribe(
|
|
453
435
|
"form:submit",
|
|
454
436
|
a.current.onSubmit,
|
|
455
437
|
{ formId: s }
|
|
456
438
|
)
|
|
457
439
|
), a.current.onView && i.push(
|
|
458
|
-
|
|
440
|
+
g.subscribe(
|
|
459
441
|
"form:view",
|
|
460
442
|
a.current.onView,
|
|
461
443
|
{ formId: s }
|
|
462
444
|
)
|
|
463
445
|
), a.current.onClose && i.push(
|
|
464
|
-
|
|
446
|
+
g.subscribe(
|
|
465
447
|
"form:close",
|
|
466
448
|
a.current.onClose,
|
|
467
449
|
{ formId: s }
|
|
468
450
|
)
|
|
469
451
|
), a.current.onSectionChange && i.push(
|
|
470
|
-
|
|
452
|
+
g.subscribe(
|
|
471
453
|
"form:section:change",
|
|
472
454
|
a.current.onSectionChange,
|
|
473
455
|
{ formId: s }
|
|
474
456
|
)
|
|
475
457
|
), a.current.onQuestionAnswered && i.push(
|
|
476
|
-
|
|
458
|
+
g.subscribe(
|
|
477
459
|
"form:question:answered",
|
|
478
460
|
a.current.onQuestionAnswered,
|
|
479
461
|
{ formId: s }
|
|
480
462
|
)
|
|
481
463
|
), a.current.onError && i.push(
|
|
482
|
-
|
|
464
|
+
g.subscribe(
|
|
483
465
|
"form:error",
|
|
484
466
|
a.current.onError,
|
|
485
467
|
{ formId: s }
|
|
@@ -498,27 +480,27 @@ const de = ({
|
|
|
498
480
|
"[EncatchPreview] Data validation failed, retrying in 100ms..."
|
|
499
481
|
);
|
|
500
482
|
}, [t]);
|
|
501
|
-
const
|
|
502
|
-
t.onClose && t.onClose(),
|
|
483
|
+
const y = se(() => {
|
|
484
|
+
t.onClose && t.onClose(), T(!1);
|
|
503
485
|
}, [t.onClose]);
|
|
504
486
|
return S(() => {
|
|
505
487
|
if (!m || !E.current)
|
|
506
488
|
return;
|
|
507
489
|
const i = document.createElement("encatch-app");
|
|
508
|
-
return i.theme = t.theme, i.currentMode = t.currentMode, i.currentLanguage = t.currentLanguage, i.questions = t.questions, i.questionLanguages = t.questionLanguages, i.otherConfigurationProperties = t.otherConfigurationProperties, i.welcomeScreenProperties = t.welcomeScreenProperties, i.endScreenProperties = t.endScreenProperties, i.translations = t.translations, i.sections = t.sections, i.themeSettings = t.themeSettings, i.onClose =
|
|
490
|
+
return i.theme = t.theme, i.currentMode = t.currentMode, i.currentLanguage = t.currentLanguage, i.questions = t.questions, i.questionLanguages = t.questionLanguages, i.otherConfigurationProperties = t.otherConfigurationProperties, i.welcomeScreenProperties = t.welcomeScreenProperties, i.endScreenProperties = t.endScreenProperties, i.translations = t.translations, i.sections = t.sections, i.themeSettings = t.themeSettings, i.onClose = y, i.onSectionChange = t.onSectionChange, i.apiKey = t.apiKey, i.hostUrl = t.hostUrl, i.feedbackConfigId = t.feedbackConfigId, i.identifier = t.identifier, r && (i.cssLink = r), i.scale = n, i.persistMode = u, s && (i.instanceId = s), v.current = i, E.current.appendChild(i), () => {
|
|
509
491
|
E.current && v.current && E.current.removeChild(v.current), v.current = null;
|
|
510
492
|
};
|
|
511
|
-
}, [m, t, r, n,
|
|
493
|
+
}, [m, t, r, n, y, u, s]), R ? /* @__PURE__ */ ae.jsx("div", { ref: E }) : null;
|
|
512
494
|
};
|
|
513
495
|
function be(t, r, n) {
|
|
514
|
-
S(() =>
|
|
496
|
+
S(() => g.subscribe(
|
|
515
497
|
t,
|
|
516
498
|
r,
|
|
517
499
|
n
|
|
518
500
|
), [t, n?.formId, r]);
|
|
519
501
|
}
|
|
520
502
|
function me(t, r) {
|
|
521
|
-
S(() =>
|
|
503
|
+
S(() => g.subscribeAll(t, r), [r?.formId, t]);
|
|
522
504
|
}
|
|
523
505
|
export {
|
|
524
506
|
de as EncatchPreview,
|