@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,50 +1,49 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as e, jsxs as
|
|
2
|
+
import { jsx as e, jsxs as a } from "react/jsx-runtime";
|
|
3
3
|
/* empty css */
|
|
4
4
|
import { Alert as E, AlertDescription as $ } from "../../../../../../ui/src/components/alert/alert.js";
|
|
5
5
|
import { Button as m } from "../../../../../../ui/src/components/button/button.js";
|
|
6
|
-
import { Dialog as
|
|
6
|
+
import { Dialog as x, DialogContent as D, DialogHeader as V, DialogTitle as A, DialogDescription as L } from "../../../../../../ui/src/components/dialog/dialog.js";
|
|
7
7
|
import { ValidationCode as P } from "../../../../../../ui/src/components/ValidationCode/ValidationCode.js";
|
|
8
8
|
import { CheckCircle as _, Mail as j, AlertCircle as q } from "lucide-react";
|
|
9
|
-
import { memo as H, useState as f, useEffect as I, useCallback as
|
|
9
|
+
import { memo as H, useState as f, useEffect as I, useCallback as O } from "react";
|
|
10
10
|
import i from "./EmailVerificationDialog.module.css.js";
|
|
11
|
-
const
|
|
11
|
+
const W = H(
|
|
12
12
|
({
|
|
13
13
|
config: h,
|
|
14
|
-
formData:
|
|
15
|
-
onButtonClick:
|
|
16
|
-
onClose:
|
|
17
|
-
isOpen:
|
|
14
|
+
formData: Y,
|
|
15
|
+
onButtonClick: u,
|
|
16
|
+
onClose: z,
|
|
17
|
+
isOpen: C
|
|
18
18
|
}) => {
|
|
19
|
-
|
|
20
|
-
const t = h.templateMetadata, [c, C] = f(""), [n, r] = f("idle"), [p, l] = f(""), [d, v] = f(0), [b, k] = f(0);
|
|
19
|
+
const t = h.templateMetadata, [c, p] = f(""), [n, s] = f("idle"), [g, l] = f(""), [d, v] = f(0), [b, k] = f(0);
|
|
21
20
|
I(() => {
|
|
22
21
|
if (d > 0) {
|
|
23
|
-
const
|
|
24
|
-
return () => clearTimeout(
|
|
22
|
+
const o = setTimeout(() => v(d - 1), 1e3);
|
|
23
|
+
return () => clearTimeout(o);
|
|
25
24
|
}
|
|
26
25
|
}, [d]);
|
|
27
|
-
const N =
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
k(
|
|
26
|
+
const N = O(async () => {
|
|
27
|
+
s("verifying");
|
|
28
|
+
const o = b + 1;
|
|
29
|
+
k(o);
|
|
31
30
|
try {
|
|
32
|
-
if (await new Promise((
|
|
33
|
-
|
|
31
|
+
if (await new Promise((r) => setTimeout(r, 1500)), c === "123456" || c === "000000" || c === "111111")
|
|
32
|
+
s("success");
|
|
34
33
|
else {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
|
|
34
|
+
const r = t?.maxAttempts;
|
|
35
|
+
if (r && o >= r)
|
|
36
|
+
s("blocked"), l(
|
|
38
37
|
"Maximum verification attempts exceeded. Please request a new verification code."
|
|
39
38
|
);
|
|
40
39
|
else {
|
|
41
|
-
|
|
42
|
-
const M =
|
|
40
|
+
s("error");
|
|
41
|
+
const M = r ? r - o : null, R = t?.errorMessage || "Invalid code. Please try again.", S = M ? ` (${M} attempts remaining)` : "";
|
|
43
42
|
l(R + S);
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
45
|
} catch {
|
|
47
|
-
|
|
46
|
+
s("error"), l(
|
|
48
47
|
t?.errorMessage || "Verification failed. Please try again."
|
|
49
48
|
);
|
|
50
49
|
}
|
|
@@ -53,18 +52,18 @@ const Y = H(
|
|
|
53
52
|
t?.errorMessage,
|
|
54
53
|
t?.maxAttempts,
|
|
55
54
|
b
|
|
56
|
-
]), w = (
|
|
57
|
-
|
|
58
|
-
}, T = (
|
|
59
|
-
|
|
55
|
+
]), w = (o) => {
|
|
56
|
+
p(o), (n === "error" || n === "blocked") && (s("idle"), l(""));
|
|
57
|
+
}, T = (o) => {
|
|
58
|
+
t?.enableAutoSubmit && n === "idle" && N();
|
|
60
59
|
}, y = () => {
|
|
61
|
-
v(t?.resendTimer || 60),
|
|
60
|
+
v(t?.resendTimer || 60), p(""), s("idle"), l(""), k(0);
|
|
62
61
|
}, B = () => {
|
|
63
|
-
|
|
62
|
+
u({ type: "close" });
|
|
64
63
|
};
|
|
65
|
-
return n === "success" ? /* @__PURE__ */ e(
|
|
66
|
-
/* @__PURE__ */
|
|
67
|
-
/* @__PURE__ */
|
|
64
|
+
return n === "success" ? /* @__PURE__ */ e(x, { open: C, onOpenChange: () => !1, children: /* @__PURE__ */ a(D, { className: i.dialogContent, children: [
|
|
65
|
+
/* @__PURE__ */ a(V, { children: [
|
|
66
|
+
/* @__PURE__ */ a("div", { className: i.headerRow, children: [
|
|
68
67
|
/* @__PURE__ */ e(_, { className: `${i.iconMd} ${i.iconSuccess}` }),
|
|
69
68
|
/* @__PURE__ */ e(A, { children: t?.successTitle || "Verification Successful" })
|
|
70
69
|
] }),
|
|
@@ -73,7 +72,7 @@ const Y = H(
|
|
|
73
72
|
/* @__PURE__ */ e("div", { className: i.successButtonRow, children: /* @__PURE__ */ e(
|
|
74
73
|
m,
|
|
75
74
|
{
|
|
76
|
-
onClick: () =>
|
|
75
|
+
onClick: () => u(
|
|
77
76
|
t?.onVerifiedAction || {
|
|
78
77
|
type: "navigate",
|
|
79
78
|
direction: "next"
|
|
@@ -83,16 +82,16 @@ const Y = H(
|
|
|
83
82
|
children: t?.continueButtonLabel || "Continue"
|
|
84
83
|
}
|
|
85
84
|
) })
|
|
86
|
-
] }) }) : /* @__PURE__ */ e(
|
|
87
|
-
/* @__PURE__ */
|
|
88
|
-
/* @__PURE__ */
|
|
85
|
+
] }) }) : /* @__PURE__ */ e(x, { open: C, onOpenChange: () => !1, children: /* @__PURE__ */ a(D, { className: i.dialogContent, children: [
|
|
86
|
+
/* @__PURE__ */ a(V, { children: [
|
|
87
|
+
/* @__PURE__ */ a("div", { className: i.headerRow, children: [
|
|
89
88
|
/* @__PURE__ */ e(j, { className: `${i.iconMd} ${i.iconMail}` }),
|
|
90
89
|
/* @__PURE__ */ e(A, { children: h.title })
|
|
91
90
|
] }),
|
|
92
91
|
/* @__PURE__ */ e(L, { children: h.content })
|
|
93
92
|
] }),
|
|
94
|
-
/* @__PURE__ */
|
|
95
|
-
/* @__PURE__ */
|
|
93
|
+
/* @__PURE__ */ a("div", { className: i.formContent, children: [
|
|
94
|
+
/* @__PURE__ */ a("div", { className: i.codeSection, children: [
|
|
96
95
|
/* @__PURE__ */ e("div", { className: i.codeLabel, children: "Verification Code" }),
|
|
97
96
|
/* @__PURE__ */ e("div", { className: i.codeCenter, children: /* @__PURE__ */ e(
|
|
98
97
|
P,
|
|
@@ -105,9 +104,9 @@ const Y = H(
|
|
|
105
104
|
}
|
|
106
105
|
) })
|
|
107
106
|
] }),
|
|
108
|
-
(n === "error" || n === "blocked") &&
|
|
107
|
+
(n === "error" || n === "blocked") && g && /* @__PURE__ */ a(E, { variant: "destructive", children: [
|
|
109
108
|
/* @__PURE__ */ e(q, { className: i.iconSm }),
|
|
110
|
-
/* @__PURE__ */ e($, { children:
|
|
109
|
+
/* @__PURE__ */ e($, { children: g })
|
|
111
110
|
] }),
|
|
112
111
|
t?.enableResend && n !== "blocked" && /* @__PURE__ */ e("div", { className: i.resendText, children: d > 0 ? `Resend code in ${d}s` : /* @__PURE__ */ e(
|
|
113
112
|
m,
|
|
@@ -128,7 +127,7 @@ const Y = H(
|
|
|
128
127
|
}
|
|
129
128
|
) })
|
|
130
129
|
] }),
|
|
131
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ a("div", { className: i.footerButtonRow, children: [
|
|
132
131
|
/* @__PURE__ */ e(m, { variant: "secondary", onClick: B, children: t?.cancelButtonLabel || "Cancel" }),
|
|
133
132
|
/* @__PURE__ */ e(
|
|
134
133
|
m,
|
|
@@ -142,8 +141,8 @@ const Y = H(
|
|
|
142
141
|
] }) });
|
|
143
142
|
}
|
|
144
143
|
);
|
|
145
|
-
|
|
144
|
+
W.displayName = "EmailVerificationDialog";
|
|
146
145
|
export {
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
W as EmailVerificationDialog,
|
|
147
|
+
W as default
|
|
149
148
|
};
|
|
@@ -1,110 +1,63 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { wizardDefaultRenderer as
|
|
2
|
+
import { jsx as r, jsxs as d } from "react/jsx-runtime";
|
|
3
|
+
import { wizardDefaultRenderer as u } from "../../../renderer/wizardRenderer.js";
|
|
4
4
|
/* empty css */
|
|
5
5
|
import { FormLayout as m } from "../../../../../ui/src/components/FormLayout/FormLayout.js";
|
|
6
|
-
import { formWizardQueryClient as
|
|
7
|
-
import { QueryClientProvider as
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import {
|
|
16
|
-
import
|
|
17
|
-
import {
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
V(z);
|
|
24
|
-
const v = N(
|
|
6
|
+
import { formWizardQueryClient as g } from "../../../../../ui/src/lib/queryClient.js";
|
|
7
|
+
import { QueryClientProvider as y } from "@tanstack/react-query";
|
|
8
|
+
import { memo as C, useMemo as s } from "react";
|
|
9
|
+
import F from "./FormWizard.module.css.js";
|
|
10
|
+
import v from "../components/FormStep/FormStep.js";
|
|
11
|
+
import S from "../components/StepProgressIndicator/StepProgressIndicator.js";
|
|
12
|
+
import { ThemeProvider as M, useThemeConfig as z } from "../../../../../ui/src/theme/ThemeProvider.js";
|
|
13
|
+
import { useFormMachineProvider as P, FormMachineContext as N } from "../../state-management/machines/useFormMachine.js";
|
|
14
|
+
import W from "../../../../../ui/src/lib/error-boundaries/FormWizardErrorBoundary.js";
|
|
15
|
+
import { FormEditingProvider as E } from "../../../../../ui/src/lib/providers/FormEditingContext.js";
|
|
16
|
+
import i from "../../../../../ui/src/lib/error-boundaries/ComponentErrorBoundary.js";
|
|
17
|
+
import { ActionManager as x } from "../../trigger-action-system/components/ActionManager.js";
|
|
18
|
+
import { registerRenderComponent as L } from "../../../../../ui/src/component-registry/renderComponent.js";
|
|
19
|
+
import { ValidationEngine as w } from "../../validation-system/validation/ValidationEngine.js";
|
|
20
|
+
import { Heading as I } from "@rijkshuisstijl-community/components-react";
|
|
21
|
+
L(u);
|
|
22
|
+
const p = C(
|
|
25
23
|
({
|
|
26
|
-
config:
|
|
27
|
-
initialData:
|
|
28
|
-
onSubmit:
|
|
29
|
-
queryClient:
|
|
24
|
+
config: e,
|
|
25
|
+
initialData: o = {},
|
|
26
|
+
onSubmit: l,
|
|
27
|
+
queryClient: c = g
|
|
30
28
|
}) => {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
validationMessageStyle: r.validationMessageStyle,
|
|
38
|
-
hasInitialData: Object.keys(a).length > 0
|
|
39
|
-
}
|
|
40
|
-
), typeof window < "u" && setTimeout(() => {
|
|
41
|
-
console.log(
|
|
42
|
-
"🚨 [FormWizard] MOUNTED SUCCESSFULLY - Check console for detailed logs"
|
|
43
|
-
);
|
|
44
|
-
}, 100);
|
|
45
|
-
const [t, d] = h(null), [c, f] = h(null);
|
|
46
|
-
w(() => {
|
|
47
|
-
(async () => {
|
|
48
|
-
try {
|
|
49
|
-
if (f(null), P(r)) {
|
|
50
|
-
const o = await T(r);
|
|
51
|
-
d(o);
|
|
52
|
-
} else
|
|
53
|
-
d(r);
|
|
54
|
-
} catch (o) {
|
|
55
|
-
f(
|
|
56
|
-
o instanceof Error ? o.message : "Failed to resolve configuration"
|
|
57
|
-
), console.error("Error resolving form configuration:", o);
|
|
58
|
-
}
|
|
59
|
-
})();
|
|
60
|
-
}, [r]);
|
|
61
|
-
const p = u(() => {
|
|
62
|
-
console.log(
|
|
63
|
-
"🚀 [FormWizard] Creating ValidationEngine with messageStyle:",
|
|
64
|
-
r.validationMessageStyle || "withLabel"
|
|
65
|
-
);
|
|
66
|
-
const i = new k({
|
|
67
|
-
messageStyle: r.validationMessageStyle || "withLabel"
|
|
68
|
-
});
|
|
69
|
-
return console.log("✅ [FormWizard] ValidationEngine created:", {
|
|
70
|
-
engine: !!i,
|
|
71
|
-
validateField: typeof i.validateField,
|
|
72
|
-
messageStyle: r.validationMessageStyle || "withLabel"
|
|
73
|
-
}), i;
|
|
74
|
-
}, [r.validationMessageStyle]), S = u(() => t ? {
|
|
75
|
-
...t,
|
|
76
|
-
steps: t.steps.map((i) => {
|
|
77
|
-
const o = i;
|
|
29
|
+
const n = s(() => new w({
|
|
30
|
+
messageStyle: e.validationMessageStyle || "withLabel"
|
|
31
|
+
}), [e.validationMessageStyle]), f = s(() => ({
|
|
32
|
+
...e,
|
|
33
|
+
steps: e.steps.map((a) => {
|
|
34
|
+
const t = a;
|
|
78
35
|
return {
|
|
79
|
-
...
|
|
80
|
-
schema:
|
|
36
|
+
...t,
|
|
37
|
+
schema: t.schema || n.getStepSchema(t)
|
|
81
38
|
};
|
|
82
39
|
})
|
|
83
|
-
}
|
|
84
|
-
config:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
onSubmit: C
|
|
40
|
+
}), [e, n]), h = P({
|
|
41
|
+
config: f,
|
|
42
|
+
initialData: o,
|
|
43
|
+
onSubmit: l
|
|
88
44
|
});
|
|
89
|
-
return c
|
|
90
|
-
/* @__PURE__ */
|
|
91
|
-
/* @__PURE__ */
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/* @__PURE__ */ e(m.Title, { children: /* @__PURE__ */ e(A, { level: 1, children: r.title }) }),
|
|
96
|
-
/* @__PURE__ */ e(m.LeftColumn, { children: /* @__PURE__ */ e(s, { componentName: "StepProgressIndicator", children: /* @__PURE__ */ e(L, {}) }) }),
|
|
97
|
-
/* @__PURE__ */ e(s, { componentName: "FormStep", children: /* @__PURE__ */ e(W, {}) })
|
|
45
|
+
return /* @__PURE__ */ r(y, { client: c, children: /* @__PURE__ */ r(W, { formId: e.id, children: /* @__PURE__ */ r(E, { children: /* @__PURE__ */ d(N.Provider, { value: h, children: [
|
|
46
|
+
/* @__PURE__ */ r(i, { componentName: "ActionManager", children: /* @__PURE__ */ r(x, {}) }),
|
|
47
|
+
/* @__PURE__ */ d(m, { className: F.formLayout, children: [
|
|
48
|
+
/* @__PURE__ */ r(m.Title, { children: /* @__PURE__ */ r(I, { level: 1, children: e.title }) }),
|
|
49
|
+
/* @__PURE__ */ r(m.LeftColumn, { children: /* @__PURE__ */ r(i, { componentName: "StepProgressIndicator", children: /* @__PURE__ */ r(S, {}) }) }),
|
|
50
|
+
/* @__PURE__ */ r(i, { componentName: "FormStep", children: /* @__PURE__ */ r(v, {}) })
|
|
98
51
|
] })
|
|
99
|
-
] }) }) }) })
|
|
52
|
+
] }) }) }) });
|
|
100
53
|
}
|
|
101
54
|
);
|
|
102
|
-
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
return /* @__PURE__ */
|
|
55
|
+
p.displayName = "FormWizardCore";
|
|
56
|
+
const T = (e) => {
|
|
57
|
+
const o = z();
|
|
58
|
+
return /* @__PURE__ */ r(M, { config: o, children: /* @__PURE__ */ r(p, { ...e }) });
|
|
106
59
|
};
|
|
107
|
-
|
|
60
|
+
T.displayName = "FormWizard";
|
|
108
61
|
export {
|
|
109
|
-
|
|
62
|
+
T as default
|
|
110
63
|
};
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
const o = "fb-
|
|
3
|
-
|
|
4
|
-
errorHeading: t,
|
|
5
|
-
loadingState: e,
|
|
6
|
-
loadingPulse: r,
|
|
7
|
-
formLayout: a
|
|
2
|
+
const o = "fb-formLayout_JzC8E", t = {
|
|
3
|
+
formLayout: o
|
|
8
4
|
};
|
|
9
5
|
export {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
o as errorState,
|
|
13
|
-
a as formLayout,
|
|
14
|
-
r as loadingPulse,
|
|
15
|
-
e as loadingState
|
|
6
|
+
t as default,
|
|
7
|
+
o as formLayout
|
|
16
8
|
};
|
|
@@ -1,209 +1,78 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import { clsx as
|
|
2
|
+
import { jsx as h, jsxs as F } from "react/jsx-runtime";
|
|
3
|
+
import { clsx as b } from "clsx";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { useFormContext as
|
|
6
|
-
import { useFormEditing as
|
|
7
|
-
import { useFormMachine as
|
|
8
|
-
import { Button as
|
|
9
|
-
const
|
|
10
|
-
navigation:
|
|
11
|
-
children:
|
|
12
|
-
isDisplayOnly:
|
|
13
|
-
onNext:
|
|
14
|
-
isLastStep:
|
|
5
|
+
import { useFormContext as S } from "../hooks/useFormContext.js";
|
|
6
|
+
import { useFormEditing as g } from "../../../../../ui/src/lib/providers/FormEditingContext.js";
|
|
7
|
+
import { useFormMachine as N } from "../../state-management/machines/useFormMachine.js";
|
|
8
|
+
import { Button as A } from "@rijkshuisstijl-community/components-react";
|
|
9
|
+
const I = ({
|
|
10
|
+
navigation: r,
|
|
11
|
+
children: a,
|
|
12
|
+
isDisplayOnly: e = !1,
|
|
13
|
+
onNext: c,
|
|
14
|
+
isLastStep: p = !1,
|
|
15
15
|
isDisabled: n = !1,
|
|
16
|
-
|
|
16
|
+
labels: i,
|
|
17
|
+
...o
|
|
17
18
|
}) => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
};
|
|
21
|
-
return /* @__PURE__ */
|
|
19
|
+
const l = () => {
|
|
20
|
+
e || n || c?.();
|
|
21
|
+
}, m = r?.next?.label || (p ? i?.finish ?? "Voltooien" : i?.next ?? "Volgende");
|
|
22
|
+
return /* @__PURE__ */ F(
|
|
22
23
|
"div",
|
|
23
24
|
{
|
|
24
|
-
className:
|
|
25
|
-
(n ||
|
|
26
|
-
|
|
25
|
+
className: b(
|
|
26
|
+
(n || e) && "opacity-50",
|
|
27
|
+
o.className
|
|
27
28
|
),
|
|
28
|
-
...
|
|
29
|
+
...o,
|
|
29
30
|
children: [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
a,
|
|
32
|
+
r?.next?.enabled !== !1 && /* @__PURE__ */ h(
|
|
33
|
+
A,
|
|
33
34
|
{
|
|
34
35
|
appearance: "primary-action-button",
|
|
35
|
-
onClick:
|
|
36
|
-
disabled: n ||
|
|
37
|
-
children:
|
|
36
|
+
onClick: l,
|
|
37
|
+
disabled: n || e,
|
|
38
|
+
children: m
|
|
38
39
|
}
|
|
39
40
|
)
|
|
40
41
|
]
|
|
41
42
|
}
|
|
42
43
|
);
|
|
43
|
-
},
|
|
44
|
-
const { isEditing:
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
}, k = ({ children: r, labels: a, ...e }) => {
|
|
45
|
+
const { isEditing: c } = g(), [p, n, i] = N(), { currentStep: o, isLastStep: l, nextStep: m } = i, { navigation: u } = o, s = S(), x = () => {
|
|
46
|
+
const d = Object.keys(s.state.fieldMeta).filter((f) => {
|
|
47
|
+
const t = s.state.fieldMeta[f];
|
|
48
|
+
return !t.isValid && t.errors?.length > 0;
|
|
49
|
+
});
|
|
50
|
+
d.length > 0 && n({ type: "TRIGGER_STEP_VALIDATION", fieldIds: d });
|
|
51
|
+
};
|
|
52
|
+
return /* @__PURE__ */ h(
|
|
53
|
+
I,
|
|
47
54
|
{
|
|
48
|
-
navigation:
|
|
55
|
+
navigation: u,
|
|
49
56
|
onNext: async () => {
|
|
57
|
+
if (!s.state.canSubmit) {
|
|
58
|
+
x();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const f = (o.actions ?? []).some((t) => t.trigger === "onStepFinish");
|
|
50
62
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
);
|
|
54
|
-
if (console.log("🔍 [FormFooter] Starting form submission check:", {
|
|
55
|
-
stepId: r.id,
|
|
56
|
-
stepActions: c.length,
|
|
57
|
-
hasFinishActions: h
|
|
58
|
-
}), h) {
|
|
59
|
-
const s = Object.keys(e.state.fieldMeta).map(
|
|
60
|
-
(t) => {
|
|
61
|
-
const o = e.state.fieldMeta[t], i = e.getFieldValue(t);
|
|
62
|
-
return {
|
|
63
|
-
fieldId: t,
|
|
64
|
-
value: i,
|
|
65
|
-
isValid: o.isValid,
|
|
66
|
-
isDirty: o.isDirty,
|
|
67
|
-
isTouched: o.isTouched,
|
|
68
|
-
errors: o.errors,
|
|
69
|
-
errorCount: o.errors?.length || 0
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
);
|
|
73
|
-
if (console.log(
|
|
74
|
-
"🔍 [FormFooter] Step has finish actions - checking form state:",
|
|
75
|
-
{
|
|
76
|
-
canSubmit: e.state.canSubmit,
|
|
77
|
-
isValid: e.state.isValid,
|
|
78
|
-
isSubmitting: e.state.isSubmitting,
|
|
79
|
-
fieldCount: Object.keys(e.state.fieldMeta).length,
|
|
80
|
-
fieldAnalysis: s,
|
|
81
|
-
formErrors: e.state.formErrors
|
|
82
|
-
}
|
|
83
|
-
), console.log("📋 [FormFooter] Detailed field analysis:"), s.forEach((t, o) => {
|
|
84
|
-
console.log(` Field ${o + 1}:`, {
|
|
85
|
-
fieldId: t.fieldId,
|
|
86
|
-
value: t.value,
|
|
87
|
-
isValid: t.isValid,
|
|
88
|
-
isDirty: t.isDirty,
|
|
89
|
-
isTouched: t.isTouched,
|
|
90
|
-
errors: t.errors,
|
|
91
|
-
errorCount: t.errorCount
|
|
92
|
-
});
|
|
93
|
-
}), e.state.canSubmit)
|
|
94
|
-
await e.handleSubmit();
|
|
95
|
-
else {
|
|
96
|
-
console.log(
|
|
97
|
-
"🚫 [FormFooter] Form validation failed for step with finish actions, triggering error display:",
|
|
98
|
-
{
|
|
99
|
-
canSubmit: e.state.canSubmit,
|
|
100
|
-
isValid: e.state.isValid,
|
|
101
|
-
isSubmitting: e.state.isSubmitting,
|
|
102
|
-
fieldMeta: e.state.fieldMeta,
|
|
103
|
-
formErrors: e.state.formErrors
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
const t = Object.keys(e.state.fieldMeta).filter(
|
|
107
|
-
(o) => {
|
|
108
|
-
const i = e.state.fieldMeta[o];
|
|
109
|
-
return !i.isValid && i.errors?.length > 0;
|
|
110
|
-
}
|
|
111
|
-
);
|
|
112
|
-
t.length > 0 && (console.log(
|
|
113
|
-
`🔍 [FormFooter] Triggering error display for ${t.length} invalid fields:`,
|
|
114
|
-
t
|
|
115
|
-
), window.dispatchEvent(
|
|
116
|
-
new CustomEvent("triggerStepValidation", {
|
|
117
|
-
detail: { fieldIds: t }
|
|
118
|
-
})
|
|
119
|
-
));
|
|
120
|
-
}
|
|
121
|
-
} else {
|
|
122
|
-
const s = Object.keys(e.state.fieldMeta).map(
|
|
123
|
-
(t) => {
|
|
124
|
-
const o = e.state.fieldMeta[t], i = e.getFieldValue(t);
|
|
125
|
-
return {
|
|
126
|
-
fieldId: t,
|
|
127
|
-
value: i,
|
|
128
|
-
isValid: o.isValid,
|
|
129
|
-
isDirty: o.isDirty,
|
|
130
|
-
isTouched: o.isTouched,
|
|
131
|
-
errors: o.errors,
|
|
132
|
-
errorCount: o.errors?.length || 0
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
);
|
|
136
|
-
if (console.log(
|
|
137
|
-
"🔍 [FormFooter] Step has no finish actions - checking form state:",
|
|
138
|
-
{
|
|
139
|
-
canSubmit: e.state.canSubmit,
|
|
140
|
-
isValid: e.state.isValid,
|
|
141
|
-
isSubmitting: e.state.isSubmitting,
|
|
142
|
-
fieldCount: Object.keys(e.state.fieldMeta).length,
|
|
143
|
-
fieldAnalysis: s,
|
|
144
|
-
formErrors: e.state.formErrors
|
|
145
|
-
}
|
|
146
|
-
), console.log("📋 [FormFooter] Detailed field analysis:"), s.forEach((t, o) => {
|
|
147
|
-
console.log(` Field ${o + 1}:`, {
|
|
148
|
-
fieldId: t.fieldId,
|
|
149
|
-
value: t.value,
|
|
150
|
-
isValid: t.isValid,
|
|
151
|
-
isDirty: t.isDirty,
|
|
152
|
-
isTouched: t.isTouched,
|
|
153
|
-
errors: t.errors,
|
|
154
|
-
errorCount: t.errorCount
|
|
155
|
-
});
|
|
156
|
-
}), e.state.canSubmit) {
|
|
157
|
-
const t = e.state.values, o = {};
|
|
158
|
-
console.log("🔄 [FormFooter] Preparing form values for navigation:", {
|
|
159
|
-
formValues: t,
|
|
160
|
-
fieldIds: Object.keys(t)
|
|
161
|
-
}), Object.keys(t).forEach((i) => {
|
|
162
|
-
const F = e.getFieldValue(i);
|
|
163
|
-
o[i] = F, console.log(`🔄 [FormFooter] Prepared field ${i}:`, F);
|
|
164
|
-
}), m({
|
|
165
|
-
type: "REQUEST_NAVIGATION",
|
|
166
|
-
navigationType: "next"
|
|
167
|
-
});
|
|
168
|
-
} else {
|
|
169
|
-
console.log(
|
|
170
|
-
"🚫 [FormFooter] Form cannot be submitted (validation failed or form is submitting), triggering error display:",
|
|
171
|
-
{
|
|
172
|
-
canSubmit: e.state.canSubmit,
|
|
173
|
-
isValid: e.state.isValid,
|
|
174
|
-
isSubmitting: e.state.isSubmitting,
|
|
175
|
-
fieldMeta: e.state.fieldMeta,
|
|
176
|
-
formErrors: e.state.formErrors,
|
|
177
|
-
values: e.state.values
|
|
178
|
-
}
|
|
179
|
-
);
|
|
180
|
-
const t = Object.keys(e.state.fieldMeta).filter(
|
|
181
|
-
(o) => {
|
|
182
|
-
const i = e.state.fieldMeta[o];
|
|
183
|
-
return !i.isValid && i.errors?.length > 0;
|
|
184
|
-
}
|
|
185
|
-
);
|
|
186
|
-
t.length > 0 && (console.log(
|
|
187
|
-
`🔍 [FormFooter] Triggering error display for ${t.length} invalid fields:`,
|
|
188
|
-
t
|
|
189
|
-
), window.dispatchEvent(
|
|
190
|
-
new CustomEvent("triggerStepValidation", {
|
|
191
|
-
detail: { fieldIds: t }
|
|
192
|
-
})
|
|
193
|
-
));
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
} catch (c) {
|
|
197
|
-
console.log("🚫 [FormFooter] Form submission failed:", c);
|
|
63
|
+
f ? await s.handleSubmit() : m();
|
|
64
|
+
} catch (t) {
|
|
65
|
+
console.error("Form submission failed:", t);
|
|
198
66
|
}
|
|
199
67
|
},
|
|
200
|
-
isLastStep:
|
|
201
|
-
isDisabled:
|
|
202
|
-
|
|
203
|
-
|
|
68
|
+
isLastStep: l,
|
|
69
|
+
isDisabled: c,
|
|
70
|
+
labels: a,
|
|
71
|
+
...e,
|
|
72
|
+
children: /* @__PURE__ */ h(s.Subscribe, { children: r })
|
|
204
73
|
}
|
|
205
74
|
);
|
|
206
75
|
};
|
|
207
76
|
export {
|
|
208
|
-
|
|
77
|
+
k as default
|
|
209
78
|
};
|