@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.
- package/core/src/types/guards.js +0 -12
- package/core/src/utils/apiBodyUtils.js +43 -75
- package/features/form-runtime/components/FormFooter.d.ts +5 -0
- package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
- package/features/state-management/machines/formMachine.d.ts +3 -0
- package/features/state-management/machines/types.d.ts +4 -0
- package/features/state-management/machines/useFormMachine.d.ts +18 -0
- package/index.d.ts +2 -8
- package/index.js +2 -108
- package/package.json +1 -30
- package/styles.css +1 -1
- package/ui/src/lib/utils/templateUtils.js +11 -43
- package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
- package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
- package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
- package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +56 -78
- package/wizard/src/features/form-runtime/components/FormField.js +28 -28
- package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +152 -196
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +82 -91
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
- package/wizard/src/features/form-runtime/config/configResolver.js +10 -14
- package/wizard/src/features/form-runtime/config/templateLoader.js +71 -108
- package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +45 -88
- package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +27 -41
- package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +5 -5
- package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
- package/wizard/src/features/form-runtime/utils/errorUtils.js +31 -42
- package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
- package/wizard/src/features/form-runtime/utils/logger.js +12 -12
- package/wizard/src/features/form-runtime/utils/validationUX.js +14 -55
- package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
- package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
- package/wizard/src/features/state-management/machines/formMachine.js +558 -677
- package/wizard/src/features/state-management/machines/useFormMachine.js +172 -190
- package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
- package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
- package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
- package/wizard/src/features/validation-system/validation/ValidationEngine.js +24 -29
- package/wizard/src/features/validation-system/validation/ValidationExecutor.js +26 -58
- package/FormWizard.d.ts +0 -10
- package/core/src/types/api.js +0 -12
- package/core/src/types/form-config.js +0 -60
- package/core/src/types/form-wizard-config-schema.js +0 -113
- package/core/src/types/validation.js +0 -61
- package/features/api-integration.d.ts +0 -2
- package/features/api-integration.js +0 -17
- package/features/dialog-system.d.ts +0 -2
- package/features/dialog-system.js +0 -9
- package/features/form-runtime/utils/formSaver.d.ts +0 -22
- package/features/form-runtime.d.ts +0 -2
- package/features/form-runtime.js +0 -63
- package/features/index.d.ts +0 -11
- package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
- package/features/state-management/machines/__tests__/setup.d.ts +0 -0
- package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
- package/features/state-management/machines/actions/validationActions.d.ts +0 -68
- package/features/state-management/machines/lazyLoading.d.ts +0 -34
- package/features/state-management/machines/validation/index.d.ts +0 -5
- package/features/state-management/machines/validation/validateField.d.ts +0 -2
- package/features/state-management/machines/validation/validateForm.d.ts +0 -2
- package/features/state-management/machines/validation/validateSection.d.ts +0 -2
- package/features/state-management/machines/validation/validateStep.d.ts +0 -2
- package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
- package/features/state-management.d.ts +0 -2
- package/features/state-management.js +0 -21
- package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
- package/features/trigger-action-system.d.ts +0 -2
- package/features/trigger-action-system.js +0 -12
- package/features/validation-system.d.ts +0 -2
- package/features/validation-system.js +0 -23
- package/styles/index.d.ts +0 -0
- package/ui/src/components/badge/badge.js +0 -20
- package/ui/src/components/badge/badge.module.css.js +0 -12
- package/wizard/src/features/api-integration/services/ActionExecutor.js +0 -339
- package/wizard/src/features/api-integration/services/ApiCallExecutor.js +0 -6
- package/wizard/src/features/api-integration/services/DialogExecutor.js +0 -6
- package/wizard/src/features/api-integration/services/GenericTriggerService.js +0 -284
- package/wizard/src/features/api-integration/services/NavigationExecutor.js +0 -6
- package/wizard/src/features/form-runtime/config/templateConfig.js +0 -156
- package/wizard/src/features/form-runtime/config/templateUtils.js +0 -14
- package/wizard/src/features/form-runtime/utils/validation.js +0 -100
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +0 -46
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +0 -30
- package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +0 -376
- package/wizard/src/features/validation-system/components/ValidationDebugger.js +0 -69
- package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +0 -17
- package/wizard/src/features/validation-system/validation/validationService.js +0 -74
|
@@ -1,102 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
const
|
|
5
|
-
componentId:
|
|
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:
|
|
7
|
+
onValueChange: a
|
|
8
8
|
}) => {
|
|
9
|
-
const [, ,
|
|
10
|
-
evaluateComponentTriggers:
|
|
11
|
-
setComponentOriginalValue:
|
|
12
|
-
getComponentAlerts:
|
|
13
|
-
dismissComponentAlert:
|
|
9
|
+
const [, , C] = z(), {
|
|
10
|
+
evaluateComponentTriggers: u,
|
|
11
|
+
setComponentOriginalValue: c,
|
|
12
|
+
getComponentAlerts: T,
|
|
13
|
+
dismissComponentAlert: l,
|
|
14
14
|
hasComponentTriggers: A,
|
|
15
15
|
hasComponentActions: m,
|
|
16
|
-
getComponentTriggerState:
|
|
17
|
-
} =
|
|
18
|
-
o !== void 0 && !
|
|
19
|
-
const
|
|
20
|
-
(
|
|
21
|
-
|
|
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
|
-
[
|
|
31
|
-
),
|
|
32
|
-
(
|
|
33
|
-
|
|
23
|
+
[r, u]
|
|
24
|
+
), R = i(
|
|
25
|
+
(s, g = "api_populated") => {
|
|
26
|
+
c(r, s, g), n.current = s;
|
|
34
27
|
},
|
|
35
|
-
[
|
|
36
|
-
),
|
|
37
|
-
(
|
|
38
|
-
|
|
28
|
+
[r, c]
|
|
29
|
+
), b = T(r), F = i(
|
|
30
|
+
(s) => {
|
|
31
|
+
l(r, s);
|
|
39
32
|
},
|
|
40
|
-
[
|
|
41
|
-
),
|
|
42
|
-
(
|
|
43
|
-
|
|
44
|
-
`๐งช [useComponentTriggers] handleValueChange called for ${e}:`,
|
|
45
|
-
{
|
|
46
|
-
value: r,
|
|
47
|
-
oldValue: 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
|
-
[
|
|
58
|
-
),
|
|
59
|
-
|
|
60
|
-
}, [
|
|
61
|
-
|
|
62
|
-
}, [
|
|
38
|
+
[e, t, a, r]
|
|
39
|
+
), v = i(() => {
|
|
40
|
+
t && e("focus", n.current);
|
|
41
|
+
}, [e, t]), x = i(() => {
|
|
42
|
+
t && e("blur", n.current);
|
|
43
|
+
}, [e, t]);
|
|
63
44
|
return {
|
|
64
|
-
evaluateTriggers:
|
|
65
|
-
setOriginalValue:
|
|
66
|
-
alerts:
|
|
67
|
-
dismissAlert:
|
|
68
|
-
hasTriggers:
|
|
69
|
-
hasActions:
|
|
70
|
-
triggerState:
|
|
71
|
-
handleValueChange:
|
|
72
|
-
handleFocus:
|
|
73
|
-
handleBlur:
|
|
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
|
-
|
|
101
|
-
x as useFieldTriggerMonitor
|
|
58
|
+
_ as useComponentTriggers
|
|
102
59
|
};
|
|
@@ -1,61 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
7
|
-
componentId:
|
|
8
|
-
hasIsDirtyTriggers:
|
|
9
|
-
originalValueFromMachine:
|
|
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 [, ,
|
|
14
|
-
(
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
23
|
+
s.hasTriggers && !i && a !== e && s.handleValueChange(e);
|
|
38
24
|
},
|
|
39
25
|
[
|
|
40
|
-
|
|
26
|
+
r,
|
|
41
27
|
h,
|
|
42
28
|
f,
|
|
43
|
-
r,
|
|
44
29
|
i,
|
|
30
|
+
l,
|
|
45
31
|
n,
|
|
46
|
-
|
|
32
|
+
s
|
|
47
33
|
]
|
|
48
|
-
),
|
|
49
|
-
(
|
|
50
|
-
|
|
34
|
+
), c = m(
|
|
35
|
+
(t) => () => {
|
|
36
|
+
o(r), t.handleBlur(), s.hasTriggers && s.handleBlur();
|
|
51
37
|
},
|
|
52
|
-
[
|
|
38
|
+
[r, s]
|
|
53
39
|
);
|
|
54
40
|
return {
|
|
55
41
|
handleChange: C,
|
|
56
|
-
handleBlur:
|
|
42
|
+
handleBlur: c
|
|
57
43
|
};
|
|
58
44
|
};
|
|
59
45
|
export {
|
|
60
|
-
|
|
46
|
+
b as useFieldEventHandlers
|
|
61
47
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
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] =
|
|
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
|
|
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
|
|
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:
|
|
5
|
+
componentId: e
|
|
5
6
|
}) => {
|
|
6
|
-
const [
|
|
7
|
-
|
|
8
|
-
}, [])
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
20
|
+
return window.addEventListener(
|
|
18
21
|
"triggerFieldValidation",
|
|
19
|
-
|
|
20
|
-
), window.addEventListener(
|
|
21
|
-
"triggerStepValidation",
|
|
22
|
-
l
|
|
22
|
+
o
|
|
23
23
|
), () => {
|
|
24
24
|
window.removeEventListener(
|
|
25
25
|
"triggerFieldValidation",
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
"triggerStepValidation",
|
|
29
|
-
l
|
|
30
|
-
), a.current = null;
|
|
26
|
+
o
|
|
27
|
+
);
|
|
31
28
|
};
|
|
32
|
-
}, [
|
|
33
|
-
forceShowValidation:
|
|
34
|
-
resetValidationState:
|
|
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
|
|
3
|
-
const
|
|
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
|
-
},
|
|
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
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
switch (
|
|
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
|
|
21
|
+
return i.type === "string" ? "minLength" : "min";
|
|
22
22
|
case "too_big":
|
|
23
|
-
return
|
|
23
|
+
return i.type === "string" ? "maxLength" : "max";
|
|
24
24
|
case "invalid_string":
|
|
25
|
-
return
|
|
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
|
|
34
|
-
if (
|
|
35
|
-
if (
|
|
36
|
-
if (
|
|
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
|
-
},
|
|
39
|
+
}, a = (t) => {
|
|
40
40
|
if (t == null) return "";
|
|
41
41
|
if (typeof t == "string")
|
|
42
42
|
return t;
|
|
43
|
-
if (t instanceof
|
|
44
|
-
return t.errors.map((
|
|
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((
|
|
51
|
+
return t.issues.map((i) => i.message || "Validation error").join(", ");
|
|
52
52
|
if ("error" in t)
|
|
53
|
-
return
|
|
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
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
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
|
-
},
|
|
70
|
+
}, f = (t) => {
|
|
71
71
|
if (!t || t.length === 0) return "";
|
|
72
|
-
const
|
|
73
|
-
message:
|
|
74
|
-
type:
|
|
75
|
-
priority:
|
|
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
|
|
78
|
-
}
|
|
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
|
-
|
|
89
|
-
|
|
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(
|
|
3
|
-
const
|
|
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
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
17
|
-
currentValue:
|
|
18
|
-
isDirtyBefore:
|
|
19
|
-
isTouchedBefore:
|
|
20
|
-
isDefaultValueBefore:
|
|
21
|
-
}),
|
|
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
|
-
}),
|
|
25
|
-
const l =
|
|
26
|
-
console.log(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
}),
|
|
25
|
+
}), o && console.log("[formDirtyStateSync] Reset complete:", {
|
|
37
26
|
formStateAfter: {
|
|
38
|
-
isDirty:
|
|
39
|
-
dirtyFields:
|
|
40
|
-
values:
|
|
27
|
+
isDirty: e.state.isDirty,
|
|
28
|
+
dirtyFields: e.state.dirtyFields,
|
|
29
|
+
values: e.state.values
|
|
41
30
|
}
|
|
42
31
|
});
|
|
43
|
-
} catch (
|
|
32
|
+
} catch (s) {
|
|
44
33
|
throw console.error(
|
|
45
34
|
"โ [formDirtyStateSync] Error during dirty state reset:",
|
|
46
|
-
|
|
47
|
-
),
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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(
|
|
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),
|
|
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:
|
|
103
|
-
isEnabled:
|
|
102
|
+
disable: d,
|
|
103
|
+
isEnabled: t,
|
|
104
104
|
logger: i
|
|
105
105
|
});
|
|
106
106
|
export {
|
|
107
|
-
|
|
107
|
+
d as disableFormFieldLogging,
|
|
108
108
|
l as enableFormFieldLogging,
|
|
109
|
-
|
|
109
|
+
t as isFormFieldLoggingEnabled,
|
|
110
110
|
i as logger
|
|
111
111
|
};
|