@encatch/ws-react 0.0.50-beta.1 → 0.0.50-beta.10

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/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # @encatch/ws-react
2
2
 
3
+
3
4
  React wrapper for Encatch web form engine. This package provides React components and hooks to easily integrate Encatch forms into your React applications with full event handling capabilities.
4
5
 
5
6
  ## Purpose
@@ -34,40 +35,34 @@ yarn add @encatch/ws-react
34
35
 
35
36
  ### EncatchPreview
36
37
 
37
- The main component for rendering Encatch forms in your React application.
38
+ The main component for rendering Encatch forms in an iframe. Provide `formConfig` and `formPageUrl` (e.g. your shareable app route) to render the form.
38
39
 
39
40
  ```tsx
40
41
  import { EncatchPreview } from '@encatch/ws-react';
41
42
 
42
43
  function App() {
43
- const formData = {
44
- theme: 'default',
45
- currentMode: 'light',
46
- currentLanguage: 'en',
47
- questions: [],
48
- questionLanguages: [],
49
- otherConfigurationProperties: {},
44
+ const formConfig = {
45
+ questionnaireFields: { questions: {}, sections: [], selectedLanguages: [], translations: {} },
46
+ appearanceProperties: { themes: {}, featureSettings: {} },
50
47
  welcomeScreenProperties: {},
51
48
  endScreenProperties: {},
52
- translations: {},
53
- sections: [],
54
- themeSettings: null,
55
- onClose: () => console.log('Form closed'),
56
- onSectionChange: (index) => console.log('Section changed:', index),
57
- apiKey: 'your-api-key',
58
- hostUrl: 'https://api.encatch.com',
59
- feedbackConfigId: 'your-config-id',
60
- identifier: 'user-identifier',
49
+ otherConfigurationProperties: {},
50
+ feedbackConfigurationId: 'your-config-id',
51
+ feedbackIdentifier: 'user-identifier',
61
52
  };
62
53
 
63
54
  return (
64
- <EncatchPreview
65
- formData={formData}
66
- cssLink="https://your-styles.css"
67
- scale={100}
68
- persistMode="none"
69
- instanceId="unique-form-id"
70
- />
55
+ <div style={{ width: '100%', height: '500px' }}>
56
+ <EncatchPreview
57
+ formConfig={formConfig}
58
+ formPageUrl="https://your-shareable-app.com/s/encatch-preview-form"
59
+ scale={100}
60
+ formId="unique-form-id"
61
+ onFormEvent={(formEvent) => {
62
+ formEvent.onSubmit((data) => console.log('Submitted', data));
63
+ }}
64
+ />
65
+ </div>
71
66
  );
72
67
  }
73
68
  ```
@@ -76,12 +71,12 @@ function App() {
76
71
 
77
72
  | Prop | Type | Required | Default | Description |
78
73
  |------|------|----------|---------|-------------|
79
- | `formData` | `object` | Yes | - | Form configuration object |
80
- | `cssLink` | `string` | Yes | - | URL to the form's CSS stylesheet |
81
- | `scale` | `number` | No | `100` | Scale factor for the form (percentage) |
82
- | `persistMode` | `"retain" \| "reset" \| "none"` | No | `"none"` | Form state persistence mode |
83
- | `instanceId` | `string` | No | - | Unique identifier for filtering events |
84
- | `onFormEvent` | `OnFormEventHandler` | No | - | Event handler builder function |
74
+ | `formConfig` | `EncatchFormConfig` | Yes* | - | Form configuration for the iframe. Required with formPageUrl to render. |
75
+ | `formPageUrl` | `string` | Yes* | - | URL of the iframe form page (e.g. shareable app route). Required with formConfig to render. |
76
+ | `formId` | `string` | No | from formConfig or "preview" | Form id for URL and message payloads. |
77
+ | `scale` | `number` | No | `100` | Visual scale of iframe content, 1–100. Applied via CSS transform. |
78
+ | `instanceId` | `string` | No | - | Unique identifier for filtering events. |
79
+ | `onFormEvent` | `OnFormEventHandler` | No | - | Event handler builder function. |
85
80
 
86
81
  ### Event Handling with onFormEvent
87
82
 
@@ -125,8 +120,8 @@ function App() {
125
120
 
126
121
  return (
127
122
  <EncatchPreview
128
- formData={formData}
129
- cssLink="https://your-styles.css"
123
+ formConfig={formConfig}
124
+ formPageUrl="https://your-shareable-app.com/s/encatch-preview-form"
130
125
  instanceId="my-form"
131
126
  onFormEvent={handleFormEvents}
132
127
  />
@@ -169,7 +164,7 @@ function MyComponent() {
169
164
  - `form:show` - Form shown/displayed event
170
165
  - `form:close` - Form closed event
171
166
  - `form:section:change` - Section navigation event
172
- - `form:question:answered` - Question answered event
167
+ - `form:answered` - Question answered event
173
168
  - `form:error` - Error event
174
169
 
175
170
  ### useEncatchFormEventAll
@@ -253,14 +248,14 @@ function MultiFormApp() {
253
248
  return (
254
249
  <>
255
250
  <EncatchPreview
256
- formData={surveyFormData}
257
- cssLink="https://styles.css"
251
+ formConfig={surveyFormConfig}
252
+ formPageUrl="https://your-shareable-app.com/s/encatch-preview-form"
258
253
  instanceId="survey-form"
259
254
  />
260
255
 
261
256
  <EncatchPreview
262
- formData={feedbackFormData}
263
- cssLink="https://styles.css"
257
+ formConfig={feedbackFormConfig}
258
+ formPageUrl="https://your-shareable-app.com/s/encatch-preview-form"
264
259
  instanceId="feedback-form"
265
260
  />
266
261
  </>
@@ -1,58 +1,14 @@
1
- import { AppProps, Section } from "@encatch/schema";
2
1
  import React from "react";
3
- import type { OnFormEventHandler } from "./types";
4
- declare module "react" {
5
- namespace JSX {
6
- interface IntrinsicElements {
7
- "encatch-app": React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> & {
8
- theme?: AppProps["theme"];
9
- currentMode?: "light" | "dark";
10
- currentLanguage?: AppProps["currentLanguage"];
11
- questions?: AppProps["questions"];
12
- questionLanguages?: AppProps["questionLanguages"];
13
- otherConfigurationProperties?: AppProps["otherConfigurationProperties"];
14
- welcomeScreenProperties?: AppProps["welcomeScreenProperties"];
15
- endScreenProperties?: AppProps["endScreenProperties"];
16
- translations?: AppProps["translations"];
17
- sections?: Section[];
18
- themeSettings?: AppProps["themeSettings"] | null;
19
- onClose?: () => void;
20
- onSectionChange?: (index: number) => void;
21
- apiKey?: string;
22
- hostUrl?: string;
23
- feedbackConfigId?: string;
24
- identifier?: string;
25
- cssLink?: string;
26
- scale?: number;
27
- persistMode?: "retain" | "reset" | "none";
28
- instanceId?: string;
29
- };
30
- }
31
- }
32
- }
2
+ import type { EncatchFormConfig, OnFormEventHandler } from "./types";
33
3
  interface EncatchPreviewProps {
34
- formData: {
35
- theme: AppProps["theme"];
36
- currentMode: "light" | "dark";
37
- currentLanguage: AppProps["currentLanguage"];
38
- questions: AppProps["questions"];
39
- questionLanguages: AppProps["questionLanguages"];
40
- otherConfigurationProperties: AppProps["otherConfigurationProperties"];
41
- welcomeScreenProperties: AppProps["welcomeScreenProperties"];
42
- endScreenProperties: AppProps["endScreenProperties"];
43
- translations: AppProps["translations"];
44
- sections: Section[];
45
- themeSettings: AppProps["themeSettings"] | null;
46
- onClose: () => void;
47
- onSectionChange: (index: number) => void;
48
- apiKey: string;
49
- hostUrl: string;
50
- feedbackConfigId: string;
51
- identifier: string;
52
- };
53
- cssLink?: string;
4
+ /** Form config for the iframe. Required together with formPageUrl to render. */
5
+ formConfig?: EncatchFormConfig;
6
+ /** URL of the iframe form page (e.g. shareable origin + /encatch-preview-form). Required together with formConfig to render. */
7
+ formPageUrl?: string;
8
+ /** Optional form id for iframe URL query and message payloads. Defaults to formConfig.formId or "preview". */
9
+ formId?: string;
10
+ /** Visual scale of the iframe content (e.g. 1–100). Passed to the iframe in config and applied inside the form; no transform on the iframe. Default 100. */
54
11
  scale?: number;
55
- persistMode?: "retain" | "reset" | "none";
56
12
  instanceId?: string;
57
13
  /**
58
14
  * Callback function that receives a FormEventBuilder to register event handlers
@@ -0,0 +1,32 @@
1
+ /**
2
+ * PostMessage types for EncatchPreview iframe communication.
3
+ * Keeps message type strings and payload shapes consistent between
4
+ * EncatchPreview (parent) and the iframe form page.
5
+ */
6
+ /** Message types sent from parent (EncatchPreview) to iframe */
7
+ export type SDKMessageType = "sdk:formConfig" | "sdk:theme" | "sdk:locale" | "sdk:resetData" | "sdk:prefillResponses";
8
+ /** Message types sent from iframe to parent */
9
+ export type FormMessageType = "form:ready" | "form:submit" | "form:complete" | "form:close" | "form:error" | "form:resize" | "form:closeButton" | "form:themeData";
10
+ /** Event-publisher messages (prefixed with encatch:) from iframe to parent */
11
+ export type EncatchFormEventType = "encatch:form:show" | "encatch:form:started" | "encatch:form:section:change" | "encatch:form:answered";
12
+ export interface SDKMessage {
13
+ type: SDKMessageType;
14
+ data?: Record<string, unknown>;
15
+ }
16
+ export interface FormMessage {
17
+ type: FormMessageType | EncatchFormEventType;
18
+ formId?: string;
19
+ data?: Record<string, unknown>;
20
+ payload?: Record<string, unknown>;
21
+ }
22
+ /** Normalize encatch:* message type to form:* for handler switch */
23
+ export declare function normalizeMessageType(type: string, data: {
24
+ type: string;
25
+ formId?: string;
26
+ data?: Record<string, unknown>;
27
+ payload?: Record<string, unknown>;
28
+ }): {
29
+ messageType: string;
30
+ formId: string | undefined;
31
+ payload: Record<string, unknown> | undefined;
32
+ };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export { EncatchPreview } from "./EncatchPreview";
2
2
  export { useEncatchFormEvent, useEncatchFormEventAll } from "./useEncatchFormEvent";
3
3
  export type { FormEventType, FormEventPayload, SubscriptionOptions, FormIdFilter, } from "./useEncatchFormEvent";
4
- export type { FormEventBuilder, OnFormEventHandler, OnSubmitCallback, OnShowCallback, OnCloseCallback, OnSectionChangeCallback, OnQuestionAnsweredCallback, OnErrorCallback, } from "./types";
4
+ export type { EncatchFormConfig, EncatchPreviewIframeModeProps, FormEventBuilder, OnFormEventHandler, OnSubmitCallback, OnShowCallback, OnCloseCallback, OnSectionChangeCallback, OnQuestionAnsweredCallback, OnErrorCallback, } from "./types";
package/dist/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
- import I, { useState as U, useRef as oe, useEffect as S, useCallback as se } from "react";
2
- var A = { exports: {} }, P = {};
1
+ import q, { useRef as $, useEffect as O, useCallback as X } from "react";
2
+ var j = { exports: {} }, A = {};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.js
@@ -9,29 +9,29 @@ var A = { exports: {} }, P = {};
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 J;
13
- function ie() {
14
- if (J) return P;
15
- J = 1;
16
- var o = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
17
- function t(u, s, c) {
12
+ var H;
13
+ function ae() {
14
+ if (H) return A;
15
+ H = 1;
16
+ var l = Symbol.for("react.transitional.element"), r = Symbol.for("react.fragment");
17
+ function n(a, 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 = {};
21
- for (var p in s)
22
- p !== "key" && (c[p] = s[p]);
21
+ for (var w in s)
22
+ w !== "key" && (c[w] = s[w]);
23
23
  } else c = s;
24
24
  return s = c.ref, {
25
- $$typeof: o,
26
- type: u,
25
+ $$typeof: l,
26
+ type: a,
27
27
  key: m,
28
28
  ref: s !== void 0 ? s : null,
29
29
  props: c
30
30
  };
31
31
  }
32
- return P.Fragment = r, P.jsx = t, P.jsxs = t, P;
32
+ return A.Fragment = r, A.jsx = n, A.jsxs = n, A;
33
33
  }
34
- var k = {};
34
+ var C = {};
35
35
  /**
36
36
  * @license React
37
37
  * react-jsx-runtime.development.js
@@ -41,47 +41,47 @@ var k = {};
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 V;
45
- function ue() {
46
- return V || (V = 1, process.env.NODE_ENV !== "production" && (function() {
47
- function o(e) {
44
+ var Z;
45
+ function se() {
46
+ return Z || (Z = 1, process.env.NODE_ENV !== "production" && (function() {
47
+ function l(e) {
48
48
  if (e == null) return null;
49
49
  if (typeof e == "function")
50
- return e.$$typeof === re ? null : e.displayName || e.name || null;
50
+ return e.$$typeof === te ? 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 Q:
55
+ case P:
56
56
  return "Profiler";
57
- case G:
57
+ case d:
58
58
  return "StrictMode";
59
- case Z:
59
+ case _:
60
60
  return "Suspense";
61
- case K:
61
+ case T:
62
62
  return "SuspenseList";
63
- case ee:
63
+ case re:
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 i:
70
+ case N:
71
71
  return "Portal";
72
- case B:
72
+ case F:
73
73
  return (e.displayName || "Context") + ".Provider";
74
- case X:
74
+ case x:
75
75
  return (e._context.displayName || "Context") + ".Consumer";
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;
76
+ case E:
77
+ var t = e.render;
78
+ return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
79
+ case o:
80
+ return t = e.displayName || null, t !== null ? t : l(e.type) || "Memo";
81
+ case J:
82
+ t = e._payload, e = e._init;
83
83
  try {
84
- return o(e(n));
84
+ return l(e(t));
85
85
  } catch {
86
86
  }
87
87
  }
@@ -90,76 +90,76 @@ function ue() {
90
90
  function r(e) {
91
91
  return "" + e;
92
92
  }
93
- function t(e) {
93
+ function n(e) {
94
94
  try {
95
95
  r(e);
96
- var n = !1;
96
+ var t = !1;
97
97
  } catch {
98
- n = !0;
98
+ t = !0;
99
99
  }
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
- return l.call(
104
- n,
100
+ if (t) {
101
+ t = console;
102
+ var u = t.error, b = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
103
+ return u.call(
104
+ t,
105
105
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
106
- d
106
+ b
107
107
  ), r(e);
108
108
  }
109
109
  }
110
- function u(e) {
110
+ function a(e) {
111
111
  if (e === f) return "<>";
112
- if (typeof e == "object" && e !== null && e.$$typeof === M)
112
+ if (typeof e == "object" && e !== null && e.$$typeof === J)
113
113
  return "<...>";
114
114
  try {
115
- var n = o(e);
116
- return n ? "<" + n + ">" : "<...>";
115
+ var t = l(e);
116
+ return t ? "<" + t + ">" : "<...>";
117
117
  } catch {
118
118
  return "<...>";
119
119
  }
120
120
  }
121
121
  function s() {
122
- var e = C.A;
122
+ var e = D.A;
123
123
  return e === null ? null : e.getOwner();
124
124
  }
125
125
  function c() {
126
126
  return Error("react-stack-top-frame");
127
127
  }
128
128
  function m(e) {
129
- if (F.call(e, "key")) {
130
- var n = Object.getOwnPropertyDescriptor(e, "key").get;
131
- if (n && n.isReactWarning) return !1;
129
+ if (U.call(e, "key")) {
130
+ var t = Object.getOwnPropertyDescriptor(e, "key").get;
131
+ if (t && t.isReactWarning) return !1;
132
132
  }
133
133
  return e.key !== void 0;
134
134
  }
135
- function p(e, n) {
136
- function l() {
137
- Y || (Y = !0, console.error(
135
+ function w(e, t) {
136
+ function u() {
137
+ V || (V = !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
- n
139
+ t
140
140
  ));
141
141
  }
142
- l.isReactWarning = !0, Object.defineProperty(e, "key", {
143
- get: l,
142
+ u.isReactWarning = !0, Object.defineProperty(e, "key", {
143
+ get: u,
144
144
  configurable: !0
145
145
  });
146
146
  }
147
- function R() {
148
- var e = o(this.type);
149
- return L[e] || (L[e] = !0, console.error(
147
+ function v() {
148
+ var e = l(this.type);
149
+ return z[e] || (z[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, n, l, d, w, h, x, j) {
154
- return l = h.ref, e = {
155
- $$typeof: y,
153
+ function h(e, t, u, b, k, g, Y, W) {
154
+ return u = g.ref, e = {
155
+ $$typeof: I,
156
156
  type: e,
157
- key: n,
158
- props: h,
159
- _owner: w
160
- }, (l !== void 0 ? l : null) !== null ? Object.defineProperty(e, "ref", {
157
+ key: t,
158
+ props: g,
159
+ _owner: k
160
+ }, (u !== void 0 ? u : null) !== null ? Object.defineProperty(e, "ref", {
161
161
  enumerable: !1,
162
- get: R
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,119 +174,254 @@ function ue() {
174
174
  configurable: !1,
175
175
  enumerable: !1,
176
176
  writable: !0,
177
- value: x
177
+ value: Y
178
178
  }), Object.defineProperty(e, "_debugTask", {
179
179
  configurable: !1,
180
180
  enumerable: !1,
181
181
  writable: !0,
182
- value: j
182
+ value: W
183
183
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
184
184
  }
185
- function E(e, n, l, d, w, h, x, j) {
186
- var b = n.children;
187
- if (b !== void 0)
188
- if (d)
189
- if (te(b)) {
190
- for (d = 0; d < b.length; d++)
191
- v(b[d]);
192
- Object.freeze && Object.freeze(b);
185
+ function R(e, t, u, b, k, g, Y, W) {
186
+ var p = t.children;
187
+ if (p !== void 0)
188
+ if (b)
189
+ if (ne(p)) {
190
+ for (b = 0; b < p.length; b++)
191
+ y(p[b]);
192
+ Object.freeze && Object.freeze(p);
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 v(b);
198
- if (F.call(n, "key")) {
199
- b = o(e);
200
- var _ = Object.keys(n).filter(function(ne) {
201
- return ne !== "key";
197
+ else y(p);
198
+ if (U.call(t, "key")) {
199
+ p = l(e);
200
+ var S = Object.keys(t).filter(function(oe) {
201
+ return oe !== "key";
202
202
  });
203
- d = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", q[b + d] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
203
+ b = 0 < S.length ? "{key: someKey, " + S.join(": ..., ") + ": ...}" : "{key: someKey}", Q[p + b] || (S = 0 < S.length ? "{" + S.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
- d,
211
210
  b,
212
- _,
213
- b
214
- ), q[b + d] = !0);
211
+ p,
212
+ S,
213
+ p
214
+ ), Q[p + b] = !0);
215
215
  }
216
- if (b = null, l !== void 0 && (t(l), b = "" + l), m(n) && (t(n.key), b = "" + n.key), "key" in n) {
217
- l = {};
218
- for (var N in n)
219
- N !== "key" && (l[N] = n[N]);
220
- } else l = n;
221
- return b && p(
222
- l,
216
+ if (p = null, u !== void 0 && (n(u), p = "" + u), m(t) && (n(t.key), p = "" + t.key), "key" in t) {
217
+ u = {};
218
+ for (var L in t)
219
+ L !== "key" && (u[L] = t[L]);
220
+ } else u = t;
221
+ return p && w(
222
+ u,
223
223
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
224
- ), T(
224
+ ), h(
225
225
  e,
226
- b,
227
- h,
228
- w,
226
+ p,
227
+ g,
228
+ k,
229
229
  s(),
230
- l,
231
- x,
232
- j
230
+ u,
231
+ Y,
232
+ W
233
233
  );
234
234
  }
235
- function v(e) {
236
- typeof e == "object" && e !== null && e.$$typeof === y && e._store && (e._store.validated = 1);
235
+ function y(e) {
236
+ typeof e == "object" && e !== null && e.$$typeof === I && 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"), 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() {
238
+ var i = q, I = Symbol.for("react.transitional.element"), N = Symbol.for("react.portal"), f = Symbol.for("react.fragment"), d = Symbol.for("react.strict_mode"), P = Symbol.for("react.profiler"), x = Symbol.for("react.consumer"), F = Symbol.for("react.context"), E = Symbol.for("react.forward_ref"), _ = Symbol.for("react.suspense"), T = Symbol.for("react.suspense_list"), o = Symbol.for("react.memo"), J = Symbol.for("react.lazy"), re = Symbol.for("react.activity"), te = Symbol.for("react.client.reference"), D = i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, ne = Array.isArray, M = console.createTask ? console.createTask : function() {
239
239
  return null;
240
240
  };
241
- a = {
241
+ i = {
242
242
  react_stack_bottom_frame: function(e) {
243
243
  return e();
244
244
  }
245
245
  };
246
- var Y, L = {}, W = a.react_stack_bottom_frame.bind(
247
- a,
246
+ var V, z = {}, G = i.react_stack_bottom_frame.bind(
247
+ i,
248
248
  c
249
- )(), $ = O(u(c)), q = {};
250
- k.Fragment = f, k.jsx = function(e, n, l, d, w) {
251
- var h = 1e4 > C.recentlyCreatedOwnerStacks++;
252
- return E(
249
+ )(), B = M(a(c)), Q = {};
250
+ C.Fragment = f, C.jsx = function(e, t, u, b, k) {
251
+ var g = 1e4 > D.recentlyCreatedOwnerStacks++;
252
+ return R(
253
253
  e,
254
- n,
255
- l,
254
+ t,
255
+ u,
256
256
  !1,
257
- d,
258
- w,
259
- h ? Error("react-stack-top-frame") : W,
260
- h ? O(u(e)) : $
257
+ b,
258
+ k,
259
+ g ? Error("react-stack-top-frame") : G,
260
+ g ? M(a(e)) : B
261
261
  );
262
- }, k.jsxs = function(e, n, l, d, w) {
263
- var h = 1e4 > C.recentlyCreatedOwnerStacks++;
264
- return E(
262
+ }, C.jsxs = function(e, t, u, b, k) {
263
+ var g = 1e4 > D.recentlyCreatedOwnerStacks++;
264
+ return R(
265
265
  e,
266
- n,
267
- l,
266
+ t,
267
+ u,
268
268
  !0,
269
- d,
270
- w,
271
- h ? Error("react-stack-top-frame") : W,
272
- h ? O(u(e)) : $
269
+ b,
270
+ k,
271
+ g ? Error("react-stack-top-frame") : G,
272
+ g ? M(a(e)) : B
273
273
  );
274
274
  };
275
- })()), k;
275
+ })()), C;
276
276
  }
277
- var z;
278
- function ce() {
279
- return z || (z = 1, process.env.NODE_ENV === "production" ? A.exports = ie() : A.exports = ue()), A.exports;
277
+ var K;
278
+ function ie() {
279
+ return K || (K = 1, process.env.NODE_ENV === "production" ? j.exports = ae() : j.exports = se()), j.exports;
280
280
  }
281
- var ae = ce();
282
- class le extends EventTarget {
281
+ var ce = ie();
282
+ const fe = ({
283
+ formConfig: l,
284
+ formPageUrl: r,
285
+ formId: n,
286
+ scale: a = 100,
287
+ instanceId: s,
288
+ onFormEvent: c
289
+ }) => {
290
+ const m = !!(l && r), w = n ?? l?.formId ?? s ?? "preview", v = q.useRef(null), h = q.useRef(null), R = $(!1), y = $(() => {
291
+ }), i = $({});
292
+ O(() => {
293
+ if (!c) return;
294
+ c({
295
+ onSubmit: (d) => {
296
+ i.current.onSubmit = d;
297
+ },
298
+ onShow: (d) => {
299
+ i.current.onShow = d;
300
+ },
301
+ onClose: (d) => {
302
+ i.current.onClose = d;
303
+ },
304
+ onSectionChange: (d) => {
305
+ i.current.onSectionChange = d;
306
+ },
307
+ onQuestionAnswered: (d) => {
308
+ i.current.onQuestionAnswered = d;
309
+ },
310
+ onError: (d) => {
311
+ i.current.onError = d;
312
+ }
313
+ });
314
+ }, [c]);
315
+ const I = X(() => {
316
+ if (!h.current?.contentWindow || !l) return;
317
+ const f = { formId: w, scale: a, ...l };
318
+ h.current.contentWindow.postMessage(
319
+ { type: "sdk:formConfig", data: f },
320
+ "*"
321
+ );
322
+ }, [l, w, a]);
323
+ y.current = I, O(() => {
324
+ !m || !R.current || y.current();
325
+ }, [m, l, I]);
326
+ const N = X((f) => {
327
+ f.style.border = "none", f.style.width = "100%", f.style.height = "100%";
328
+ }, []);
329
+ return O(() => {
330
+ if (!m || !v.current || !l || !r) return;
331
+ const f = document.createElement("div");
332
+ f.style.width = "100%", f.style.height = "100%", f.style.display = "flex", f.style.flexDirection = "column", f.style.justifyContent = "flex-end", f.style.overflow = "auto";
333
+ const d = document.createElement("iframe"), P = new URL(r, window.location.origin);
334
+ P.searchParams.set("formId", w), d.src = P.toString(), d.title = "Encatch form", N(d), h.current = d, f.appendChild(d), v.current.appendChild(f);
335
+ const x = (F) => {
336
+ const E = F.data;
337
+ if (!E || typeof E != "object" || !E.type) return;
338
+ let _ = E.type, T = E.formId, o = E.data;
339
+ switch (_.startsWith("encatch:") && (_ = _.replace("encatch:", ""), T = E.payload?.feedbackConfigurationId, o = E.payload), _) {
340
+ case "form:resize":
341
+ h.current && o && typeof o.height == "number" && (h.current.style.height = `${o.height}px`);
342
+ break;
343
+ case "form:ready":
344
+ R.current = !0, y.current();
345
+ break;
346
+ case "form:close":
347
+ i.current.onClose?.({ timestamp: Date.now() });
348
+ break;
349
+ case "form:complete":
350
+ i.current.onClose?.({ timestamp: Date.now() });
351
+ break;
352
+ case "form:submit":
353
+ o && i.current.onSubmit && i.current.onSubmit({
354
+ feedbackConfigurationId: o.feedbackConfigurationId,
355
+ feedbackIdentifier: o.feedbackIdentifier,
356
+ response: o.response,
357
+ isPartialSubmit: o.isPartialSubmit,
358
+ timestamp: Date.now()
359
+ });
360
+ break;
361
+ case "form:show":
362
+ o && i.current.onShow && i.current.onShow({
363
+ feedbackConfigurationId: o.feedbackConfigurationId,
364
+ feedbackIdentifier: o.feedbackIdentifier,
365
+ timestamp: Date.now()
366
+ });
367
+ break;
368
+ case "form:started":
369
+ o && i.current.onShow && i.current.onShow({
370
+ feedbackConfigurationId: o.feedbackConfigurationId,
371
+ feedbackIdentifier: o.feedbackIdentifier,
372
+ timestamp: Date.now()
373
+ });
374
+ break;
375
+ case "form:section:change":
376
+ o && i.current.onSectionChange && i.current.onSectionChange({
377
+ feedbackConfigurationId: o.feedbackConfigurationId ?? T ?? "",
378
+ sectionIndex: o.sectionIndex,
379
+ sectionId: o.sectionId,
380
+ timestamp: Date.now()
381
+ });
382
+ break;
383
+ case "form:answered":
384
+ o && i.current.onQuestionAnswered && i.current.onQuestionAnswered({
385
+ feedbackConfigurationId: o.feedbackConfigurationId ?? T ?? "",
386
+ questionId: o.questionId,
387
+ questionType: o.questionType,
388
+ answer: o.answer,
389
+ timestamp: Date.now()
390
+ });
391
+ break;
392
+ case "form:error":
393
+ o && i.current.onError && i.current.onError({
394
+ feedbackConfigurationId: o.feedbackConfigurationId ?? T ?? "",
395
+ questionId: o.questionId,
396
+ error: o.error ?? "Unknown error",
397
+ timestamp: Date.now()
398
+ });
399
+ break;
400
+ }
401
+ };
402
+ return window.addEventListener("message", x), () => {
403
+ window.removeEventListener("message", x), R.current = !1, f.parentNode && f.parentNode.removeChild(f), h.current = null;
404
+ };
405
+ }, [m, r, w]), /* @__PURE__ */ ce.jsx(
406
+ "div",
407
+ {
408
+ ref: v,
409
+ title: "encatchPreview1",
410
+ style: m ? {
411
+ width: "100%",
412
+ height: "100%"
413
+ } : void 0
414
+ }
415
+ );
416
+ };
417
+ class ue extends EventTarget {
283
418
  subscriptions = /* @__PURE__ */ new Map();
284
419
  targetOrigin = "*";
285
420
  /**
286
421
  * Check if a form ID matches the filter
287
422
  */
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;
423
+ matchesFilter(r, n) {
424
+ return !n || n === "*" || n === null || n === void 0 ? !0 : typeof n == "string" ? r === n : Array.isArray(n) ? n.includes(r || "") : typeof n == "function" ? n(r || "") : !1;
290
425
  }
291
426
  /**
292
427
  * Get form ID from payload
@@ -297,29 +432,29 @@ class le extends EventTarget {
297
432
  /**
298
433
  * Publish an event to all matching subscribers
299
434
  */
300
- publish(r, t, u) {
435
+ publish(r, n, a) {
301
436
  typeof window < "u" && window.dispatchEvent(
302
437
  new CustomEvent(r, {
303
- detail: t,
438
+ detail: n,
304
439
  bubbles: !0
305
440
  })
306
- ), u?.usePostMessage !== !1 && this.sendPostMessage(r, t);
441
+ ), a?.usePostMessage !== !1 && this.sendPostMessage(r, n);
307
442
  }
308
443
  /**
309
444
  * Subscribe to form events with optional form ID filtering
310
445
  */
311
- subscribe(r, t, u) {
446
+ subscribe(r, n, a) {
312
447
  const s = Symbol("subscription"), c = {
313
448
  eventType: r,
314
- handler: t,
315
- filter: u?.formId,
449
+ handler: n,
450
+ filter: a?.formId,
316
451
  id: s,
317
- once: u?.once
452
+ once: a?.once
318
453
  };
319
454
  this.subscriptions.has(r) || this.subscriptions.set(r, []), this.subscriptions.get(r).push(c);
320
- const m = (p) => {
321
- const R = p, T = this.getFormIdFromPayload(R.detail);
322
- this.matchesFilter(T, u?.formId) && (t(R.detail), u?.once && typeof window < "u" && window.removeEventListener(r, m));
455
+ const m = (w) => {
456
+ const v = w, h = this.getFormIdFromPayload(v.detail);
457
+ this.matchesFilter(h, a?.formId) && (n(v.detail), a?.once && typeof window < "u" && window.removeEventListener(r, m));
323
458
  };
324
459
  return typeof window < "u" && window.addEventListener(r, m), () => {
325
460
  this.unsubscribe(s), typeof window < "u" && window.removeEventListener(r, m);
@@ -329,10 +464,10 @@ class le extends EventTarget {
329
464
  * Unsubscribe by subscription ID
330
465
  */
331
466
  unsubscribe(r) {
332
- for (const [t, u] of this.subscriptions.entries()) {
333
- const s = u.findIndex((c) => c.id === r);
467
+ for (const [n, a] of this.subscriptions.entries()) {
468
+ const s = a.findIndex((c) => c.id === r);
334
469
  if (s !== -1) {
335
- u.splice(s, 1), u.length === 0 && this.subscriptions.delete(t);
470
+ a.splice(s, 1), a.length === 0 && this.subscriptions.delete(n);
336
471
  break;
337
472
  }
338
473
  }
@@ -340,21 +475,21 @@ class le extends EventTarget {
340
475
  /**
341
476
  * Subscribe to all form events with optional filtering
342
477
  */
343
- subscribeAll(r, t) {
344
- const u = [
478
+ subscribeAll(r, n) {
479
+ const a = [
345
480
  "form:show",
346
481
  "form:started",
347
482
  "form:submit",
348
483
  "form:close",
349
484
  "form:section:change",
350
- "form:question:answered",
485
+ "form:answered",
351
486
  "form:error"
352
487
  ], s = [];
353
- return u.forEach((c) => {
488
+ return a.forEach((c) => {
354
489
  const m = this.subscribe(
355
490
  c,
356
- (p) => r(c, p),
357
- t
491
+ (w) => r(c, w),
492
+ n
358
493
  );
359
494
  s.push(m);
360
495
  }), () => {
@@ -365,7 +500,7 @@ class le extends EventTarget {
365
500
  * Get active subscriptions count (for debugging)
366
501
  */
367
502
  getSubscriptionCount(r) {
368
- return r ? this.subscriptions.get(r)?.length || 0 : Array.from(this.subscriptions.values()).reduce((t, u) => t + u.length, 0);
503
+ return r ? this.subscriptions.get(r)?.length || 0 : Array.from(this.subscriptions.values()).reduce((n, a) => n + a.length, 0);
369
504
  }
370
505
  /**
371
506
  * Clear all subscriptions for an event type (or all events)
@@ -373,130 +508,33 @@ class le extends EventTarget {
373
508
  clearSubscriptions(r) {
374
509
  r ? this.subscriptions.delete(r) : this.subscriptions.clear();
375
510
  }
376
- sendPostMessage(r, t) {
377
- const u = {
511
+ sendPostMessage(r, n) {
512
+ const a = {
378
513
  type: `encatch:${r}`,
379
- payload: t,
514
+ payload: n,
380
515
  source: "encatch-form-engine"
381
516
  };
382
- window.parent && window.parent !== window && window.parent.postMessage(u, this.targetOrigin), document.querySelectorAll("iframe").forEach((s) => {
383
- s.contentWindow && s.contentWindow.postMessage(u, this.targetOrigin);
517
+ window.parent && window.parent !== window && window.parent.postMessage(a, this.targetOrigin), document.querySelectorAll("iframe").forEach((s) => {
518
+ s.contentWindow && s.contentWindow.postMessage(a, this.targetOrigin);
384
519
  }), typeof window.ReactNativeWebView < "u" && window.ReactNativeWebView.postMessage(JSON.stringify({
385
520
  action: r.replace("form:", ""),
386
- data: JSON.stringify(t)
521
+ data: JSON.stringify(n)
387
522
  }));
388
523
  }
389
524
  }
390
- const g = new le(), de = ({
391
- formData: o,
392
- cssLink: r,
393
- scale: t = 100,
394
- persistMode: u = "none",
395
- instanceId: s,
396
- onFormEvent: c
397
- }) => {
398
- const [m, p] = U(!1), [R, T] = U(!0), E = I.useRef(null), v = I.useRef(
399
- null
400
- ), a = oe({});
401
- S(() => {
402
- if (!c) return;
403
- c({
404
- onSubmit: (f) => {
405
- a.current.onSubmit = f;
406
- },
407
- onShow: (f) => {
408
- a.current.onShow = f;
409
- },
410
- onClose: (f) => {
411
- a.current.onClose = f;
412
- },
413
- onSectionChange: (f) => {
414
- a.current.onSectionChange = f;
415
- },
416
- onQuestionAnswered: (f) => {
417
- a.current.onQuestionAnswered = f;
418
- },
419
- onError: (f) => {
420
- a.current.onError = f;
421
- }
422
- });
423
- }, [c]), S(() => {
424
- if (!s) return;
425
- const i = [];
426
- return a.current.onSubmit && i.push(
427
- g.subscribe(
428
- "form:submit",
429
- a.current.onSubmit,
430
- { formId: s }
431
- )
432
- ), a.current.onShow && i.push(
433
- g.subscribe(
434
- "form:show",
435
- a.current.onShow,
436
- { formId: s }
437
- )
438
- ), a.current.onClose && i.push(
439
- g.subscribe(
440
- "form:close",
441
- a.current.onClose,
442
- { formId: s }
443
- )
444
- ), a.current.onSectionChange && i.push(
445
- g.subscribe(
446
- "form:section:change",
447
- a.current.onSectionChange,
448
- { formId: s }
449
- )
450
- ), a.current.onQuestionAnswered && i.push(
451
- g.subscribe(
452
- "form:question:answered",
453
- a.current.onQuestionAnswered,
454
- { formId: s }
455
- )
456
- ), a.current.onError && i.push(
457
- g.subscribe(
458
- "form:error",
459
- a.current.onError,
460
- { formId: s }
461
- )
462
- ), () => {
463
- i.forEach((f) => f());
464
- };
465
- }, [s]), S(() => {
466
- (() => {
467
- try {
468
- return o ? !0 : (console.warn("[EncatchPreview] formData is not defined"), !1);
469
- } catch (f) {
470
- return console.error("[EncatchPreview] Error during data validation:", f), !1;
471
- }
472
- })() ? p(!0) : console.warn(
473
- "[EncatchPreview] Data validation failed, retrying in 100ms..."
474
- );
475
- }, [o]);
476
- const y = se(() => {
477
- o.onClose && o.onClose(), T(!1);
478
- }, [o.onClose]);
479
- return S(() => {
480
- if (!m || !E.current)
481
- return;
482
- const i = document.createElement("encatch-app");
483
- 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), v.current = i, E.current.appendChild(i), () => {
484
- E.current && v.current && E.current.removeChild(v.current), v.current = null;
485
- };
486
- }, [m, o, r, t, y, u, s]), R ? /* @__PURE__ */ ae.jsx("div", { ref: E }) : null;
487
- };
488
- function be(o, r, t) {
489
- S(() => g.subscribe(
490
- o,
525
+ const ee = new ue();
526
+ function de(l, r, n) {
527
+ O(() => ee.subscribe(
528
+ l,
491
529
  r,
492
- t
493
- ), [o, t?.formId, r]);
530
+ n
531
+ ), [l, n?.formId, r]);
494
532
  }
495
- function me(o, r) {
496
- S(() => g.subscribeAll(o, r), [r?.formId, o]);
533
+ function me(l, r) {
534
+ O(() => ee.subscribeAll(l, r), [r?.formId, l]);
497
535
  }
498
536
  export {
499
- de as EncatchPreview,
500
- be as useEncatchFormEvent,
537
+ fe as EncatchPreview,
538
+ de as useEncatchFormEvent,
501
539
  me as useEncatchFormEventAll
502
540
  };
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(w,d){typeof exports=="object"&&typeof module<"u"?d(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],d):(w=typeof globalThis<"u"?globalThis:w||self,d(w.WsReact={},w.React))})(this,(function(w,d){"use strict";var C={exports:{}},y={};/**
1
+ (function(k,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(k=typeof globalThis<"u"?globalThis:k||self,m(k.WsReact={},k.React))})(this,(function(k,m){"use strict";var x={exports:{}},C={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var M;function z(){if(M)return y;M=1;var o=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function t(u,s,c){var E=null;if(c!==void 0&&(E=""+c),s.key!==void 0&&(E=""+s.key),"key"in s){c={};for(var h in s)h!=="key"&&(c[h]=s[h])}else c=s;return s=c.ref,{$$typeof:o,type:u,key:E,ref:s!==void 0?s:null,props:c}}return y.Fragment=r,y.jsx=t,y.jsxs=t,y}var P={};/**
9
+ */var q;function K(){if(q)return C;q=1;var f=Symbol.for("react.transitional.element"),r=Symbol.for("react.fragment");function n(s,a,c){var b=null;if(c!==void 0&&(b=""+c),a.key!==void 0&&(b=""+a.key),"key"in a){c={};for(var h in a)h!=="key"&&(c[h]=a[h])}else c=a;return a=c.ref,{$$typeof:f,type:s,key:b,ref:a!==void 0?a:null,props:c}}return C.Fragment=r,C.jsx=n,C.jsxs=n,C}var O={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,9 +14,9 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var F;function G(){return F||(F=1,process.env.NODE_ENV!=="production"&&(function(){function o(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case f:return"Fragment";case ee:return"Profiler";case D:return"StrictMode";case oe:return"Suspense";case se:return"SuspenseList";case ue:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case i:return"Portal";case te:return(e.displayName||"Context")+".Provider";case re:return(e._context.displayName||"Context")+".Consumer";case ne:var n=e.render;return e=e.displayName,e||(e=n.displayName||n.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case ie:return n=e.displayName||null,n!==null?n:o(e.type)||"Memo";case L:n=e._payload,e=e._init;try{return o(e(n))}catch{}}return null}function r(e){return""+e}function t(e){try{r(e);var n=!1}catch{n=!0}if(n){n=console;var l=n.error,b=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return l.call(n,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",b),r(e)}}function u(e){if(e===f)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===L)return"<...>";try{var n=o(e);return n?"<"+n+">":"<...>"}catch{return"<...>"}}function s(){var e=O.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function E(e){if(W.call(e,"key")){var n=Object.getOwnPropertyDescriptor(e,"key").get;if(n&&n.isReactWarning)return!1}return e.key!==void 0}function h(e,n){function l(){q||(q=!0,console.error("%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)",n))}l.isReactWarning=!0,Object.defineProperty(e,"key",{get:l,configurable:!0})}function R(){var e=o(this.type);return $[e]||($[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function A(e,n,l,b,S,p,x,N){return l=p.ref,e={$$typeof:k,type:e,key:n,props:p,_owner:S},(l!==void 0?l:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:R}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:x}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:N}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function g(e,n,l,b,S,p,x,N){var m=n.children;if(m!==void 0)if(b)if(ae(m)){for(b=0;b<m.length;b++)_(m[b]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else _(m);if(W.call(n,"key")){m=o(e);var T=Object.keys(n).filter(function(le){return le!=="key"});b=0<T.length?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}",V[m+b]||(T=0<T.length?"{"+T.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var J;function ee(){return J||(J=1,process.env.NODE_ENV!=="production"&&(function(){function f(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case l:return"Fragment";case j:return"Profiler";case d:return"StrictMode";case S:return"Suspense";case I:return"SuspenseList";case ie:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case F:return"Portal";case D:return(e.displayName||"Context")+".Provider";case N:return(e._context.displayName||"Context")+".Consumer";case v:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case o:return t=e.displayName||null,t!==null?t:f(e.type)||"Memo";case z:t=e._payload,e=e._init;try{return f(e(t))}catch{}}return null}function r(e){return""+e}function n(e){try{r(e);var t=!1}catch{t=!0}if(t){t=console;var u=t.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return u.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),r(e)}}function s(e){if(e===l)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===z)return"<...>";try{var t=f(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function a(){var e=M.A;return e===null?null:e.getOwner()}function c(){return Error("react-stack-top-frame")}function b(e){if(G.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function h(e,t){function u(){B||(B=!0,console.error("%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)",t))}u.isReactWarning=!0,Object.defineProperty(e,"key",{get:u,configurable:!0})}function y(){var e=f(this.type);return Q[e]||(Q[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function E(e,t,u,p,R,g,W,L){return u=g.ref,e={$$typeof:P,type:e,key:t,props:g,_owner:R},(u!==void 0?u:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:y}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:W}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:L}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function _(e,t,u,p,R,g,W,L){var w=t.children;if(w!==void 0)if(p)if(ue(w)){for(p=0;p<w.length;p++)T(w[p]);Object.freeze&&Object.freeze(w)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else T(w);if(G.call(t,"key")){w=f(e);var A=Object.keys(t).filter(function(fe){return fe!=="key"});p=0<A.length?"{key: someKey, "+A.join(": ..., ")+": ...}":"{key: someKey}",Z[w+p]||(A=0<A.length?"{"+A.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,b,m,T,m),V[m+b]=!0)}if(m=null,l!==void 0&&(t(l),m=""+l),E(n)&&(t(n.key),m=""+n.key),"key"in n){l={};for(var I in n)I!=="key"&&(l[I]=n[I])}else l=n;return m&&h(l,typeof e=="function"?e.displayName||e.name||"Unknown":e),A(e,m,p,S,s(),l,x,N)}function _(e){typeof e=="object"&&e!==null&&e.$$typeof===k&&e._store&&(e._store.validated=1)}var a=d,k=Symbol.for("react.transitional.element"),i=Symbol.for("react.portal"),f=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),ee=Symbol.for("react.profiler"),re=Symbol.for("react.consumer"),te=Symbol.for("react.context"),ne=Symbol.for("react.forward_ref"),oe=Symbol.for("react.suspense"),se=Symbol.for("react.suspense_list"),ie=Symbol.for("react.memo"),L=Symbol.for("react.lazy"),ue=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),O=a.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,ae=Array.isArray,j=console.createTask?console.createTask:function(){return null};a={react_stack_bottom_frame:function(e){return e()}};var q,$={},U=a.react_stack_bottom_frame.bind(a,c)(),J=j(u(c)),V={};P.Fragment=f,P.jsx=function(e,n,l,b,S){var p=1e4>O.recentlyCreatedOwnerStacks++;return g(e,n,l,!1,b,S,p?Error("react-stack-top-frame"):U,p?j(u(e)):J)},P.jsxs=function(e,n,l,b,S){var p=1e4>O.recentlyCreatedOwnerStacks++;return g(e,n,l,!0,b,S,p?Error("react-stack-top-frame"):U,p?j(u(e)):J)}})()),P}var Y;function Q(){return Y||(Y=1,process.env.NODE_ENV==="production"?C.exports=z():C.exports=G()),C.exports}var X=Q();class B extends EventTarget{subscriptions=new Map;targetOrigin="*";matchesFilter(r,t){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}getFormIdFromPayload(r){return r?.feedbackConfigurationId}publish(r,t,u){typeof window<"u"&&window.dispatchEvent(new CustomEvent(r,{detail:t,bubbles:!0})),u?.usePostMessage!==!1&&this.sendPostMessage(r,t)}subscribe(r,t,u){const s=Symbol("subscription"),c={eventType:r,handler:t,filter:u?.formId,id:s,once:u?.once};this.subscriptions.has(r)||this.subscriptions.set(r,[]),this.subscriptions.get(r).push(c);const E=h=>{const R=h,A=this.getFormIdFromPayload(R.detail);this.matchesFilter(A,u?.formId)&&(t(R.detail),u?.once&&typeof window<"u"&&window.removeEventListener(r,E))};return typeof window<"u"&&window.addEventListener(r,E),()=>{this.unsubscribe(s),typeof window<"u"&&window.removeEventListener(r,E)}}unsubscribe(r){for(const[t,u]of this.subscriptions.entries()){const s=u.findIndex(c=>c.id===r);if(s!==-1){u.splice(s,1),u.length===0&&this.subscriptions.delete(t);break}}}subscribeAll(r,t){const u=["form:show","form:started","form:submit","form:close","form:section:change","form:question:answered","form:error"],s=[];return u.forEach(c=>{const E=this.subscribe(c,h=>r(c,h),t);s.push(E)}),()=>{s.forEach(c=>c())}}getSubscriptionCount(r){return r?this.subscriptions.get(r)?.length||0:Array.from(this.subscriptions.values()).reduce((t,u)=>t+u.length,0)}clearSubscriptions(r){r?this.subscriptions.delete(r):this.subscriptions.clear()}sendPostMessage(r,t){const u={type:`encatch:${r}`,payload:t,source:"encatch-form-engine"};window.parent&&window.parent!==window&&window.parent.postMessage(u,this.targetOrigin),document.querySelectorAll("iframe").forEach(s=>{s.contentWindow&&s.contentWindow.postMessage(u,this.targetOrigin)}),typeof window.ReactNativeWebView<"u"&&window.ReactNativeWebView.postMessage(JSON.stringify({action:r.replace("form:",""),data:JSON.stringify(t)}))}}const v=new B,H=({formData:o,cssLink:r,scale:t=100,persistMode:u="none",instanceId:s,onFormEvent:c})=>{const[E,h]=d.useState(!1),[R,A]=d.useState(!0),g=d.useRef(null),_=d.useRef(null),a=d.useRef({});d.useEffect(()=>{if(!c)return;c({onSubmit:f=>{a.current.onSubmit=f},onShow:f=>{a.current.onShow=f},onClose:f=>{a.current.onClose=f},onSectionChange:f=>{a.current.onSectionChange=f},onQuestionAnswered:f=>{a.current.onQuestionAnswered=f},onError:f=>{a.current.onError=f}})},[c]),d.useEffect(()=>{if(!s)return;const i=[];return a.current.onSubmit&&i.push(v.subscribe("form:submit",a.current.onSubmit,{formId:s})),a.current.onShow&&i.push(v.subscribe("form:show",a.current.onShow,{formId:s})),a.current.onClose&&i.push(v.subscribe("form:close",a.current.onClose,{formId:s})),a.current.onSectionChange&&i.push(v.subscribe("form:section:change",a.current.onSectionChange,{formId:s})),a.current.onQuestionAnswered&&i.push(v.subscribe("form:question:answered",a.current.onQuestionAnswered,{formId:s})),a.current.onError&&i.push(v.subscribe("form:error",a.current.onError,{formId:s})),()=>{i.forEach(f=>f())}},[s]),d.useEffect(()=>{(()=>{try{return o?!0:(console.warn("[EncatchPreview] formData is not defined"),!1)}catch(f){return console.error("[EncatchPreview] Error during data validation:",f),!1}})()?h(!0):console.warn("[EncatchPreview] Data validation failed, retrying in 100ms...")},[o]);const k=d.useCallback(()=>{o.onClose&&o.onClose(),A(!1)},[o.onClose]);return d.useEffect(()=>{if(!E||!g.current)return;const i=document.createElement("encatch-app");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=k,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),_.current=i,g.current.appendChild(i),()=>{g.current&&_.current&&g.current.removeChild(_.current),_.current=null}},[E,o,r,t,k,u,s]),R?X.jsx("div",{ref:g}):null};function Z(o,r,t){d.useEffect(()=>v.subscribe(o,r,t),[o,t?.formId,r])}function K(o,r){d.useEffect(()=>v.subscribeAll(o,r),[r?.formId,o])}w.EncatchPreview=H,w.useEncatchFormEvent=Z,w.useEncatchFormEventAll=K,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})}));
22
+ <%s key={someKey} {...props} />`,p,w,A,w),Z[w+p]=!0)}if(w=null,u!==void 0&&(n(u),w=""+u),b(t)&&(n(t.key),w=""+t.key),"key"in t){u={};for(var $ in t)$!=="key"&&(u[$]=t[$])}else u=t;return w&&h(u,typeof e=="function"?e.displayName||e.name||"Unknown":e),E(e,w,g,R,a(),u,W,L)}function T(e){typeof e=="object"&&e!==null&&e.$$typeof===P&&e._store&&(e._store.validated=1)}var i=m,P=Symbol.for("react.transitional.element"),F=Symbol.for("react.portal"),l=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),N=Symbol.for("react.consumer"),D=Symbol.for("react.context"),v=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),I=Symbol.for("react.suspense_list"),o=Symbol.for("react.memo"),z=Symbol.for("react.lazy"),ie=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),M=i.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,G=Object.prototype.hasOwnProperty,ue=Array.isArray,Y=console.createTask?console.createTask:function(){return null};i={react_stack_bottom_frame:function(e){return e()}};var B,Q={},X=i.react_stack_bottom_frame.bind(i,c)(),H=Y(s(c)),Z={};O.Fragment=l,O.jsx=function(e,t,u,p,R){var g=1e4>M.recentlyCreatedOwnerStacks++;return _(e,t,u,!1,p,R,g?Error("react-stack-top-frame"):X,g?Y(s(e)):H)},O.jsxs=function(e,t,u,p,R){var g=1e4>M.recentlyCreatedOwnerStacks++;return _(e,t,u,!0,p,R,g?Error("react-stack-top-frame"):X,g?Y(s(e)):H)}})()),O}var U;function re(){return U||(U=1,process.env.NODE_ENV==="production"?x.exports=K():x.exports=ee()),x.exports}var te=re();const ne=({formConfig:f,formPageUrl:r,formId:n,scale:s=100,instanceId:a,onFormEvent:c})=>{const b=!!(f&&r),h=n??f?.formId??a??"preview",y=m.useRef(null),E=m.useRef(null),_=m.useRef(!1),T=m.useRef(()=>{}),i=m.useRef({});m.useEffect(()=>{if(!c)return;c({onSubmit:d=>{i.current.onSubmit=d},onShow:d=>{i.current.onShow=d},onClose:d=>{i.current.onClose=d},onSectionChange:d=>{i.current.onSectionChange=d},onQuestionAnswered:d=>{i.current.onQuestionAnswered=d},onError:d=>{i.current.onError=d}})},[c]);const P=m.useCallback(()=>{if(!E.current?.contentWindow||!f)return;const l={formId:h,scale:s,...f};E.current.contentWindow.postMessage({type:"sdk:formConfig",data:l},"*")},[f,h,s]);T.current=P,m.useEffect(()=>{!b||!_.current||T.current()},[b,f,P]);const F=m.useCallback(l=>{l.style.border="none",l.style.width="100%",l.style.height="100%"},[]);return m.useEffect(()=>{if(!b||!y.current||!f||!r)return;const l=document.createElement("div");l.style.width="100%",l.style.height="100%",l.style.display="flex",l.style.flexDirection="column",l.style.justifyContent="flex-end",l.style.overflow="auto";const d=document.createElement("iframe"),j=new URL(r,window.location.origin);j.searchParams.set("formId",h),d.src=j.toString(),d.title="Encatch form",F(d),E.current=d,l.appendChild(d),y.current.appendChild(l);const N=D=>{const v=D.data;if(!v||typeof v!="object"||!v.type)return;let S=v.type,I=v.formId,o=v.data;switch(S.startsWith("encatch:")&&(S=S.replace("encatch:",""),I=v.payload?.feedbackConfigurationId,o=v.payload),S){case"form:resize":E.current&&o&&typeof o.height=="number"&&(E.current.style.height=`${o.height}px`);break;case"form:ready":_.current=!0,T.current();break;case"form:close":i.current.onClose?.({timestamp:Date.now()});break;case"form:complete":i.current.onClose?.({timestamp:Date.now()});break;case"form:submit":o&&i.current.onSubmit&&i.current.onSubmit({feedbackConfigurationId:o.feedbackConfigurationId,feedbackIdentifier:o.feedbackIdentifier,response:o.response,isPartialSubmit:o.isPartialSubmit,timestamp:Date.now()});break;case"form:show":o&&i.current.onShow&&i.current.onShow({feedbackConfigurationId:o.feedbackConfigurationId,feedbackIdentifier:o.feedbackIdentifier,timestamp:Date.now()});break;case"form:started":o&&i.current.onShow&&i.current.onShow({feedbackConfigurationId:o.feedbackConfigurationId,feedbackIdentifier:o.feedbackIdentifier,timestamp:Date.now()});break;case"form:section:change":o&&i.current.onSectionChange&&i.current.onSectionChange({feedbackConfigurationId:o.feedbackConfigurationId??I??"",sectionIndex:o.sectionIndex,sectionId:o.sectionId,timestamp:Date.now()});break;case"form:answered":o&&i.current.onQuestionAnswered&&i.current.onQuestionAnswered({feedbackConfigurationId:o.feedbackConfigurationId??I??"",questionId:o.questionId,questionType:o.questionType,answer:o.answer,timestamp:Date.now()});break;case"form:error":o&&i.current.onError&&i.current.onError({feedbackConfigurationId:o.feedbackConfigurationId??I??"",questionId:o.questionId,error:o.error??"Unknown error",timestamp:Date.now()});break}};return window.addEventListener("message",N),()=>{window.removeEventListener("message",N),_.current=!1,l.parentNode&&l.parentNode.removeChild(l),E.current=null}},[b,r,h]),te.jsx("div",{ref:y,title:"encatchPreview1",style:b?{width:"100%",height:"100%"}:void 0})};class oe extends EventTarget{subscriptions=new Map;targetOrigin="*";matchesFilter(r,n){return!n||n==="*"||n===null||n===void 0?!0:typeof n=="string"?r===n:Array.isArray(n)?n.includes(r||""):typeof n=="function"?n(r||""):!1}getFormIdFromPayload(r){return r?.feedbackConfigurationId}publish(r,n,s){typeof window<"u"&&window.dispatchEvent(new CustomEvent(r,{detail:n,bubbles:!0})),s?.usePostMessage!==!1&&this.sendPostMessage(r,n)}subscribe(r,n,s){const a=Symbol("subscription"),c={eventType:r,handler:n,filter:s?.formId,id:a,once:s?.once};this.subscriptions.has(r)||this.subscriptions.set(r,[]),this.subscriptions.get(r).push(c);const b=h=>{const y=h,E=this.getFormIdFromPayload(y.detail);this.matchesFilter(E,s?.formId)&&(n(y.detail),s?.once&&typeof window<"u"&&window.removeEventListener(r,b))};return typeof window<"u"&&window.addEventListener(r,b),()=>{this.unsubscribe(a),typeof window<"u"&&window.removeEventListener(r,b)}}unsubscribe(r){for(const[n,s]of this.subscriptions.entries()){const a=s.findIndex(c=>c.id===r);if(a!==-1){s.splice(a,1),s.length===0&&this.subscriptions.delete(n);break}}}subscribeAll(r,n){const s=["form:show","form:started","form:submit","form:close","form:section:change","form:answered","form:error"],a=[];return s.forEach(c=>{const b=this.subscribe(c,h=>r(c,h),n);a.push(b)}),()=>{a.forEach(c=>c())}}getSubscriptionCount(r){return r?this.subscriptions.get(r)?.length||0:Array.from(this.subscriptions.values()).reduce((n,s)=>n+s.length,0)}clearSubscriptions(r){r?this.subscriptions.delete(r):this.subscriptions.clear()}sendPostMessage(r,n){const s={type:`encatch:${r}`,payload:n,source:"encatch-form-engine"};window.parent&&window.parent!==window&&window.parent.postMessage(s,this.targetOrigin),document.querySelectorAll("iframe").forEach(a=>{a.contentWindow&&a.contentWindow.postMessage(s,this.targetOrigin)}),typeof window.ReactNativeWebView<"u"&&window.ReactNativeWebView.postMessage(JSON.stringify({action:r.replace("form:",""),data:JSON.stringify(n)}))}}const V=new oe;function se(f,r,n){m.useEffect(()=>V.subscribe(f,r,n),[f,n?.formId,r])}function ae(f,r){m.useEffect(()=>V.subscribeAll(f,r),[r?.formId,f])}k.EncatchPreview=ne,k.useEncatchFormEvent=se,k.useEncatchFormEventAll=ae,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
package/dist/types.d.ts CHANGED
@@ -1,4 +1,45 @@
1
1
  import type { FormEventPayload } from '@encatch/event-publisher';
2
+ /**
3
+ * Full form configuration object used when rendering the form in an iframe (EncatchPreview iframe mode).
4
+ * Matches the payload shape expected by the shareable iframe form page (sdk:formConfig).
5
+ * EncatchPreview sends this via postMessage when formPageUrl is provided.
6
+ */
7
+ export interface EncatchFormConfig {
8
+ formId?: string;
9
+ questionnaireFields?: {
10
+ questions?: Record<string, unknown>;
11
+ sections?: unknown[];
12
+ selectedLanguages?: Array<{
13
+ value: string;
14
+ label: string;
15
+ isFixed?: boolean;
16
+ }>;
17
+ translations?: Record<string, unknown>;
18
+ };
19
+ appearanceProperties?: {
20
+ themes?: {
21
+ light?: {
22
+ theme?: string;
23
+ };
24
+ dark?: {
25
+ theme?: string;
26
+ };
27
+ };
28
+ featureSettings?: {
29
+ closeButton?: boolean;
30
+ shareableMode?: string;
31
+ };
32
+ };
33
+ welcomeScreenProperties?: unknown;
34
+ endScreenProperties?: unknown;
35
+ otherConfigurationProperties?: unknown;
36
+ feedbackConfigurationId?: string;
37
+ feedbackIdentifier?: string;
38
+ formConfiguration?: {
39
+ formTitle?: string;
40
+ };
41
+ [key: string]: unknown;
42
+ }
2
43
  /**
3
44
  * Callback function for form submit events
4
45
  */
@@ -18,7 +59,7 @@ export type OnSectionChangeCallback = (payload: FormEventPayload['form:section:c
18
59
  /**
19
60
  * Callback function for question answered events
20
61
  */
21
- export type OnQuestionAnsweredCallback = (payload: FormEventPayload['form:question:answered']) => void;
62
+ export type OnQuestionAnsweredCallback = (payload: FormEventPayload['form:answered']) => void;
22
63
  /**
23
64
  * Callback function for form error events
24
65
  */
@@ -85,3 +126,13 @@ export interface FormEventBuilder {
85
126
  * Function type for the onFormEvent prop
86
127
  */
87
128
  export type OnFormEventHandler = (formEvent: FormEventBuilder) => void;
129
+ /**
130
+ * Props for EncatchPreview when used in iframe mode.
131
+ * Pass formConfig and formPageUrl to render the form inside an iframe;
132
+ * formPageUrl should point at the shareable encatch-preview-form route (e.g. origin + /encatch-preview-form).
133
+ */
134
+ export interface EncatchPreviewIframeModeProps {
135
+ formConfig: EncatchFormConfig;
136
+ formPageUrl: string;
137
+ formId?: string;
138
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@encatch/ws-react",
3
- "version": "0.0.50-beta.1",
3
+ "version": "0.0.50-beta.10",
4
4
  "type": "module",
5
5
  "main": "./dist/index.umd.js",
6
6
  "module": "./dist/index.es.js",
@@ -20,8 +20,8 @@
20
20
  "react-dom": "^19.1.1"
21
21
  },
22
22
  "dependencies": {
23
- "@encatch/schema": "1.0.0-beta.1",
24
- "@encatch/event-publisher": "1.0.0-beta.1"
23
+ "@encatch/schema": "1.0.0",
24
+ "@encatch/event-publisher": "1.0.0-beta.2"
25
25
  },
26
26
  "devDependencies": {
27
27
  "@eslint/js": "^9.36.0",