@encatch/ws-react 0.0.11 → 0.0.12

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.
@@ -1,5 +1,5 @@
1
- import O, { useState as te, useEffect as M } from "react";
2
- var _ = { exports: {} }, v = {};
1
+ import C, { useState as $, useEffect as U, useCallback as ne } from "react";
2
+ var w = { exports: {} }, b = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.js
@@ -9,29 +9,29 @@ var _ = { exports: {} }, v = {};
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 ne() {
14
- if ($) return v;
15
- $ = 1;
12
+ var q;
13
+ function oe() {
14
+ if (q) return b;
15
+ q = 1;
16
16
  var t = Symbol.for("react.transitional.element"), f = Symbol.for("react.fragment");
17
- function d(E, i, a) {
18
- var u = null;
19
- if (a !== void 0 && (u = "" + a), i.key !== void 0 && (u = "" + i.key), "key" in i) {
20
- a = {};
21
- for (var n in i)
22
- n !== "key" && (a[n] = i[n]);
23
- } else a = i;
24
- return i = a.ref, {
17
+ function d(E, c, i) {
18
+ var p = null;
19
+ if (i !== void 0 && (p = "" + i), c.key !== void 0 && (p = "" + c.key), "key" in c) {
20
+ i = {};
21
+ for (var u in c)
22
+ u !== "key" && (i[u] = c[u]);
23
+ } else i = c;
24
+ return c = i.ref, {
25
25
  $$typeof: t,
26
26
  type: E,
27
- key: u,
28
- ref: i !== void 0 ? i : null,
29
- props: a
27
+ key: p,
28
+ ref: c !== void 0 ? c : null,
29
+ props: i
30
30
  };
31
31
  }
32
- return v.Fragment = f, v.jsx = d, v.jsxs = d, v;
32
+ return b.Fragment = f, b.jsx = d, b.jsxs = d, b;
33
33
  }
34
- var R = {};
34
+ var _ = {};
35
35
  /**
36
36
  * @license React
37
37
  * react-jsx-runtime.development.js
@@ -41,42 +41,42 @@ var R = {};
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 U;
45
- function oe() {
46
- return U || (U = 1, process.env.NODE_ENV !== "production" && (function() {
44
+ var W;
45
+ function ae() {
46
+ return W || (W = 1, process.env.NODE_ENV !== "production" && (function() {
47
47
  function t(e) {
48
48
  if (e == null) return null;
49
49
  if (typeof e == "function")
50
- return e.$$typeof === K ? null : e.displayName || e.name || null;
50
+ return e.$$typeof === ee ? null : e.displayName || e.name || null;
51
51
  if (typeof e == "string") return e;
52
52
  switch (e) {
53
- case h:
53
+ case P:
54
54
  return "Fragment";
55
- case V:
55
+ case G:
56
56
  return "Profiler";
57
- case z:
57
+ case V:
58
58
  return "StrictMode";
59
- case D:
59
+ case Z:
60
60
  return "Suspense";
61
- case H:
62
- return "SuspenseList";
63
61
  case Q:
62
+ return "SuspenseList";
63
+ case K:
64
64
  return "Activity";
65
65
  }
66
66
  if (typeof e == "object")
67
67
  switch (typeof e.tag == "number" && console.error(
68
68
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
69
69
  ), e.$$typeof) {
70
- case J:
70
+ case z:
71
71
  return "Portal";
72
- case X:
72
+ case B:
73
73
  return (e.displayName || "Context") + ".Provider";
74
- case G:
74
+ case X:
75
75
  return (e._context.displayName || "Context") + ".Consumer";
76
- case B:
76
+ case H:
77
77
  var r = e.render;
78
78
  return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
- case Z:
79
+ case D:
80
80
  return r = e.displayName || null, r !== null ? r : t(e.type) || "Memo";
81
81
  case x:
82
82
  r = e._payload, e = e._init;
@@ -99,16 +99,16 @@ function oe() {
99
99
  }
100
100
  if (r) {
101
101
  r = console;
102
- var o = r.error, s = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
102
+ var o = r.error, a = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
103
  return o.call(
104
104
  r,
105
105
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
- s
106
+ a
107
107
  ), f(e);
108
108
  }
109
109
  }
110
110
  function E(e) {
111
- if (e === h) return "<>";
111
+ if (e === P) return "<>";
112
112
  if (typeof e == "object" && e !== null && e.$$typeof === x)
113
113
  return "<...>";
114
114
  try {
@@ -118,23 +118,23 @@ function oe() {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
- function i() {
122
- var e = T.A;
121
+ function c() {
122
+ var e = k.A;
123
123
  return e === null ? null : e.getOwner();
124
124
  }
125
- function a() {
125
+ function i() {
126
126
  return Error("react-stack-top-frame");
127
127
  }
128
- function u(e) {
129
- if (C.call(e, "key")) {
128
+ function p(e) {
129
+ if (N.call(e, "key")) {
130
130
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
131
131
  if (r && r.isReactWarning) return !1;
132
132
  }
133
133
  return e.key !== void 0;
134
134
  }
135
- function n(e, r) {
135
+ function u(e, r) {
136
136
  function o() {
137
- N || (N = !0, console.error(
137
+ I || (I = !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
  r
140
140
  ));
@@ -144,13 +144,13 @@ function oe() {
144
144
  configurable: !0
145
145
  });
146
146
  }
147
- function g() {
147
+ function v() {
148
148
  var e = t(this.type);
149
149
  return Y[e] || (Y[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 W(e, r, o, s, m, l, P, k) {
153
+ function g(e, r, o, a, m, l, O, A) {
154
154
  return o = l.ref, e = {
155
155
  $$typeof: j,
156
156
  type: e,
@@ -159,7 +159,7 @@ function oe() {
159
159
  _owner: m
160
160
  }, (o !== void 0 ? o : null) !== null ? Object.defineProperty(e, "ref", {
161
161
  enumerable: !1,
162
- get: g
162
+ get: v
163
163
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
164
164
  configurable: !1,
165
165
  enumerable: !1,
@@ -174,111 +174,111 @@ function oe() {
174
174
  configurable: !1,
175
175
  enumerable: !1,
176
176
  writable: !0,
177
- value: P
177
+ value: O
178
178
  }), Object.defineProperty(e, "_debugTask", {
179
179
  configurable: !1,
180
180
  enumerable: !1,
181
181
  writable: !0,
182
- value: k
182
+ value: A
183
183
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
184
184
  }
185
- function A(e, r, o, s, m, l, P, k) {
186
- var c = r.children;
187
- if (c !== void 0)
188
- if (s)
189
- if (ee(c)) {
190
- for (s = 0; s < c.length; s++)
191
- y(c[s]);
192
- Object.freeze && Object.freeze(c);
185
+ function n(e, r, o, a, m, l, O, A) {
186
+ var s = r.children;
187
+ if (s !== void 0)
188
+ if (a)
189
+ if (re(s)) {
190
+ for (a = 0; a < s.length; a++)
191
+ h(s[a]);
192
+ Object.freeze && Object.freeze(s);
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 y(c);
198
- if (C.call(r, "key")) {
199
- c = t(e);
200
- var p = Object.keys(r).filter(function(re) {
201
- return re !== "key";
197
+ else h(s);
198
+ if (N.call(r, "key")) {
199
+ s = t(e);
200
+ var R = Object.keys(r).filter(function(te) {
201
+ return te !== "key";
202
202
  });
203
- s = 0 < p.length ? "{key: someKey, " + p.join(": ..., ") + ": ...}" : "{key: someKey}", F[c + s] || (p = 0 < p.length ? "{" + p.join(": ..., ") + ": ...}" : "{}", console.error(
203
+ a = 0 < R.length ? "{key: someKey, " + R.join(": ..., ") + ": ...}" : "{key: someKey}", F[s + a] || (R = 0 < R.length ? "{" + R.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} />
207
207
  React keys must be passed directly to JSX without using spread:
208
208
  let props = %s;
209
209
  <%s key={someKey} {...props} />`,
210
+ a,
210
211
  s,
211
- c,
212
- p,
213
- c
214
- ), F[c + s] = !0);
212
+ R,
213
+ s
214
+ ), F[s + a] = !0);
215
215
  }
216
- if (c = null, o !== void 0 && (d(o), c = "" + o), u(r) && (d(r.key), c = "" + r.key), "key" in r) {
216
+ if (s = null, o !== void 0 && (d(o), s = "" + o), p(r) && (d(r.key), s = "" + r.key), "key" in r) {
217
217
  o = {};
218
- for (var S in r)
219
- S !== "key" && (o[S] = r[S]);
218
+ for (var y in r)
219
+ y !== "key" && (o[y] = r[y]);
220
220
  } else o = r;
221
- return c && n(
221
+ return s && u(
222
222
  o,
223
223
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
224
- ), W(
224
+ ), g(
225
225
  e,
226
- c,
226
+ s,
227
227
  l,
228
228
  m,
229
- i(),
229
+ c(),
230
230
  o,
231
- P,
232
- k
231
+ O,
232
+ A
233
233
  );
234
234
  }
235
- function y(e) {
235
+ function h(e) {
236
236
  typeof e == "object" && e !== null && e.$$typeof === j && e._store && (e._store.validated = 1);
237
237
  }
238
- var b = O, j = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), h = Symbol.for("react.fragment"), z = Symbol.for("react.strict_mode"), V = Symbol.for("react.profiler"), G = Symbol.for("react.consumer"), X = Symbol.for("react.context"), B = Symbol.for("react.forward_ref"), D = Symbol.for("react.suspense"), H = Symbol.for("react.suspense_list"), Z = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), Q = Symbol.for("react.activity"), K = Symbol.for("react.client.reference"), T = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, C = Object.prototype.hasOwnProperty, ee = Array.isArray, w = console.createTask ? console.createTask : function() {
238
+ var T = C, j = Symbol.for("react.transitional.element"), z = Symbol.for("react.portal"), P = Symbol.for("react.fragment"), V = Symbol.for("react.strict_mode"), G = 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"), Q = Symbol.for("react.suspense_list"), D = Symbol.for("react.memo"), x = Symbol.for("react.lazy"), K = Symbol.for("react.activity"), ee = Symbol.for("react.client.reference"), k = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, re = Array.isArray, S = console.createTask ? console.createTask : function() {
239
239
  return null;
240
240
  };
241
- b = {
241
+ T = {
242
242
  react_stack_bottom_frame: function(e) {
243
243
  return e();
244
244
  }
245
245
  };
246
- var N, Y = {}, I = b.react_stack_bottom_frame.bind(
247
- b,
248
- a
249
- )(), L = w(E(a)), F = {};
250
- R.Fragment = h, R.jsx = function(e, r, o, s, m) {
251
- var l = 1e4 > T.recentlyCreatedOwnerStacks++;
252
- return A(
246
+ var I, Y = {}, M = T.react_stack_bottom_frame.bind(
247
+ T,
248
+ i
249
+ )(), L = S(E(i)), F = {};
250
+ _.Fragment = P, _.jsx = function(e, r, o, a, m) {
251
+ var l = 1e4 > k.recentlyCreatedOwnerStacks++;
252
+ return n(
253
253
  e,
254
254
  r,
255
255
  o,
256
256
  !1,
257
- s,
257
+ a,
258
258
  m,
259
- l ? Error("react-stack-top-frame") : I,
260
- l ? w(E(e)) : L
259
+ l ? Error("react-stack-top-frame") : M,
260
+ l ? S(E(e)) : L
261
261
  );
262
- }, R.jsxs = function(e, r, o, s, m) {
263
- var l = 1e4 > T.recentlyCreatedOwnerStacks++;
264
- return A(
262
+ }, _.jsxs = function(e, r, o, a, m) {
263
+ var l = 1e4 > k.recentlyCreatedOwnerStacks++;
264
+ return n(
265
265
  e,
266
266
  r,
267
267
  o,
268
268
  !0,
269
- s,
269
+ a,
270
270
  m,
271
- l ? Error("react-stack-top-frame") : I,
272
- l ? w(E(e)) : L
271
+ l ? Error("react-stack-top-frame") : M,
272
+ l ? S(E(e)) : L
273
273
  );
274
274
  };
275
- })()), R;
275
+ })()), _;
276
276
  }
277
- var q;
278
- function ae() {
279
- return q || (q = 1, process.env.NODE_ENV === "production" ? _.exports = ne() : _.exports = oe()), _.exports;
277
+ var J;
278
+ function se() {
279
+ return J || (J = 1, process.env.NODE_ENV === "production" ? w.exports = oe() : w.exports = ae()), w.exports;
280
280
  }
281
- var se = ae();
281
+ var ce = se();
282
282
  typeof window < "u" && import("./web-form-engine-core.umd-DfbJvtSZ.js").then((t) => t.w).then(({ EncatchAppElement: t }) => {
283
283
  try {
284
284
  customElements.get("encatch-app") || customElements.define("encatch-app", t);
@@ -286,36 +286,40 @@ typeof window < "u" && import("./web-form-engine-core.umd-DfbJvtSZ.js").then((t)
286
286
  console.debug("Custom element registration:", f);
287
287
  }
288
288
  });
289
- const ie = ({
289
+ const ue = ({
290
290
  formData: t,
291
291
  cssLink: f,
292
292
  scale: d = 100
293
293
  }) => {
294
- const [E, i] = te(!1), a = O.useRef(null), u = O.useRef(
294
+ const [E, c] = $(!1), [i, p] = $(!0), u = C.useRef(null), v = C.useRef(
295
295
  null
296
296
  );
297
- return M(() => {
297
+ U(() => {
298
298
  (() => {
299
299
  try {
300
300
  return t ? !0 : (console.warn("[EncatchPreview] formData is not defined"), !1);
301
- } catch (g) {
302
- return console.error("[EncatchPreview] Error during data validation:", g), !1;
301
+ } catch (h) {
302
+ return console.error("[EncatchPreview] Error during data validation:", h), !1;
303
303
  }
304
- })() ? (i(!0), console.log("[EncatchPreview] Data is ready, rendering web component")) : console.warn(
304
+ })() ? (c(!0), console.log("[EncatchPreview] Data is ready, rendering web component")) : console.warn(
305
305
  "[EncatchPreview] Data validation failed, retrying in 100ms..."
306
306
  );
307
- }, [t]), M(() => {
308
- if (!E || !a.current)
307
+ }, [t]);
308
+ const g = ne(() => {
309
+ console.log("[EncatchPreview] Close triggered, unmounting component"), t.onClose && t.onClose(), p(!1);
310
+ }, [t.onClose]);
311
+ return U(() => {
312
+ if (!E || !u.current)
309
313
  return;
310
314
  console.log(
311
315
  "[EncatchPreview] Creating web component imperatively with properties"
312
316
  );
313
317
  const n = document.createElement("encatch-app");
314
- return n.theme = t.theme, n.currentMode = t.currentMode, n.currentLanguage = t.currentLanguage, n.questions = t.questions, n.questionLanguages = t.questionLanguages, n.otherConfigurationProperties = t.otherConfigurationProperties, n.welcomeScreenProperties = t.welcomeScreenProperties, n.endScreenProperties = t.endScreenProperties, n.translations = t.translations, n.sections = t.sections, n.themeSettings = t.themeSettings, n.onClose = t.onClose, n.onSectionChange = t.onSectionChange, n.apiKey = t.apiKey, n.hostUrl = t.hostUrl, n.feedbackConfigId = t.feedbackConfigId, n.identifier = t.identifier, n.cssLink = f, n.scale = d, console.log("[EncatchPreview] All properties set, now adding to DOM"), u.current = n, a.current.appendChild(n), () => {
315
- console.log("[EncatchPreview] Unmounting web component"), a.current && u.current && a.current.removeChild(u.current), u.current = null;
318
+ return n.theme = t.theme, n.currentMode = t.currentMode, n.currentLanguage = t.currentLanguage, n.questions = t.questions, n.questionLanguages = t.questionLanguages, n.otherConfigurationProperties = t.otherConfigurationProperties, n.welcomeScreenProperties = t.welcomeScreenProperties, n.endScreenProperties = t.endScreenProperties, n.translations = t.translations, n.sections = t.sections, n.themeSettings = t.themeSettings, n.onClose = g, n.onSectionChange = t.onSectionChange, n.apiKey = t.apiKey, n.hostUrl = t.hostUrl, n.feedbackConfigId = t.feedbackConfigId, n.identifier = t.identifier, n.cssLink = f, n.scale = d, console.log("[EncatchPreview] All properties set, now adding to DOM"), v.current = n, u.current.appendChild(n), () => {
319
+ console.log("[EncatchPreview] Unmounting web component"), u.current && v.current && u.current.removeChild(v.current), v.current = null;
316
320
  };
317
- }, [E, t, f, d]), /* @__PURE__ */ se.jsx("div", { ref: a });
321
+ }, [E, t, f, d, g]), i ? /* @__PURE__ */ ce.jsx("div", { ref: u }) : null;
318
322
  };
319
323
  export {
320
- ie as EncatchPreview
324
+ ue as EncatchPreview
321
325
  };