@digiform/wizard 0.3.1 โ 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/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/package.json +1 -3
- package/styles.css +1 -1
- 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 +54 -79
- 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 +83 -92
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
- package/wizard/src/features/form-runtime/config/templateLoader.js +48 -55
- 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 +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/ValidationExecutor.js +26 -58
- 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
|
@@ -1,61 +1,47 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback as
|
|
3
|
-
import { markFieldAsUserInteracted as
|
|
2
|
+
import { useCallback as m } from "react";
|
|
3
|
+
import { markFieldAsUserInteracted as o } from "../utils/validationUX.js";
|
|
4
4
|
import { useComponentTriggers as B } from "./useComponentTriggers.js";
|
|
5
|
-
import { useFormMachine as
|
|
6
|
-
const
|
|
7
|
-
componentId:
|
|
8
|
-
hasIsDirtyTriggers:
|
|
9
|
-
originalValueFromMachine:
|
|
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,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,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
|
};
|
|
@@ -12,7 +12,8 @@ t({
|
|
|
12
12
|
);
|
|
13
13
|
return e.config.steps[n]?.id || "";
|
|
14
14
|
},
|
|
15
|
-
pendingNavigation: null
|
|
15
|
+
pendingNavigation: null,
|
|
16
|
+
forcedValidationFields: []
|
|
16
17
|
});
|
|
17
18
|
t({
|
|
18
19
|
currentStepIndex: ({ context: e }) => Math.max(e.currentStepIndex - 1, 0),
|
|
@@ -20,18 +21,20 @@ t({
|
|
|
20
21
|
const n = Math.max(e.currentStepIndex - 1, 0);
|
|
21
22
|
return e.config.steps[n]?.id || "";
|
|
22
23
|
},
|
|
23
|
-
pendingNavigation: null
|
|
24
|
+
pendingNavigation: null,
|
|
25
|
+
forcedValidationFields: []
|
|
24
26
|
});
|
|
25
27
|
t({
|
|
26
28
|
currentStepIndex: ({ context: e, event: n }) => {
|
|
27
29
|
if (n.type !== "GO_TO_STEP") return e.currentStepIndex;
|
|
28
30
|
const i = e.config.steps.findIndex(
|
|
29
|
-
(
|
|
31
|
+
(a) => a.id === n.stepId
|
|
30
32
|
);
|
|
31
33
|
return i >= 0 ? i : e.currentStepIndex;
|
|
32
34
|
},
|
|
33
35
|
currentStepId: ({ context: e, event: n }) => n.type !== "GO_TO_STEP" ? e.currentStepId : n.stepId,
|
|
34
|
-
pendingNavigation: null
|
|
36
|
+
pendingNavigation: null,
|
|
37
|
+
forcedValidationFields: []
|
|
35
38
|
});
|
|
36
39
|
t({
|
|
37
40
|
currentStepIndex: ({ context: e }) => {
|
|
@@ -42,7 +45,8 @@ t({
|
|
|
42
45
|
},
|
|
43
46
|
currentStepId: ({ context: e }) => e.pendingNavigation?.stepId || e.currentStepId,
|
|
44
47
|
pendingNavigation: null,
|
|
45
|
-
canNavigate: !0
|
|
48
|
+
canNavigate: !0,
|
|
49
|
+
forcedValidationFields: []
|
|
46
50
|
});
|
|
47
51
|
t({
|
|
48
52
|
pendingNavigation: { type: "next" }
|
|
@@ -95,9 +99,10 @@ t({
|
|
|
95
99
|
activeWarnings: [],
|
|
96
100
|
pendingVerifications: [],
|
|
97
101
|
verificationResults: {}
|
|
98
|
-
}
|
|
102
|
+
},
|
|
103
|
+
forcedValidationFields: []
|
|
99
104
|
});
|
|
100
|
-
const
|
|
105
|
+
const d = ({
|
|
101
106
|
context: e,
|
|
102
107
|
self: n
|
|
103
108
|
}) => {
|
|
@@ -118,5 +123,5 @@ const p = ({
|
|
|
118
123
|
}
|
|
119
124
|
};
|
|
120
125
|
export {
|
|
121
|
-
|
|
126
|
+
d as executePendingNavigation
|
|
122
127
|
};
|