@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.
Files changed (43) hide show
  1. package/features/form-runtime/components/FormFooter.d.ts +5 -0
  2. package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
  3. package/features/state-management/machines/formMachine.d.ts +3 -0
  4. package/features/state-management/machines/types.d.ts +4 -0
  5. package/features/state-management/machines/useFormMachine.d.ts +18 -0
  6. package/package.json +1 -3
  7. package/styles.css +1 -1
  8. package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
  9. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
  10. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
  11. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
  12. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +54 -79
  13. package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
  14. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +150 -194
  15. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +83 -92
  16. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
  17. package/wizard/src/features/form-runtime/config/templateLoader.js +48 -55
  18. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +44 -63
  19. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +26 -40
  20. package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
  21. package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
  22. package/wizard/src/features/form-runtime/utils/logger.js +12 -12
  23. package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
  24. package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
  25. package/wizard/src/features/state-management/machines/formMachine.js +558 -677
  26. package/wizard/src/features/state-management/machines/useFormMachine.js +172 -190
  27. package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
  28. package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
  29. package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
  30. package/wizard/src/features/validation-system/validation/ValidationExecutor.js +26 -58
  31. package/features/form-runtime/utils/formSaver.d.ts +0 -22
  32. package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
  33. package/features/state-management/machines/__tests__/setup.d.ts +0 -0
  34. package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
  35. package/features/state-management/machines/actions/validationActions.d.ts +0 -68
  36. package/features/state-management/machines/lazyLoading.d.ts +0 -34
  37. package/features/state-management/machines/validation/index.d.ts +0 -5
  38. package/features/state-management/machines/validation/validateField.d.ts +0 -2
  39. package/features/state-management/machines/validation/validateForm.d.ts +0 -2
  40. package/features/state-management/machines/validation/validateSection.d.ts +0 -2
  41. package/features/state-management/machines/validation/validateStep.d.ts +0 -2
  42. package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
  43. package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
@@ -1,31 +1,31 @@
1
1
  "use client";
2
- import { jsxs as f, jsx as i, Fragment as M } from "react/jsx-runtime";
3
- import h from "./FormStep.module.css.js";
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 m } from "../../../../../../ui/src/lib/types/guards.js";
6
- import { logger as U } from "../../../../../../ui/src/lib/logger.js";
7
- import { useForm as C } from "@tanstack/react-form";
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 G } from "../../hooks/useFormContext.js";
11
- import { buildDefaultValues as E } from "../../utils/formDataBuilder.js";
12
- import { resetFormDirtyStateAfterApiPopulation as H } from "../../utils/formDirtyStateSync.js";
13
- import j from "../FormFooter.js";
14
- import z from "../FormHeader.js";
15
- import q from "../FormSection/FormSection.js";
16
- import { ProgressLoaderRuntime as K } from "../ProgressLoaderRuntime.js";
17
- import { useFormMachine as Q } from "../../../state-management/machines/useFormMachine.js";
18
- import { EnhancedActionExecutor as X } from "../../../api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js";
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: s,
22
- hasStepLoader: a,
21
+ currentStep: r,
22
+ hasStepLoader: s,
23
23
  loaderConfig: o
24
24
  }) => {
25
- const { isLoadingComplete: t } = W(), d = m(s) ? [] : s.sections || [];
26
- return /* @__PURE__ */ f("div", { className: h.stepContent, children: [
27
- a && /* @__PURE__ */ i("div", { className: h.loaderWrapper, children: /* @__PURE__ */ i(
28
- K,
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
- (!a || t) && /* @__PURE__ */ i(M, { children: d.map((c) => /* @__PURE__ */ i(q, { section: c }, c.id)) })
49
+ (!s || e) && /* @__PURE__ */ n(M, { children: u.map((i) => /* @__PURE__ */ n(K, { section: i }, i.id)) })
50
50
  ] });
51
51
  }, Y = () => {
52
- const [s, a, o] = Q(), { currentStep: t, config: d } = o, c = p(), u = p(), F = p(), b = d.validationMessageStyle || "withLabel";
53
- c.current || (c.current = new B({ messageStyle: b })), (!u.current || F.current !== t.id) && (m(t) ? u.current = c.current.getStepSchema({
54
- ...t,
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
- }) : u.current = c.current.getStepSchema(t), F.current = t.id);
57
- const v = { ...m(t) ? E({
58
- ...t,
56
+ }) : d.current = i.current.getStepSchema(e), F.current = e.id);
57
+ const b = { ...l(e) ? v({
58
+ ...e,
59
59
  sections: []
60
- }) : E(t), ...o.data }, y = (e) => {
61
- (t.actions || []).length > 0 && a({ type: "EXECUTE_ACTIONS", trigger: e });
62
- }, x = p(), g = p(!1);
63
- t.id !== x.current && (t.actions || []).length > 0 && !g.current && (x.current = t.id, g.current = !0, setTimeout(() => {
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
- g.current = !1;
65
+ f.current = !1;
66
66
  }, 1e3);
67
67
  }, 0));
68
- const N = async ({
69
- value: e
68
+ const L = async ({
69
+ value: t
70
70
  }) => {
71
- const n = t.actions || [], r = n.some(
72
- (S) => S.trigger === "onStepFinish"
73
- );
74
- console.log("🎯 [FormStep] handleSubmit called with form values:", {
75
- stepActions: n.length,
76
- hasFinishActions: r,
77
- formValue: e
78
- }), r ? (console.log(
79
- "🎯 [FormStep] Step has onStepFinish actions, requesting navigation first"
80
- ), a({ type: "REQUEST_NAVIGATION", navigationType: "next" })) : (console.log("🎯 [FormStep] No step actions, direct navigation"), o.nextStep());
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
- e.targetStep && o.goToStep(e.targetStep);
88
+ t.targetStep && o.goToStep(t.targetStep);
96
89
  break;
97
90
  }
98
- }, l = C({
99
- defaultValues: v,
100
- onSubmit: N
101
- }), w = (e, n) => {
102
- console.log("🎯 handleFieldUpdate called:", { fieldPath: e, value: n });
103
- const r = e, S = l.getFieldValue(r), R = s.context.componentOriginalValues[r]?.value;
104
- if (S !== n) {
105
- console.log("🔄 Updating TanStack Form field:", { componentId: r, value: n });
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
- H(l, {
110
- updatedFields: [r],
100
+ z(m, {
101
+ updatedFields: [c],
111
102
  debug: process.env.NODE_ENV === "development"
112
- }), console.log("✅ Dirty state reset complete for:", r);
113
- } catch (P) {
114
- console.error("❌ Failed to reset dirty state:", P);
103
+ });
104
+ } catch (I) {
105
+ console.error("❌ Failed to reset dirty state:", I);
115
106
  }
116
107
  }
117
- R !== n && (console.log("🎯 Marking component as populated:", { componentId: r, value: n }), setTimeout(() => {
118
- a({
108
+ _ !== a && setTimeout(() => {
109
+ s({
119
110
  type: "MARK_COMPONENT_AS_POPULATED",
120
- componentId: r,
121
- value: n
111
+ componentId: c,
112
+ value: a
122
113
  });
123
- }, 0));
124
- }, A = t, T = !m(t) && A.waitForLoader === !0, _ = T ? A.loaderConfig : void 0;
125
- return /* @__PURE__ */ f(G, { value: l, children: [
126
- s.matches("executingActions") && (s.context.executingTrigger === "onStepLoad" || s.context.executingTrigger === "onStepFinish") && /* @__PURE__ */ i(
127
- X,
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: t.actions || [],
130
- trigger: s.context.executingTrigger || "onStepLoad",
131
- formData: s.context.data,
132
- onComplete: D,
133
- onError: L,
134
- onFieldUpdate: w,
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: a
129
+ send: s
139
130
  }
140
131
  }
141
132
  ),
142
- /* @__PURE__ */ f(
133
+ /* @__PURE__ */ h(
143
134
  "form",
144
135
  {
145
- onSubmit: (e) => {
146
- e.preventDefault(), e.stopPropagation(), l.handleSubmit();
136
+ onSubmit: (t) => {
137
+ t.preventDefault(), t.stopPropagation(), m.handleSubmit();
147
138
  },
148
139
  children: [
149
- /* @__PURE__ */ i(z, {}),
150
- /* @__PURE__ */ i(k, { children: /* @__PURE__ */ i(
140
+ /* @__PURE__ */ n(H, {}),
141
+ /* @__PURE__ */ n(k, { children: /* @__PURE__ */ n(
151
142
  J,
152
143
  {
153
- currentStep: t,
154
- hasStepLoader: T,
155
- loaderConfig: _
144
+ currentStep: e,
145
+ hasStepLoader: E,
146
+ loaderConfig: R
156
147
  }
157
148
  ) }),
158
- /* @__PURE__ */ i(j, { className: h.footer })
149
+ /* @__PURE__ */ n(G, { className: S.footer })
159
150
  ]
160
151
  }
161
152
  )
@@ -1,57 +1,51 @@
1
1
  "use client";
2
- import { jsxs as r, jsx as t } from "react/jsx-runtime";
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 h } from "../../../state-management/machines/useFormMachine.js";
7
- import v from "../../../../../../ui/src/lib/assets/icons/Check.js";
8
- import N from "../../../../../../ui/src/lib/assets/icons/ChevronRight.js";
9
- import { Heading as f } from "@rijkshuisstijl-community/components-react";
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] = h(), { currentStepIndex: l, steps: c, config: p } = m;
12
- return console.log("🏁 StepProgressIndicator render:", {
13
- currentStepIndex: l,
14
- totalSteps: c.length,
15
- formId: p.id,
16
- stepIds: c.map((s) => s.id),
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]: d,
20
+ [e.inactive]: p,
27
21
  [e.completed]: a,
28
- [e.current]: n
22
+ [e.current]: i
29
23
  }),
30
24
  children: [
31
- /* @__PURE__ */ r("div", { className: e.leftContainer, children: [
32
- /* @__PURE__ */ t("div", { className: e.circle, children: a ? /* @__PURE__ */ t(v, {}) : /* @__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]: n
30
+ [e.currentDot]: i
37
31
  })
38
32
  }
39
33
  ) }),
40
- i < c.length - 1 && /* @__PURE__ */ t("div", { className: e.connector })
34
+ r < l.length - 1 && /* @__PURE__ */ t("div", { className: e.connector })
41
35
  ] }),
42
- /* @__PURE__ */ r("div", { className: e.content, children: [
43
- /* @__PURE__ */ r("div", { className: e.contentText, children: [
44
- /* @__PURE__ */ r("div", { className: e.stepNumber, children: [
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
- i + 1
40
+ r + 1
47
41
  ] }),
48
- /* @__PURE__ */ t("span", { className: e.stepTitle, children: s.title })
42
+ /* @__PURE__ */ t("span", { className: e.stepTitle, children: n.title })
49
43
  ] }),
50
- n ? /* @__PURE__ */ t("div", { className: e.iconRightContainer, children: /* @__PURE__ */ t(N, {}) }) : null
44
+ i ? /* @__PURE__ */ t("div", { className: e.iconRightContainer, children: /* @__PURE__ */ t(v, {}) }) : null
51
45
  ] })
52
46
  ]
53
47
  },
54
- s.id
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 m() {
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 m();
14
+ const e = await g();
15
15
  if (!e) return;
16
16
  if (!e.isReady()) {
17
- const i = await fetch("/form.config.json");
18
- if (i.ok) {
19
- const r = (await i.json()).storage?.paths?.templates;
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(), c = {
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 i;
89
+ let a;
90
90
  if (v(e)) {
91
- const a = c[e];
92
- if (!a) {
93
- const o = Object.keys(c);
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: ${o.join(", ")}`
95
+ `Generic template '${e}' not found. Available generic templates: ${s.join(", ")}`
96
96
  );
97
97
  }
98
- const r = await a();
99
- i = d(
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 a = await m();
105
- if (!a)
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 a.loadTemplate(
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
- i = d(r.data);
117
+ a = d(r.data);
118
118
  } else {
119
- const a = c[e];
120
- if (a) {
121
- const r = await a();
122
- i = d(
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(c);
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 (!i.metadata || !Array.isArray(i.stepsData))
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, i), i;
137
- } catch (i) {
136
+ return f.set(e, a), a;
137
+ } catch (a) {
138
138
  throw new Error(
139
- `Failed to load template '${e}': ${i instanceof Error ? i.message : "Unknown error"}`
139
+ `Failed to load template '${e}': ${a instanceof Error ? a.message : "Unknown error"}`
140
140
  );
141
141
  }
142
142
  }
143
- async function E(e, i, a) {
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
- console.log("Loaded template:", r);
152
- let o;
145
+ let s;
153
146
  if (r.stepsData && Array.isArray(r.stepsData) && r.stepsData.length > 0)
154
- a !== void 0 && a >= 0 && a < r.stepsData.length ? (o = r.stepsData[a], console.log(`Using template data for step ${a}:`, o)) : (o = r.stepsData[0], console.warn(
155
- `Invalid stepIndex ${a} for template, using first step`
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 = o.sections?.map((w) => ({
152
+ const u = s.sections?.map((w) => ({
160
153
  ...w,
161
154
  components: w.components.map((t) => {
162
- const g = ((l) => `comp-${e.id}-${t.id || l}`)(t.id), s = {
163
- id: g,
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
- (l, p) => ([
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) || (l[p] = t.properties[p]), l),
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?.[g];
186
+ }, n = e.componentOverrides?.[m];
194
187
  return n ? {
195
- ...s,
188
+ ...o,
196
189
  ...n,
197
190
  // Merge properties deeply to allow partial property updates
198
191
  properties: {
199
- ...s.properties,
192
+ ...o.properties,
200
193
  ...n.properties
201
194
  },
202
195
  // Merge validation deeply if both exist
203
- ...s.validation && n.validation && {
196
+ ...o.validation && n.validation && {
204
197
  validation: {
205
- ...s.validation,
198
+ ...o.validation,
206
199
  ...n.validation
207
200
  }
208
201
  }
209
- } : s;
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 || o.title,
216
- displayTitle: o.displayTitle,
217
- showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber : o.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
- ...i,
222
- ...o.navigation,
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
- ...o.actions && {
228
- actions: o.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 C, useCallback as g } from "react";
3
- import { useFormMachine as x } from "../../state-management/machines/useFormMachine.js";
4
- const M = ({
5
- componentId: e,
6
- initialValue: l,
7
- onValueChange: i
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 [, , T] = x(), {
10
- evaluateComponentTriggers: n,
11
- setComponentOriginalValue: u,
12
- getComponentAlerts: h,
13
- dismissComponentAlert: c,
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
- } = T, f = C(!1), o = C(l);
18
- l !== void 0 && !f.current && (u(e, l), o.current = l, f.current = !0);
19
- const t = g(
20
- (r, a) => {
21
- console.log(
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
- [e, n]
31
- ), $ = g(
32
- (r, a = "api_populated") => {
33
- u(e, r, a), o.current = r;
23
+ [r, u]
24
+ ), R = i(
25
+ (s, g = "api_populated") => {
26
+ c(r, s, g), n.current = s;
34
27
  },
35
- [e, u]
36
- ), b = h(e), R = g(
37
- (r) => {
38
- c(e, r);
28
+ [r, c]
29
+ ), b = T(r), F = i(
30
+ (s) => {
31
+ l(r, s);
39
32
  },
40
- [e, c]
41
- ), s = A(e), F = m(e), O = p(e), S = g(
42
- (r) => {
43
- console.log(
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
- [t, s, i, e]
58
- ), k = g(() => {
59
- s && t("focus", o.current);
60
- }, [t, s]), v = g(() => {
61
- s && t("blur", o.current);
62
- }, [t, s]);
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: t,
65
- setOriginalValue: $,
45
+ evaluateTriggers: e,
46
+ setOriginalValue: R,
66
47
  alerts: b,
67
- dismissAlert: R,
68
- hasTriggers: s,
69
- hasActions: F,
70
- triggerState: O,
71
- handleValueChange: S,
72
- handleFocus: k,
73
- handleBlur: v
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
- M as useComponentTriggers
58
+ _ as useComponentTriggers
78
59
  };