@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,141 +1,125 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as f, jsx as
|
|
3
|
-
import
|
|
2
|
+
import { jsxs as f, jsx as r, Fragment as _ } from "react/jsx-runtime";
|
|
3
|
+
import g from "./FormStep.module.css.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { useForm as C } from "@tanstack/react-form";
|
|
5
|
+
import { logger as w } from "../../../../../../ui/src/lib/logger.js";
|
|
6
|
+
import { useForm as I } from "@tanstack/react-form";
|
|
8
7
|
import { useRef as p } from "react";
|
|
9
|
-
import { LoaderProvider as
|
|
10
|
-
import { FormProvider as
|
|
11
|
-
import { buildDefaultValues as
|
|
12
|
-
import { resetFormDirtyStateAfterApiPopulation as
|
|
8
|
+
import { LoaderProvider as M, useLoaderContext as C } from "../../context/LoaderContext.js";
|
|
9
|
+
import { FormProvider as U } from "../../hooks/useFormContext.js";
|
|
10
|
+
import { buildDefaultValues as k } from "../../utils/formDataBuilder.js";
|
|
11
|
+
import { resetFormDirtyStateAfterApiPopulation as W } from "../../utils/formDirtyStateSync.js";
|
|
13
12
|
import j from "../FormFooter.js";
|
|
14
13
|
import z from "../FormHeader.js";
|
|
15
|
-
import
|
|
16
|
-
import { ProgressLoaderRuntime as
|
|
17
|
-
import { useFormMachine as
|
|
18
|
-
import { EnhancedActionExecutor as
|
|
19
|
-
import { ValidationEngine as
|
|
20
|
-
const
|
|
21
|
-
currentStep:
|
|
22
|
-
hasStepLoader:
|
|
23
|
-
loaderConfig:
|
|
14
|
+
import G from "../FormSection/FormSection.js";
|
|
15
|
+
import { ProgressLoaderRuntime as H } from "../ProgressLoaderRuntime.js";
|
|
16
|
+
import { useFormMachine as K } from "../../../state-management/machines/useFormMachine.js";
|
|
17
|
+
import { EnhancedActionExecutor as Q } from "../../../api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js";
|
|
18
|
+
import { ValidationEngine as X } from "../../../validation-system/validation/ValidationEngine.js";
|
|
19
|
+
const q = ({
|
|
20
|
+
currentStep: n,
|
|
21
|
+
hasStepLoader: s,
|
|
22
|
+
loaderConfig: t
|
|
24
23
|
}) => {
|
|
25
|
-
const { isLoadingComplete:
|
|
26
|
-
return /* @__PURE__ */ f("div", { className:
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
const { isLoadingComplete: o } = C(), l = n.sections || [];
|
|
25
|
+
return /* @__PURE__ */ f("div", { className: g.stepContent, children: [
|
|
26
|
+
s && /* @__PURE__ */ r("div", { className: g.loaderWrapper, children: /* @__PURE__ */ r(
|
|
27
|
+
H,
|
|
29
28
|
{
|
|
30
29
|
properties: {
|
|
31
|
-
label:
|
|
32
|
-
showPercentage:
|
|
33
|
-
duration:
|
|
34
|
-
size:
|
|
35
|
-
variant:
|
|
36
|
-
animationSpeed:
|
|
30
|
+
label: t?.label,
|
|
31
|
+
showPercentage: t?.showPercentage ?? !0,
|
|
32
|
+
duration: t?.duration ?? 3,
|
|
33
|
+
size: t?.size ?? "md",
|
|
34
|
+
variant: t?.variant ?? "default",
|
|
35
|
+
animationSpeed: t?.animationSpeed ?? "normal",
|
|
37
36
|
autoStart: !0,
|
|
38
37
|
hideOnComplete: !0,
|
|
39
|
-
onComplete:
|
|
38
|
+
onComplete: t?.completionMessage ? {
|
|
40
39
|
showMessage: {
|
|
41
40
|
enabled: !0,
|
|
42
|
-
text:
|
|
41
|
+
text: t.completionMessage,
|
|
43
42
|
type: "success"
|
|
44
43
|
}
|
|
45
44
|
} : void 0
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
) }),
|
|
49
|
-
(!
|
|
48
|
+
(!s || o) && /* @__PURE__ */ r(_, { children: l.map((c) => /* @__PURE__ */ r(G, { section: c }, c.id)) })
|
|
50
49
|
] });
|
|
51
|
-
},
|
|
52
|
-
const [
|
|
53
|
-
c.current || (c.current = new
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}) : E(t), ...o.data }, y = (e) => {
|
|
61
|
-
(t.actions || []).length > 0 && a({ type: "EXECUTE_ACTIONS", trigger: e });
|
|
62
|
-
}, x = p(), g = p(!1);
|
|
63
|
-
t.id !== x.current && (t.actions || []).length > 0 && !g.current && (x.current = t.id, g.current = !0, setTimeout(() => {
|
|
64
|
-
y("onStepLoad"), setTimeout(() => {
|
|
65
|
-
g.current = !1;
|
|
50
|
+
}, B = () => {
|
|
51
|
+
const [n, s, t] = K(), { currentStep: o, config: l } = t, c = p(), h = p(), S = p(), A = l.validationMessageStyle || "withLabel";
|
|
52
|
+
c.current || (c.current = new X({ messageStyle: A })), (!h.current || S.current !== o.id) && (h.current = c.current.getStepSchema(o), S.current = o.id);
|
|
53
|
+
const E = { ...k(o), ...t.data }, v = (e) => {
|
|
54
|
+
(o.actions || []).length > 0 && s({ type: "EXECUTE_ACTIONS", trigger: e });
|
|
55
|
+
}, F = p(), u = p(!1);
|
|
56
|
+
o.id !== F.current && (o.actions || []).length > 0 && !u.current && (F.current = o.id, u.current = !0, setTimeout(() => {
|
|
57
|
+
v("onStepLoad"), setTimeout(() => {
|
|
58
|
+
u.current = !1;
|
|
66
59
|
}, 1e3);
|
|
67
60
|
}, 0));
|
|
68
|
-
const
|
|
61
|
+
const b = async ({
|
|
69
62
|
value: e
|
|
70
63
|
}) => {
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
formValue: e
|
|
78
|
-
}), r ? (console.log(
|
|
79
|
-
"🎯 [FormStep] Step has onStepFinish actions, requesting navigation first"
|
|
80
|
-
), a({ type: "REQUEST_NAVIGATION", navigationType: "next" })) : (console.log("🎯 [FormStep] No step actions, direct navigation"), o.nextStep());
|
|
81
|
-
}, D = (e) => {
|
|
64
|
+
(o.actions || []).some(
|
|
65
|
+
(d) => d.trigger === "onStepFinish"
|
|
66
|
+
) ? s({ type: "REQUEST_NAVIGATION", navigationType: "next" }) : t.nextStep();
|
|
67
|
+
}, y = (e) => {
|
|
68
|
+
}, T = (e) => {
|
|
69
|
+
w.error("Action execution failed", { error: e.message }, e);
|
|
82
70
|
}, L = (e) => {
|
|
83
|
-
|
|
84
|
-
},
|
|
85
|
-
console.log("🔥 FormStep: handleShowDialog called", { dialogConfig: e }), a({ type: "SHOW_ACTION_DIALOG", dialogConfig: e }), console.log("🔥 FormStep: SHOW_ACTION_DIALOG event sent");
|
|
86
|
-
}, V = (e) => {
|
|
71
|
+
s({ type: "SHOW_ACTION_DIALOG", dialogConfig: e });
|
|
72
|
+
}, N = (e) => {
|
|
87
73
|
switch (e.type) {
|
|
88
74
|
case "next":
|
|
89
|
-
|
|
75
|
+
t.nextStep();
|
|
90
76
|
break;
|
|
91
77
|
case "previous":
|
|
92
|
-
|
|
78
|
+
t.previousStep();
|
|
93
79
|
break;
|
|
94
80
|
case "step":
|
|
95
|
-
e.targetStep &&
|
|
81
|
+
e.targetStep && t.goToStep(e.targetStep);
|
|
96
82
|
break;
|
|
97
83
|
}
|
|
98
|
-
},
|
|
99
|
-
defaultValues:
|
|
100
|
-
onSubmit:
|
|
101
|
-
}),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const I = n;
|
|
107
|
-
o.setData(r, I), l.setFieldValue(r, n);
|
|
84
|
+
}, m = I({
|
|
85
|
+
defaultValues: E,
|
|
86
|
+
onSubmit: b
|
|
87
|
+
}), D = (e, i) => {
|
|
88
|
+
const a = e, d = m.getFieldValue(a), V = n.context.componentOriginalValues[a]?.value;
|
|
89
|
+
if (d !== i) {
|
|
90
|
+
const P = i;
|
|
91
|
+
t.setData(a, P), m.setFieldValue(a, i);
|
|
108
92
|
try {
|
|
109
|
-
|
|
110
|
-
updatedFields: [
|
|
93
|
+
W(m, {
|
|
94
|
+
updatedFields: [a],
|
|
111
95
|
debug: process.env.NODE_ENV === "development"
|
|
112
|
-
})
|
|
113
|
-
} catch (
|
|
114
|
-
console.error("❌ Failed to reset dirty state:",
|
|
96
|
+
});
|
|
97
|
+
} catch (R) {
|
|
98
|
+
console.error("❌ Failed to reset dirty state:", R);
|
|
115
99
|
}
|
|
116
100
|
}
|
|
117
|
-
|
|
118
|
-
|
|
101
|
+
V !== i && setTimeout(() => {
|
|
102
|
+
s({
|
|
119
103
|
type: "MARK_COMPONENT_AS_POPULATED",
|
|
120
|
-
componentId:
|
|
121
|
-
value:
|
|
104
|
+
componentId: a,
|
|
105
|
+
value: i
|
|
122
106
|
});
|
|
123
|
-
}, 0)
|
|
124
|
-
},
|
|
125
|
-
return /* @__PURE__ */ f(
|
|
126
|
-
|
|
127
|
-
|
|
107
|
+
}, 0);
|
|
108
|
+
}, x = o.waitForLoader === !0, O = x ? o.loaderConfig : void 0;
|
|
109
|
+
return /* @__PURE__ */ f(U, { value: m, children: [
|
|
110
|
+
n.matches("executingActions") && (n.context.executingTrigger === "onStepLoad" || n.context.executingTrigger === "onStepFinish") && /* @__PURE__ */ r(
|
|
111
|
+
Q,
|
|
128
112
|
{
|
|
129
|
-
actions:
|
|
130
|
-
trigger:
|
|
131
|
-
formData:
|
|
132
|
-
onComplete:
|
|
133
|
-
onError:
|
|
134
|
-
onFieldUpdate:
|
|
135
|
-
onShowDialog:
|
|
136
|
-
onNavigate:
|
|
113
|
+
actions: o.actions || [],
|
|
114
|
+
trigger: n.context.executingTrigger || "onStepLoad",
|
|
115
|
+
formData: n.context.data,
|
|
116
|
+
onComplete: y,
|
|
117
|
+
onError: T,
|
|
118
|
+
onFieldUpdate: D,
|
|
119
|
+
onShowDialog: L,
|
|
120
|
+
onNavigate: N,
|
|
137
121
|
machineRef: {
|
|
138
|
-
send:
|
|
122
|
+
send: s
|
|
139
123
|
}
|
|
140
124
|
}
|
|
141
125
|
),
|
|
@@ -143,25 +127,25 @@ const J = ({
|
|
|
143
127
|
"form",
|
|
144
128
|
{
|
|
145
129
|
onSubmit: (e) => {
|
|
146
|
-
e.preventDefault(), e.stopPropagation(),
|
|
130
|
+
e.preventDefault(), e.stopPropagation(), m.handleSubmit();
|
|
147
131
|
},
|
|
148
132
|
children: [
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
151
|
-
|
|
133
|
+
/* @__PURE__ */ r(z, {}),
|
|
134
|
+
/* @__PURE__ */ r(M, { children: /* @__PURE__ */ r(
|
|
135
|
+
q,
|
|
152
136
|
{
|
|
153
|
-
currentStep:
|
|
154
|
-
hasStepLoader:
|
|
155
|
-
loaderConfig:
|
|
137
|
+
currentStep: o,
|
|
138
|
+
hasStepLoader: x,
|
|
139
|
+
loaderConfig: O
|
|
156
140
|
}
|
|
157
141
|
) }),
|
|
158
|
-
/* @__PURE__ */
|
|
142
|
+
/* @__PURE__ */ r(j, { className: g.footer })
|
|
159
143
|
]
|
|
160
144
|
}
|
|
161
145
|
)
|
|
162
146
|
] });
|
|
163
147
|
};
|
|
164
|
-
|
|
148
|
+
B.displayName = "FormStep";
|
|
165
149
|
export {
|
|
166
|
-
|
|
150
|
+
B as default
|
|
167
151
|
};
|
package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js
CHANGED
|
@@ -1,57 +1,51 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
2
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import o from "clsx";
|
|
5
5
|
import e from "./StepProgressIndicator.module.css.js";
|
|
6
|
-
import { useFormMachine as
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import { Heading as
|
|
6
|
+
import { useFormMachine as d } from "../../../state-management/machines/useFormMachine.js";
|
|
7
|
+
import h from "../../../../../../ui/src/lib/assets/icons/Check.js";
|
|
8
|
+
import v from "../../../../../../ui/src/lib/assets/icons/ChevronRight.js";
|
|
9
|
+
import { Heading as N } from "@rijkshuisstijl-community/components-react";
|
|
10
10
|
const x = () => {
|
|
11
|
-
const [, , m] =
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
stepTitles: c.map((s) => s.title)
|
|
18
|
-
}), /* @__PURE__ */ r("div", { className: e.stepListWrapper, children: [
|
|
19
|
-
/* @__PURE__ */ t(f, { level: 2, children: "Stappenplan" }),
|
|
20
|
-
/* @__PURE__ */ t("ul", { className: e.stepList, children: c.map((s, i) => {
|
|
21
|
-
const n = i === l, d = i > l, a = i < l;
|
|
22
|
-
return /* @__PURE__ */ r(
|
|
11
|
+
const [, , m] = d(), { currentStepIndex: c, steps: l } = m;
|
|
12
|
+
return /* @__PURE__ */ s("div", { className: e.stepListWrapper, children: [
|
|
13
|
+
/* @__PURE__ */ t(N, { level: 2, children: "Stappenplan" }),
|
|
14
|
+
/* @__PURE__ */ t("ul", { className: e.stepList, children: l.map((n, r) => {
|
|
15
|
+
const i = r === c, p = r > c, a = r < c;
|
|
16
|
+
return /* @__PURE__ */ s(
|
|
23
17
|
"li",
|
|
24
18
|
{
|
|
25
19
|
className: o(e.stepListItem, {
|
|
26
|
-
[e.inactive]:
|
|
20
|
+
[e.inactive]: p,
|
|
27
21
|
[e.completed]: a,
|
|
28
|
-
[e.current]:
|
|
22
|
+
[e.current]: i
|
|
29
23
|
}),
|
|
30
24
|
children: [
|
|
31
|
-
/* @__PURE__ */
|
|
32
|
-
/* @__PURE__ */ t("div", { className: e.circle, children: a ? /* @__PURE__ */ t(
|
|
25
|
+
/* @__PURE__ */ s("div", { className: e.leftContainer, children: [
|
|
26
|
+
/* @__PURE__ */ t("div", { className: e.circle, children: a ? /* @__PURE__ */ t(h, {}) : /* @__PURE__ */ t(
|
|
33
27
|
"div",
|
|
34
28
|
{
|
|
35
29
|
className: o({
|
|
36
|
-
[e.currentDot]:
|
|
30
|
+
[e.currentDot]: i
|
|
37
31
|
})
|
|
38
32
|
}
|
|
39
33
|
) }),
|
|
40
|
-
|
|
34
|
+
r < l.length - 1 && /* @__PURE__ */ t("div", { className: e.connector })
|
|
41
35
|
] }),
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
36
|
+
/* @__PURE__ */ s("div", { className: e.content, children: [
|
|
37
|
+
/* @__PURE__ */ s("div", { className: e.contentText, children: [
|
|
38
|
+
/* @__PURE__ */ s("div", { className: e.stepNumber, children: [
|
|
45
39
|
"Stap ",
|
|
46
|
-
|
|
40
|
+
r + 1
|
|
47
41
|
] }),
|
|
48
|
-
/* @__PURE__ */ t("span", { className: e.stepTitle, children:
|
|
42
|
+
/* @__PURE__ */ t("span", { className: e.stepTitle, children: n.title })
|
|
49
43
|
] }),
|
|
50
|
-
|
|
44
|
+
i ? /* @__PURE__ */ t("div", { className: e.iconRightContainer, children: /* @__PURE__ */ t(v, {}) }) : null
|
|
51
45
|
] })
|
|
52
46
|
]
|
|
53
47
|
},
|
|
54
|
-
|
|
48
|
+
n.id
|
|
55
49
|
);
|
|
56
50
|
}) })
|
|
57
51
|
] });
|
|
@@ -1,78 +1,59 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useRef as
|
|
3
|
-
import { useFormMachine as
|
|
4
|
-
const
|
|
5
|
-
componentId:
|
|
6
|
-
initialValue:
|
|
7
|
-
onValueChange:
|
|
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
|
+
initialValue: o,
|
|
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
16
|
getComponentTriggerState: p
|
|
17
|
-
} =
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
(
|
|
21
|
-
|
|
22
|
-
`🧪 [useComponentTriggers] evaluateTriggers called for ${e}:`,
|
|
23
|
-
{
|
|
24
|
-
eventType: r,
|
|
25
|
-
value: a,
|
|
26
|
-
evaluateComponentTriggers: !!n
|
|
27
|
-
}
|
|
28
|
-
), n(e, r, a);
|
|
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
|
-
), b =
|
|
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: o.current,
|
|
48
|
-
hasTriggers: s,
|
|
49
|
-
onValueChange: !!i
|
|
50
|
-
}
|
|
51
|
-
), o.current = r, i && i(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:
|
|
45
|
+
evaluateTriggers: e,
|
|
46
|
+
setOriginalValue: R,
|
|
66
47
|
alerts: b,
|
|
67
|
-
dismissAlert:
|
|
68
|
-
hasTriggers:
|
|
69
|
-
hasActions:
|
|
70
|
-
triggerState:
|
|
71
|
-
handleValueChange:
|
|
72
|
-
handleFocus:
|
|
73
|
-
handleBlur:
|
|
48
|
+
dismissAlert: F,
|
|
49
|
+
hasTriggers: t,
|
|
50
|
+
hasActions: O,
|
|
51
|
+
triggerState: S,
|
|
52
|
+
handleValueChange: k,
|
|
53
|
+
handleFocus: v,
|
|
54
|
+
handleBlur: x
|
|
74
55
|
};
|
|
75
56
|
};
|
|
76
57
|
export {
|
|
77
|
-
|
|
58
|
+
_ as useComponentTriggers
|
|
78
59
|
};
|
|
@@ -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 {
|