@digiform/wizard 0.3.1 → 0.3.3

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 (54) 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/form-runtime/index.d.ts +0 -1
  4. package/features/state-management/machines/formMachine.d.ts +3 -0
  5. package/features/state-management/machines/types.d.ts +4 -0
  6. package/features/state-management/machines/useFormMachine.d.ts +24 -6
  7. package/package.json +31 -15
  8. package/styles.css +1 -1
  9. package/ui/src/lib/types/guards.js +1 -5
  10. package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
  11. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
  12. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
  13. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
  14. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +48 -95
  15. package/wizard/src/features/form-runtime/FormWizard/FormWizard.module.css.js +4 -12
  16. package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
  17. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +150 -194
  18. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +92 -108
  19. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
  20. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +44 -63
  21. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +26 -40
  22. package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
  23. package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
  24. package/wizard/src/features/form-runtime/utils/logger.js +12 -12
  25. package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
  26. package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
  27. package/wizard/src/features/state-management/machines/formMachine.js +558 -677
  28. package/wizard/src/features/state-management/machines/useFormMachine.js +173 -191
  29. package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
  30. package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
  31. package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
  32. package/wizard/src/features/validation-system/validation/ValidationExecutor.js +47 -87
  33. package/core/src/types/guards.js +0 -7
  34. package/features/form-runtime/config/configResolver.d.ts +0 -14
  35. package/features/form-runtime/config/index.d.ts +0 -9
  36. package/features/form-runtime/config/templateConfig.d.ts +0 -148
  37. package/features/form-runtime/config/templateLoader.d.ts +0 -25
  38. package/features/form-runtime/config/templateUtils.d.ts +0 -12
  39. package/features/form-runtime/utils/formSaver.d.ts +0 -22
  40. package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
  41. package/features/state-management/machines/__tests__/setup.d.ts +0 -0
  42. package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
  43. package/features/state-management/machines/actions/validationActions.d.ts +0 -68
  44. package/features/state-management/machines/lazyLoading.d.ts +0 -34
  45. package/features/state-management/machines/validation/index.d.ts +0 -5
  46. package/features/state-management/machines/validation/validateField.d.ts +0 -2
  47. package/features/state-management/machines/validation/validateForm.d.ts +0 -2
  48. package/features/state-management/machines/validation/validateSection.d.ts +0 -2
  49. package/features/state-management/machines/validation/validateStep.d.ts +0 -2
  50. package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
  51. package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
  52. package/ui/src/lib/utils/templateUtils.js +0 -20
  53. package/wizard/src/features/form-runtime/config/configResolver.js +0 -34
  54. package/wizard/src/features/form-runtime/config/templateLoader.js +0 -235
@@ -1,141 +1,125 @@
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 f, jsx as r, Fragment as _ } from "react/jsx-runtime";
3
+ import g 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 { logger as w } from "../../../../../../ui/src/lib/logger.js";
6
+ import { useForm as I } from "@tanstack/react-form";
8
7
  import { useRef as p } from "react";
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";
8
+ import { LoaderProvider as M, useLoaderContext as C } from "../../context/LoaderContext.js";
9
+ import { FormProvider as U } from "../../hooks/useFormContext.js";
10
+ import { buildDefaultValues as k } from "../../utils/formDataBuilder.js";
11
+ import { resetFormDirtyStateAfterApiPopulation as W } from "../../utils/formDirtyStateSync.js";
13
12
  import j from "../FormFooter.js";
14
13
  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";
19
- import { ValidationEngine as B } from "../../../validation-system/validation/ValidationEngine.js";
20
- const J = ({
21
- currentStep: s,
22
- hasStepLoader: a,
23
- loaderConfig: o
14
+ import G from "../FormSection/FormSection.js";
15
+ import { ProgressLoaderRuntime as H } from "../ProgressLoaderRuntime.js";
16
+ import { useFormMachine as K } from "../../../state-management/machines/useFormMachine.js";
17
+ import { EnhancedActionExecutor as Q } from "../../../api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js";
18
+ import { ValidationEngine as X } from "../../../validation-system/validation/ValidationEngine.js";
19
+ const q = ({
20
+ currentStep: n,
21
+ hasStepLoader: s,
22
+ loaderConfig: t
24
23
  }) => {
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,
24
+ const { isLoadingComplete: o } = C(), l = n.sections || [];
25
+ return /* @__PURE__ */ f("div", { className: g.stepContent, children: [
26
+ s && /* @__PURE__ */ r("div", { className: g.loaderWrapper, children: /* @__PURE__ */ r(
27
+ H,
29
28
  {
30
29
  properties: {
31
- label: o?.label,
32
- showPercentage: o?.showPercentage ?? !0,
33
- duration: o?.duration ?? 3,
34
- size: o?.size ?? "md",
35
- variant: o?.variant ?? "default",
36
- animationSpeed: o?.animationSpeed ?? "normal",
30
+ label: t?.label,
31
+ showPercentage: t?.showPercentage ?? !0,
32
+ duration: t?.duration ?? 3,
33
+ size: t?.size ?? "md",
34
+ variant: t?.variant ?? "default",
35
+ animationSpeed: t?.animationSpeed ?? "normal",
37
36
  autoStart: !0,
38
37
  hideOnComplete: !0,
39
- onComplete: o?.completionMessage ? {
38
+ onComplete: t?.completionMessage ? {
40
39
  showMessage: {
41
40
  enabled: !0,
42
- text: o.completionMessage,
41
+ text: t.completionMessage,
43
42
  type: "success"
44
43
  }
45
44
  } : void 0
46
45
  }
47
46
  }
48
47
  ) }),
49
- (!a || t) && /* @__PURE__ */ i(M, { children: d.map((c) => /* @__PURE__ */ i(q, { section: c }, c.id)) })
48
+ (!s || o) && /* @__PURE__ */ r(_, { children: l.map((c) => /* @__PURE__ */ r(G, { section: c }, c.id)) })
50
49
  ] });
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,
55
- sections: []
56
- }) : u.current = c.current.getStepSchema(t), F.current = t.id);
57
- const v = { ...m(t) ? E({
58
- ...t,
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(() => {
64
- y("onStepLoad"), setTimeout(() => {
65
- g.current = !1;
50
+ }, B = () => {
51
+ const [n, s, t] = K(), { currentStep: o, config: l } = t, c = p(), h = p(), S = p(), A = l.validationMessageStyle || "withLabel";
52
+ c.current || (c.current = new X({ messageStyle: A })), (!h.current || S.current !== o.id) && (h.current = c.current.getStepSchema(o), S.current = o.id);
53
+ const E = { ...k(o), ...t.data }, v = (e) => {
54
+ (o.actions || []).length > 0 && s({ type: "EXECUTE_ACTIONS", trigger: e });
55
+ }, F = p(), u = p(!1);
56
+ o.id !== F.current && (o.actions || []).length > 0 && !u.current && (F.current = o.id, u.current = !0, setTimeout(() => {
57
+ v("onStepLoad"), setTimeout(() => {
58
+ u.current = !1;
66
59
  }, 1e3);
67
60
  }, 0));
68
- const N = async ({
61
+ const b = async ({
69
62
  value: e
70
63
  }) => {
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) => {
64
+ (o.actions || []).some(
65
+ (d) => d.trigger === "onStepFinish"
66
+ ) ? s({ type: "REQUEST_NAVIGATION", navigationType: "next" }) : t.nextStep();
67
+ }, y = (e) => {
68
+ }, T = (e) => {
69
+ w.error("Action execution failed", { error: e.message }, e);
82
70
  }, 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) => {
71
+ s({ type: "SHOW_ACTION_DIALOG", dialogConfig: e });
72
+ }, N = (e) => {
87
73
  switch (e.type) {
88
74
  case "next":
89
- o.nextStep();
75
+ t.nextStep();
90
76
  break;
91
77
  case "previous":
92
- o.previousStep();
78
+ t.previousStep();
93
79
  break;
94
80
  case "step":
95
- e.targetStep && o.goToStep(e.targetStep);
81
+ e.targetStep && t.goToStep(e.targetStep);
96
82
  break;
97
83
  }
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);
84
+ }, m = I({
85
+ defaultValues: E,
86
+ onSubmit: b
87
+ }), D = (e, i) => {
88
+ const a = e, d = m.getFieldValue(a), V = n.context.componentOriginalValues[a]?.value;
89
+ if (d !== i) {
90
+ const P = i;
91
+ t.setData(a, P), m.setFieldValue(a, i);
108
92
  try {
109
- H(l, {
110
- updatedFields: [r],
93
+ W(m, {
94
+ updatedFields: [a],
111
95
  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);
96
+ });
97
+ } catch (R) {
98
+ console.error("❌ Failed to reset dirty state:", R);
115
99
  }
116
100
  }
117
- R !== n && (console.log("🎯 Marking component as populated:", { componentId: r, value: n }), setTimeout(() => {
118
- a({
101
+ V !== i && setTimeout(() => {
102
+ s({
119
103
  type: "MARK_COMPONENT_AS_POPULATED",
120
- componentId: r,
121
- value: n
104
+ componentId: a,
105
+ value: i
122
106
  });
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,
107
+ }, 0);
108
+ }, x = o.waitForLoader === !0, O = x ? o.loaderConfig : void 0;
109
+ return /* @__PURE__ */ f(U, { value: m, children: [
110
+ n.matches("executingActions") && (n.context.executingTrigger === "onStepLoad" || n.context.executingTrigger === "onStepFinish") && /* @__PURE__ */ r(
111
+ Q,
128
112
  {
129
- actions: t.actions || [],
130
- trigger: s.context.executingTrigger || "onStepLoad",
131
- formData: s.context.data,
132
- onComplete: D,
133
- onError: L,
134
- onFieldUpdate: w,
135
- onShowDialog: O,
136
- onNavigate: V,
113
+ actions: o.actions || [],
114
+ trigger: n.context.executingTrigger || "onStepLoad",
115
+ formData: n.context.data,
116
+ onComplete: y,
117
+ onError: T,
118
+ onFieldUpdate: D,
119
+ onShowDialog: L,
120
+ onNavigate: N,
137
121
  machineRef: {
138
- send: a
122
+ send: s
139
123
  }
140
124
  }
141
125
  ),
@@ -143,25 +127,25 @@ const J = ({
143
127
  "form",
144
128
  {
145
129
  onSubmit: (e) => {
146
- e.preventDefault(), e.stopPropagation(), l.handleSubmit();
130
+ e.preventDefault(), e.stopPropagation(), m.handleSubmit();
147
131
  },
148
132
  children: [
149
- /* @__PURE__ */ i(z, {}),
150
- /* @__PURE__ */ i(k, { children: /* @__PURE__ */ i(
151
- J,
133
+ /* @__PURE__ */ r(z, {}),
134
+ /* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(
135
+ q,
152
136
  {
153
- currentStep: t,
154
- hasStepLoader: T,
155
- loaderConfig: _
137
+ currentStep: o,
138
+ hasStepLoader: x,
139
+ loaderConfig: O
156
140
  }
157
141
  ) }),
158
- /* @__PURE__ */ i(j, { className: h.footer })
142
+ /* @__PURE__ */ r(j, { className: g.footer })
159
143
  ]
160
144
  }
161
145
  )
162
146
  ] });
163
147
  };
164
- Y.displayName = "FormStep";
148
+ B.displayName = "FormStep";
165
149
  export {
166
- Y as default
150
+ B as default
167
151
  };
@@ -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,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
  };
@@ -1,61 +1,47 @@
1
1
  "use client";
2
- import { useCallback as g } from "react";
3
- import { markFieldAsUserInteracted as u } from "../utils/validationUX.js";
2
+ import { useCallback as m } from "react";
3
+ import { markFieldAsUserInteracted as o } from "../utils/validationUX.js";
4
4
  import { useComponentTriggers as B } from "./useComponentTriggers.js";
5
- import { useFormMachine as F } from "../../state-management/machines/useFormMachine.js";
6
- const E = ({
7
- componentId: s,
8
- hasIsDirtyTriggers: r,
9
- originalValueFromMachine: i,
5
+ import { useFormMachine as k } from "../../state-management/machines/useFormMachine.js";
6
+ const b = ({
7
+ componentId: r,
8
+ hasIsDirtyTriggers: i,
9
+ originalValueFromMachine: l,
10
10
  getEnhancedIsDirty: n,
11
11
  resetValidationState: f
12
12
  }) => {
13
- const [, , d] = F(), { setData: h } = d, t = B({ componentId: s }), C = g(
14
- (a) => (e) => {
15
- const l = a.state.value;
16
- if (console.log(
17
- `🔍 [useFieldEventHandlers] handleChange for ${s}:`,
18
- {
19
- oldValue: l,
20
- newValue: e,
21
- valueType: typeof e,
22
- isSameValue: l === e
23
- }
24
- ), u(s), a.handleChange(e), console.log(
25
- `🔍 [useFieldEventHandlers] AFTER field.handleChange for ${s}:`,
26
- {
27
- fieldStateValue: a.state.value,
28
- fieldStateMeta: a.state.meta
29
- }
30
- ), l !== e && h(s, e), f(), r && i !== void 0) {
31
- const c = n(
32
- l,
33
- a.state.meta.isDirty
34
- ), o = e !== i;
35
- o !== c && (o ? t.evaluateTriggers("valueChange", e) : t.dismissAlert());
13
+ const [, , u] = k(), { setData: h } = u, s = B({ componentId: r }), C = m(
14
+ (t) => (e) => {
15
+ const a = t.state.value;
16
+ if (o(r), t.handleChange(e), a !== e && h(r, e), f(), i && l !== void 0) {
17
+ const d = n(
18
+ a,
19
+ t.state.meta.isDirty
20
+ ), g = e !== l;
21
+ g !== d && (g ? s.evaluateTriggers("valueChange", e) : s.dismissAlert());
36
22
  }
37
- t.hasTriggers && !r && l !== e && t.handleValueChange(e);
23
+ s.hasTriggers && !i && a !== e && s.handleValueChange(e);
38
24
  },
39
25
  [
40
- s,
26
+ r,
41
27
  h,
42
28
  f,
43
- r,
44
29
  i,
30
+ l,
45
31
  n,
46
- t
32
+ s
47
33
  ]
48
- ), m = g(
49
- (a) => () => {
50
- u(s), a.handleBlur(), t.hasTriggers && t.handleBlur();
34
+ ), c = m(
35
+ (t) => () => {
36
+ o(r), t.handleBlur(), s.hasTriggers && s.handleBlur();
51
37
  },
52
- [s, t]
38
+ [r, s]
53
39
  );
54
40
  return {
55
41
  handleChange: C,
56
- handleBlur: m
42
+ handleBlur: c
57
43
  };
58
44
  };
59
45
  export {
60
- E as useFieldEventHandlers
46
+ b as useFieldEventHandlers
61
47
  };
@@ -1,37 +1,34 @@
1
1
  "use client";
2
- import { useState as s, useRef as u, useCallback as c, useEffect as f } from "react";
2
+ import { useState as c, useCallback as f, useMemo as u, useEffect as r } from "react";
3
+ import { useFormMachine as V } from "../../state-management/machines/useFormMachine.js";
3
4
  const w = ({
4
- componentId: t
5
+ componentId: e
5
6
  }) => {
6
- const [d, i] = s(!1), a = u(null), o = c(() => {
7
- i(!1);
8
- }, []);
9
- return f(() => {
10
- const r = (n) => {
11
- const { fieldId: e } = n.detail;
12
- e === t && i(!0);
13
- }, l = (n) => {
14
- const { fieldIds: e } = n.detail;
15
- Array.isArray(e) && e.includes(t) && i(!0);
7
+ const [i] = V(), [n, t] = c(!1), s = f(() => {
8
+ t(!1);
9
+ }, []), a = u(
10
+ () => i.context.forcedValidationFields.includes(e),
11
+ [i.context.forcedValidationFields, e]
12
+ );
13
+ return r(() => {
14
+ a && t(!0);
15
+ }, [a]), r(() => {
16
+ const o = (d) => {
17
+ const { fieldId: l } = d.detail;
18
+ l === e && t(!0);
16
19
  };
17
- return a.current = r, window.addEventListener(
20
+ return window.addEventListener(
18
21
  "triggerFieldValidation",
19
- r
20
- ), window.addEventListener(
21
- "triggerStepValidation",
22
- l
22
+ o
23
23
  ), () => {
24
24
  window.removeEventListener(
25
25
  "triggerFieldValidation",
26
- r
27
- ), window.removeEventListener(
28
- "triggerStepValidation",
29
- l
30
- ), a.current = null;
26
+ o
27
+ );
31
28
  };
32
- }, [t]), {
33
- forceShowValidation: d,
34
- resetValidationState: o
29
+ }, [e]), {
30
+ forceShowValidation: n,
31
+ resetValidationState: s
35
32
  };
36
33
  };
37
34
  export {