@digiform/wizard 0.3.0 → 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 (89) hide show
  1. package/core/src/types/guards.js +0 -12
  2. package/core/src/utils/apiBodyUtils.js +43 -75
  3. package/features/form-runtime/components/FormFooter.d.ts +5 -0
  4. package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
  5. package/features/state-management/machines/formMachine.d.ts +3 -0
  6. package/features/state-management/machines/types.d.ts +4 -0
  7. package/features/state-management/machines/useFormMachine.d.ts +18 -0
  8. package/index.d.ts +2 -8
  9. package/index.js +2 -108
  10. package/package.json +1 -30
  11. package/styles.css +1 -1
  12. package/ui/src/lib/utils/templateUtils.js +11 -43
  13. package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
  14. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
  15. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
  16. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
  17. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +56 -78
  18. package/wizard/src/features/form-runtime/components/FormField.js +28 -28
  19. package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
  20. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +152 -196
  21. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +82 -91
  22. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
  23. package/wizard/src/features/form-runtime/config/configResolver.js +10 -14
  24. package/wizard/src/features/form-runtime/config/templateLoader.js +71 -108
  25. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +45 -88
  26. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +27 -41
  27. package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +5 -5
  28. package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
  29. package/wizard/src/features/form-runtime/utils/errorUtils.js +31 -42
  30. package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
  31. package/wizard/src/features/form-runtime/utils/logger.js +12 -12
  32. package/wizard/src/features/form-runtime/utils/validationUX.js +14 -55
  33. package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
  34. package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
  35. package/wizard/src/features/state-management/machines/formMachine.js +558 -677
  36. package/wizard/src/features/state-management/machines/useFormMachine.js +172 -190
  37. package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
  38. package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
  39. package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
  40. package/wizard/src/features/validation-system/validation/ValidationEngine.js +24 -29
  41. package/wizard/src/features/validation-system/validation/ValidationExecutor.js +26 -58
  42. package/FormWizard.d.ts +0 -10
  43. package/core/src/types/api.js +0 -12
  44. package/core/src/types/form-config.js +0 -60
  45. package/core/src/types/form-wizard-config-schema.js +0 -113
  46. package/core/src/types/validation.js +0 -61
  47. package/features/api-integration.d.ts +0 -2
  48. package/features/api-integration.js +0 -17
  49. package/features/dialog-system.d.ts +0 -2
  50. package/features/dialog-system.js +0 -9
  51. package/features/form-runtime/utils/formSaver.d.ts +0 -22
  52. package/features/form-runtime.d.ts +0 -2
  53. package/features/form-runtime.js +0 -63
  54. package/features/index.d.ts +0 -11
  55. package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
  56. package/features/state-management/machines/__tests__/setup.d.ts +0 -0
  57. package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
  58. package/features/state-management/machines/actions/validationActions.d.ts +0 -68
  59. package/features/state-management/machines/lazyLoading.d.ts +0 -34
  60. package/features/state-management/machines/validation/index.d.ts +0 -5
  61. package/features/state-management/machines/validation/validateField.d.ts +0 -2
  62. package/features/state-management/machines/validation/validateForm.d.ts +0 -2
  63. package/features/state-management/machines/validation/validateSection.d.ts +0 -2
  64. package/features/state-management/machines/validation/validateStep.d.ts +0 -2
  65. package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
  66. package/features/state-management.d.ts +0 -2
  67. package/features/state-management.js +0 -21
  68. package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
  69. package/features/trigger-action-system.d.ts +0 -2
  70. package/features/trigger-action-system.js +0 -12
  71. package/features/validation-system.d.ts +0 -2
  72. package/features/validation-system.js +0 -23
  73. package/styles/index.d.ts +0 -0
  74. package/ui/src/components/badge/badge.js +0 -20
  75. package/ui/src/components/badge/badge.module.css.js +0 -12
  76. package/wizard/src/features/api-integration/services/ActionExecutor.js +0 -339
  77. package/wizard/src/features/api-integration/services/ApiCallExecutor.js +0 -6
  78. package/wizard/src/features/api-integration/services/DialogExecutor.js +0 -6
  79. package/wizard/src/features/api-integration/services/GenericTriggerService.js +0 -284
  80. package/wizard/src/features/api-integration/services/NavigationExecutor.js +0 -6
  81. package/wizard/src/features/form-runtime/config/templateConfig.js +0 -156
  82. package/wizard/src/features/form-runtime/config/templateUtils.js +0 -14
  83. package/wizard/src/features/form-runtime/utils/validation.js +0 -100
  84. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +0 -46
  85. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +0 -30
  86. package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +0 -376
  87. package/wizard/src/features/validation-system/components/ValidationDebugger.js +0 -69
  88. package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +0 -17
  89. package/wizard/src/features/validation-system/validation/validationService.js +0 -74
@@ -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 { EnhancedActionExecutor as C } from "../../../api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js";
8
- import { useFormMachine as k } from "../../../state-management/machines/useFormMachine.js";
9
- import { useForm as W } 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";
10
8
  import { useRef as p } from "react";
11
- import { LoaderProvider as G, useLoaderContext as H } from "../../context/LoaderContext.js";
9
+ import { LoaderProvider as k, useLoaderContext as W } from "../../context/LoaderContext.js";
12
10
  import { FormProvider as j } from "../../hooks/useFormContext.js";
13
- import { buildDefaultValues as E } from "../../utils/formDataBuilder.js";
11
+ import { buildDefaultValues as v } from "../../utils/formDataBuilder.js";
14
12
  import { resetFormDirtyStateAfterApiPopulation as z } from "../../utils/formDirtyStateSync.js";
15
- import q from "../FormFooter.js";
16
- import K from "../FormHeader.js";
17
- import Q from "../FormSection/FormSection.js";
18
- import { ProgressLoaderRuntime as X } from "../ProgressLoaderRuntime.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 } = H(), 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
- X,
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] = k(), { 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 = W({
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
- z(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(j, { value: l, children: [
126
- s.matches("executingActions") && (s.context.executingTrigger === "onStepLoad" || s.context.executingTrigger === "onStepFinish") && /* @__PURE__ */ i(
127
- C,
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(K, {}),
150
- /* @__PURE__ */ i(G, { 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(q, { 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
- import { useFormMachine as h } from "../../../state-management/machines/useFormMachine.js";
5
4
  import o from "clsx";
6
5
  import e from "./StepProgressIndicator.module.css.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,23 +1,23 @@
1
1
  "use client";
2
2
  import { resolveTemplateStep as i } from "./templateLoader.js";
3
- import { isTemplateStep as r } from "../../../../../core/src/types/guards.js";
3
+ import { isTemplateStep as n } from "../../../../../core/src/types/guards.js";
4
4
  async function m(e) {
5
- const t = {
5
+ const s = {
6
6
  next: { label: "Next", enabled: !0 },
7
7
  previous: { label: "Previous", enabled: !0 }
8
8
  }, l = await Promise.all(
9
- e.steps.map(async (s, n) => {
10
- if (r(s)) {
11
- const a = { ...t };
12
- n === 0 && (a.previous.enabled = !1), n === e.steps.length - 1 && (a.next.label = "Submit");
13
- const o = s.stepIndex;
9
+ e.steps.map(async (t, r) => {
10
+ if (n(t)) {
11
+ const a = { ...s };
12
+ r === 0 && (a.previous.enabled = !1), r === e.steps.length - 1 && (a.next.label = "Submit");
13
+ const o = t.stepIndex;
14
14
  return await i(
15
- s,
15
+ t,
16
16
  a,
17
17
  o
18
18
  );
19
19
  }
20
- return s;
20
+ return t;
21
21
  })
22
22
  );
23
23
  return {
@@ -26,13 +26,9 @@ async function m(e) {
26
26
  };
27
27
  }
28
28
  function f(e) {
29
- return e.steps.some((t) => r(t));
30
- }
31
- function d(e) {
32
- return e.steps.filter(r).map((t) => t.templateId);
29
+ return e.steps.some((s) => n(s));
33
30
  }
34
31
  export {
35
- d as getUsedTemplateIds,
36
32
  f as hasTemplateSteps,
37
33
  m as resolveFormWizardConfig
38
34
  };
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  /* empty css */
3
- import { isGenericTemplate as y, isTeamTemplate as b } from "../../../../../ui/src/lib/utils/templateUtils.js";
4
- async function m() {
3
+ import { isGenericTemplate as v, isTeamTemplate as h } from "../../../../../ui/src/lib/utils/templateUtils.js";
4
+ async function g() {
5
5
  try {
6
6
  const { templateStorageService: e } = await import("@formbuilder/builder");
7
7
  return e;
@@ -9,22 +9,22 @@ async function m() {
9
9
  return console.warn("Template storage service not available:", e), null;
10
10
  }
11
11
  }
12
- async function u() {
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 r = await fetch("/form.config.json");
18
- if (r.ok) {
19
- const t = (await r.json()).storage?.paths?.templates;
20
- t && await e.initialize(t);
17
+ const a = await fetch("/form.config.json");
18
+ if (a.ok) {
19
+ const r = (await a.json()).storage?.paths?.templates;
20
+ r && await e.initialize(r);
21
21
  }
22
22
  }
23
23
  } catch (e) {
24
24
  console.warn("Failed to initialize template storage service:", e);
25
25
  }
26
26
  }
27
- function f(e) {
27
+ function d(e) {
28
28
  return {
29
29
  metadata: e.metadata,
30
30
  stepsData: e.stepsData || [],
@@ -40,7 +40,7 @@ function f(e) {
40
40
  }
41
41
  };
42
42
  }
43
- const p = /* @__PURE__ */ new Map(), o = {
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"
@@ -82,100 +82,93 @@ const p = /* @__PURE__ */ new Map(), o = {
82
82
  return e.json();
83
83
  }
84
84
  };
85
- async function v(e) {
86
- if (p.has(e))
87
- return p.get(e);
85
+ async function b(e) {
86
+ if (f.has(e))
87
+ return f.get(e);
88
88
  try {
89
- let r;
90
- if (y(e)) {
91
- const i = o[e];
89
+ let a;
90
+ if (v(e)) {
91
+ const i = l[e];
92
92
  if (!i) {
93
- const s = Object.keys(o);
93
+ const s = Object.keys(l);
94
94
  throw new Error(
95
95
  `Generic template '${e}' not found. Available generic templates: ${s.join(", ")}`
96
96
  );
97
97
  }
98
- const t = await i();
99
- r = f(
100
- t
98
+ const r = await i();
99
+ a = d(
100
+ r
101
101
  );
102
- } else if (b(e)) {
103
- await u();
104
- const i = await m();
102
+ } else if (h(e)) {
103
+ await y();
104
+ const i = await g();
105
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 t = await i.loadTemplate(
109
+ const r = await i.loadTemplate(
110
110
  e,
111
111
  "team"
112
112
  );
113
- if (!t.success)
113
+ if (!r.success)
114
114
  throw new Error(
115
- `Team template '${e}' not found: ${"error" in t && t.error?.message || "Unknown error"}`
115
+ `Team template '${e}' not found: ${"error" in r && r.error?.message || "Unknown error"}`
116
116
  );
117
- r = f(t.data);
117
+ a = d(r.data);
118
118
  } else {
119
- const i = o[e];
119
+ const i = l[e];
120
120
  if (i) {
121
- const t = await i();
122
- r = f(
123
- t
121
+ const r = await i();
122
+ a = d(
123
+ r
124
124
  );
125
125
  } else {
126
- const t = Object.keys(o);
126
+ const r = Object.keys(l);
127
127
  throw new Error(
128
- `Template '${e}' not found. Available generic templates: ${t.join(", ")}`
128
+ `Template '${e}' not found. Available generic templates: ${r.join(", ")}`
129
129
  );
130
130
  }
131
131
  }
132
- if (!r.metadata || !Array.isArray(r.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 p.set(e, r), r;
137
- } catch (r) {
136
+ return f.set(e, a), a;
137
+ } catch (a) {
138
138
  throw new Error(
139
- `Failed to load template '${e}': ${r instanceof Error ? r.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 S(e, r, i) {
144
- console.log(
145
- "Resolving template step:",
146
- e,
147
- "stepIndex:",
148
- i
149
- );
150
- const t = await v(e.templateId);
151
- console.log("Loaded template:", t);
143
+ async function E(e, a, i) {
144
+ const r = await b(e.templateId);
152
145
  let s;
153
- if (t.stepsData && Array.isArray(t.stepsData) && t.stepsData.length > 0)
154
- i !== void 0 && i >= 0 && i < t.stepsData.length ? (s = t.stepsData[i], console.log(`Using template data for step ${i}:`, s)) : (s = t.stepsData[0], console.warn(
146
+ if (r.stepsData && Array.isArray(r.stepsData) && r.stepsData.length > 0)
147
+ i !== void 0 && i >= 0 && i < r.stepsData.length ? s = r.stepsData[i] : (s = r.stepsData[0], console.warn(
155
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 h = s.sections?.map((w) => ({
152
+ const u = s.sections?.map((w) => ({
160
153
  ...w,
161
- components: w.components.map((a) => {
162
- const g = ((c) => `comp-${e.id}-${a.id || c}`)(a.id), n = {
163
- id: g,
164
- type: a.type,
154
+ components: w.components.map((t) => {
155
+ const m = ((c) => `comp-${e.id}-${t.id || c}`)(t.id), o = {
156
+ id: m,
157
+ type: t.type,
165
158
  properties: {
166
159
  // Use properties from component.properties if it exists, otherwise fallback to root level
167
- label: a.properties?.label || a.label || "",
168
- placeholder: a.properties?.placeholder || a.placeholder || "",
169
- description: a.properties?.description || a.description || "",
170
- required: a.properties?.required || a.required || !1,
171
- disabled: a.properties?.disabled || a.disabled || !1,
172
- readOnly: a.properties?.readOnly || a.readOnly || !1,
173
- invalid: a.properties?.invalid || !1,
160
+ label: t.properties?.label || t.label || "",
161
+ placeholder: t.properties?.placeholder || t.placeholder || "",
162
+ description: t.properties?.description || t.description || "",
163
+ required: t.properties?.required || t.required || !1,
164
+ disabled: t.properties?.disabled || t.disabled || !1,
165
+ readOnly: t.properties?.readOnly || t.readOnly || !1,
166
+ invalid: t.properties?.invalid || !1,
174
167
  // Add type-specific properties
175
- type: a.properties?.type || a.type,
168
+ type: t.properties?.type || t.type,
176
169
  // Copy all other properties from component.properties if it exists
177
- ...a.properties && Object.keys(a.properties).reduce(
178
- (c, d) => ([
170
+ ...t.properties && Object.keys(t.properties).reduce(
171
+ (c, p) => ([
179
172
  "label",
180
173
  "placeholder",
181
174
  "description",
@@ -184,29 +177,29 @@ async function S(e, r, i) {
184
177
  "readOnly",
185
178
  "invalid",
186
179
  "type"
187
- ].includes(d) || (c[d] = a.properties[d]), c),
180
+ ].includes(p) || (c[p] = t.properties[p]), c),
188
181
  {}
189
182
  )
190
183
  },
191
184
  // Copy validation if it exists
192
- ...a.validation && { validation: a.validation }
193
- }, l = e.componentOverrides?.[g];
194
- return l ? {
185
+ ...t.validation && { validation: t.validation }
186
+ }, n = e.componentOverrides?.[m];
187
+ return n ? {
188
+ ...o,
195
189
  ...n,
196
- ...l,
197
190
  // Merge properties deeply to allow partial property updates
198
191
  properties: {
199
- ...n.properties,
200
- ...l.properties
192
+ ...o.properties,
193
+ ...n.properties
201
194
  },
202
195
  // Merge validation deeply if both exist
203
- ...n.validation && l.validation && {
196
+ ...o.validation && n.validation && {
204
197
  validation: {
205
- ...n.validation,
206
- ...l.validation
198
+ ...o.validation,
199
+ ...n.validation
207
200
  }
208
201
  }
209
- } : n;
202
+ } : o;
210
203
  })
211
204
  }));
212
205
  return {
@@ -215,10 +208,10 @@ async function S(e, r, i) {
215
208
  title: e.title || s.title,
216
209
  displayTitle: s.displayTitle,
217
210
  showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber : s.showStepNumber,
218
- sections: h,
211
+ sections: u,
219
212
  navigation: {
220
213
  // Use default navigation, then template navigation if available, then step override
221
- ...r,
214
+ ...a,
222
215
  ...s.navigation,
223
216
  // Cast since navigation might not exist in Omit type
224
217
  ...e.navigation
@@ -229,37 +222,7 @@ async function S(e, r, i) {
229
222
  }
230
223
  };
231
224
  }
232
- async function E(e) {
233
- return (await v(e)).metadata;
234
- }
235
- async function D() {
236
- const e = Object.keys(o);
237
- try {
238
- await u();
239
- const r = await m();
240
- if (r) {
241
- const i = await r.listTemplates("team");
242
- if (i.success && i.data) {
243
- const t = i.data.map((s) => s.metadata.id);
244
- return [...e, ...t];
245
- }
246
- }
247
- } catch (r) {
248
- console.warn("Failed to load team templates:", r);
249
- }
250
- return e;
251
- }
252
- function O() {
253
- return Object.keys(o);
254
- }
255
- function A() {
256
- p.clear();
257
- }
258
225
  export {
259
- A as clearTemplateCache,
260
- O as getAvailableGenericTemplates,
261
- D as getAvailableTemplates,
262
- E as getTemplateMetadata,
263
- v as loadTemplate,
264
- S as resolveTemplateStep
226
+ b as loadTemplate,
227
+ E as resolveTemplateStep
265
228
  };