@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,102 +1,59 @@
1
1
  "use client";
2
- import { useFormMachine as M } from "../../state-management/machines/useFormMachine.js";
3
- import { useRef as T, useCallback as n } from "react";
4
- const S = ({
5
- componentId: e,
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
6
  initialValue: o,
7
- onValueChange: l
7
+ onValueChange: a
8
8
  }) => {
9
- const [, , f] = M(), {
10
- evaluateComponentTriggers: a,
11
- setComponentOriginalValue: i,
12
- getComponentAlerts: h,
13
- dismissComponentAlert: u,
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
- getComponentTriggerState: F
17
- } = f, C = T(!1), g = T(o);
18
- o !== void 0 && !C.current && (i(e, o), g.current = o, C.current = !0);
19
- const t = n(
20
- (r, c) => {
21
- console.log(
22
- `๐Ÿงช [useComponentTriggers] evaluateTriggers called for ${e}:`,
23
- {
24
- eventType: r,
25
- value: c,
26
- evaluateComponentTriggers: !!a
27
- }
28
- ), a(e, r, c);
16
+ getComponentTriggerState: p
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, a]
31
- ), p = n(
32
- (r, c = "api_populated") => {
33
- i(e, r, c), g.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, i]
36
- ), $ = h(e), b = n(
37
- (r) => {
38
- u(e, r);
28
+ [r, c]
29
+ ), b = T(r), F = i(
30
+ (s) => {
31
+ l(r, s);
39
32
  },
40
- [e, u]
41
- ), s = A(e), B = m(e), O = F(e), R = n(
42
- (r) => {
43
- console.log(
44
- `๐Ÿงช [useComponentTriggers] handleValueChange called for ${e}:`,
45
- {
46
- value: r,
47
- oldValue: g.current,
48
- hasTriggers: s,
49
- onValueChange: !!l
50
- }
51
- ), g.current = r, l && l(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, l, e]
58
- ), V = n(() => {
59
- s && t("focus", g.current);
60
- }, [t, s]), d = n(() => {
61
- s && t("blur", g.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: p,
66
- alerts: $,
67
- dismissAlert: b,
68
- hasTriggers: s,
69
- hasActions: B,
70
- triggerState: O,
71
- handleValueChange: R,
72
- handleFocus: V,
73
- handleBlur: d
74
- };
75
- }, x = (e, o) => {
76
- const {
77
- handleValueChange: l,
78
- handleFocus: f,
79
- handleBlur: a,
80
- alerts: i,
81
- dismissAlert: h,
82
- setOriginalValue: u
83
- } = S({
84
- componentId: e,
85
- initialValue: o
86
- });
87
- return {
88
- // Event handlers to attach to form fields
89
- onChange: l,
90
- onFocus: f,
91
- onBlur: a,
92
- // Alert management
93
- alerts: i,
94
- dismissAlert: h,
95
- // For setting original value after API population
96
- setOriginalValue: u
45
+ evaluateTriggers: e,
46
+ setOriginalValue: R,
47
+ alerts: b,
48
+ dismissAlert: F,
49
+ hasTriggers: t,
50
+ hasActions: O,
51
+ triggerState: S,
52
+ handleValueChange: k,
53
+ handleFocus: v,
54
+ handleBlur: x
97
55
  };
98
56
  };
99
57
  export {
100
- S as useComponentTriggers,
101
- x as useFieldTriggerMonitor
58
+ _ as useComponentTriggers
102
59
  };
@@ -1,61 +1,47 @@
1
1
  "use client";
2
- import { useFormMachine as B } from "../../state-management/machines/useFormMachine.js";
3
- import { useCallback as g } from "react";
4
- import { markFieldAsUserInteracted as u } from "../utils/validationUX.js";
5
- import { useComponentTriggers as F } from "./useComponentTriggers.js";
6
- const E = ({
7
- componentId: s,
8
- hasIsDirtyTriggers: r,
9
- originalValueFromMachine: i,
2
+ import { useCallback as m } from "react";
3
+ import { markFieldAsUserInteracted as o } from "../utils/validationUX.js";
4
+ import { useComponentTriggers as B } from "./useComponentTriggers.js";
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] = B(), { setData: h } = d, t = F({ 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,12 +1,12 @@
1
1
  "use client";
2
- import { useFormMachine as p } from "../../state-management/machines/useFormMachine.js";
3
- import { useRef as F, useCallback as u, useEffect as O } from "react";
4
- import { useFormContext as h } from "./useFormContext.js";
2
+ import { useRef as F, useCallback as u, useEffect as p } from "react";
3
+ import { useFormContext as O } from "./useFormContext.js";
4
+ import { useFormMachine as h } from "../../state-management/machines/useFormMachine.js";
5
5
  const b = ({
6
6
  componentId: r,
7
7
  hasIsDirtyTriggers: s
8
8
  }) => {
9
- const [V] = p(), t = h(), a = F(!1), c = F(), d = (e) => typeof e == "string" || typeof e == "boolean" || typeof e == "number" || e === null || e === void 0, f = V.context.componentOriginalValues[r]?.value, i = d(f) ? f : void 0, g = u(() => {
9
+ const [V] = h(), t = O(), a = F(!1), c = F(), d = (e) => typeof e == "string" || typeof e == "boolean" || typeof e == "number" || e === null || e === void 0, f = V.context.componentOriginalValues[r]?.value, i = d(f) ? f : void 0, g = u(() => {
10
10
  if (a.current) return;
11
11
  const e = t.getFieldValue(r);
12
12
  return a.current = !0, e;
@@ -26,7 +26,7 @@ const b = ({
26
26
  (e, l) => i !== void 0 ? e !== i : l,
27
27
  [i]
28
28
  );
29
- return O(() => {
29
+ return p(() => {
30
30
  o();
31
31
  }, [o]), {
32
32
  originalValueFromMachine: i,
@@ -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 {
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { z as a } from "zod";
3
- const u = {
2
+ import { z as s } from "zod";
3
+ const l = {
4
4
  required: 10,
5
5
  minLength: 8,
6
6
  maxLength: 7,
@@ -10,19 +10,19 @@ const u = {
10
10
  email: 3,
11
11
  custom: 2,
12
12
  default: 1
13
- }, i = (t) => {
13
+ }, e = (t) => {
14
14
  if (typeof t == "string")
15
15
  return t.includes("verplicht") || t.includes("required") ? "required" : t.includes("minimaal") && t.includes("tekens") ? "minLength" : t.includes("maximaal") && t.includes("tekens") ? "maxLength" : t.includes("minimaal") && !t.includes("tekens") ? "min" : t.includes("maximaal") && !t.includes("tekens") ? "max" : t.includes("formaat") || t.includes("format") || t.includes("pattern") ? "pattern" : t.includes("e-mail") || t.includes("email") ? "email" : "default";
16
- if (t instanceof a.ZodError) {
17
- const e = t.errors[0];
18
- if (e?.code)
19
- switch (e.code) {
16
+ if (t instanceof s.ZodError) {
17
+ const i = t.errors[0];
18
+ if (i?.code)
19
+ switch (i.code) {
20
20
  case "too_small":
21
- return e.type === "string" ? "minLength" : "min";
21
+ return i.type === "string" ? "minLength" : "min";
22
22
  case "too_big":
23
- return e.type === "string" ? "maxLength" : "max";
23
+ return i.type === "string" ? "maxLength" : "max";
24
24
  case "invalid_string":
25
- return e.validation === "email" ? "email" : "pattern";
25
+ return i.validation === "email" ? "email" : "pattern";
26
26
  case "custom":
27
27
  return "custom";
28
28
  default:
@@ -30,27 +30,27 @@ const u = {
30
30
  }
31
31
  }
32
32
  if (typeof t == "object" && t !== null && "code" in t) {
33
- const e = t.code;
34
- if (e === "too_small") return "minLength";
35
- if (e === "too_big") return "maxLength";
36
- if (e === "invalid_string") return "email";
33
+ const i = t.code;
34
+ if (i === "too_small") return "minLength";
35
+ if (i === "too_big") return "maxLength";
36
+ if (i === "invalid_string") return "email";
37
37
  }
38
38
  return "default";
39
- }, s = (t) => {
39
+ }, a = (t) => {
40
40
  if (t == null) return "";
41
41
  if (typeof t == "string")
42
42
  return t;
43
- if (t instanceof a.ZodError)
44
- return t.errors.map((e) => e.message).join(", ");
43
+ if (t instanceof s.ZodError)
44
+ return t.errors.map((i) => i.message).join(", ");
45
45
  if (typeof t == "object" && t !== null) {
46
46
  if ("message" in t && typeof t.message == "string")
47
47
  return t.message;
48
48
  if ("_errors" in t && Array.isArray(t._errors))
49
49
  return t._errors.filter(Boolean).join(", ");
50
50
  if ("issues" in t && Array.isArray(t.issues))
51
- return t.issues.map((e) => e.message || "Validation error").join(", ");
51
+ return t.issues.map((i) => i.message || "Validation error").join(", ");
52
52
  if ("error" in t)
53
- return s(t.error);
53
+ return a(t.error);
54
54
  try {
55
55
  if (Object.keys(t).length > 0) {
56
56
  for (const n of ["message", "msg", "error", "description"])
@@ -61,33 +61,22 @@ const u = {
61
61
  }
62
62
  }
63
63
  try {
64
- const e = JSON.stringify(t);
65
- if (e.length < 200)
66
- return e;
64
+ const i = JSON.stringify(t);
65
+ if (i.length < 200)
66
+ return i;
67
67
  } catch {
68
68
  }
69
69
  return "Validation error occurred";
70
- }, c = (t) => t.filter((e) => e != null).map((e) => s(e)).filter((e) => e.length > 0), m = (t) => {
70
+ }, f = (t) => {
71
71
  if (!t || t.length === 0) return "";
72
- const e = t.filter((n) => n != null).map((n) => ({
73
- message: s(n),
74
- type: i(n),
75
- priority: u[i(n)]
72
+ const i = t.filter((n) => n != null).map((n) => ({
73
+ message: a(n),
74
+ type: e(n),
75
+ priority: l[e(n)]
76
76
  })).filter((n) => n.message.length > 0);
77
- return e.length === 0 ? "" : (e.sort((n, l) => l.priority - n.priority), e[0].message);
78
- }, g = (t) => c(t)[0] || "", d = (t) => t.map((e, n) => ({
79
- index: n,
80
- type: typeof e,
81
- constructor: e?.constructor?.name,
82
- raw: e,
83
- parsed: s(e),
84
- validationType: i(e),
85
- priority: u[i(e)]
86
- }));
77
+ return i.length === 0 ? "" : (i.sort((n, u) => u.priority - n.priority), i[0].message);
78
+ };
87
79
  export {
88
- d as getErrorDebugInfo,
89
- g as getFirstErrorMessage,
90
- m as getMostRelevantError,
91
- c as parseAllErrors,
92
- s as parseError
80
+ f as getMostRelevantError,
81
+ a as parseError
93
82
  };
@@ -1,50 +1,39 @@
1
1
  "use client";
2
- function n(u, f = {}) {
3
- const t = u, { updatedFields: a, debug: r = !1 } = f;
4
- r && console.log("๐Ÿ”„ [formDirtyStateSync] Starting dirty state reset:", {
5
- updatedFields: a,
6
- formState: {
7
- isDirty: t.state.isDirty,
8
- dirtyFields: t.state.dirtyFields,
9
- values: t.state.values
10
- }
11
- });
2
+ function n(a, u = {}) {
3
+ const e = a, { updatedFields: c, debug: o = !1 } = u;
12
4
  try {
13
- const i = Object.keys(t.state.values), c = a || i;
14
- r && console.log("๐Ÿ”„ [formDirtyStateSync] Fields to reset:", c), c.forEach((e) => {
15
- const s = t.getFieldValue(e), o = t.getFieldMeta(e);
16
- if (r && console.log(`๐Ÿ”„ [formDirtyStateSync] Resetting field ${e}:`, {
17
- currentValue: s,
18
- isDirtyBefore: o?.isDirty,
19
- isTouchedBefore: o?.isTouched,
20
- isDefaultValueBefore: o?.isDefaultValue
21
- }), t.resetField(e), s != null && s !== "" && t.setFieldValue(e, s, {
5
+ const s = Object.keys(e.state.values);
6
+ (c || s).forEach((t) => {
7
+ const r = e.getFieldValue(t), i = e.getFieldMeta(t);
8
+ if (o && console.log(`[formDirtyStateSync] Field ${t} before reset:`, {
9
+ currentValue: r,
10
+ isDirtyBefore: i?.isDirty,
11
+ isTouchedBefore: i?.isTouched,
12
+ isDefaultValueBefore: i?.isDefaultValue
13
+ }), e.resetField(t), r != null && r !== "" && e.setFieldValue(t, r, {
22
14
  dontUpdateMeta: !0
23
15
  // This prevents updating isDirty/isTouched flags
24
- }), r) {
25
- const l = t.getFieldMeta(e);
26
- console.log(
27
- `โœ… [formDirtyStateSync] Field ${e} reset complete:`,
28
- {
29
- isDirtyAfter: l?.isDirty,
30
- isTouchedAfter: l?.isTouched,
31
- isDefaultValueAfter: l?.isDefaultValue,
32
- currentValueAfter: t.getFieldValue(e)
33
- }
34
- );
16
+ }), o) {
17
+ const l = e.getFieldMeta(t);
18
+ console.log(`[formDirtyStateSync] Field ${t} reset complete:`, {
19
+ isDirtyAfter: l?.isDirty,
20
+ isTouchedAfter: l?.isTouched,
21
+ isDefaultValueAfter: l?.isDefaultValue,
22
+ currentValueAfter: e.getFieldValue(t)
23
+ });
35
24
  }
36
- }), r && console.log("โœ… [formDirtyStateSync] Dirty state reset complete:", {
25
+ }), o && console.log("[formDirtyStateSync] Reset complete:", {
37
26
  formStateAfter: {
38
- isDirty: t.state.isDirty,
39
- dirtyFields: t.state.dirtyFields,
40
- values: t.state.values
27
+ isDirty: e.state.isDirty,
28
+ dirtyFields: e.state.dirtyFields,
29
+ values: e.state.values
41
30
  }
42
31
  });
43
- } catch (i) {
32
+ } catch (s) {
44
33
  throw console.error(
45
34
  "โŒ [formDirtyStateSync] Error during dirty state reset:",
46
- i
47
- ), i;
35
+ s
36
+ ), s;
48
37
  }
49
38
  }
50
39
  export {
@@ -39,13 +39,13 @@ class n {
39
39
  * Debug level logging
40
40
  */
41
41
  debug(e, o) {
42
- this.config.enabled && console.log(`๐Ÿ”ง [FormField] ${e}`, o);
42
+ this.config.enabled && console.log(`[FormField] ${e}`, ...o !== void 0 ? [o] : []);
43
43
  }
44
44
  /**
45
45
  * Info level logging
46
46
  */
47
47
  info(e, o) {
48
- this.config.enabled && console.log(`โ„น๏ธ [FormField] ${e}`, o);
48
+ this.config.enabled && console.log(`[FormField] ${e}`, ...o !== void 0 ? [o] : []);
49
49
  }
50
50
  /**
51
51
  * Warning level logging
@@ -69,43 +69,43 @@ class n {
69
69
  * Validation specific logging
70
70
  */
71
71
  validation(e, o) {
72
- this.config.enabled && console.log(`๐Ÿ” [FormField] ${e}`, o);
72
+ this.config.enabled && console.log(`[FormField:validation] ${e}`, ...o !== void 0 ? [o] : []);
73
73
  }
74
74
  /**
75
75
  * State management specific logging
76
76
  */
77
77
  state(e, o) {
78
- this.config.enabled && console.log(`๐Ÿ“‹ [FormField] ${e}`, o);
78
+ this.config.enabled && console.log(`[FormField:state] ${e}`, ...o !== void 0 ? [o] : []);
79
79
  }
80
80
  /**
81
81
  * Component lifecycle logging
82
82
  */
83
83
  lifecycle(e, o) {
84
- this.config.enabled && console.log(`๐Ÿ [FormField] ${e}`, o);
84
+ this.config.enabled && console.log(`[FormField:lifecycle] ${e}`, ...o !== void 0 ? [o] : []);
85
85
  }
86
86
  /**
87
87
  * Change event logging
88
88
  */
89
89
  change(e, o) {
90
- this.config.enabled && console.log(`๐Ÿ”„ [FormField] ${e}`, o);
90
+ this.config.enabled && console.log(`[FormField:change] ${e}`, ...o !== void 0 ? [o] : []);
91
91
  }
92
92
  /**
93
93
  * Test/experimental logging
94
94
  */
95
95
  test(e, o) {
96
- this.config.enabled && console.log(`๐Ÿงช [FormField] ${e}`, o);
96
+ this.config.enabled && console.log(`[FormField:test] ${e}`, ...o !== void 0 ? [o] : []);
97
97
  }
98
98
  }
99
- const i = new n(), l = () => i.setEnabled(!0), t = () => i.setEnabled(!1), d = () => i.isEnabled();
99
+ const i = new n(), l = () => i.setEnabled(!0), d = () => i.setEnabled(!1), t = () => i.isEnabled();
100
100
  typeof window < "u" && (window.formFieldLogger = {
101
101
  enable: l,
102
- disable: t,
103
- isEnabled: d,
102
+ disable: d,
103
+ isEnabled: t,
104
104
  logger: i
105
105
  });
106
106
  export {
107
- t as disableFormFieldLogging,
107
+ d as disableFormFieldLogging,
108
108
  l as enableFormFieldLogging,
109
- d as isFormFieldLoggingEnabled,
109
+ t as isFormFieldLoggingEnabled,
110
110
  i as logger
111
111
  };