react-formio-engine 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,119 @@
1
+ # @preshin/react-formio-engine
2
+
3
+ React functional components for form rendering and building, powered by [formiojs](https://github.com/formio/formio.js). Drop-in replacement for `@formio/react` and `@converselabs/react-formio` with no class components.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @preshin/react-formio-engine
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```jsx
14
+ import { Form } from '@preshin/react-formio-engine';
15
+ import 'bootstrap/dist/css/bootstrap.css';
16
+ import 'formiojs/dist/formio.full.css';
17
+
18
+ const schema = {
19
+ display: 'form',
20
+ components: [
21
+ { type: 'textfield', key: 'name', label: 'Name', validate: { required: true } },
22
+ { type: 'email', key: 'email', label: 'Email' },
23
+ { type: 'button', action: 'submit', label: 'Submit' },
24
+ ],
25
+ };
26
+
27
+ function App() {
28
+ return <Form src={schema} onSubmit={({ data }) => console.log(data)} />;
29
+ }
30
+ ```
31
+
32
+ ## Exports
33
+
34
+ | Export | Description |
35
+ |--------|-------------|
36
+ | `Form` / `FormRenderer` | Renders a form from a JSON schema |
37
+ | `FormBuilder` | Drag-and-drop form builder |
38
+ | `Formio` | Formio singleton for advanced usage |
39
+ | `FormEngineProvider` | Theme context provider |
40
+ | `ReactComponent` | Base class for custom components (backward compat) |
41
+ | `baseEditForm` | Base settings form for custom component editors |
42
+ | `createFormComponent` | Factory for custom components (functional API) |
43
+ | `registerComponent` | Register a custom component type |
44
+ | `removeSubmitFormio` | Remove submit buttons from a form schema |
45
+ | `removeAutoFocusFormio` | Remove autofocus from form components |
46
+
47
+ ## Form Renderer
48
+
49
+ ```jsx
50
+ import { Form } from '@preshin/react-formio-engine';
51
+
52
+ <Form
53
+ src={formSchema} // Form JSON schema
54
+ submission={{ data: { name: 'John' } }} // Initial data
55
+ options={{ noAlerts: true }} // Formio options
56
+ onSubmit={({ data }) => {}} // Submit callback
57
+ onChange={(submission) => {}} // Change callback
58
+ ref={formRef} // Access formRef.formio.submit()
59
+ />
60
+ ```
61
+
62
+ ## Form Builder
63
+
64
+ ```jsx
65
+ import { FormBuilder } from '@preshin/react-formio-engine';
66
+
67
+ <FormBuilder
68
+ form={{ display: 'form', components: [] }}
69
+ options={{
70
+ builder: {
71
+ basic: false,
72
+ customBasic: {
73
+ title: 'Fields',
74
+ default: true,
75
+ components: { textfield: true, email: true, textarea: true, button: true },
76
+ },
77
+ },
78
+ }}
79
+ onChange={(schema) => console.log(schema)}
80
+ />
81
+ ```
82
+
83
+ ## Custom Components
84
+
85
+ ```jsx
86
+ import { createFormComponent, registerComponent, Formio } from '@preshin/react-formio-engine';
87
+
88
+ const MyColorPicker = createFormComponent({
89
+ type: 'colorpicker',
90
+ label: 'Color Picker',
91
+ icon: 'paint-brush',
92
+ render: ({ value, onChange }) => (
93
+ <input type="color" value={value || '#000'} onChange={(e) => onChange(e.target.value)} />
94
+ ),
95
+ });
96
+
97
+ // Register for use in forms
98
+ Formio.registerComponent('colorpicker', MyColorPicker);
99
+ ```
100
+
101
+ ## Theme Provider
102
+
103
+ ```jsx
104
+ import { FormEngineProvider, Form } from '@preshin/react-formio-engine';
105
+
106
+ <FormEngineProvider theme="antd">
107
+ <Form src={schema} />
108
+ </FormEngineProvider>
109
+ ```
110
+
111
+ ## Backward Compatibility
112
+
113
+ - Supports the same JSON schema format as formio.js v4
114
+ - `ReactComponent` and `baseEditForm` re-exported for existing custom components
115
+ - Drop-in API compatible with `@converselabs/react-formio`
116
+
117
+ ## License
118
+
119
+ MIT
@@ -0,0 +1,826 @@
1
+ import Ne, { createContext as Rr, forwardRef as Er, useRef as N, useContext as _r, useImperativeHandle as br, useEffect as ve } from "react";
2
+ import { Formio as Le } from "formiojs";
3
+ import { Formio as qr } from "formiojs";
4
+ import Cr from "formiojs/Form";
5
+ import Ue from "formiojs/components/Components";
6
+ import Me from "formiojs/components";
7
+ import Tr from "formiojs/FormBuilder";
8
+ import { createRoot as wr } from "react-dom/client";
9
+ import $e from "formiojs/components/_classes/field/Field";
10
+ import { default as Gr } from "formiojs/components/_classes/field/Field";
11
+ import { default as Xr } from "formiojs/components/_classes/component/Component.form";
12
+ var H = { exports: {} }, B = {};
13
+ var Ie;
14
+ function Sr() {
15
+ if (Ie) return B;
16
+ Ie = 1;
17
+ var c = Ne, f = /* @__PURE__ */ Symbol.for("react.element"), g = /* @__PURE__ */ Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, O = c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, P = { key: !0, ref: !0, __self: !0, __source: !0 };
18
+ function T(E, d, w) {
19
+ var a, l = {}, _ = null, k = null;
20
+ w !== void 0 && (_ = "" + w), d.key !== void 0 && (_ = "" + d.key), d.ref !== void 0 && (k = d.ref);
21
+ for (a in d) m.call(d, a) && !P.hasOwnProperty(a) && (l[a] = d[a]);
22
+ if (E && E.defaultProps) for (a in d = E.defaultProps, d) l[a] === void 0 && (l[a] = d[a]);
23
+ return { $$typeof: f, type: E, key: _, ref: k, props: l, _owner: O.current };
24
+ }
25
+ return B.Fragment = g, B.jsx = T, B.jsxs = T, B;
26
+ }
27
+ var J = {};
28
+ var We;
29
+ function Or() {
30
+ return We || (We = 1, process.env.NODE_ENV !== "production" && (function() {
31
+ var c = Ne, f = /* @__PURE__ */ Symbol.for("react.element"), g = /* @__PURE__ */ Symbol.for("react.portal"), m = /* @__PURE__ */ Symbol.for("react.fragment"), O = /* @__PURE__ */ Symbol.for("react.strict_mode"), P = /* @__PURE__ */ Symbol.for("react.profiler"), T = /* @__PURE__ */ Symbol.for("react.provider"), E = /* @__PURE__ */ Symbol.for("react.context"), d = /* @__PURE__ */ Symbol.for("react.forward_ref"), w = /* @__PURE__ */ Symbol.for("react.suspense"), a = /* @__PURE__ */ Symbol.for("react.suspense_list"), l = /* @__PURE__ */ Symbol.for("react.memo"), _ = /* @__PURE__ */ Symbol.for("react.lazy"), k = /* @__PURE__ */ Symbol.for("react.offscreen"), h = Symbol.iterator, F = "@@iterator";
32
+ function Q(e) {
33
+ if (e === null || typeof e != "object")
34
+ return null;
35
+ var r = h && e[h] || e[F];
36
+ return typeof r == "function" ? r : null;
37
+ }
38
+ var A = c.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
39
+ function y(e) {
40
+ {
41
+ for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), n = 1; n < r; n++)
42
+ t[n - 1] = arguments[n];
43
+ ee("error", e, t);
44
+ }
45
+ }
46
+ function ee(e, r, t) {
47
+ {
48
+ var n = A.ReactDebugCurrentFrame, u = n.getStackAddendum();
49
+ u !== "" && (r += "%s", t = t.concat([u]));
50
+ var s = t.map(function(i) {
51
+ return String(i);
52
+ });
53
+ s.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, s);
54
+ }
55
+ }
56
+ var L = !1, x = !1, re = !1, q = !1, te = !1, V;
57
+ V = /* @__PURE__ */ Symbol.for("react.module.reference");
58
+ function ne(e) {
59
+ return !!(typeof e == "string" || typeof e == "function" || e === m || e === P || te || e === O || e === w || e === a || q || e === k || L || x || re || typeof e == "object" && e !== null && (e.$$typeof === _ || e.$$typeof === l || e.$$typeof === T || e.$$typeof === E || e.$$typeof === d || // This needs to include all possible module reference object
60
+ // types supported by any Flight configuration anywhere since
61
+ // we don't know which Flight build this will end up being used
62
+ // with.
63
+ e.$$typeof === V || e.getModuleId !== void 0));
64
+ }
65
+ function ae(e, r, t) {
66
+ var n = e.displayName;
67
+ if (n)
68
+ return n;
69
+ var u = r.displayName || r.name || "";
70
+ return u !== "" ? t + "(" + u + ")" : t;
71
+ }
72
+ function I(e) {
73
+ return e.displayName || "Context";
74
+ }
75
+ function R(e) {
76
+ if (e == null)
77
+ return null;
78
+ if (typeof e.tag == "number" && y("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
79
+ return e.displayName || e.name || null;
80
+ if (typeof e == "string")
81
+ return e;
82
+ switch (e) {
83
+ case m:
84
+ return "Fragment";
85
+ case g:
86
+ return "Portal";
87
+ case P:
88
+ return "Profiler";
89
+ case O:
90
+ return "StrictMode";
91
+ case w:
92
+ return "Suspense";
93
+ case a:
94
+ return "SuspenseList";
95
+ }
96
+ if (typeof e == "object")
97
+ switch (e.$$typeof) {
98
+ case E:
99
+ var r = e;
100
+ return I(r) + ".Consumer";
101
+ case T:
102
+ var t = e;
103
+ return I(t._context) + ".Provider";
104
+ case d:
105
+ return ae(e, e.render, "ForwardRef");
106
+ case l:
107
+ var n = e.displayName || null;
108
+ return n !== null ? n : R(e.type) || "Memo";
109
+ case _: {
110
+ var u = e, s = u._payload, i = u._init;
111
+ try {
112
+ return R(i(s));
113
+ } catch {
114
+ return null;
115
+ }
116
+ }
117
+ }
118
+ return null;
119
+ }
120
+ var j = Object.assign, D = 0, U, pe, me, he, ge, ye, Re;
121
+ function Ee() {
122
+ }
123
+ Ee.__reactDisabledLog = !0;
124
+ function qe() {
125
+ {
126
+ if (D === 0) {
127
+ U = console.log, pe = console.info, me = console.warn, he = console.error, ge = console.group, ye = console.groupCollapsed, Re = console.groupEnd;
128
+ var e = {
129
+ configurable: !0,
130
+ enumerable: !0,
131
+ value: Ee,
132
+ writable: !0
133
+ };
134
+ Object.defineProperties(console, {
135
+ info: e,
136
+ log: e,
137
+ warn: e,
138
+ error: e,
139
+ group: e,
140
+ groupCollapsed: e,
141
+ groupEnd: e
142
+ });
143
+ }
144
+ D++;
145
+ }
146
+ }
147
+ function Ke() {
148
+ {
149
+ if (D--, D === 0) {
150
+ var e = {
151
+ configurable: !0,
152
+ enumerable: !0,
153
+ writable: !0
154
+ };
155
+ Object.defineProperties(console, {
156
+ log: j({}, e, {
157
+ value: U
158
+ }),
159
+ info: j({}, e, {
160
+ value: pe
161
+ }),
162
+ warn: j({}, e, {
163
+ value: me
164
+ }),
165
+ error: j({}, e, {
166
+ value: he
167
+ }),
168
+ group: j({}, e, {
169
+ value: ge
170
+ }),
171
+ groupCollapsed: j({}, e, {
172
+ value: ye
173
+ }),
174
+ groupEnd: j({}, e, {
175
+ value: Re
176
+ })
177
+ });
178
+ }
179
+ D < 0 && y("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
180
+ }
181
+ }
182
+ var oe = A.ReactCurrentDispatcher, ie;
183
+ function K(e, r, t) {
184
+ {
185
+ if (ie === void 0)
186
+ try {
187
+ throw Error();
188
+ } catch (u) {
189
+ var n = u.stack.trim().match(/\n( *(at )?)/);
190
+ ie = n && n[1] || "";
191
+ }
192
+ return `
193
+ ` + ie + e;
194
+ }
195
+ }
196
+ var ue = !1, G;
197
+ {
198
+ var Ge = typeof WeakMap == "function" ? WeakMap : Map;
199
+ G = new Ge();
200
+ }
201
+ function _e(e, r) {
202
+ if (!e || ue)
203
+ return "";
204
+ {
205
+ var t = G.get(e);
206
+ if (t !== void 0)
207
+ return t;
208
+ }
209
+ var n;
210
+ ue = !0;
211
+ var u = Error.prepareStackTrace;
212
+ Error.prepareStackTrace = void 0;
213
+ var s;
214
+ s = oe.current, oe.current = null, qe();
215
+ try {
216
+ if (r) {
217
+ var i = function() {
218
+ throw Error();
219
+ };
220
+ if (Object.defineProperty(i.prototype, "props", {
221
+ set: function() {
222
+ throw Error();
223
+ }
224
+ }), typeof Reflect == "object" && Reflect.construct) {
225
+ try {
226
+ Reflect.construct(i, []);
227
+ } catch (C) {
228
+ n = C;
229
+ }
230
+ Reflect.construct(e, [], i);
231
+ } else {
232
+ try {
233
+ i.call();
234
+ } catch (C) {
235
+ n = C;
236
+ }
237
+ e.call(i.prototype);
238
+ }
239
+ } else {
240
+ try {
241
+ throw Error();
242
+ } catch (C) {
243
+ n = C;
244
+ }
245
+ e();
246
+ }
247
+ } catch (C) {
248
+ if (C && n && typeof C.stack == "string") {
249
+ for (var o = C.stack.split(`
250
+ `), b = n.stack.split(`
251
+ `), v = o.length - 1, p = b.length - 1; v >= 1 && p >= 0 && o[v] !== b[p]; )
252
+ p--;
253
+ for (; v >= 1 && p >= 0; v--, p--)
254
+ if (o[v] !== b[p]) {
255
+ if (v !== 1 || p !== 1)
256
+ do
257
+ if (v--, p--, p < 0 || o[v] !== b[p]) {
258
+ var S = `
259
+ ` + o[v].replace(" at new ", " at ");
260
+ return e.displayName && S.includes("<anonymous>") && (S = S.replace("<anonymous>", e.displayName)), typeof e == "function" && G.set(e, S), S;
261
+ }
262
+ while (v >= 1 && p >= 0);
263
+ break;
264
+ }
265
+ }
266
+ } finally {
267
+ ue = !1, oe.current = s, Ke(), Error.prepareStackTrace = u;
268
+ }
269
+ var Y = e ? e.displayName || e.name : "", $ = Y ? K(Y) : "";
270
+ return typeof e == "function" && G.set(e, $), $;
271
+ }
272
+ function ze(e, r, t) {
273
+ return _e(e, !1);
274
+ }
275
+ function Xe(e) {
276
+ var r = e.prototype;
277
+ return !!(r && r.isReactComponent);
278
+ }
279
+ function z(e, r, t) {
280
+ if (e == null)
281
+ return "";
282
+ if (typeof e == "function")
283
+ return _e(e, Xe(e));
284
+ if (typeof e == "string")
285
+ return K(e);
286
+ switch (e) {
287
+ case w:
288
+ return K("Suspense");
289
+ case a:
290
+ return K("SuspenseList");
291
+ }
292
+ if (typeof e == "object")
293
+ switch (e.$$typeof) {
294
+ case d:
295
+ return ze(e.render);
296
+ case l:
297
+ return z(e.type, r, t);
298
+ case _: {
299
+ var n = e, u = n._payload, s = n._init;
300
+ try {
301
+ return z(s(u), r, t);
302
+ } catch {
303
+ }
304
+ }
305
+ }
306
+ return "";
307
+ }
308
+ var M = Object.prototype.hasOwnProperty, be = {}, Ce = A.ReactDebugCurrentFrame;
309
+ function X(e) {
310
+ if (e) {
311
+ var r = e._owner, t = z(e.type, e._source, r ? r.type : null);
312
+ Ce.setExtraStackFrame(t);
313
+ } else
314
+ Ce.setExtraStackFrame(null);
315
+ }
316
+ function He(e, r, t, n, u) {
317
+ {
318
+ var s = Function.call.bind(M);
319
+ for (var i in e)
320
+ if (s(e, i)) {
321
+ var o = void 0;
322
+ try {
323
+ if (typeof e[i] != "function") {
324
+ var b = Error((n || "React class") + ": " + t + " type `" + i + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[i] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
325
+ throw b.name = "Invariant Violation", b;
326
+ }
327
+ o = e[i](r, i, n, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
328
+ } catch (v) {
329
+ o = v;
330
+ }
331
+ o && !(o instanceof Error) && (X(u), y("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", n || "React class", t, i, typeof o), X(null)), o instanceof Error && !(o.message in be) && (be[o.message] = !0, X(u), y("Failed %s type: %s", t, o.message), X(null));
332
+ }
333
+ }
334
+ }
335
+ var Ze = Array.isArray;
336
+ function se(e) {
337
+ return Ze(e);
338
+ }
339
+ function Qe(e) {
340
+ {
341
+ var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
342
+ return t;
343
+ }
344
+ }
345
+ function er(e) {
346
+ try {
347
+ return Te(e), !1;
348
+ } catch {
349
+ return !0;
350
+ }
351
+ }
352
+ function Te(e) {
353
+ return "" + e;
354
+ }
355
+ function we(e) {
356
+ if (er(e))
357
+ return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Qe(e)), Te(e);
358
+ }
359
+ var Se = A.ReactCurrentOwner, rr = {
360
+ key: !0,
361
+ ref: !0,
362
+ __self: !0,
363
+ __source: !0
364
+ }, Oe, Pe;
365
+ function tr(e) {
366
+ if (M.call(e, "ref")) {
367
+ var r = Object.getOwnPropertyDescriptor(e, "ref").get;
368
+ if (r && r.isReactWarning)
369
+ return !1;
370
+ }
371
+ return e.ref !== void 0;
372
+ }
373
+ function nr(e) {
374
+ if (M.call(e, "key")) {
375
+ var r = Object.getOwnPropertyDescriptor(e, "key").get;
376
+ if (r && r.isReactWarning)
377
+ return !1;
378
+ }
379
+ return e.key !== void 0;
380
+ }
381
+ function ar(e, r) {
382
+ typeof e.ref == "string" && Se.current;
383
+ }
384
+ function or(e, r) {
385
+ {
386
+ var t = function() {
387
+ Oe || (Oe = !0, y("%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://reactjs.org/link/special-props)", r));
388
+ };
389
+ t.isReactWarning = !0, Object.defineProperty(e, "key", {
390
+ get: t,
391
+ configurable: !0
392
+ });
393
+ }
394
+ }
395
+ function ir(e, r) {
396
+ {
397
+ var t = function() {
398
+ Pe || (Pe = !0, y("%s: `ref` 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://reactjs.org/link/special-props)", r));
399
+ };
400
+ t.isReactWarning = !0, Object.defineProperty(e, "ref", {
401
+ get: t,
402
+ configurable: !0
403
+ });
404
+ }
405
+ }
406
+ var ur = function(e, r, t, n, u, s, i) {
407
+ var o = {
408
+ // This tag allows us to uniquely identify this as a React Element
409
+ $$typeof: f,
410
+ // Built-in properties that belong on the element
411
+ type: e,
412
+ key: r,
413
+ ref: t,
414
+ props: i,
415
+ // Record the component responsible for creating this element.
416
+ _owner: s
417
+ };
418
+ return o._store = {}, Object.defineProperty(o._store, "validated", {
419
+ configurable: !1,
420
+ enumerable: !1,
421
+ writable: !0,
422
+ value: !1
423
+ }), Object.defineProperty(o, "_self", {
424
+ configurable: !1,
425
+ enumerable: !1,
426
+ writable: !1,
427
+ value: n
428
+ }), Object.defineProperty(o, "_source", {
429
+ configurable: !1,
430
+ enumerable: !1,
431
+ writable: !1,
432
+ value: u
433
+ }), Object.freeze && (Object.freeze(o.props), Object.freeze(o)), o;
434
+ };
435
+ function sr(e, r, t, n, u) {
436
+ {
437
+ var s, i = {}, o = null, b = null;
438
+ t !== void 0 && (we(t), o = "" + t), nr(r) && (we(r.key), o = "" + r.key), tr(r) && (b = r.ref, ar(r, u));
439
+ for (s in r)
440
+ M.call(r, s) && !rr.hasOwnProperty(s) && (i[s] = r[s]);
441
+ if (e && e.defaultProps) {
442
+ var v = e.defaultProps;
443
+ for (s in v)
444
+ i[s] === void 0 && (i[s] = v[s]);
445
+ }
446
+ if (o || b) {
447
+ var p = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
448
+ o && or(i, p), b && ir(i, p);
449
+ }
450
+ return ur(e, o, b, u, n, Se.current, i);
451
+ }
452
+ }
453
+ var ce = A.ReactCurrentOwner, Fe = A.ReactDebugCurrentFrame;
454
+ function W(e) {
455
+ if (e) {
456
+ var r = e._owner, t = z(e.type, e._source, r ? r.type : null);
457
+ Fe.setExtraStackFrame(t);
458
+ } else
459
+ Fe.setExtraStackFrame(null);
460
+ }
461
+ var le;
462
+ le = !1;
463
+ function fe(e) {
464
+ return typeof e == "object" && e !== null && e.$$typeof === f;
465
+ }
466
+ function xe() {
467
+ {
468
+ if (ce.current) {
469
+ var e = R(ce.current.type);
470
+ if (e)
471
+ return `
472
+
473
+ Check the render method of \`` + e + "`.";
474
+ }
475
+ return "";
476
+ }
477
+ }
478
+ function cr(e) {
479
+ return "";
480
+ }
481
+ var je = {};
482
+ function lr(e) {
483
+ {
484
+ var r = xe();
485
+ if (!r) {
486
+ var t = typeof e == "string" ? e : e.displayName || e.name;
487
+ t && (r = `
488
+
489
+ Check the top-level render call using <` + t + ">.");
490
+ }
491
+ return r;
492
+ }
493
+ }
494
+ function ke(e, r) {
495
+ {
496
+ if (!e._store || e._store.validated || e.key != null)
497
+ return;
498
+ e._store.validated = !0;
499
+ var t = lr(r);
500
+ if (je[t])
501
+ return;
502
+ je[t] = !0;
503
+ var n = "";
504
+ e && e._owner && e._owner !== ce.current && (n = " It was passed a child from " + R(e._owner.type) + "."), W(e), y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, n), W(null);
505
+ }
506
+ }
507
+ function Ae(e, r) {
508
+ {
509
+ if (typeof e != "object")
510
+ return;
511
+ if (se(e))
512
+ for (var t = 0; t < e.length; t++) {
513
+ var n = e[t];
514
+ fe(n) && ke(n, r);
515
+ }
516
+ else if (fe(e))
517
+ e._store && (e._store.validated = !0);
518
+ else if (e) {
519
+ var u = Q(e);
520
+ if (typeof u == "function" && u !== e.entries)
521
+ for (var s = u.call(e), i; !(i = s.next()).done; )
522
+ fe(i.value) && ke(i.value, r);
523
+ }
524
+ }
525
+ }
526
+ function fr(e) {
527
+ {
528
+ var r = e.type;
529
+ if (r == null || typeof r == "string")
530
+ return;
531
+ var t;
532
+ if (typeof r == "function")
533
+ t = r.propTypes;
534
+ else if (typeof r == "object" && (r.$$typeof === d || // Note: Memo only checks outer props here.
535
+ // Inner props are checked in the reconciler.
536
+ r.$$typeof === l))
537
+ t = r.propTypes;
538
+ else
539
+ return;
540
+ if (t) {
541
+ var n = R(r);
542
+ He(t, e.props, "prop", n, e);
543
+ } else if (r.PropTypes !== void 0 && !le) {
544
+ le = !0;
545
+ var u = R(r);
546
+ y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", u || "Unknown");
547
+ }
548
+ typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
549
+ }
550
+ }
551
+ function dr(e) {
552
+ {
553
+ for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
554
+ var n = r[t];
555
+ if (n !== "children" && n !== "key") {
556
+ W(e), y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", n), W(null);
557
+ break;
558
+ }
559
+ }
560
+ e.ref !== null && (W(e), y("Invalid attribute `ref` supplied to `React.Fragment`."), W(null));
561
+ }
562
+ }
563
+ var De = {};
564
+ function Ve(e, r, t, n, u, s) {
565
+ {
566
+ var i = ne(e);
567
+ if (!i) {
568
+ var o = "";
569
+ (e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (o += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
570
+ var b = cr();
571
+ b ? o += b : o += xe();
572
+ var v;
573
+ e === null ? v = "null" : se(e) ? v = "array" : e !== void 0 && e.$$typeof === f ? (v = "<" + (R(e.type) || "Unknown") + " />", o = " Did you accidentally export a JSX literal instead of a component?") : v = typeof e, y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", v, o);
574
+ }
575
+ var p = sr(e, r, t, u, s);
576
+ if (p == null)
577
+ return p;
578
+ if (i) {
579
+ var S = r.children;
580
+ if (S !== void 0)
581
+ if (n)
582
+ if (se(S)) {
583
+ for (var Y = 0; Y < S.length; Y++)
584
+ Ae(S[Y], e);
585
+ Object.freeze && Object.freeze(S);
586
+ } else
587
+ y("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
588
+ else
589
+ Ae(S, e);
590
+ }
591
+ if (M.call(r, "key")) {
592
+ var $ = R(e), C = Object.keys(r).filter(function(yr) {
593
+ return yr !== "key";
594
+ }), de = C.length > 0 ? "{key: someKey, " + C.join(": ..., ") + ": ...}" : "{key: someKey}";
595
+ if (!De[$ + de]) {
596
+ var gr = C.length > 0 ? "{" + C.join(": ..., ") + ": ...}" : "{}";
597
+ y(`A props object containing a "key" prop is being spread into JSX:
598
+ let props = %s;
599
+ <%s {...props} />
600
+ React keys must be passed directly to JSX without using spread:
601
+ let props = %s;
602
+ <%s key={someKey} {...props} />`, de, $, gr, $), De[$ + de] = !0;
603
+ }
604
+ }
605
+ return e === m ? dr(p) : fr(p), p;
606
+ }
607
+ }
608
+ function vr(e, r, t) {
609
+ return Ve(e, r, t, !0);
610
+ }
611
+ function pr(e, r, t) {
612
+ return Ve(e, r, t, !1);
613
+ }
614
+ var mr = pr, hr = vr;
615
+ J.Fragment = m, J.jsx = mr, J.jsxs = hr;
616
+ })()), J;
617
+ }
618
+ var Ye;
619
+ function Pr() {
620
+ return Ye || (Ye = 1, process.env.NODE_ENV === "production" ? H.exports = Sr() : H.exports = Or()), H.exports;
621
+ }
622
+ var Z = Pr();
623
+ const Be = Rr({ theme: "default" }), Fr = ({ theme: c = "default", children: f }) => {
624
+ const g = {
625
+ theme: c,
626
+ className: `form-engine-theme-${c}`
627
+ };
628
+ return /* @__PURE__ */ Z.jsx(Be.Provider, { value: g, children: f });
629
+ };
630
+ Fr.displayName = "FormEngineProvider";
631
+ Ue.setComponents(Me);
632
+ typeof window < "u" && (window.Formio = Le);
633
+ const xr = Er(function({
634
+ src: f,
635
+ form: g,
636
+ submission: m,
637
+ options: O = {},
638
+ onSubmit: P,
639
+ onChange: T,
640
+ onError: E,
641
+ onRender: d,
642
+ onCustomEvent: w,
643
+ onSubmitDone: a,
644
+ onFormLoad: l,
645
+ onAttach: _,
646
+ onBuild: k,
647
+ onFocus: h,
648
+ onBlur: F,
649
+ onInitialized: Q,
650
+ formioform: A,
651
+ ...y
652
+ }, ee) {
653
+ const L = N(null), x = N(null), re = N(null), q = N(null), te = _r(Be);
654
+ return br(ee, () => ({
655
+ get formio() {
656
+ return x.current;
657
+ }
658
+ })), ve(() => {
659
+ const V = f || g;
660
+ if (!V || !L.current) return;
661
+ const ne = { ...O }, ae = A || Cr, I = new ae(L.current, V, ne);
662
+ return re.current = I, q.current = I.ready.then((R) => (x.current = R, f ? R.src = V : R.form = V, R)), I.onAny(function(R, ...j) {
663
+ if (R.startsWith("formio.")) {
664
+ const D = "on" + R.charAt(7).toUpperCase() + R.slice(8), U = {
665
+ onSubmit: P,
666
+ onChange: T,
667
+ onError: E,
668
+ onRender: d,
669
+ onCustomEvent: w,
670
+ onSubmitDone: a,
671
+ onFormLoad: l,
672
+ onAttach: _,
673
+ onBuild: k,
674
+ onFocus: h,
675
+ onBlur: F,
676
+ onInitialized: Q,
677
+ ...y
678
+ };
679
+ typeof U[D] == "function" && U[D](...j);
680
+ }
681
+ }), q.current.then(() => {
682
+ m && x.current && (x.current.submission = m);
683
+ }), () => {
684
+ x.current && (x.current.destroy(!0), x.current = null);
685
+ };
686
+ }, [f, g]), ve(() => {
687
+ m && x.current && (x.current.submission = m);
688
+ }, [m]), /* @__PURE__ */ Z.jsx("div", { ref: L, className: te?.className || "" });
689
+ });
690
+ xr.displayName = "FormRenderer";
691
+ Ue.setComponents(Me);
692
+ const jr = ({
693
+ form: c,
694
+ options: f = {},
695
+ onChange: g,
696
+ onSaveComponent: m,
697
+ onUpdateComponent: O,
698
+ onDeleteComponent: P,
699
+ onCancelComponent: T,
700
+ onEditComponent: E,
701
+ Builder: d
702
+ }) => {
703
+ const w = N(null), a = N(null);
704
+ return ve(() => {
705
+ if (!w.current) return;
706
+ const l = d || Tr, _ = { ...c }, k = { ...f };
707
+ a.current && a.current.instance?.destroy(!0);
708
+ const h = new l(w.current.firstChild, _, k);
709
+ a.current = h, h.ready.then(() => {
710
+ F(), m && h.instance.on("saveComponent", m), O && h.instance.on("updateComponent", O), P && h.instance.on("removeComponent", P), T && h.instance.on("cancelComponent", T), E && h.instance.on("editComponent", E), h.instance.on("addComponent", F), h.instance.on("saveComponent", F), h.instance.on("updateComponent", F), h.instance.on("removeComponent", F), h.instance.on("deleteComponent", F), h.instance.on("pdfUploaded", F);
711
+ });
712
+ function F() {
713
+ typeof g == "function" && a.current?.instance && g(a.current.instance.form);
714
+ }
715
+ return () => {
716
+ a.current?.instance && (a.current.instance.destroy(!0), a.current = null);
717
+ };
718
+ }, [c?.display]), /* @__PURE__ */ Z.jsx("div", { ref: w, children: /* @__PURE__ */ Z.jsx("div", {}) });
719
+ };
720
+ jr.displayName = "FormBuilder";
721
+ function Nr({
722
+ type: c,
723
+ label: f,
724
+ icon: g,
725
+ group: m = "basic",
726
+ weight: O = 10,
727
+ defaultValue: P = "",
728
+ settingsForm: T,
729
+ render: E
730
+ }) {
731
+ const d = $e.default || $e;
732
+ return class Je extends d {
733
+ static get builderInfo() {
734
+ return {
735
+ title: f,
736
+ icon: g || "cog",
737
+ group: m,
738
+ documentation: "",
739
+ weight: O,
740
+ schema: Je.schema()
741
+ };
742
+ }
743
+ static schema() {
744
+ return d.schema({
745
+ type: c,
746
+ label: f,
747
+ defaultValue: P ?? ""
748
+ });
749
+ }
750
+ static editForm = T;
751
+ constructor(a, l, _) {
752
+ super(a, l, _), this._root = null;
753
+ }
754
+ updateValue = (a) => {
755
+ const l = a ?? this.getValue(), _ = l !== void 0 ? this.hasChanged(l, this.dataValue) : !1;
756
+ return this.dataValue = Array.isArray(l) ? [...l] : l, this.updateOnChange({}, _), !0;
757
+ };
758
+ render() {
759
+ return super.render(`<div ref="react-${this.id}"></div>`);
760
+ }
761
+ attach(a) {
762
+ super.attach(a), this.loadRefs(a, { [`react-${this.id}`]: "single" });
763
+ const l = this.refs[`react-${this.id}`];
764
+ return l && (this._root = wr(l), this._root.render(
765
+ E({
766
+ component: this.component,
767
+ value: this.dataValue,
768
+ onChange: this.updateValue,
769
+ data: this.data
770
+ })
771
+ ), this.shouldSetValue && (this.setValue(this.dataForSetting), this.updateValue(this.dataForSetting))), Promise.resolve();
772
+ }
773
+ detach() {
774
+ this.refs[`react-${this.id}`] && this._root && (this._root.unmount(), this._root = null), super.detach();
775
+ }
776
+ setValue(a) {
777
+ this._root ? (this._root.render(
778
+ E({
779
+ component: this.component,
780
+ value: a,
781
+ onChange: this.updateValue,
782
+ data: this.data
783
+ })
784
+ ), this.shouldSetValue = !1) : (this.shouldSetValue = !0, this.dataForSetting = a);
785
+ }
786
+ getValue() {
787
+ return this.dataValue;
788
+ }
789
+ };
790
+ }
791
+ function Lr(c, f) {
792
+ Le.registerComponent(c, f);
793
+ }
794
+ const Ur = (c) => {
795
+ if (c && c.components) {
796
+ const f = c.components.filter(
797
+ (g) => g.action !== "submit"
798
+ );
799
+ return { display: c.display, components: f };
800
+ }
801
+ return c;
802
+ }, Mr = (c) => {
803
+ const f = c?.components;
804
+ if (f) {
805
+ const g = f.map((m) => ({
806
+ ...m,
807
+ autofocus: !1
808
+ }));
809
+ return { ...c, components: g };
810
+ }
811
+ return c;
812
+ };
813
+ export {
814
+ xr as Form,
815
+ jr as FormBuilder,
816
+ Be as FormEngineContext,
817
+ Fr as FormEngineProvider,
818
+ xr as FormRenderer,
819
+ qr as Formio,
820
+ Gr as ReactComponent,
821
+ Xr as baseEditForm,
822
+ Nr as createFormComponent,
823
+ Lr as registerComponent,
824
+ Mr as removeAutoFocusFormio,
825
+ Ur as removeSubmitFormio
826
+ };
@@ -0,0 +1,14 @@
1
+ (function(c,h){typeof exports=="object"&&typeof module<"u"?h(exports,require("react"),require("formiojs"),require("formiojs/Form"),require("formiojs/components/Components"),require("formiojs/components"),require("formiojs/FormBuilder"),require("react-dom/client"),require("formiojs/components/_classes/field/Field"),require("formiojs/components/_classes/component/Component.form")):typeof define=="function"&&define.amd?define(["exports","react","formiojs","formiojs/Form","formiojs/components/Components","formiojs/components","formiojs/FormBuilder","react-dom/client","formiojs/components/_classes/field/Field","formiojs/components/_classes/component/Component.form"],h):(c=typeof globalThis<"u"?globalThis:c||self,h(c.FormEngine={},c.React,c.Formio,c.FormioForm,c.Components,c.components,c.FormioFormBuilder,c.ReactDOMClient,c.Field,c.Component_form))})(this,(function(c,h,ee,Xe,ge,Re,qe,He,re,Ze){"use strict";var z={exports:{}},L={};var Ee;function Qe(){if(Ee)return L;Ee=1;var f=h,d=Symbol.for("react.element"),R=Symbol.for("react.fragment"),y=Object.prototype.hasOwnProperty,P=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,w={key:!0,ref:!0,__self:!0,__source:!0};function j(b,m,S){var o,l={},C=null,D=null;S!==void 0&&(C=""+S),m.key!==void 0&&(C=""+m.key),m.ref!==void 0&&(D=m.ref);for(o in m)y.call(m,o)&&!w.hasOwnProperty(o)&&(l[o]=m[o]);if(b&&b.defaultProps)for(o in m=b.defaultProps,m)l[o]===void 0&&(l[o]=m[o]);return{$$typeof:d,type:b,key:C,ref:D,props:l,_owner:P.current}}return L.Fragment=R,L.jsx=j,L.jsxs=j,L}var U={};var _e;function $e(){return _e||(_e=1,process.env.NODE_ENV!=="production"&&(function(){var f=h,d=Symbol.for("react.element"),R=Symbol.for("react.portal"),y=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),w=Symbol.for("react.profiler"),j=Symbol.for("react.provider"),b=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),S=Symbol.for("react.suspense"),o=Symbol.for("react.suspense_list"),l=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),g=Symbol.iterator,x="@@iterator";function oe(e){if(e===null||typeof e!="object")return null;var r=g&&e[g]||e[x];return typeof r=="function"?r:null}var V=f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function E(e){{for(var r=arguments.length,t=new Array(r>1?r-1:0),n=1;n<r;n++)t[n-1]=arguments[n];ae("error",e,t)}}function ae(e,r,t){{var n=V.ReactDebugCurrentFrame,s=n.getStackAddendum();s!==""&&(r+="%s",t=t.concat([s]));var u=t.map(function(i){return String(i)});u.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,u)}}var J=!1,k=!1,ie=!1,q=!1,se=!1,W;W=Symbol.for("react.module.reference");function ue(e){return!!(typeof e=="string"||typeof e=="function"||e===y||e===w||se||e===P||e===S||e===o||q||e===D||J||k||ie||typeof e=="object"&&e!==null&&(e.$$typeof===C||e.$$typeof===l||e.$$typeof===j||e.$$typeof===b||e.$$typeof===m||e.$$typeof===W||e.getModuleId!==void 0))}function ce(e,r,t){var n=e.displayName;if(n)return n;var s=r.displayName||r.name||"";return s!==""?t+"("+s+")":t}function N(e){return e.displayName||"Context"}function _(e){if(e==null)return null;if(typeof e.tag=="number"&&E("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case y:return"Fragment";case R:return"Portal";case w:return"Profiler";case P:return"StrictMode";case S:return"Suspense";case o:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case b:var r=e;return N(r)+".Consumer";case j:var t=e;return N(t._context)+".Provider";case m:return ce(e,e.render,"ForwardRef");case l:var n=e.displayName||null;return n!==null?n:_(e.type)||"Memo";case C:{var s=e,u=s._payload,i=s._init;try{return _(i(u))}catch{return null}}}return null}var A=Object.assign,I=0,K,Te,je,Se,Oe,Pe,we;function xe(){}xe.__reactDisabledLog=!0;function ar(){{if(I===0){K=console.log,Te=console.info,je=console.warn,Se=console.error,Oe=console.group,Pe=console.groupCollapsed,we=console.groupEnd;var e={configurable:!0,enumerable:!0,value:xe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}I++}}function ir(){{if(I--,I===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:A({},e,{value:K}),info:A({},e,{value:Te}),warn:A({},e,{value:je}),error:A({},e,{value:Se}),group:A({},e,{value:Oe}),groupCollapsed:A({},e,{value:Pe}),groupEnd:A({},e,{value:we})})}I<0&&E("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var fe=V.ReactCurrentDispatcher,le;function H(e,r,t){{if(le===void 0)try{throw Error()}catch(s){var n=s.stack.trim().match(/\n( *(at )?)/);le=n&&n[1]||""}return`
2
+ `+le+e}}var de=!1,Z;{var sr=typeof WeakMap=="function"?WeakMap:Map;Z=new sr}function ke(e,r){if(!e||de)return"";{var t=Z.get(e);if(t!==void 0)return t}var n;de=!0;var s=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var u;u=fe.current,fe.current=null,ar();try{if(r){var i=function(){throw Error()};if(Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(T){n=T}Reflect.construct(e,[],i)}else{try{i.call()}catch(T){n=T}e.call(i.prototype)}}else{try{throw Error()}catch(T){n=T}e()}}catch(T){if(T&&n&&typeof T.stack=="string"){for(var a=T.stack.split(`
3
+ `),F=n.stack.split(`
4
+ `),v=a.length-1,p=F.length-1;v>=1&&p>=0&&a[v]!==F[p];)p--;for(;v>=1&&p>=0;v--,p--)if(a[v]!==F[p]){if(v!==1||p!==1)do if(v--,p--,p<0||a[v]!==F[p]){var O=`
5
+ `+a[v].replace(" at new "," at ");return e.displayName&&O.includes("<anonymous>")&&(O=O.replace("<anonymous>",e.displayName)),typeof e=="function"&&Z.set(e,O),O}while(v>=1&&p>=0);break}}}finally{de=!1,fe.current=u,ir(),Error.prepareStackTrace=s}var B=e?e.displayName||e.name:"",Y=B?H(B):"";return typeof e=="function"&&Z.set(e,Y),Y}function ur(e,r,t){return ke(e,!1)}function cr(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function Q(e,r,t){if(e==null)return"";if(typeof e=="function")return ke(e,cr(e));if(typeof e=="string")return H(e);switch(e){case S:return H("Suspense");case o:return H("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case m:return ur(e.render);case l:return Q(e.type,r,t);case C:{var n=e,s=n._payload,u=n._init;try{return Q(u(s),r,t)}catch{}}}return""}var G=Object.prototype.hasOwnProperty,Ae={},De=V.ReactDebugCurrentFrame;function $(e){if(e){var r=e._owner,t=Q(e.type,e._source,r?r.type:null);De.setExtraStackFrame(t)}else De.setExtraStackFrame(null)}function fr(e,r,t,n,s){{var u=Function.call.bind(G);for(var i in e)if(u(e,i)){var a=void 0;try{if(typeof e[i]!="function"){var F=Error((n||"React class")+": "+t+" type `"+i+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[i]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw F.name="Invariant Violation",F}a=e[i](r,i,n,t,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(v){a=v}a&&!(a instanceof Error)&&($(s),E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",n||"React class",t,i,typeof a),$(null)),a instanceof Error&&!(a.message in Ae)&&(Ae[a.message]=!0,$(s),E("Failed %s type: %s",t,a.message),$(null))}}}var lr=Array.isArray;function me(e){return lr(e)}function dr(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,t=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return t}}function mr(e){try{return Ve(e),!1}catch{return!0}}function Ve(e){return""+e}function Ie(e){if(mr(e))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",dr(e)),Ve(e)}var We=V.ReactCurrentOwner,vr={key:!0,ref:!0,__self:!0,__source:!0},Ye,Ne;function pr(e){if(G.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function hr(e){if(G.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function yr(e,r){typeof e.ref=="string"&&We.current}function gr(e,r){{var t=function(){Ye||(Ye=!0,E("%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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"key",{get:t,configurable:!0})}}function Rr(e,r){{var t=function(){Ne||(Ne=!0,E("%s: `ref` 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://reactjs.org/link/special-props)",r))};t.isReactWarning=!0,Object.defineProperty(e,"ref",{get:t,configurable:!0})}}var Er=function(e,r,t,n,s,u,i){var a={$$typeof:d,type:e,key:r,ref:t,props:i,_owner:u};return a._store={},Object.defineProperty(a._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(a,"_self",{configurable:!1,enumerable:!1,writable:!1,value:n}),Object.defineProperty(a,"_source",{configurable:!1,enumerable:!1,writable:!1,value:s}),Object.freeze&&(Object.freeze(a.props),Object.freeze(a)),a};function _r(e,r,t,n,s){{var u,i={},a=null,F=null;t!==void 0&&(Ie(t),a=""+t),hr(r)&&(Ie(r.key),a=""+r.key),pr(r)&&(F=r.ref,yr(r,s));for(u in r)G.call(r,u)&&!vr.hasOwnProperty(u)&&(i[u]=r[u]);if(e&&e.defaultProps){var v=e.defaultProps;for(u in v)i[u]===void 0&&(i[u]=v[u])}if(a||F){var p=typeof e=="function"?e.displayName||e.name||"Unknown":e;a&&gr(i,p),F&&Rr(i,p)}return Er(e,a,F,s,n,We.current,i)}}var ve=V.ReactCurrentOwner,Me=V.ReactDebugCurrentFrame;function M(e){if(e){var r=e._owner,t=Q(e.type,e._source,r?r.type:null);Me.setExtraStackFrame(t)}else Me.setExtraStackFrame(null)}var pe;pe=!1;function he(e){return typeof e=="object"&&e!==null&&e.$$typeof===d}function Be(){{if(ve.current){var e=_(ve.current.type);if(e)return`
6
+
7
+ Check the render method of \``+e+"`."}return""}}function br(e){return""}var Le={};function Cr(e){{var r=Be();if(!r){var t=typeof e=="string"?e:e.displayName||e.name;t&&(r=`
8
+
9
+ Check the top-level render call using <`+t+">.")}return r}}function Ue(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var t=Cr(r);if(Le[t])return;Le[t]=!0;var n="";e&&e._owner&&e._owner!==ve.current&&(n=" It was passed a child from "+_(e._owner.type)+"."),M(e),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',t,n),M(null)}}function Je(e,r){{if(typeof e!="object")return;if(me(e))for(var t=0;t<e.length;t++){var n=e[t];he(n)&&Ue(n,r)}else if(he(e))e._store&&(e._store.validated=!0);else if(e){var s=oe(e);if(typeof s=="function"&&s!==e.entries)for(var u=s.call(e),i;!(i=u.next()).done;)he(i.value)&&Ue(i.value,r)}}}function Fr(e){{var r=e.type;if(r==null||typeof r=="string")return;var t;if(typeof r=="function")t=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===m||r.$$typeof===l))t=r.propTypes;else return;if(t){var n=_(r);fr(t,e.props,"prop",n,e)}else if(r.PropTypes!==void 0&&!pe){pe=!0;var s=_(r);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",s||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Tr(e){{for(var r=Object.keys(e.props),t=0;t<r.length;t++){var n=r[t];if(n!=="children"&&n!=="key"){M(e),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",n),M(null);break}}e.ref!==null&&(M(e),E("Invalid attribute `ref` supplied to `React.Fragment`."),M(null))}}var Ke={};function Ge(e,r,t,n,s,u){{var i=ue(e);if(!i){var a="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(a+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var F=br();F?a+=F:a+=Be();var v;e===null?v="null":me(e)?v="array":e!==void 0&&e.$$typeof===d?(v="<"+(_(e.type)||"Unknown")+" />",a=" Did you accidentally export a JSX literal instead of a component?"):v=typeof e,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",v,a)}var p=_r(e,r,t,s,u);if(p==null)return p;if(i){var O=r.children;if(O!==void 0)if(n)if(me(O)){for(var B=0;B<O.length;B++)Je(O[B],e);Object.freeze&&Object.freeze(O)}else E("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 Je(O,e)}if(G.call(r,"key")){var Y=_(e),T=Object.keys(r).filter(function(xr){return xr!=="key"}),ye=T.length>0?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}";if(!Ke[Y+ye]){var wr=T.length>0?"{"+T.join(": ..., ")+": ...}":"{}";E(`A props object containing a "key" prop is being spread into JSX:
10
+ let props = %s;
11
+ <%s {...props} />
12
+ React keys must be passed directly to JSX without using spread:
13
+ let props = %s;
14
+ <%s key={someKey} {...props} />`,ye,Y,wr,Y),Ke[Y+ye]=!0}}return e===y?Tr(p):Fr(p),p}}function jr(e,r,t){return Ge(e,r,t,!0)}function Sr(e,r,t){return Ge(e,r,t,!1)}var Or=Sr,Pr=jr;U.Fragment=y,U.jsx=Or,U.jsxs=Pr})()),U}var be;function er(){return be||(be=1,process.env.NODE_ENV==="production"?z.exports=Qe():z.exports=$e()),z.exports}var X=er();const te=h.createContext({theme:"default"}),Ce=({theme:f="default",children:d})=>{const R={theme:f,className:`form-engine-theme-${f}`};return X.jsx(te.Provider,{value:R,children:d})};Ce.displayName="FormEngineProvider",ge.setComponents(Re),typeof window<"u"&&(window.Formio=ee.Formio);const ne=h.forwardRef(function({src:d,form:R,submission:y,options:P={},onSubmit:w,onChange:j,onError:b,onRender:m,onCustomEvent:S,onSubmitDone:o,onFormLoad:l,onAttach:C,onBuild:D,onFocus:g,onBlur:x,onInitialized:oe,formioform:V,...E},ae){const J=h.useRef(null),k=h.useRef(null),ie=h.useRef(null),q=h.useRef(null),se=h.useContext(te);return h.useImperativeHandle(ae,()=>({get formio(){return k.current}})),h.useEffect(()=>{const W=d||R;if(!W||!J.current)return;const ue={...P},ce=V||Xe,N=new ce(J.current,W,ue);return ie.current=N,q.current=N.ready.then(_=>(k.current=_,d?_.src=W:_.form=W,_)),N.onAny(function(_,...A){if(_.startsWith("formio.")){const I="on"+_.charAt(7).toUpperCase()+_.slice(8),K={onSubmit:w,onChange:j,onError:b,onRender:m,onCustomEvent:S,onSubmitDone:o,onFormLoad:l,onAttach:C,onBuild:D,onFocus:g,onBlur:x,onInitialized:oe,...E};typeof K[I]=="function"&&K[I](...A)}}),q.current.then(()=>{y&&k.current&&(k.current.submission=y)}),()=>{k.current&&(k.current.destroy(!0),k.current=null)}},[d,R]),h.useEffect(()=>{y&&k.current&&(k.current.submission=y)},[y]),X.jsx("div",{ref:J,className:se?.className||""})});ne.displayName="FormRenderer",ge.setComponents(Re);const Fe=({form:f,options:d={},onChange:R,onSaveComponent:y,onUpdateComponent:P,onDeleteComponent:w,onCancelComponent:j,onEditComponent:b,Builder:m})=>{const S=h.useRef(null),o=h.useRef(null);return h.useEffect(()=>{if(!S.current)return;const l=m||qe,C={...f},D={...d};o.current&&o.current.instance?.destroy(!0);const g=new l(S.current.firstChild,C,D);o.current=g,g.ready.then(()=>{x(),y&&g.instance.on("saveComponent",y),P&&g.instance.on("updateComponent",P),w&&g.instance.on("removeComponent",w),j&&g.instance.on("cancelComponent",j),b&&g.instance.on("editComponent",b),g.instance.on("addComponent",x),g.instance.on("saveComponent",x),g.instance.on("updateComponent",x),g.instance.on("removeComponent",x),g.instance.on("deleteComponent",x),g.instance.on("pdfUploaded",x)});function x(){typeof R=="function"&&o.current?.instance&&R(o.current.instance.form)}return()=>{o.current?.instance&&(o.current.instance.destroy(!0),o.current=null)}},[f?.display]),X.jsx("div",{ref:S,children:X.jsx("div",{})})};Fe.displayName="FormBuilder";function rr({type:f,label:d,icon:R,group:y="basic",weight:P=10,defaultValue:w="",settingsForm:j,render:b}){const m=re.default||re;return class ze extends m{static get builderInfo(){return{title:d,icon:R||"cog",group:y,documentation:"",weight:P,schema:ze.schema()}}static schema(){return m.schema({type:f,label:d,defaultValue:w??""})}static editForm=j;constructor(o,l,C){super(o,l,C),this._root=null}updateValue=o=>{const l=o??this.getValue(),C=l!==void 0?this.hasChanged(l,this.dataValue):!1;return this.dataValue=Array.isArray(l)?[...l]:l,this.updateOnChange({},C),!0};render(){return super.render(`<div ref="react-${this.id}"></div>`)}attach(o){super.attach(o),this.loadRefs(o,{[`react-${this.id}`]:"single"});const l=this.refs[`react-${this.id}`];return l&&(this._root=He.createRoot(l),this._root.render(b({component:this.component,value:this.dataValue,onChange:this.updateValue,data:this.data})),this.shouldSetValue&&(this.setValue(this.dataForSetting),this.updateValue(this.dataForSetting))),Promise.resolve()}detach(){this.refs[`react-${this.id}`]&&this._root&&(this._root.unmount(),this._root=null),super.detach()}setValue(o){this._root?(this._root.render(b({component:this.component,value:o,onChange:this.updateValue,data:this.data})),this.shouldSetValue=!1):(this.shouldSetValue=!0,this.dataForSetting=o)}getValue(){return this.dataValue}}}function tr(f,d){ee.Formio.registerComponent(f,d)}const nr=f=>{if(f&&f.components){const d=f.components.filter(R=>R.action!=="submit");return{display:f.display,components:d}}return f},or=f=>{const d=f?.components;if(d){const R=d.map(y=>({...y,autofocus:!1}));return{...f,components:R}}return f};Object.defineProperty(c,"Formio",{enumerable:!0,get:()=>ee.Formio}),c.ReactComponent=re,c.baseEditForm=Ze,c.Form=ne,c.FormBuilder=Fe,c.FormEngineContext=te,c.FormEngineProvider=Ce,c.FormRenderer=ne,c.createFormComponent=rr,c.registerComponent=tr,c.removeAutoFocusFormio=or,c.removeSubmitFormio=nr,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"})}));
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "react-formio-engine",
3
+ "version": "1.0.0",
4
+ "description": "Form engine with builder and renderer - formiojs-powered with React functional components",
5
+ "type": "module",
6
+ "main": "dist/form-engine.umd.js",
7
+ "module": "dist/form-engine.es.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": "./dist/form-engine.es.js",
11
+ "require": "./dist/form-engine.umd.js"
12
+ },
13
+ "./themes/default.css": "./src/themes/default.css",
14
+ "./themes/antd.css": "./src/themes/antd.css"
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "src/themes"
19
+ ],
20
+ "scripts": {
21
+ "dev": "vite",
22
+ "build": "vite build",
23
+ "preview": "vite preview"
24
+ },
25
+ "peerDependencies": {
26
+ "react": ">=17",
27
+ "react-dom": ">=17"
28
+ },
29
+ "devDependencies": {
30
+ "@vitejs/plugin-react": "^5.1.3",
31
+ "bootstrap": "^4.6.2",
32
+ "react": "^18.3.1",
33
+ "react-dom": "^18.3.1",
34
+ "vite": "^7.3.1"
35
+ },
36
+ "license": "MIT",
37
+ "dependencies": {
38
+ "formiojs": "^4.21.7"
39
+ }
40
+ }
@@ -0,0 +1,65 @@
1
+ /*
2
+ * Ant Design theme for @workato/form-engine
3
+ *
4
+ * Imports the default formio CSS and adds overrides to better match
5
+ * Ant Design's visual style. Use this in projects that use antd.
6
+ *
7
+ * Usage:
8
+ * import '@workato/form-engine/themes/antd.css';
9
+ */
10
+ @import './default.css';
11
+
12
+ /* Ant Design style overrides for formio components */
13
+ .form-engine-theme-antd .formio-component input.form-control {
14
+ border-radius: 6px;
15
+ border-color: #d9d9d9;
16
+ padding: 4px 11px;
17
+ font-size: 14px;
18
+ line-height: 1.5714;
19
+ transition: all 0.2s;
20
+ }
21
+
22
+ .form-engine-theme-antd .formio-component input.form-control:hover {
23
+ border-color: #5159F6;
24
+ }
25
+
26
+ .form-engine-theme-antd .formio-component input.form-control:focus {
27
+ border-color: #5159F6;
28
+ box-shadow: 0 0 0 2px rgba(81, 89, 246, 0.2);
29
+ outline: none;
30
+ }
31
+
32
+ .form-engine-theme-antd .formio-component .btn-primary {
33
+ background-color: #5159F6;
34
+ border-color: #5159F6;
35
+ border-radius: 6px;
36
+ font-size: 14px;
37
+ padding: 4px 15px;
38
+ line-height: 1.5714;
39
+ transition: all 0.2s;
40
+ }
41
+
42
+ .form-engine-theme-antd .formio-component .btn-primary:hover {
43
+ background-color: #351DCB;
44
+ border-color: #351DCB;
45
+ }
46
+
47
+ .form-engine-theme-antd .formio-component select.form-control {
48
+ border-radius: 6px;
49
+ border-color: #d9d9d9;
50
+ padding: 4px 11px;
51
+ font-size: 14px;
52
+ }
53
+
54
+ .form-engine-theme-antd .formio-component textarea.form-control {
55
+ border-radius: 6px;
56
+ border-color: #d9d9d9;
57
+ padding: 4px 11px;
58
+ font-size: 14px;
59
+ }
60
+
61
+ .form-engine-theme-antd .formio-component label {
62
+ font-size: 14px;
63
+ color: rgba(0, 0, 0, 0.88);
64
+ font-weight: 500;
65
+ }
@@ -0,0 +1,11 @@
1
+ /*
2
+ * Default theme for @workato/form-engine
3
+ *
4
+ * This imports formio's self-contained CSS which includes all necessary
5
+ * styles for form rendering. No external framework (antd, Bootstrap, etc.)
6
+ * is required.
7
+ *
8
+ * Usage:
9
+ * import '@workato/form-engine/themes/default.css';
10
+ */
11
+ @import 'formiojs/dist/formio.full.css';