@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,108 +1,57 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import {
|
|
4
|
-
import { useFormMachine as
|
|
5
|
-
import {
|
|
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
|
-
d,
|
|
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,55 +1,55 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { SchemaBuilder as
|
|
3
|
-
import { ValidationCache as
|
|
4
|
-
import { ValidationExecutor as
|
|
5
|
-
class
|
|
2
|
+
import { SchemaBuilder as n } from "./SchemaBuilder.js";
|
|
3
|
+
import { ValidationCache as r } from "./ValidationCache.js";
|
|
4
|
+
import { ValidationExecutor as d } from "./ValidationExecutor.js";
|
|
5
|
+
class o {
|
|
6
6
|
debounceTimers = /* @__PURE__ */ new Map();
|
|
7
7
|
debounceMs;
|
|
8
8
|
schemaBuilder;
|
|
9
9
|
validationExecutor;
|
|
10
10
|
validationCache;
|
|
11
11
|
constructor(e = {}) {
|
|
12
|
-
this.debounceMs = e.debounceMs || 300, this.schemaBuilder = new
|
|
12
|
+
this.debounceMs = e.debounceMs || 300, this.schemaBuilder = new n(
|
|
13
13
|
e.messageStyle || "withLabel",
|
|
14
14
|
e.secureValidatorConfig
|
|
15
|
-
), this.validationExecutor = new
|
|
15
|
+
), this.validationExecutor = new d(this.schemaBuilder), this.validationCache = new r(this.schemaBuilder);
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Validates a single field with debouncing
|
|
19
19
|
*/
|
|
20
|
-
async validateFieldDebounced(e,
|
|
21
|
-
return new Promise((
|
|
20
|
+
async validateFieldDebounced(e, a) {
|
|
21
|
+
return new Promise((i) => {
|
|
22
22
|
const t = `field_${e.id}`;
|
|
23
23
|
if (this.debounceTimers.has(t)) {
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const s = this.debounceTimers.get(t);
|
|
25
|
+
s && clearTimeout(s);
|
|
26
26
|
}
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
this.debounceTimers.delete(t),
|
|
27
|
+
const c = setTimeout(() => {
|
|
28
|
+
const s = this.validateField(e, a);
|
|
29
|
+
this.debounceTimers.delete(t), i(s);
|
|
30
30
|
}, this.debounceMs);
|
|
31
|
-
this.debounceTimers.set(t,
|
|
31
|
+
this.debounceTimers.set(t, c);
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
35
|
* Validates a single field immediately (synchronous)
|
|
36
36
|
*/
|
|
37
|
-
validateField(e,
|
|
38
|
-
const
|
|
39
|
-
return this.validationExecutor.validateFieldSync(
|
|
37
|
+
validateField(e, a) {
|
|
38
|
+
const i = this.validationCache.getComponentSchema(e);
|
|
39
|
+
return this.validationExecutor.validateFieldSync(a, i);
|
|
40
40
|
}
|
|
41
41
|
/**
|
|
42
42
|
* Validates all fields in a step
|
|
43
43
|
*/
|
|
44
|
-
async validateStep(e,
|
|
45
|
-
const
|
|
46
|
-
return await this.validationExecutor.validateStep(
|
|
44
|
+
async validateStep(e, a) {
|
|
45
|
+
const i = this.validationCache.getStepSchema(e);
|
|
46
|
+
return await this.validationExecutor.validateStep(a, i);
|
|
47
47
|
}
|
|
48
48
|
/**
|
|
49
49
|
* Validates an entire form
|
|
50
50
|
*/
|
|
51
|
-
async validateForm(e,
|
|
52
|
-
return await this.validationExecutor.validateForm(e,
|
|
51
|
+
async validateForm(e, a) {
|
|
52
|
+
return await this.validationExecutor.validateForm(e, a);
|
|
53
53
|
}
|
|
54
54
|
/**
|
|
55
55
|
* Creates and caches a Zod schema for a component
|
|
@@ -86,12 +86,7 @@ class c {
|
|
|
86
86
|
), this.validationCache.clearCache());
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
function g(s) {
|
|
91
|
-
return new c(s);
|
|
92
|
-
}
|
|
89
|
+
new o();
|
|
93
90
|
export {
|
|
94
|
-
|
|
95
|
-
g as createValidationEngine,
|
|
96
|
-
v as defaultValidationEngine
|
|
91
|
+
o as ValidationEngine
|
|
97
92
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { isTemplateStep as
|
|
3
|
+
import { isTemplateStep as c } from "../../../../../ui/src/lib/types/guards.js";
|
|
4
4
|
class u {
|
|
5
5
|
schemaBuilder;
|
|
6
|
-
constructor(
|
|
7
|
-
this.schemaBuilder =
|
|
6
|
+
constructor(s) {
|
|
7
|
+
this.schemaBuilder = s;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* Validates a single field
|
|
11
11
|
*/
|
|
12
|
-
async validateField(
|
|
12
|
+
async validateField(s, i) {
|
|
13
13
|
try {
|
|
14
|
-
const e = await i.parseAsync(
|
|
14
|
+
const e = await i.parseAsync(s);
|
|
15
15
|
return {
|
|
16
16
|
isValid: !0,
|
|
17
17
|
errors: [],
|
|
@@ -22,60 +22,28 @@ class u {
|
|
|
22
22
|
return e && typeof e == "object" && "errors" in e ? r = e.errors.map((a) => a.message) : r = ["Validation failed"], {
|
|
23
23
|
isValid: !1,
|
|
24
24
|
errors: r,
|
|
25
|
-
value:
|
|
25
|
+
value: s
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Validates a single field synchronously
|
|
31
31
|
*/
|
|
32
|
-
validateFieldSync(
|
|
33
|
-
let e =
|
|
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
|
-
});
|
|
32
|
+
validateFieldSync(s, i) {
|
|
33
|
+
let e = s;
|
|
34
|
+
s == null && (e = "");
|
|
42
35
|
try {
|
|
43
36
|
const r = i.parse(e);
|
|
44
|
-
return
|
|
45
|
-
value: t,
|
|
46
|
-
result: r,
|
|
47
|
-
isValid: !0
|
|
48
|
-
}), {
|
|
37
|
+
return {
|
|
49
38
|
isValid: !0,
|
|
50
39
|
errors: [],
|
|
51
40
|
value: r
|
|
52
41
|
};
|
|
53
42
|
} catch (r) {
|
|
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 {
|
|
43
|
+
let t = [];
|
|
44
|
+
return r && typeof r == "object" && "errors" in r ? t = r.errors.map((o) => o.message) : t = ["Validation failed"], {
|
|
77
45
|
isValid: !1,
|
|
78
|
-
errors:
|
|
46
|
+
errors: t,
|
|
79
47
|
value: e
|
|
80
48
|
};
|
|
81
49
|
}
|
|
@@ -83,16 +51,16 @@ class u {
|
|
|
83
51
|
/**
|
|
84
52
|
* Validates a step
|
|
85
53
|
*/
|
|
86
|
-
async validateStep(
|
|
54
|
+
async validateStep(s, i) {
|
|
87
55
|
try {
|
|
88
|
-
return await i.parseAsync(
|
|
56
|
+
return await i.parseAsync(s), {
|
|
89
57
|
isValid: !0,
|
|
90
58
|
fieldErrors: {},
|
|
91
59
|
generalErrors: []
|
|
92
60
|
};
|
|
93
61
|
} catch (e) {
|
|
94
62
|
const r = {};
|
|
95
|
-
let
|
|
63
|
+
let t = [];
|
|
96
64
|
if (e && typeof e == "object" && "errors" in e) {
|
|
97
65
|
const a = e;
|
|
98
66
|
for (const o of a.errors)
|
|
@@ -100,34 +68,34 @@ class u {
|
|
|
100
68
|
const l = o.path[0].toString();
|
|
101
69
|
r[l] || (r[l] = []), r[l].push(o.message);
|
|
102
70
|
} else
|
|
103
|
-
|
|
71
|
+
t.push(o.message);
|
|
104
72
|
} else
|
|
105
|
-
|
|
73
|
+
t = ["Step validation failed"];
|
|
106
74
|
return {
|
|
107
75
|
isValid: !1,
|
|
108
76
|
fieldErrors: r,
|
|
109
|
-
generalErrors:
|
|
77
|
+
generalErrors: t
|
|
110
78
|
};
|
|
111
79
|
}
|
|
112
80
|
}
|
|
113
81
|
/**
|
|
114
82
|
* Validates a form
|
|
115
83
|
*/
|
|
116
|
-
async validateForm(
|
|
84
|
+
async validateForm(s, i) {
|
|
117
85
|
const e = {}, r = [];
|
|
118
|
-
let
|
|
119
|
-
for (const a of
|
|
120
|
-
if (
|
|
86
|
+
let t = !0;
|
|
87
|
+
for (const a of s.steps) {
|
|
88
|
+
if (c(a)) {
|
|
121
89
|
r.push(
|
|
122
90
|
`Template step '${a.id}' needs to be resolved before validation`
|
|
123
|
-
),
|
|
91
|
+
), t = !1;
|
|
124
92
|
continue;
|
|
125
93
|
}
|
|
126
94
|
const o = a, l = this.schemaBuilder.createStepSchema(o), n = await this.validateStep(i, l);
|
|
127
|
-
n.isValid || (
|
|
95
|
+
n.isValid || (t = !1, Object.assign(e, n.fieldErrors), r.push(...n.generalErrors));
|
|
128
96
|
}
|
|
129
97
|
return {
|
|
130
|
-
isValid:
|
|
98
|
+
isValid: t,
|
|
131
99
|
fieldErrors: e,
|
|
132
100
|
generalErrors: r
|
|
133
101
|
};
|
package/FormWizard.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Form Wizard Component - Legacy export file for backward compatibility
|
|
3
|
-
*
|
|
4
|
-
* This file maintains backward compatibility for existing imports.
|
|
5
|
-
* New code should import from the features directory structure.
|
|
6
|
-
*/
|
|
7
|
-
export * from '../../core/src/index.ts';
|
|
8
|
-
export * from '../../ui/src/index.ts';
|
|
9
|
-
export * from './features/form-runtime';
|
|
10
|
-
export { FormWizard as default } from './features/form-runtime';
|