@digiform/wizard 0.3.1 → 0.3.2
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/features/form-runtime/components/FormFooter.d.ts +5 -0
- package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
- package/features/state-management/machines/formMachine.d.ts +3 -0
- package/features/state-management/machines/types.d.ts +4 -0
- package/features/state-management/machines/useFormMachine.d.ts +18 -0
- package/package.json +1 -3
- package/styles.css +1 -1
- package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
- package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
- package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
- package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +54 -79
- package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +150 -194
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +83 -92
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
- package/wizard/src/features/form-runtime/config/templateLoader.js +48 -55
- package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +44 -63
- package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +26 -40
- package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
- package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
- package/wizard/src/features/form-runtime/utils/logger.js +12 -12
- package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
- package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
- package/wizard/src/features/state-management/machines/formMachine.js +558 -677
- package/wizard/src/features/state-management/machines/useFormMachine.js +172 -190
- package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
- package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
- package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
- package/wizard/src/features/validation-system/validation/ValidationExecutor.js +26 -58
- package/features/form-runtime/utils/formSaver.d.ts +0 -22
- package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
- package/features/state-management/machines/__tests__/setup.d.ts +0 -0
- package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
- package/features/state-management/machines/actions/validationActions.d.ts +0 -68
- package/features/state-management/machines/lazyLoading.d.ts +0 -34
- package/features/state-management/machines/validation/index.d.ts +0 -5
- package/features/state-management/machines/validation/validateField.d.ts +0 -2
- package/features/state-management/machines/validation/validateForm.d.ts +0 -2
- package/features/state-management/machines/validation/validateSection.d.ts +0 -2
- package/features/state-management/machines/validation/validateStep.d.ts +0 -2
- package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
- package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import
|
|
2
|
+
import { jsxs as h, jsx as n, Fragment as M } from "react/jsx-runtime";
|
|
3
|
+
import S from "./FormStep.module.css.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { isTemplateStep as
|
|
6
|
-
import { logger as
|
|
7
|
-
import { useForm as
|
|
5
|
+
import { isTemplateStep as l } from "../../../../../../ui/src/lib/types/guards.js";
|
|
6
|
+
import { logger as C } from "../../../../../../ui/src/lib/logger.js";
|
|
7
|
+
import { useForm as U } from "@tanstack/react-form";
|
|
8
8
|
import { useRef as p } from "react";
|
|
9
9
|
import { LoaderProvider as k, useLoaderContext as W } from "../../context/LoaderContext.js";
|
|
10
|
-
import { FormProvider as
|
|
11
|
-
import { buildDefaultValues as
|
|
12
|
-
import { resetFormDirtyStateAfterApiPopulation as
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import { ProgressLoaderRuntime as
|
|
17
|
-
import { useFormMachine as
|
|
18
|
-
import { EnhancedActionExecutor as
|
|
10
|
+
import { FormProvider as j } from "../../hooks/useFormContext.js";
|
|
11
|
+
import { buildDefaultValues as v } from "../../utils/formDataBuilder.js";
|
|
12
|
+
import { resetFormDirtyStateAfterApiPopulation as z } from "../../utils/formDirtyStateSync.js";
|
|
13
|
+
import G from "../FormFooter.js";
|
|
14
|
+
import H from "../FormHeader.js";
|
|
15
|
+
import K from "../FormSection/FormSection.js";
|
|
16
|
+
import { ProgressLoaderRuntime as Q } from "../ProgressLoaderRuntime.js";
|
|
17
|
+
import { useFormMachine as X } from "../../../state-management/machines/useFormMachine.js";
|
|
18
|
+
import { EnhancedActionExecutor as q } from "../../../api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js";
|
|
19
19
|
import { ValidationEngine as B } from "../../../validation-system/validation/ValidationEngine.js";
|
|
20
20
|
const J = ({
|
|
21
|
-
currentStep:
|
|
22
|
-
hasStepLoader:
|
|
21
|
+
currentStep: r,
|
|
22
|
+
hasStepLoader: s,
|
|
23
23
|
loaderConfig: o
|
|
24
24
|
}) => {
|
|
25
|
-
const { isLoadingComplete:
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const { isLoadingComplete: e } = W(), u = l(r) ? [] : r.sections || [];
|
|
26
|
+
return /* @__PURE__ */ h("div", { className: S.stepContent, children: [
|
|
27
|
+
s && /* @__PURE__ */ n("div", { className: S.loaderWrapper, children: /* @__PURE__ */ n(
|
|
28
|
+
Q,
|
|
29
29
|
{
|
|
30
30
|
properties: {
|
|
31
31
|
label: o?.label,
|
|
@@ -46,45 +46,38 @@ const J = ({
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
) }),
|
|
49
|
-
(!
|
|
49
|
+
(!s || e) && /* @__PURE__ */ n(M, { children: u.map((i) => /* @__PURE__ */ n(K, { section: i }, i.id)) })
|
|
50
50
|
] });
|
|
51
51
|
}, Y = () => {
|
|
52
|
-
const [
|
|
53
|
-
|
|
54
|
-
...
|
|
52
|
+
const [r, s, o] = X(), { currentStep: e, config: u } = o, i = p(), d = p(), F = p(), T = u.validationMessageStyle || "withLabel";
|
|
53
|
+
i.current || (i.current = new B({ messageStyle: T })), (!d.current || F.current !== e.id) && (l(e) ? d.current = i.current.getStepSchema({
|
|
54
|
+
...e,
|
|
55
55
|
sections: []
|
|
56
|
-
}) :
|
|
57
|
-
const
|
|
58
|
-
...
|
|
56
|
+
}) : d.current = i.current.getStepSchema(e), F.current = e.id);
|
|
57
|
+
const b = { ...l(e) ? v({
|
|
58
|
+
...e,
|
|
59
59
|
sections: []
|
|
60
|
-
}) :
|
|
61
|
-
(
|
|
62
|
-
}, x = p(),
|
|
63
|
-
|
|
60
|
+
}) : v(e), ...o.data }, y = (t) => {
|
|
61
|
+
(e.actions || []).length > 0 && s({ type: "EXECUTE_ACTIONS", trigger: t });
|
|
62
|
+
}, x = p(), f = p(!1);
|
|
63
|
+
e.id !== x.current && (e.actions || []).length > 0 && !f.current && (x.current = e.id, f.current = !0, setTimeout(() => {
|
|
64
64
|
y("onStepLoad"), setTimeout(() => {
|
|
65
|
-
|
|
65
|
+
f.current = !1;
|
|
66
66
|
}, 1e3);
|
|
67
67
|
}, 0));
|
|
68
|
-
const
|
|
69
|
-
value:
|
|
68
|
+
const L = async ({
|
|
69
|
+
value: t
|
|
70
70
|
}) => {
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, D = (e) => {
|
|
82
|
-
}, L = (e) => {
|
|
83
|
-
U.error("Action execution failed", { error: e.message }, e);
|
|
84
|
-
}, O = (e) => {
|
|
85
|
-
console.log("🔥 FormStep: handleShowDialog called", { dialogConfig: e }), a({ type: "SHOW_ACTION_DIALOG", dialogConfig: e }), console.log("🔥 FormStep: SHOW_ACTION_DIALOG event sent");
|
|
86
|
-
}, V = (e) => {
|
|
87
|
-
switch (e.type) {
|
|
71
|
+
(e.actions || []).some(
|
|
72
|
+
(g) => g.trigger === "onStepFinish"
|
|
73
|
+
) ? s({ type: "REQUEST_NAVIGATION", navigationType: "next" }) : o.nextStep();
|
|
74
|
+
}, N = (t) => {
|
|
75
|
+
}, D = (t) => {
|
|
76
|
+
C.error("Action execution failed", { error: t.message }, t);
|
|
77
|
+
}, O = (t) => {
|
|
78
|
+
s({ type: "SHOW_ACTION_DIALOG", dialogConfig: t });
|
|
79
|
+
}, V = (t) => {
|
|
80
|
+
switch (t.type) {
|
|
88
81
|
case "next":
|
|
89
82
|
o.nextStep();
|
|
90
83
|
break;
|
|
@@ -92,70 +85,68 @@ const J = ({
|
|
|
92
85
|
o.previousStep();
|
|
93
86
|
break;
|
|
94
87
|
case "step":
|
|
95
|
-
|
|
88
|
+
t.targetStep && o.goToStep(t.targetStep);
|
|
96
89
|
break;
|
|
97
90
|
}
|
|
98
|
-
},
|
|
99
|
-
defaultValues:
|
|
100
|
-
onSubmit:
|
|
101
|
-
}),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const I = n;
|
|
107
|
-
o.setData(r, I), l.setFieldValue(r, n);
|
|
91
|
+
}, m = U({
|
|
92
|
+
defaultValues: b,
|
|
93
|
+
onSubmit: L
|
|
94
|
+
}), P = (t, a) => {
|
|
95
|
+
const c = t, g = m.getFieldValue(c), _ = r.context.componentOriginalValues[c]?.value;
|
|
96
|
+
if (g !== a) {
|
|
97
|
+
const w = a;
|
|
98
|
+
o.setData(c, w), m.setFieldValue(c, a);
|
|
108
99
|
try {
|
|
109
|
-
|
|
110
|
-
updatedFields: [
|
|
100
|
+
z(m, {
|
|
101
|
+
updatedFields: [c],
|
|
111
102
|
debug: process.env.NODE_ENV === "development"
|
|
112
|
-
})
|
|
113
|
-
} catch (
|
|
114
|
-
console.error("❌ Failed to reset dirty state:",
|
|
103
|
+
});
|
|
104
|
+
} catch (I) {
|
|
105
|
+
console.error("❌ Failed to reset dirty state:", I);
|
|
115
106
|
}
|
|
116
107
|
}
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
_ !== a && setTimeout(() => {
|
|
109
|
+
s({
|
|
119
110
|
type: "MARK_COMPONENT_AS_POPULATED",
|
|
120
|
-
componentId:
|
|
121
|
-
value:
|
|
111
|
+
componentId: c,
|
|
112
|
+
value: a
|
|
122
113
|
});
|
|
123
|
-
}, 0)
|
|
124
|
-
}, A =
|
|
125
|
-
return /* @__PURE__ */
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
}, 0);
|
|
115
|
+
}, A = e, E = !l(e) && A.waitForLoader === !0, R = E ? A.loaderConfig : void 0;
|
|
116
|
+
return /* @__PURE__ */ h(j, { value: m, children: [
|
|
117
|
+
r.matches("executingActions") && (r.context.executingTrigger === "onStepLoad" || r.context.executingTrigger === "onStepFinish") && /* @__PURE__ */ n(
|
|
118
|
+
q,
|
|
128
119
|
{
|
|
129
|
-
actions:
|
|
130
|
-
trigger:
|
|
131
|
-
formData:
|
|
132
|
-
onComplete:
|
|
133
|
-
onError:
|
|
134
|
-
onFieldUpdate:
|
|
120
|
+
actions: e.actions || [],
|
|
121
|
+
trigger: r.context.executingTrigger || "onStepLoad",
|
|
122
|
+
formData: r.context.data,
|
|
123
|
+
onComplete: N,
|
|
124
|
+
onError: D,
|
|
125
|
+
onFieldUpdate: P,
|
|
135
126
|
onShowDialog: O,
|
|
136
127
|
onNavigate: V,
|
|
137
128
|
machineRef: {
|
|
138
|
-
send:
|
|
129
|
+
send: s
|
|
139
130
|
}
|
|
140
131
|
}
|
|
141
132
|
),
|
|
142
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ h(
|
|
143
134
|
"form",
|
|
144
135
|
{
|
|
145
|
-
onSubmit: (
|
|
146
|
-
|
|
136
|
+
onSubmit: (t) => {
|
|
137
|
+
t.preventDefault(), t.stopPropagation(), m.handleSubmit();
|
|
147
138
|
},
|
|
148
139
|
children: [
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
140
|
+
/* @__PURE__ */ n(H, {}),
|
|
141
|
+
/* @__PURE__ */ n(k, { children: /* @__PURE__ */ n(
|
|
151
142
|
J,
|
|
152
143
|
{
|
|
153
|
-
currentStep:
|
|
154
|
-
hasStepLoader:
|
|
155
|
-
loaderConfig:
|
|
144
|
+
currentStep: e,
|
|
145
|
+
hasStepLoader: E,
|
|
146
|
+
loaderConfig: R
|
|
156
147
|
}
|
|
157
148
|
) }),
|
|
158
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ n(G, { className: S.footer })
|
|
159
150
|
]
|
|
160
151
|
}
|
|
161
152
|
)
|
package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js
CHANGED
|
@@ -1,57 +1,51 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import o from "clsx";
|
|
5
5
|
import e from "./StepProgressIndicator.module.css.js";
|
|
6
|
-
import { useFormMachine as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { Heading as
|
|
6
|
+
import { useFormMachine as d } from "../../../state-management/machines/useFormMachine.js";
|
|
7
|
+
import h from "../../../../../../ui/src/lib/assets/icons/Check.js";
|
|
8
|
+
import v from "../../../../../../ui/src/lib/assets/icons/ChevronRight.js";
|
|
9
|
+
import { Heading as N } from "@rijkshuisstijl-community/components-react";
|
|
10
10
|
const x = () => {
|
|
11
|
-
const [, , m] =
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
stepTitles: c.map((s) => s.title)
|
|
18
|
-
}), /* @__PURE__ */ r("div", { className: e.stepListWrapper, children: [
|
|
19
|
-
/* @__PURE__ */ t(f, { level: 2, children: "Stappenplan" }),
|
|
20
|
-
/* @__PURE__ */ t("ul", { className: e.stepList, children: c.map((s, i) => {
|
|
21
|
-
const n = i === l, d = i > l, a = i < l;
|
|
22
|
-
return /* @__PURE__ */ r(
|
|
11
|
+
const [, , m] = d(), { currentStepIndex: c, steps: l } = m;
|
|
12
|
+
return /* @__PURE__ */ s("div", { className: e.stepListWrapper, children: [
|
|
13
|
+
/* @__PURE__ */ t(N, { level: 2, children: "Stappenplan" }),
|
|
14
|
+
/* @__PURE__ */ t("ul", { className: e.stepList, children: l.map((n, r) => {
|
|
15
|
+
const i = r === c, p = r > c, a = r < c;
|
|
16
|
+
return /* @__PURE__ */ s(
|
|
23
17
|
"li",
|
|
24
18
|
{
|
|
25
19
|
className: o(e.stepListItem, {
|
|
26
|
-
[e.inactive]:
|
|
20
|
+
[e.inactive]: p,
|
|
27
21
|
[e.completed]: a,
|
|
28
|
-
[e.current]:
|
|
22
|
+
[e.current]: i
|
|
29
23
|
}),
|
|
30
24
|
children: [
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */ t("div", { className: e.circle, children: a ? /* @__PURE__ */ t(
|
|
25
|
+
/* @__PURE__ */ s("div", { className: e.leftContainer, children: [
|
|
26
|
+
/* @__PURE__ */ t("div", { className: e.circle, children: a ? /* @__PURE__ */ t(h, {}) : /* @__PURE__ */ t(
|
|
33
27
|
"div",
|
|
34
28
|
{
|
|
35
29
|
className: o({
|
|
36
|
-
[e.currentDot]:
|
|
30
|
+
[e.currentDot]: i
|
|
37
31
|
})
|
|
38
32
|
}
|
|
39
33
|
) }),
|
|
40
|
-
|
|
34
|
+
r < l.length - 1 && /* @__PURE__ */ t("div", { className: e.connector })
|
|
41
35
|
] }),
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
36
|
+
/* @__PURE__ */ s("div", { className: e.content, children: [
|
|
37
|
+
/* @__PURE__ */ s("div", { className: e.contentText, children: [
|
|
38
|
+
/* @__PURE__ */ s("div", { className: e.stepNumber, children: [
|
|
45
39
|
"Stap ",
|
|
46
|
-
|
|
40
|
+
r + 1
|
|
47
41
|
] }),
|
|
48
|
-
/* @__PURE__ */ t("span", { className: e.stepTitle, children:
|
|
42
|
+
/* @__PURE__ */ t("span", { className: e.stepTitle, children: n.title })
|
|
49
43
|
] }),
|
|
50
|
-
|
|
44
|
+
i ? /* @__PURE__ */ t("div", { className: e.iconRightContainer, children: /* @__PURE__ */ t(v, {}) }) : null
|
|
51
45
|
] })
|
|
52
46
|
]
|
|
53
47
|
},
|
|
54
|
-
|
|
48
|
+
n.id
|
|
55
49
|
);
|
|
56
50
|
}) })
|
|
57
51
|
] });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import { isGenericTemplate as v, isTeamTemplate as h } from "../../../../../ui/src/lib/utils/templateUtils.js";
|
|
4
|
-
async function
|
|
4
|
+
async function g() {
|
|
5
5
|
try {
|
|
6
6
|
const { templateStorageService: e } = await import("@formbuilder/builder");
|
|
7
7
|
return e;
|
|
@@ -11,12 +11,12 @@ async function m() {
|
|
|
11
11
|
}
|
|
12
12
|
async function y() {
|
|
13
13
|
try {
|
|
14
|
-
const e = await
|
|
14
|
+
const e = await g();
|
|
15
15
|
if (!e) return;
|
|
16
16
|
if (!e.isReady()) {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
const r = (await
|
|
17
|
+
const a = await fetch("/form.config.json");
|
|
18
|
+
if (a.ok) {
|
|
19
|
+
const r = (await a.json()).storage?.paths?.templates;
|
|
20
20
|
r && await e.initialize(r);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -40,7 +40,7 @@ function d(e) {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
const f = /* @__PURE__ */ new Map(),
|
|
43
|
+
const f = /* @__PURE__ */ new Map(), l = {
|
|
44
44
|
"generic-contact-information": async () => {
|
|
45
45
|
const e = await fetch(
|
|
46
46
|
"/src/packages/form-wizard/admin/templates/generic/contact-information.json"
|
|
@@ -86,27 +86,27 @@ async function b(e) {
|
|
|
86
86
|
if (f.has(e))
|
|
87
87
|
return f.get(e);
|
|
88
88
|
try {
|
|
89
|
-
let
|
|
89
|
+
let a;
|
|
90
90
|
if (v(e)) {
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
93
|
-
const
|
|
91
|
+
const i = l[e];
|
|
92
|
+
if (!i) {
|
|
93
|
+
const s = Object.keys(l);
|
|
94
94
|
throw new Error(
|
|
95
|
-
`Generic template '${e}' not found. Available generic templates: ${
|
|
95
|
+
`Generic template '${e}' not found. Available generic templates: ${s.join(", ")}`
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
|
-
const r = await
|
|
99
|
-
|
|
98
|
+
const r = await i();
|
|
99
|
+
a = d(
|
|
100
100
|
r
|
|
101
101
|
);
|
|
102
102
|
} else if (h(e)) {
|
|
103
103
|
await y();
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
104
|
+
const i = await g();
|
|
105
|
+
if (!i)
|
|
106
106
|
throw new Error(
|
|
107
107
|
`Team template '${e}' could not be loaded: template storage service is not available`
|
|
108
108
|
);
|
|
109
|
-
const r = await
|
|
109
|
+
const r = await i.loadTemplate(
|
|
110
110
|
e,
|
|
111
111
|
"team"
|
|
112
112
|
);
|
|
@@ -114,53 +114,46 @@ async function b(e) {
|
|
|
114
114
|
throw new Error(
|
|
115
115
|
`Team template '${e}' not found: ${"error" in r && r.error?.message || "Unknown error"}`
|
|
116
116
|
);
|
|
117
|
-
|
|
117
|
+
a = d(r.data);
|
|
118
118
|
} else {
|
|
119
|
-
const
|
|
120
|
-
if (
|
|
121
|
-
const r = await
|
|
122
|
-
|
|
119
|
+
const i = l[e];
|
|
120
|
+
if (i) {
|
|
121
|
+
const r = await i();
|
|
122
|
+
a = d(
|
|
123
123
|
r
|
|
124
124
|
);
|
|
125
125
|
} else {
|
|
126
|
-
const r = Object.keys(
|
|
126
|
+
const r = Object.keys(l);
|
|
127
127
|
throw new Error(
|
|
128
128
|
`Template '${e}' not found. Available generic templates: ${r.join(", ")}`
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
if (!
|
|
132
|
+
if (!a.metadata || !Array.isArray(a.stepsData))
|
|
133
133
|
throw new Error(
|
|
134
134
|
`Invalid template structure for template: ${e}. Templates must have metadata and stepsData array.`
|
|
135
135
|
);
|
|
136
|
-
return f.set(e,
|
|
137
|
-
} catch (
|
|
136
|
+
return f.set(e, a), a;
|
|
137
|
+
} catch (a) {
|
|
138
138
|
throw new Error(
|
|
139
|
-
`Failed to load template '${e}': ${
|
|
139
|
+
`Failed to load template '${e}': ${a instanceof Error ? a.message : "Unknown error"}`
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
async function E(e,
|
|
144
|
-
console.log(
|
|
145
|
-
"Resolving template step:",
|
|
146
|
-
e,
|
|
147
|
-
"stepIndex:",
|
|
148
|
-
a
|
|
149
|
-
);
|
|
143
|
+
async function E(e, a, i) {
|
|
150
144
|
const r = await b(e.templateId);
|
|
151
|
-
|
|
152
|
-
let o;
|
|
145
|
+
let s;
|
|
153
146
|
if (r.stepsData && Array.isArray(r.stepsData) && r.stepsData.length > 0)
|
|
154
|
-
|
|
155
|
-
`Invalid stepIndex ${
|
|
147
|
+
i !== void 0 && i >= 0 && i < r.stepsData.length ? s = r.stepsData[i] : (s = r.stepsData[0], console.warn(
|
|
148
|
+
`Invalid stepIndex ${i} for template, using first step`
|
|
156
149
|
));
|
|
157
150
|
else
|
|
158
151
|
throw new Error(`Template ${e.templateId} has no steps data`);
|
|
159
|
-
const u =
|
|
152
|
+
const u = s.sections?.map((w) => ({
|
|
160
153
|
...w,
|
|
161
154
|
components: w.components.map((t) => {
|
|
162
|
-
const
|
|
163
|
-
id:
|
|
155
|
+
const m = ((c) => `comp-${e.id}-${t.id || c}`)(t.id), o = {
|
|
156
|
+
id: m,
|
|
164
157
|
type: t.type,
|
|
165
158
|
properties: {
|
|
166
159
|
// Use properties from component.properties if it exists, otherwise fallback to root level
|
|
@@ -175,7 +168,7 @@ async function E(e, i, a) {
|
|
|
175
168
|
type: t.properties?.type || t.type,
|
|
176
169
|
// Copy all other properties from component.properties if it exists
|
|
177
170
|
...t.properties && Object.keys(t.properties).reduce(
|
|
178
|
-
(
|
|
171
|
+
(c, p) => ([
|
|
179
172
|
"label",
|
|
180
173
|
"placeholder",
|
|
181
174
|
"description",
|
|
@@ -184,48 +177,48 @@ async function E(e, i, a) {
|
|
|
184
177
|
"readOnly",
|
|
185
178
|
"invalid",
|
|
186
179
|
"type"
|
|
187
|
-
].includes(p) || (
|
|
180
|
+
].includes(p) || (c[p] = t.properties[p]), c),
|
|
188
181
|
{}
|
|
189
182
|
)
|
|
190
183
|
},
|
|
191
184
|
// Copy validation if it exists
|
|
192
185
|
...t.validation && { validation: t.validation }
|
|
193
|
-
}, n = e.componentOverrides?.[
|
|
186
|
+
}, n = e.componentOverrides?.[m];
|
|
194
187
|
return n ? {
|
|
195
|
-
...
|
|
188
|
+
...o,
|
|
196
189
|
...n,
|
|
197
190
|
// Merge properties deeply to allow partial property updates
|
|
198
191
|
properties: {
|
|
199
|
-
...
|
|
192
|
+
...o.properties,
|
|
200
193
|
...n.properties
|
|
201
194
|
},
|
|
202
195
|
// Merge validation deeply if both exist
|
|
203
|
-
...
|
|
196
|
+
...o.validation && n.validation && {
|
|
204
197
|
validation: {
|
|
205
|
-
...
|
|
198
|
+
...o.validation,
|
|
206
199
|
...n.validation
|
|
207
200
|
}
|
|
208
201
|
}
|
|
209
|
-
} :
|
|
202
|
+
} : o;
|
|
210
203
|
})
|
|
211
204
|
}));
|
|
212
205
|
return {
|
|
213
206
|
id: e.id,
|
|
214
207
|
// Use the step ID from the form config
|
|
215
|
-
title: e.title ||
|
|
216
|
-
displayTitle:
|
|
217
|
-
showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber :
|
|
208
|
+
title: e.title || s.title,
|
|
209
|
+
displayTitle: s.displayTitle,
|
|
210
|
+
showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber : s.showStepNumber,
|
|
218
211
|
sections: u,
|
|
219
212
|
navigation: {
|
|
220
213
|
// Use default navigation, then template navigation if available, then step override
|
|
221
|
-
...
|
|
222
|
-
...
|
|
214
|
+
...a,
|
|
215
|
+
...s.navigation,
|
|
223
216
|
// Cast since navigation might not exist in Omit type
|
|
224
217
|
...e.navigation
|
|
225
218
|
},
|
|
226
219
|
// Copy actions if they exist
|
|
227
|
-
...
|
|
228
|
-
actions:
|
|
220
|
+
...s.actions && {
|
|
221
|
+
actions: s.actions
|
|
229
222
|
}
|
|
230
223
|
};
|
|
231
224
|
}
|
|
@@ -1,78 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useFormMachine as
|
|
4
|
-
const
|
|
5
|
-
componentId:
|
|
6
|
-
initialValue:
|
|
7
|
-
onValueChange:
|
|
2
|
+
import { useRef as h, useCallback as i } from "react";
|
|
3
|
+
import { useFormMachine as z } from "../../state-management/machines/useFormMachine.js";
|
|
4
|
+
const _ = ({
|
|
5
|
+
componentId: r,
|
|
6
|
+
initialValue: o,
|
|
7
|
+
onValueChange: a
|
|
8
8
|
}) => {
|
|
9
|
-
const [, ,
|
|
10
|
-
evaluateComponentTriggers:
|
|
11
|
-
setComponentOriginalValue:
|
|
12
|
-
getComponentAlerts:
|
|
13
|
-
dismissComponentAlert:
|
|
9
|
+
const [, , C] = z(), {
|
|
10
|
+
evaluateComponentTriggers: u,
|
|
11
|
+
setComponentOriginalValue: c,
|
|
12
|
+
getComponentAlerts: T,
|
|
13
|
+
dismissComponentAlert: l,
|
|
14
14
|
hasComponentTriggers: A,
|
|
15
15
|
hasComponentActions: m,
|
|
16
16
|
getComponentTriggerState: p
|
|
17
|
-
} =
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
`🧪 [useComponentTriggers] evaluateTriggers called for ${e}:`,
|
|
23
|
-
{
|
|
24
|
-
eventType: r,
|
|
25
|
-
value: a,
|
|
26
|
-
evaluateComponentTriggers: !!n
|
|
27
|
-
}
|
|
28
|
-
), n(e, r, a);
|
|
17
|
+
} = C, f = h(!1), n = h(o);
|
|
18
|
+
o !== void 0 && !f.current && (c(r, o), n.current = o, f.current = !0);
|
|
19
|
+
const e = i(
|
|
20
|
+
(s, g) => {
|
|
21
|
+
u(r, s, g);
|
|
29
22
|
},
|
|
30
|
-
[
|
|
31
|
-
),
|
|
32
|
-
(
|
|
33
|
-
|
|
23
|
+
[r, u]
|
|
24
|
+
), R = i(
|
|
25
|
+
(s, g = "api_populated") => {
|
|
26
|
+
c(r, s, g), n.current = s;
|
|
34
27
|
},
|
|
35
|
-
[
|
|
36
|
-
), b =
|
|
37
|
-
(
|
|
38
|
-
|
|
28
|
+
[r, c]
|
|
29
|
+
), b = T(r), F = i(
|
|
30
|
+
(s) => {
|
|
31
|
+
l(r, s);
|
|
39
32
|
},
|
|
40
|
-
[
|
|
41
|
-
),
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
`🧪 [useComponentTriggers] handleValueChange called for ${e}:`,
|
|
45
|
-
{
|
|
46
|
-
value: r,
|
|
47
|
-
oldValue: o.current,
|
|
48
|
-
hasTriggers: s,
|
|
49
|
-
onValueChange: !!i
|
|
50
|
-
}
|
|
51
|
-
), o.current = r, i && i(r), s ? (console.log(
|
|
52
|
-
`🧪 [useComponentTriggers] About to call evaluateTriggers for ${e}`
|
|
53
|
-
), t("valueChange", r)) : console.log(
|
|
54
|
-
`🧪 [useComponentTriggers] hasTriggers is false for ${e}`
|
|
55
|
-
);
|
|
33
|
+
[r, l]
|
|
34
|
+
), t = A(r), O = m(r), S = p(r), k = i(
|
|
35
|
+
(s) => {
|
|
36
|
+
n.current = s, a && a(s), t && e("valueChange", s);
|
|
56
37
|
},
|
|
57
|
-
[
|
|
58
|
-
),
|
|
59
|
-
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
}, [
|
|
38
|
+
[e, t, a, r]
|
|
39
|
+
), v = i(() => {
|
|
40
|
+
t && e("focus", n.current);
|
|
41
|
+
}, [e, t]), x = i(() => {
|
|
42
|
+
t && e("blur", n.current);
|
|
43
|
+
}, [e, t]);
|
|
63
44
|
return {
|
|
64
|
-
evaluateTriggers:
|
|
65
|
-
setOriginalValue:
|
|
45
|
+
evaluateTriggers: e,
|
|
46
|
+
setOriginalValue: R,
|
|
66
47
|
alerts: b,
|
|
67
|
-
dismissAlert:
|
|
68
|
-
hasTriggers:
|
|
69
|
-
hasActions:
|
|
70
|
-
triggerState:
|
|
71
|
-
handleValueChange:
|
|
72
|
-
handleFocus:
|
|
73
|
-
handleBlur:
|
|
48
|
+
dismissAlert: F,
|
|
49
|
+
hasTriggers: t,
|
|
50
|
+
hasActions: O,
|
|
51
|
+
triggerState: S,
|
|
52
|
+
handleValueChange: k,
|
|
53
|
+
handleFocus: v,
|
|
54
|
+
handleBlur: x
|
|
74
55
|
};
|
|
75
56
|
};
|
|
76
57
|
export {
|
|
77
|
-
|
|
58
|
+
_ as useComponentTriggers
|
|
78
59
|
};
|