@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.
- package/features/form-runtime/components/FormFooter.d.ts +5 -0
- package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
- package/features/form-runtime/index.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 +24 -6
- package/package.json +31 -15
- package/styles.css +1 -1
- package/ui/src/lib/types/guards.js +1 -5
- 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 +48 -95
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.module.css.js +4 -12
- package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +150 -194
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +92 -108
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
- package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +44 -63
- package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +26 -40
- package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
- 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/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 +173 -191
- 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/ValidationExecutor.js +47 -87
- package/core/src/types/guards.js +0 -7
- package/features/form-runtime/config/configResolver.d.ts +0 -14
- package/features/form-runtime/config/index.d.ts +0 -9
- package/features/form-runtime/config/templateConfig.d.ts +0 -148
- package/features/form-runtime/config/templateLoader.d.ts +0 -25
- package/features/form-runtime/config/templateUtils.d.ts +0 -12
- package/features/form-runtime/utils/formSaver.d.ts +0 -22
- 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/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
- package/ui/src/lib/utils/templateUtils.js +0 -20
- package/wizard/src/features/form-runtime/config/configResolver.js +0 -34
- package/wizard/src/features/form-runtime/config/templateLoader.js +0 -235
|
@@ -1,108 +1,57 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import { memo as
|
|
4
|
-
import { useFormMachine as
|
|
5
|
-
import { ActionDialog as
|
|
6
|
-
const
|
|
7
|
-
const [
|
|
8
|
-
switch (
|
|
2
|
+
import { jsxs as o, jsx as O } from "react/jsx-runtime";
|
|
3
|
+
import { memo as D } from "react";
|
|
4
|
+
import { useFormMachine as g } from "../../state-management/machines/useFormMachine.js";
|
|
5
|
+
import { ActionDialog as c } from "../../dialog-system/components/ActionDialog/ActionDialog.js";
|
|
6
|
+
const d = D(({ className: n = "" }) => {
|
|
7
|
+
const [t, e] = g(), { context: i } = t, s = (a) => {
|
|
8
|
+
switch (a.type) {
|
|
9
9
|
case "close":
|
|
10
|
-
|
|
11
|
-
"🔥 ActionManager: Dialog cancelled during navigation - sending DIALOG_CANCELLED"
|
|
12
|
-
), a({ type: "DIALOG_CANCELLED" })) : a({ type: "HIDE_ACTION_DIALOG" });
|
|
10
|
+
i.pendingNavigation ? e({ type: "DIALOG_CANCELLED" }) : e({ type: "HIDE_ACTION_DIALOG" });
|
|
13
11
|
break;
|
|
14
12
|
case "navigate":
|
|
15
|
-
|
|
16
|
-
direction: e.direction,
|
|
17
|
-
targetStep: e.targetStep,
|
|
18
|
-
currentStep: n.currentStepIndex,
|
|
19
|
-
updateOriginalValue: e.updateOriginalValue,
|
|
20
|
-
componentId: e.componentId
|
|
21
|
-
}), e.type === "navigate" && e.updateOriginalValue && e.componentId && (console.log(
|
|
22
|
-
"🔥 ActionManager: Updating original value before navigation"
|
|
23
|
-
), a({
|
|
13
|
+
a.type, a.type === "navigate" && a.updateOriginalValue && a.componentId && e({
|
|
24
14
|
type: "UPDATE_COMPONENT_ORIGINAL_VALUE",
|
|
25
|
-
componentId:
|
|
26
|
-
})
|
|
27
|
-
"🔥 ActionManager: Dialog verified during navigation - sending DIALOG_VERIFIED"
|
|
28
|
-
), a({ type: "DIALOG_VERIFIED" })) : e.type === "navigate" && (e.direction === "next" ? (console.log("🔥 ActionManager: Sending NEXT event to machine"), a({ type: "NEXT" })) : e.direction === "previous" ? (console.log(
|
|
29
|
-
"🔥 ActionManager: Sending PREVIOUS event to machine"
|
|
30
|
-
), a({ type: "PREVIOUS" })) : e.targetStep && (console.log(
|
|
31
|
-
"🔥 ActionManager: Sending GO_TO_STEP event to machine"
|
|
32
|
-
), a({ type: "GO_TO_STEP", stepId: e.targetStep })));
|
|
15
|
+
componentId: a.componentId
|
|
16
|
+
}), i.pendingNavigation ? e({ type: "DIALOG_VERIFIED" }) : a.type === "navigate" && (a.direction === "next" ? e({ type: "NEXT" }) : a.direction === "previous" ? e({ type: "PREVIOUS" }) : a.targetStep && e({ type: "GO_TO_STEP", stepId: a.targetStep }));
|
|
33
17
|
break;
|
|
34
18
|
case "custom":
|
|
35
|
-
|
|
36
|
-
"🔥 ActionManager: Executing updateOriginalValue handler",
|
|
37
|
-
{
|
|
38
|
-
componentId: e.componentId,
|
|
39
|
-
pendingNavigation: n.pendingNavigation,
|
|
40
|
-
saveState: n.saveState,
|
|
41
|
-
isInSaveContext: n.saveState.savingSection !== null
|
|
42
|
-
}
|
|
43
|
-
), a({
|
|
19
|
+
a.type === "custom" && a.handler === "updateOriginalValue" && a.componentId ? (e({
|
|
44
20
|
type: "UPDATE_COMPONENT_ORIGINAL_VALUE",
|
|
45
|
-
componentId:
|
|
46
|
-
}),
|
|
47
|
-
"🔥 ActionManager: updateOriginalValue in SAVE context - hiding dialog without navigation"
|
|
48
|
-
), a({ type: "HIDE_ACTION_DIALOG" })) : (console.log(
|
|
49
|
-
"🔥 ActionManager: updateOriginalValue in non-save context - hiding dialog"
|
|
50
|
-
), a({ type: "HIDE_ACTION_DIALOG" }))) : (console.warn(
|
|
21
|
+
componentId: a.componentId
|
|
22
|
+
}), i.saveState.savingSection !== null ? e({ type: "HIDE_ACTION_DIALOG" }) : e({ type: "HIDE_ACTION_DIALOG" })) : (console.warn(
|
|
51
23
|
"Custom dialog action not implemented:",
|
|
52
|
-
|
|
53
|
-
),
|
|
24
|
+
a.handler
|
|
25
|
+
), e({ type: "HIDE_ACTION_DIALOG" }));
|
|
54
26
|
break;
|
|
55
27
|
case "updateOriginalValue":
|
|
56
|
-
|
|
57
|
-
"🔥 ActionManager: Executing UPDATE_ORIGINAL_VALUE action",
|
|
58
|
-
{
|
|
59
|
-
componentId: e.componentId,
|
|
60
|
-
pendingNavigation: n.pendingNavigation,
|
|
61
|
-
saveState: n.saveState,
|
|
62
|
-
isInSaveContext: n.saveState.savingSection !== null
|
|
63
|
-
}
|
|
64
|
-
), a({
|
|
28
|
+
e({
|
|
65
29
|
type: "UPDATE_COMPONENT_ORIGINAL_VALUE",
|
|
66
|
-
componentId:
|
|
67
|
-
}),
|
|
68
|
-
"🔥 ActionManager: Update original value in SAVE context - hiding dialog without navigation"
|
|
69
|
-
), a({ type: "HIDE_ACTION_DIALOG" })) : n.pendingNavigation ? (console.log(
|
|
70
|
-
"🔥 ActionManager: Update original value verified during navigation - sending DIALOG_VERIFIED"
|
|
71
|
-
), a({ type: "DIALOG_VERIFIED" })) : a({ type: "HIDE_ACTION_DIALOG" });
|
|
30
|
+
componentId: a.componentId
|
|
31
|
+
}), i.saveState.savingSection !== null ? e({ type: "HIDE_ACTION_DIALOG" }) : i.pendingNavigation ? e({ type: "DIALOG_VERIFIED" }) : e({ type: "HIDE_ACTION_DIALOG" });
|
|
72
32
|
break;
|
|
73
33
|
default:
|
|
74
|
-
|
|
34
|
+
e({ type: "HIDE_ACTION_DIALOG" });
|
|
75
35
|
}
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
isDialogOpen: o,
|
|
84
|
-
isExecutingActions: t,
|
|
85
|
-
activeDialog: n.activeDialog,
|
|
86
|
-
executingTrigger: n.executingTrigger
|
|
87
|
-
}), i.matches("showingActionDialog") && console.log(" ActionManager: In showingActionDialog state!", {
|
|
88
|
-
activeDialog: n.activeDialog,
|
|
89
|
-
isDialogOpen: o
|
|
90
|
-
}), /* @__PURE__ */ s("div", { className: g, children: [
|
|
91
|
-
t && !1,
|
|
92
|
-
/* @__PURE__ */ r(
|
|
93
|
-
I,
|
|
36
|
+
}, p = () => {
|
|
37
|
+
i.pendingNavigation ? e({ type: "DIALOG_CANCELLED" }) : e({ type: "HIDE_ACTION_DIALOG" });
|
|
38
|
+
}, I = t.matches("showingActionDialog") && i.activeDialog !== null, l = t.matches("executingActions");
|
|
39
|
+
return t.matches("showingActionDialog"), /* @__PURE__ */ o("div", { className: n, children: [
|
|
40
|
+
l && !1,
|
|
41
|
+
/* @__PURE__ */ O(
|
|
42
|
+
c,
|
|
94
43
|
{
|
|
95
|
-
config:
|
|
96
|
-
formData:
|
|
97
|
-
onButtonClick:
|
|
98
|
-
onClose:
|
|
99
|
-
isOpen:
|
|
44
|
+
config: i.activeDialog,
|
|
45
|
+
formData: i.data,
|
|
46
|
+
onButtonClick: s,
|
|
47
|
+
onClose: p,
|
|
48
|
+
isOpen: I
|
|
100
49
|
}
|
|
101
50
|
)
|
|
102
51
|
] });
|
|
103
52
|
});
|
|
104
|
-
|
|
53
|
+
d.displayName = "ActionManager";
|
|
105
54
|
export {
|
|
106
|
-
|
|
107
|
-
|
|
55
|
+
d as ActionManager,
|
|
56
|
+
d as default
|
|
108
57
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { z as
|
|
2
|
+
import { z as r } from "zod";
|
|
3
3
|
class d {
|
|
4
4
|
messageStyle;
|
|
5
5
|
secureValidatorConfig;
|
|
@@ -10,114 +10,63 @@ class d {
|
|
|
10
10
|
* Creates a Zod schema for a component
|
|
11
11
|
*/
|
|
12
12
|
createComponentSchema(i) {
|
|
13
|
-
console.log("🔍 [SchemaBuilder] Creating schema for component:", {
|
|
14
|
-
id: i.id,
|
|
15
|
-
type: i.type,
|
|
16
|
-
validation: i.validation
|
|
17
|
-
});
|
|
18
13
|
let a;
|
|
19
14
|
switch (i.type) {
|
|
20
15
|
case "text":
|
|
21
16
|
case "tel":
|
|
22
17
|
case "password":
|
|
23
18
|
case "textarea":
|
|
24
|
-
a =
|
|
19
|
+
a = r.string();
|
|
25
20
|
break;
|
|
26
21
|
case "email":
|
|
27
|
-
|
|
28
|
-
`🔍 [SchemaBuilder] Creating EMAIL schema for component ${i.id}`
|
|
29
|
-
), a = l.string().email("Please enter a valid email address"), console.log(
|
|
30
|
-
`✅ [SchemaBuilder] Email schema created for component ${i.id}:`,
|
|
31
|
-
{ schemaType: a.constructor.name }
|
|
32
|
-
);
|
|
22
|
+
a = r.string().email("Please enter a valid email address");
|
|
33
23
|
break;
|
|
34
24
|
case "number":
|
|
35
|
-
a =
|
|
25
|
+
a = r.number();
|
|
36
26
|
break;
|
|
37
27
|
case "checkbox":
|
|
38
|
-
a =
|
|
28
|
+
a = r.boolean();
|
|
39
29
|
break;
|
|
40
30
|
case "date":
|
|
41
31
|
case "time":
|
|
42
32
|
case "datetime-local":
|
|
43
|
-
a =
|
|
33
|
+
a = r.string();
|
|
44
34
|
break;
|
|
45
35
|
case "radioGroup":
|
|
46
36
|
case "radio":
|
|
47
37
|
case "select":
|
|
48
38
|
case "dropdown":
|
|
49
|
-
a =
|
|
39
|
+
a = r.string();
|
|
50
40
|
break;
|
|
51
41
|
case "range":
|
|
52
|
-
a =
|
|
42
|
+
a = r.number();
|
|
53
43
|
break;
|
|
54
44
|
case "file":
|
|
55
|
-
a =
|
|
45
|
+
a = r.any();
|
|
56
46
|
break;
|
|
57
47
|
case "hidden":
|
|
58
|
-
a =
|
|
48
|
+
a = r.string().optional();
|
|
59
49
|
break;
|
|
60
50
|
default:
|
|
61
|
-
a =
|
|
51
|
+
a = r.any();
|
|
62
52
|
}
|
|
63
53
|
if (i.validation) {
|
|
64
|
-
const e = i.validation,
|
|
65
|
-
if (
|
|
66
|
-
const t =
|
|
67
|
-
|
|
68
|
-
`🔍 [SchemaBuilder] Applying REQUIRED validation for ${i.id}:`,
|
|
69
|
-
{
|
|
70
|
-
message: t,
|
|
71
|
-
componentType: i.type,
|
|
72
|
-
requiredRule: r
|
|
73
|
-
}
|
|
74
|
-
), i.type === "text" || i.type === "email" || i.type === "tel" || i.type === "password" || i.type === "textarea" ? (a = a.min(1, t), console.log(
|
|
75
|
-
`🔍 [SchemaBuilder] Applied .min(1) for required text field ${i.id}`
|
|
76
|
-
)) : (i.type === "radioGroup" || i.type === "radio" || i.type === "select" || i.type === "dropdown") && (a = a.refine(
|
|
54
|
+
const e = i.validation, l = typeof e.required == "object" && e.required !== null ? e.required : null;
|
|
55
|
+
if (l && l.value === !0) {
|
|
56
|
+
const t = l.message || "This field is required";
|
|
57
|
+
i.type === "text" || i.type === "email" || i.type === "tel" || i.type === "password" || i.type === "textarea" ? a = a.min(1, t) : (i.type === "radioGroup" || i.type === "radio" || i.type === "select" || i.type === "dropdown") && (a = a.refine(
|
|
77
58
|
(s) => s != null && s !== "",
|
|
78
59
|
{
|
|
79
60
|
message: t
|
|
80
61
|
}
|
|
81
|
-
), console.log(
|
|
82
|
-
`🔍 [SchemaBuilder] Applied .refine() for required selection field ${i.id}`
|
|
83
62
|
));
|
|
84
63
|
}
|
|
85
64
|
if (e.minLength) {
|
|
86
|
-
console.log(
|
|
87
|
-
`🔍 [SchemaBuilder] Processing MINLENGTH validation for ${i.id}:`,
|
|
88
|
-
{
|
|
89
|
-
validationMinLength: e.minLength,
|
|
90
|
-
rawValue: e.minLength.value,
|
|
91
|
-
valueType: typeof e.minLength.value
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
65
|
const t = typeof e.minLength.value == "string" ? Number(e.minLength.value) : e.minLength.value;
|
|
95
|
-
if (
|
|
96
|
-
|
|
97
|
-
{
|
|
98
|
-
originalValue: e.minLength.value,
|
|
99
|
-
convertedValue: t,
|
|
100
|
-
convertedType: typeof t,
|
|
101
|
-
isValidNumber: typeof t == "number" && !Number.isNaN(t)
|
|
102
|
-
}
|
|
103
|
-
), typeof t == "number" && !Number.isNaN(t)) {
|
|
104
|
-
if (a instanceof l.ZodString) {
|
|
66
|
+
if (typeof t == "number" && !Number.isNaN(t)) {
|
|
67
|
+
if (a instanceof r.ZodString) {
|
|
105
68
|
const s = e.minLength.message || `Must be at least ${t} characters`;
|
|
106
|
-
|
|
107
|
-
`🔍 [SchemaBuilder] Applying MINLENGTH validation for ${i.id}:`,
|
|
108
|
-
{
|
|
109
|
-
minLengthValue: t,
|
|
110
|
-
message: s,
|
|
111
|
-
schemaBeforeMinLength: a._def,
|
|
112
|
-
schemaType: a.constructor.name
|
|
113
|
-
}
|
|
114
|
-
), a = a.min(t, s), console.log(
|
|
115
|
-
`🔍 [SchemaBuilder] Applied .min(${t}) for ${i.id}:`,
|
|
116
|
-
{
|
|
117
|
-
schemaAfterMinLength: a._def,
|
|
118
|
-
schemaType: a.constructor.name
|
|
119
|
-
}
|
|
120
|
-
);
|
|
69
|
+
a = a.min(t, s);
|
|
121
70
|
}
|
|
122
71
|
} else
|
|
123
72
|
console.warn(
|
|
@@ -128,7 +77,7 @@ class d {
|
|
|
128
77
|
if (e.maxLength) {
|
|
129
78
|
const t = typeof e.maxLength.value == "string" ? Number(e.maxLength.value) : e.maxLength.value;
|
|
130
79
|
if (typeof t == "number" && !Number.isNaN(t)) {
|
|
131
|
-
if (a instanceof
|
|
80
|
+
if (a instanceof r.ZodString) {
|
|
132
81
|
const s = e.maxLength.message || `Must be no more than ${t} characters`;
|
|
133
82
|
a = a.max(t, s);
|
|
134
83
|
}
|
|
@@ -138,26 +87,23 @@ class d {
|
|
|
138
87
|
e.maxLength.value
|
|
139
88
|
);
|
|
140
89
|
}
|
|
141
|
-
if (e.pattern && a instanceof
|
|
90
|
+
if (e.pattern && a instanceof r.ZodString) {
|
|
142
91
|
const t = typeof e.pattern == "string" ? { value: e.pattern, message: "Invalid format" } : e.pattern;
|
|
143
92
|
if (t.value) {
|
|
144
93
|
const s = t.message || "Invalid format";
|
|
145
94
|
a = a.regex(new RegExp(t.value), s);
|
|
146
95
|
}
|
|
147
96
|
}
|
|
148
|
-
if (e.email && i.type !== "email" && a instanceof
|
|
97
|
+
if (e.email && i.type !== "email" && a instanceof r.ZodString) {
|
|
149
98
|
const t = typeof e.email == "boolean" && e.email ? { value: !0, message: "Please enter a valid email address" } : typeof e.email == "object" && e.email !== null ? e.email : null;
|
|
150
99
|
if (t && (t.value === !0 || typeof e.email == "object" && e.email !== null && !("value" in e.email))) {
|
|
151
100
|
const n = t?.message || "Please enter a valid email address";
|
|
152
101
|
a = a.email(n);
|
|
153
102
|
}
|
|
154
103
|
}
|
|
155
|
-
if (e.email && i.type === "email" && a instanceof
|
|
104
|
+
if (e.email && i.type === "email" && a instanceof r.ZodString) {
|
|
156
105
|
const t = typeof e.email == "boolean" && e.email ? { message: "Please enter a valid email address" } : typeof e.email == "object" && e.email !== null ? e.email : null;
|
|
157
|
-
t && t.message && (
|
|
158
|
-
`🔍 [SchemaBuilder] Using custom email validation message for component ${i.id}:`,
|
|
159
|
-
{ customMessage: t.message }
|
|
160
|
-
), a = l.string().email(t.message));
|
|
106
|
+
t && t.message && (a = r.string().email(t.message));
|
|
161
107
|
}
|
|
162
108
|
if (i.type === "number" || i.type === "range") {
|
|
163
109
|
if (e.min) {
|
|
@@ -197,14 +143,14 @@ class d {
|
|
|
197
143
|
*/
|
|
198
144
|
createStepSchema(i) {
|
|
199
145
|
const a = {};
|
|
200
|
-
return i.sections?.forEach((
|
|
201
|
-
|
|
146
|
+
return i.sections?.forEach((u) => {
|
|
147
|
+
u.components?.forEach((e) => {
|
|
202
148
|
if (e.type === "button" || e.type === "submit" || e.type === "reset" || e.type === "paragraph" || e.type === "heading" || e.type === "alert")
|
|
203
149
|
return;
|
|
204
|
-
const
|
|
205
|
-
a[e.id] =
|
|
150
|
+
const l = this.createComponentSchema(e);
|
|
151
|
+
a[e.id] = l;
|
|
206
152
|
});
|
|
207
|
-
}),
|
|
153
|
+
}), r.object(a);
|
|
208
154
|
}
|
|
209
155
|
/**
|
|
210
156
|
* Updates the message style
|
|
@@ -11,38 +11,22 @@ class s {
|
|
|
11
11
|
*/
|
|
12
12
|
getComponentSchema(e) {
|
|
13
13
|
const c = `component_${e.id}`;
|
|
14
|
-
(e.id === "text-i05t2ttw" || e.id === "radioGroup-c5q6aj4v" || e.id === "text-1759502191578-gci6gq1pm") &&
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
`📋 [ValidationCache] Using cached schema for ${e.id}:`,
|
|
21
|
-
{
|
|
22
|
-
cacheKey: c,
|
|
23
|
-
schemaType: a.constructor.name
|
|
24
|
-
}
|
|
25
|
-
), a;
|
|
26
|
-
console.log(
|
|
27
|
-
`🔄 [ValidationCache] Creating new schema for ${e.id}:`,
|
|
28
|
-
{
|
|
29
|
-
cacheKey: c,
|
|
30
|
-
componentType: e.type,
|
|
31
|
-
hasValidation: !!e.validation
|
|
32
|
-
}
|
|
33
|
-
);
|
|
34
|
-
const t = this.schemaBuilder.createComponentSchema(e);
|
|
35
|
-
return this.componentSchemaCache.set(c, t), t;
|
|
14
|
+
(e.id === "text-i05t2ttw" || e.id === "radioGroup-c5q6aj4v" || e.id === "text-1759502191578-gci6gq1pm") && this.componentSchemaCache.delete(c);
|
|
15
|
+
const t = this.componentSchemaCache.get(c);
|
|
16
|
+
if (t)
|
|
17
|
+
return t;
|
|
18
|
+
const a = this.schemaBuilder.createComponentSchema(e);
|
|
19
|
+
return this.componentSchemaCache.set(c, a), a;
|
|
36
20
|
}
|
|
37
21
|
/**
|
|
38
22
|
* Gets or creates a step schema with caching
|
|
39
23
|
*/
|
|
40
24
|
getStepSchema(e) {
|
|
41
|
-
const c = `step_${e.id}`,
|
|
42
|
-
if (
|
|
43
|
-
return
|
|
44
|
-
const
|
|
45
|
-
return this.stepSchemaCache.set(c,
|
|
25
|
+
const c = `step_${e.id}`, t = this.stepSchemaCache.get(c);
|
|
26
|
+
if (t)
|
|
27
|
+
return t;
|
|
28
|
+
const a = this.schemaBuilder.createStepSchema(e);
|
|
29
|
+
return this.stepSchemaCache.set(c, a), a;
|
|
46
30
|
}
|
|
47
31
|
/**
|
|
48
32
|
* Clears all cached schemas
|
|
@@ -1,138 +1,98 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
import { isTemplateStep as d } from "../../../../../ui/src/lib/types/guards.js";
|
|
4
|
-
class u {
|
|
2
|
+
class d {
|
|
5
3
|
schemaBuilder;
|
|
6
|
-
constructor(
|
|
7
|
-
this.schemaBuilder =
|
|
4
|
+
constructor(s) {
|
|
5
|
+
this.schemaBuilder = s;
|
|
8
6
|
}
|
|
9
7
|
/**
|
|
10
8
|
* Validates a single field
|
|
11
9
|
*/
|
|
12
|
-
async validateField(
|
|
10
|
+
async validateField(s, o) {
|
|
13
11
|
try {
|
|
14
|
-
const
|
|
12
|
+
const r = await o.parseAsync(s);
|
|
15
13
|
return {
|
|
16
14
|
isValid: !0,
|
|
17
15
|
errors: [],
|
|
18
|
-
value:
|
|
16
|
+
value: r
|
|
19
17
|
};
|
|
20
|
-
} catch (
|
|
21
|
-
let
|
|
22
|
-
return
|
|
18
|
+
} catch (r) {
|
|
19
|
+
let e = [];
|
|
20
|
+
return r && typeof r == "object" && "errors" in r ? e = r.errors.map((i) => i.message) : e = ["Validation failed"], {
|
|
23
21
|
isValid: !1,
|
|
24
|
-
errors:
|
|
25
|
-
value:
|
|
22
|
+
errors: e,
|
|
23
|
+
value: s
|
|
26
24
|
};
|
|
27
25
|
}
|
|
28
26
|
}
|
|
29
27
|
/**
|
|
30
28
|
* Validates a single field synchronously
|
|
31
29
|
*/
|
|
32
|
-
validateFieldSync(
|
|
33
|
-
let
|
|
34
|
-
|
|
35
|
-
originalValue: t,
|
|
36
|
-
normalizedValue: e,
|
|
37
|
-
valueType: typeof t,
|
|
38
|
-
normalizedValueType: typeof e,
|
|
39
|
-
valueLength: typeof e == "string" ? e.length : "N/A",
|
|
40
|
-
schema: i._def
|
|
41
|
-
});
|
|
30
|
+
validateFieldSync(s, o) {
|
|
31
|
+
let r = s;
|
|
32
|
+
s == null && (r = "");
|
|
42
33
|
try {
|
|
43
|
-
const
|
|
44
|
-
return
|
|
45
|
-
value: t,
|
|
46
|
-
result: r,
|
|
47
|
-
isValid: !0
|
|
48
|
-
}), {
|
|
34
|
+
const e = o.parse(r);
|
|
35
|
+
return {
|
|
49
36
|
isValid: !0,
|
|
50
37
|
errors: [],
|
|
51
|
-
value:
|
|
38
|
+
value: e
|
|
52
39
|
};
|
|
53
|
-
} catch (
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
error: r,
|
|
57
|
-
errorType: typeof r
|
|
58
|
-
});
|
|
59
|
-
let s = [];
|
|
60
|
-
if (r && typeof r == "object" && "errors" in r) {
|
|
61
|
-
const a = r;
|
|
62
|
-
s = a.errors.map((o) => o.message), console.log("🔍 [ValidationExecutor] DETAILED Zod errors:", {
|
|
63
|
-
fullZodError: a,
|
|
64
|
-
individualErrors: a.errors.map((o) => ({
|
|
65
|
-
message: o.message,
|
|
66
|
-
path: o.path,
|
|
67
|
-
code: o.code,
|
|
68
|
-
fullError: o
|
|
69
|
-
})),
|
|
70
|
-
inputValue: t,
|
|
71
|
-
inputType: typeof t,
|
|
72
|
-
schemaType: i._def?.typeName || "unknown"
|
|
73
|
-
});
|
|
74
|
-
} else
|
|
75
|
-
s = ["Validation failed"];
|
|
76
|
-
return {
|
|
40
|
+
} catch (e) {
|
|
41
|
+
let t = [];
|
|
42
|
+
return e && typeof e == "object" && "errors" in e ? t = e.errors.map((a) => a.message) : t = ["Validation failed"], {
|
|
77
43
|
isValid: !1,
|
|
78
|
-
errors:
|
|
79
|
-
value:
|
|
44
|
+
errors: t,
|
|
45
|
+
value: r
|
|
80
46
|
};
|
|
81
47
|
}
|
|
82
48
|
}
|
|
83
49
|
/**
|
|
84
50
|
* Validates a step
|
|
85
51
|
*/
|
|
86
|
-
async validateStep(
|
|
52
|
+
async validateStep(s, o) {
|
|
87
53
|
try {
|
|
88
|
-
return await
|
|
54
|
+
return await o.parseAsync(s), {
|
|
89
55
|
isValid: !0,
|
|
90
56
|
fieldErrors: {},
|
|
91
57
|
generalErrors: []
|
|
92
58
|
};
|
|
93
|
-
} catch (
|
|
94
|
-
const
|
|
95
|
-
let
|
|
96
|
-
if (
|
|
97
|
-
const
|
|
98
|
-
for (const
|
|
99
|
-
if (
|
|
100
|
-
const l =
|
|
101
|
-
|
|
59
|
+
} catch (r) {
|
|
60
|
+
const e = {};
|
|
61
|
+
let t = [];
|
|
62
|
+
if (r && typeof r == "object" && "errors" in r) {
|
|
63
|
+
const i = r;
|
|
64
|
+
for (const a of i.errors)
|
|
65
|
+
if (a.path.length > 0) {
|
|
66
|
+
const l = a.path[0].toString();
|
|
67
|
+
e[l] || (e[l] = []), e[l].push(a.message);
|
|
102
68
|
} else
|
|
103
|
-
|
|
69
|
+
t.push(a.message);
|
|
104
70
|
} else
|
|
105
|
-
|
|
71
|
+
t = ["Step validation failed"];
|
|
106
72
|
return {
|
|
107
73
|
isValid: !1,
|
|
108
|
-
fieldErrors:
|
|
109
|
-
generalErrors:
|
|
74
|
+
fieldErrors: e,
|
|
75
|
+
generalErrors: t
|
|
110
76
|
};
|
|
111
77
|
}
|
|
112
78
|
}
|
|
113
79
|
/**
|
|
114
80
|
* Validates a form
|
|
115
81
|
*/
|
|
116
|
-
async validateForm(
|
|
117
|
-
const
|
|
118
|
-
let
|
|
119
|
-
for (const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
`Template step '${a.id}' needs to be resolved before validation`
|
|
123
|
-
), s = !1;
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
const o = a, l = this.schemaBuilder.createStepSchema(o), n = await this.validateStep(i, l);
|
|
127
|
-
n.isValid || (s = !1, Object.assign(e, n.fieldErrors), r.push(...n.generalErrors));
|
|
82
|
+
async validateForm(s, o) {
|
|
83
|
+
const r = {}, e = [];
|
|
84
|
+
let t = !0;
|
|
85
|
+
for (const i of s.steps) {
|
|
86
|
+
const a = i, l = this.schemaBuilder.createStepSchema(a), n = await this.validateStep(o, l);
|
|
87
|
+
n.isValid || (t = !1, Object.assign(r, n.fieldErrors), e.push(...n.generalErrors));
|
|
128
88
|
}
|
|
129
89
|
return {
|
|
130
|
-
isValid:
|
|
131
|
-
fieldErrors:
|
|
132
|
-
generalErrors:
|
|
90
|
+
isValid: t,
|
|
91
|
+
fieldErrors: r,
|
|
92
|
+
generalErrors: e
|
|
133
93
|
};
|
|
134
94
|
}
|
|
135
95
|
}
|
|
136
96
|
export {
|
|
137
|
-
|
|
97
|
+
d as ValidationExecutor
|
|
138
98
|
};
|
package/core/src/types/guards.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { FormWizardConfig } from '../../../../../core/src/index.ts';
|
|
2
|
-
/**
|
|
3
|
-
* Resolves a form wizard configuration, expanding any template step references
|
|
4
|
-
* to their full step configurations
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveFormWizardConfig(config: FormWizardConfig): Promise<FormWizardConfig>;
|
|
7
|
-
/**
|
|
8
|
-
* Checks if a configuration contains template step references
|
|
9
|
-
*/
|
|
10
|
-
export declare function hasTemplateSteps(config: FormWizardConfig): boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Gets template IDs used in a configuration
|
|
13
|
-
*/
|
|
14
|
-
export declare function getUsedTemplateIds(config: FormWizardConfig): string[];
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Form Runtime Configuration
|
|
3
|
-
*
|
|
4
|
-
* Configuration resolvers and template utilities
|
|
5
|
-
*/
|
|
6
|
-
export * from './configResolver';
|
|
7
|
-
export * from './templateConfig';
|
|
8
|
-
export * from './templateLoader';
|
|
9
|
-
export { getAvailableGenericTemplatesSync, getTemplateInfo, validateTemplateReferences, } from './templateUtils';
|