@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,31 +1,31 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsxs as
|
|
3
|
-
import
|
|
2
|
+
import { jsxs as h, jsx as n, Fragment as M } from "react/jsx-runtime";
|
|
3
|
+
import S from "./FormStep.module.css.js";
|
|
4
4
|
/* empty css */
|
|
5
|
-
import { isTemplateStep as
|
|
6
|
-
import { logger as
|
|
7
|
-
import {
|
|
8
|
-
import { useFormMachine as k } from "../../../state-management/machines/useFormMachine.js";
|
|
9
|
-
import { useForm as W } from "@tanstack/react-form";
|
|
5
|
+
import { isTemplateStep as l } from "../../../../../../ui/src/lib/types/guards.js";
|
|
6
|
+
import { logger as C } from "../../../../../../ui/src/lib/logger.js";
|
|
7
|
+
import { useForm as U } from "@tanstack/react-form";
|
|
10
8
|
import { useRef as p } from "react";
|
|
11
|
-
import { LoaderProvider as
|
|
9
|
+
import { LoaderProvider as k, useLoaderContext as W } from "../../context/LoaderContext.js";
|
|
12
10
|
import { FormProvider as j } from "../../hooks/useFormContext.js";
|
|
13
|
-
import { buildDefaultValues as
|
|
11
|
+
import { buildDefaultValues as v } from "../../utils/formDataBuilder.js";
|
|
14
12
|
import { resetFormDirtyStateAfterApiPopulation as z } from "../../utils/formDirtyStateSync.js";
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { ProgressLoaderRuntime as
|
|
13
|
+
import G from "../FormFooter.js";
|
|
14
|
+
import H from "../FormHeader.js";
|
|
15
|
+
import K from "../FormSection/FormSection.js";
|
|
16
|
+
import { ProgressLoaderRuntime as Q } from "../ProgressLoaderRuntime.js";
|
|
17
|
+
import { useFormMachine as X } from "../../../state-management/machines/useFormMachine.js";
|
|
18
|
+
import { EnhancedActionExecutor as q } from "../../../api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js";
|
|
19
19
|
import { ValidationEngine as B } from "../../../validation-system/validation/ValidationEngine.js";
|
|
20
20
|
const J = ({
|
|
21
|
-
currentStep:
|
|
22
|
-
hasStepLoader:
|
|
21
|
+
currentStep: r,
|
|
22
|
+
hasStepLoader: s,
|
|
23
23
|
loaderConfig: o
|
|
24
24
|
}) => {
|
|
25
|
-
const { isLoadingComplete:
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
const { isLoadingComplete: e } = W(), u = l(r) ? [] : r.sections || [];
|
|
26
|
+
return /* @__PURE__ */ h("div", { className: S.stepContent, children: [
|
|
27
|
+
s && /* @__PURE__ */ n("div", { className: S.loaderWrapper, children: /* @__PURE__ */ n(
|
|
28
|
+
Q,
|
|
29
29
|
{
|
|
30
30
|
properties: {
|
|
31
31
|
label: o?.label,
|
|
@@ -46,45 +46,38 @@ const J = ({
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
) }),
|
|
49
|
-
(!
|
|
49
|
+
(!s || e) && /* @__PURE__ */ n(M, { children: u.map((i) => /* @__PURE__ */ n(K, { section: i }, i.id)) })
|
|
50
50
|
] });
|
|
51
51
|
}, Y = () => {
|
|
52
|
-
const [
|
|
53
|
-
|
|
54
|
-
...
|
|
52
|
+
const [r, s, o] = X(), { currentStep: e, config: u } = o, i = p(), d = p(), F = p(), T = u.validationMessageStyle || "withLabel";
|
|
53
|
+
i.current || (i.current = new B({ messageStyle: T })), (!d.current || F.current !== e.id) && (l(e) ? d.current = i.current.getStepSchema({
|
|
54
|
+
...e,
|
|
55
55
|
sections: []
|
|
56
|
-
}) :
|
|
57
|
-
const
|
|
58
|
-
...
|
|
56
|
+
}) : d.current = i.current.getStepSchema(e), F.current = e.id);
|
|
57
|
+
const b = { ...l(e) ? v({
|
|
58
|
+
...e,
|
|
59
59
|
sections: []
|
|
60
|
-
}) :
|
|
61
|
-
(
|
|
62
|
-
}, x = p(),
|
|
63
|
-
|
|
60
|
+
}) : v(e), ...o.data }, y = (t) => {
|
|
61
|
+
(e.actions || []).length > 0 && s({ type: "EXECUTE_ACTIONS", trigger: t });
|
|
62
|
+
}, x = p(), f = p(!1);
|
|
63
|
+
e.id !== x.current && (e.actions || []).length > 0 && !f.current && (x.current = e.id, f.current = !0, setTimeout(() => {
|
|
64
64
|
y("onStepLoad"), setTimeout(() => {
|
|
65
|
-
|
|
65
|
+
f.current = !1;
|
|
66
66
|
}, 1e3);
|
|
67
67
|
}, 0));
|
|
68
|
-
const
|
|
69
|
-
value:
|
|
68
|
+
const L = async ({
|
|
69
|
+
value: t
|
|
70
70
|
}) => {
|
|
71
|
-
|
|
72
|
-
(
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}, D = (e) => {
|
|
82
|
-
}, L = (e) => {
|
|
83
|
-
U.error("Action execution failed", { error: e.message }, e);
|
|
84
|
-
}, O = (e) => {
|
|
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) => {
|
|
87
|
-
switch (e.type) {
|
|
71
|
+
(e.actions || []).some(
|
|
72
|
+
(g) => g.trigger === "onStepFinish"
|
|
73
|
+
) ? s({ type: "REQUEST_NAVIGATION", navigationType: "next" }) : o.nextStep();
|
|
74
|
+
}, N = (t) => {
|
|
75
|
+
}, D = (t) => {
|
|
76
|
+
C.error("Action execution failed", { error: t.message }, t);
|
|
77
|
+
}, O = (t) => {
|
|
78
|
+
s({ type: "SHOW_ACTION_DIALOG", dialogConfig: t });
|
|
79
|
+
}, V = (t) => {
|
|
80
|
+
switch (t.type) {
|
|
88
81
|
case "next":
|
|
89
82
|
o.nextStep();
|
|
90
83
|
break;
|
|
@@ -92,70 +85,68 @@ const J = ({
|
|
|
92
85
|
o.previousStep();
|
|
93
86
|
break;
|
|
94
87
|
case "step":
|
|
95
|
-
|
|
88
|
+
t.targetStep && o.goToStep(t.targetStep);
|
|
96
89
|
break;
|
|
97
90
|
}
|
|
98
|
-
},
|
|
99
|
-
defaultValues:
|
|
100
|
-
onSubmit:
|
|
101
|
-
}),
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
const I = n;
|
|
107
|
-
o.setData(r, I), l.setFieldValue(r, n);
|
|
91
|
+
}, m = U({
|
|
92
|
+
defaultValues: b,
|
|
93
|
+
onSubmit: L
|
|
94
|
+
}), P = (t, a) => {
|
|
95
|
+
const c = t, g = m.getFieldValue(c), _ = r.context.componentOriginalValues[c]?.value;
|
|
96
|
+
if (g !== a) {
|
|
97
|
+
const w = a;
|
|
98
|
+
o.setData(c, w), m.setFieldValue(c, a);
|
|
108
99
|
try {
|
|
109
|
-
z(
|
|
110
|
-
updatedFields: [
|
|
100
|
+
z(m, {
|
|
101
|
+
updatedFields: [c],
|
|
111
102
|
debug: process.env.NODE_ENV === "development"
|
|
112
|
-
})
|
|
113
|
-
} catch (
|
|
114
|
-
console.error("❌ Failed to reset dirty state:",
|
|
103
|
+
});
|
|
104
|
+
} catch (I) {
|
|
105
|
+
console.error("❌ Failed to reset dirty state:", I);
|
|
115
106
|
}
|
|
116
107
|
}
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
_ !== a && setTimeout(() => {
|
|
109
|
+
s({
|
|
119
110
|
type: "MARK_COMPONENT_AS_POPULATED",
|
|
120
|
-
componentId:
|
|
121
|
-
value:
|
|
111
|
+
componentId: c,
|
|
112
|
+
value: a
|
|
122
113
|
});
|
|
123
|
-
}, 0)
|
|
124
|
-
}, A =
|
|
125
|
-
return /* @__PURE__ */
|
|
126
|
-
|
|
127
|
-
|
|
114
|
+
}, 0);
|
|
115
|
+
}, A = e, E = !l(e) && A.waitForLoader === !0, R = E ? A.loaderConfig : void 0;
|
|
116
|
+
return /* @__PURE__ */ h(j, { value: m, children: [
|
|
117
|
+
r.matches("executingActions") && (r.context.executingTrigger === "onStepLoad" || r.context.executingTrigger === "onStepFinish") && /* @__PURE__ */ n(
|
|
118
|
+
q,
|
|
128
119
|
{
|
|
129
|
-
actions:
|
|
130
|
-
trigger:
|
|
131
|
-
formData:
|
|
132
|
-
onComplete:
|
|
133
|
-
onError:
|
|
134
|
-
onFieldUpdate:
|
|
120
|
+
actions: e.actions || [],
|
|
121
|
+
trigger: r.context.executingTrigger || "onStepLoad",
|
|
122
|
+
formData: r.context.data,
|
|
123
|
+
onComplete: N,
|
|
124
|
+
onError: D,
|
|
125
|
+
onFieldUpdate: P,
|
|
135
126
|
onShowDialog: O,
|
|
136
127
|
onNavigate: V,
|
|
137
128
|
machineRef: {
|
|
138
|
-
send:
|
|
129
|
+
send: s
|
|
139
130
|
}
|
|
140
131
|
}
|
|
141
132
|
),
|
|
142
|
-
/* @__PURE__ */
|
|
133
|
+
/* @__PURE__ */ h(
|
|
143
134
|
"form",
|
|
144
135
|
{
|
|
145
|
-
onSubmit: (
|
|
146
|
-
|
|
136
|
+
onSubmit: (t) => {
|
|
137
|
+
t.preventDefault(), t.stopPropagation(), m.handleSubmit();
|
|
147
138
|
},
|
|
148
139
|
children: [
|
|
149
|
-
/* @__PURE__ */
|
|
150
|
-
/* @__PURE__ */
|
|
140
|
+
/* @__PURE__ */ n(H, {}),
|
|
141
|
+
/* @__PURE__ */ n(k, { children: /* @__PURE__ */ n(
|
|
151
142
|
J,
|
|
152
143
|
{
|
|
153
|
-
currentStep:
|
|
154
|
-
hasStepLoader:
|
|
155
|
-
loaderConfig:
|
|
144
|
+
currentStep: e,
|
|
145
|
+
hasStepLoader: E,
|
|
146
|
+
loaderConfig: R
|
|
156
147
|
}
|
|
157
148
|
) }),
|
|
158
|
-
/* @__PURE__ */
|
|
149
|
+
/* @__PURE__ */ n(G, { className: S.footer })
|
|
159
150
|
]
|
|
160
151
|
}
|
|
161
152
|
)
|
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
|
-
import { useFormMachine as h } from "../../../state-management/machines/useFormMachine.js";
|
|
5
4
|
import o from "clsx";
|
|
6
5
|
import e from "./StepProgressIndicator.module.css.js";
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
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,23 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { resolveTemplateStep as i } from "./templateLoader.js";
|
|
3
|
-
import { isTemplateStep as
|
|
3
|
+
import { isTemplateStep as n } from "../../../../../core/src/types/guards.js";
|
|
4
4
|
async function m(e) {
|
|
5
|
-
const
|
|
5
|
+
const s = {
|
|
6
6
|
next: { label: "Next", enabled: !0 },
|
|
7
7
|
previous: { label: "Previous", enabled: !0 }
|
|
8
8
|
}, l = await Promise.all(
|
|
9
|
-
e.steps.map(async (
|
|
10
|
-
if (
|
|
11
|
-
const a = { ...
|
|
12
|
-
|
|
13
|
-
const o =
|
|
9
|
+
e.steps.map(async (t, r) => {
|
|
10
|
+
if (n(t)) {
|
|
11
|
+
const a = { ...s };
|
|
12
|
+
r === 0 && (a.previous.enabled = !1), r === e.steps.length - 1 && (a.next.label = "Submit");
|
|
13
|
+
const o = t.stepIndex;
|
|
14
14
|
return await i(
|
|
15
|
-
|
|
15
|
+
t,
|
|
16
16
|
a,
|
|
17
17
|
o
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
-
return
|
|
20
|
+
return t;
|
|
21
21
|
})
|
|
22
22
|
);
|
|
23
23
|
return {
|
|
@@ -26,13 +26,9 @@ async function m(e) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
function f(e) {
|
|
29
|
-
return e.steps.some((
|
|
30
|
-
}
|
|
31
|
-
function d(e) {
|
|
32
|
-
return e.steps.filter(r).map((t) => t.templateId);
|
|
29
|
+
return e.steps.some((s) => n(s));
|
|
33
30
|
}
|
|
34
31
|
export {
|
|
35
|
-
d as getUsedTemplateIds,
|
|
36
32
|
f as hasTemplateSteps,
|
|
37
33
|
m as resolveFormWizardConfig
|
|
38
34
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
/* empty css */
|
|
3
|
-
import { isGenericTemplate as
|
|
4
|
-
async function
|
|
3
|
+
import { isGenericTemplate as v, isTeamTemplate as h } from "../../../../../ui/src/lib/utils/templateUtils.js";
|
|
4
|
+
async function g() {
|
|
5
5
|
try {
|
|
6
6
|
const { templateStorageService: e } = await import("@formbuilder/builder");
|
|
7
7
|
return e;
|
|
@@ -9,22 +9,22 @@ async function m() {
|
|
|
9
9
|
return console.warn("Template storage service not available:", e), null;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
async function
|
|
12
|
+
async function y() {
|
|
13
13
|
try {
|
|
14
|
-
const e = await
|
|
14
|
+
const e = await g();
|
|
15
15
|
if (!e) return;
|
|
16
16
|
if (!e.isReady()) {
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
19
|
-
const
|
|
20
|
-
|
|
17
|
+
const a = await fetch("/form.config.json");
|
|
18
|
+
if (a.ok) {
|
|
19
|
+
const r = (await a.json()).storage?.paths?.templates;
|
|
20
|
+
r && await e.initialize(r);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
} catch (e) {
|
|
24
24
|
console.warn("Failed to initialize template storage service:", e);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function d(e) {
|
|
28
28
|
return {
|
|
29
29
|
metadata: e.metadata,
|
|
30
30
|
stepsData: e.stepsData || [],
|
|
@@ -40,7 +40,7 @@ function f(e) {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
const
|
|
43
|
+
const f = /* @__PURE__ */ new Map(), l = {
|
|
44
44
|
"generic-contact-information": async () => {
|
|
45
45
|
const e = await fetch(
|
|
46
46
|
"/src/packages/form-wizard/admin/templates/generic/contact-information.json"
|
|
@@ -82,100 +82,93 @@ const p = /* @__PURE__ */ new Map(), o = {
|
|
|
82
82
|
return e.json();
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
-
async function
|
|
86
|
-
if (
|
|
87
|
-
return
|
|
85
|
+
async function b(e) {
|
|
86
|
+
if (f.has(e))
|
|
87
|
+
return f.get(e);
|
|
88
88
|
try {
|
|
89
|
-
let
|
|
90
|
-
if (
|
|
91
|
-
const i =
|
|
89
|
+
let a;
|
|
90
|
+
if (v(e)) {
|
|
91
|
+
const i = l[e];
|
|
92
92
|
if (!i) {
|
|
93
|
-
const s = Object.keys(
|
|
93
|
+
const s = Object.keys(l);
|
|
94
94
|
throw new Error(
|
|
95
95
|
`Generic template '${e}' not found. Available generic templates: ${s.join(", ")}`
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
|
-
const
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
const r = await i();
|
|
99
|
+
a = d(
|
|
100
|
+
r
|
|
101
101
|
);
|
|
102
|
-
} else if (
|
|
103
|
-
await
|
|
104
|
-
const i = await
|
|
102
|
+
} else if (h(e)) {
|
|
103
|
+
await y();
|
|
104
|
+
const i = await g();
|
|
105
105
|
if (!i)
|
|
106
106
|
throw new Error(
|
|
107
107
|
`Team template '${e}' could not be loaded: template storage service is not available`
|
|
108
108
|
);
|
|
109
|
-
const
|
|
109
|
+
const r = await i.loadTemplate(
|
|
110
110
|
e,
|
|
111
111
|
"team"
|
|
112
112
|
);
|
|
113
|
-
if (!
|
|
113
|
+
if (!r.success)
|
|
114
114
|
throw new Error(
|
|
115
|
-
`Team template '${e}' not found: ${"error" in
|
|
115
|
+
`Team template '${e}' not found: ${"error" in r && r.error?.message || "Unknown error"}`
|
|
116
116
|
);
|
|
117
|
-
|
|
117
|
+
a = d(r.data);
|
|
118
118
|
} else {
|
|
119
|
-
const i =
|
|
119
|
+
const i = l[e];
|
|
120
120
|
if (i) {
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
const r = await i();
|
|
122
|
+
a = d(
|
|
123
|
+
r
|
|
124
124
|
);
|
|
125
125
|
} else {
|
|
126
|
-
const
|
|
126
|
+
const r = Object.keys(l);
|
|
127
127
|
throw new Error(
|
|
128
|
-
`Template '${e}' not found. Available generic templates: ${
|
|
128
|
+
`Template '${e}' not found. Available generic templates: ${r.join(", ")}`
|
|
129
129
|
);
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
if (!
|
|
132
|
+
if (!a.metadata || !Array.isArray(a.stepsData))
|
|
133
133
|
throw new Error(
|
|
134
134
|
`Invalid template structure for template: ${e}. Templates must have metadata and stepsData array.`
|
|
135
135
|
);
|
|
136
|
-
return
|
|
137
|
-
} catch (
|
|
136
|
+
return f.set(e, a), a;
|
|
137
|
+
} catch (a) {
|
|
138
138
|
throw new Error(
|
|
139
|
-
`Failed to load template '${e}': ${
|
|
139
|
+
`Failed to load template '${e}': ${a instanceof Error ? a.message : "Unknown error"}`
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
}
|
|
143
|
-
async function
|
|
144
|
-
|
|
145
|
-
"Resolving template step:",
|
|
146
|
-
e,
|
|
147
|
-
"stepIndex:",
|
|
148
|
-
i
|
|
149
|
-
);
|
|
150
|
-
const t = await v(e.templateId);
|
|
151
|
-
console.log("Loaded template:", t);
|
|
143
|
+
async function E(e, a, i) {
|
|
144
|
+
const r = await b(e.templateId);
|
|
152
145
|
let s;
|
|
153
|
-
if (
|
|
154
|
-
i !== void 0 && i >= 0 && i <
|
|
146
|
+
if (r.stepsData && Array.isArray(r.stepsData) && r.stepsData.length > 0)
|
|
147
|
+
i !== void 0 && i >= 0 && i < r.stepsData.length ? s = r.stepsData[i] : (s = r.stepsData[0], console.warn(
|
|
155
148
|
`Invalid stepIndex ${i} for template, using first step`
|
|
156
149
|
));
|
|
157
150
|
else
|
|
158
151
|
throw new Error(`Template ${e.templateId} has no steps data`);
|
|
159
|
-
const
|
|
152
|
+
const u = s.sections?.map((w) => ({
|
|
160
153
|
...w,
|
|
161
|
-
components: w.components.map((
|
|
162
|
-
const
|
|
163
|
-
id:
|
|
164
|
-
type:
|
|
154
|
+
components: w.components.map((t) => {
|
|
155
|
+
const m = ((c) => `comp-${e.id}-${t.id || c}`)(t.id), o = {
|
|
156
|
+
id: m,
|
|
157
|
+
type: t.type,
|
|
165
158
|
properties: {
|
|
166
159
|
// Use properties from component.properties if it exists, otherwise fallback to root level
|
|
167
|
-
label:
|
|
168
|
-
placeholder:
|
|
169
|
-
description:
|
|
170
|
-
required:
|
|
171
|
-
disabled:
|
|
172
|
-
readOnly:
|
|
173
|
-
invalid:
|
|
160
|
+
label: t.properties?.label || t.label || "",
|
|
161
|
+
placeholder: t.properties?.placeholder || t.placeholder || "",
|
|
162
|
+
description: t.properties?.description || t.description || "",
|
|
163
|
+
required: t.properties?.required || t.required || !1,
|
|
164
|
+
disabled: t.properties?.disabled || t.disabled || !1,
|
|
165
|
+
readOnly: t.properties?.readOnly || t.readOnly || !1,
|
|
166
|
+
invalid: t.properties?.invalid || !1,
|
|
174
167
|
// Add type-specific properties
|
|
175
|
-
type:
|
|
168
|
+
type: t.properties?.type || t.type,
|
|
176
169
|
// Copy all other properties from component.properties if it exists
|
|
177
|
-
...
|
|
178
|
-
(c,
|
|
170
|
+
...t.properties && Object.keys(t.properties).reduce(
|
|
171
|
+
(c, p) => ([
|
|
179
172
|
"label",
|
|
180
173
|
"placeholder",
|
|
181
174
|
"description",
|
|
@@ -184,29 +177,29 @@ async function S(e, r, i) {
|
|
|
184
177
|
"readOnly",
|
|
185
178
|
"invalid",
|
|
186
179
|
"type"
|
|
187
|
-
].includes(
|
|
180
|
+
].includes(p) || (c[p] = t.properties[p]), c),
|
|
188
181
|
{}
|
|
189
182
|
)
|
|
190
183
|
},
|
|
191
184
|
// Copy validation if it exists
|
|
192
|
-
...
|
|
193
|
-
},
|
|
194
|
-
return
|
|
185
|
+
...t.validation && { validation: t.validation }
|
|
186
|
+
}, n = e.componentOverrides?.[m];
|
|
187
|
+
return n ? {
|
|
188
|
+
...o,
|
|
195
189
|
...n,
|
|
196
|
-
...l,
|
|
197
190
|
// Merge properties deeply to allow partial property updates
|
|
198
191
|
properties: {
|
|
199
|
-
...
|
|
200
|
-
...
|
|
192
|
+
...o.properties,
|
|
193
|
+
...n.properties
|
|
201
194
|
},
|
|
202
195
|
// Merge validation deeply if both exist
|
|
203
|
-
...
|
|
196
|
+
...o.validation && n.validation && {
|
|
204
197
|
validation: {
|
|
205
|
-
...
|
|
206
|
-
...
|
|
198
|
+
...o.validation,
|
|
199
|
+
...n.validation
|
|
207
200
|
}
|
|
208
201
|
}
|
|
209
|
-
} :
|
|
202
|
+
} : o;
|
|
210
203
|
})
|
|
211
204
|
}));
|
|
212
205
|
return {
|
|
@@ -215,10 +208,10 @@ async function S(e, r, i) {
|
|
|
215
208
|
title: e.title || s.title,
|
|
216
209
|
displayTitle: s.displayTitle,
|
|
217
210
|
showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber : s.showStepNumber,
|
|
218
|
-
sections:
|
|
211
|
+
sections: u,
|
|
219
212
|
navigation: {
|
|
220
213
|
// Use default navigation, then template navigation if available, then step override
|
|
221
|
-
...
|
|
214
|
+
...a,
|
|
222
215
|
...s.navigation,
|
|
223
216
|
// Cast since navigation might not exist in Omit type
|
|
224
217
|
...e.navigation
|
|
@@ -229,37 +222,7 @@ async function S(e, r, i) {
|
|
|
229
222
|
}
|
|
230
223
|
};
|
|
231
224
|
}
|
|
232
|
-
async function E(e) {
|
|
233
|
-
return (await v(e)).metadata;
|
|
234
|
-
}
|
|
235
|
-
async function D() {
|
|
236
|
-
const e = Object.keys(o);
|
|
237
|
-
try {
|
|
238
|
-
await u();
|
|
239
|
-
const r = await m();
|
|
240
|
-
if (r) {
|
|
241
|
-
const i = await r.listTemplates("team");
|
|
242
|
-
if (i.success && i.data) {
|
|
243
|
-
const t = i.data.map((s) => s.metadata.id);
|
|
244
|
-
return [...e, ...t];
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
} catch (r) {
|
|
248
|
-
console.warn("Failed to load team templates:", r);
|
|
249
|
-
}
|
|
250
|
-
return e;
|
|
251
|
-
}
|
|
252
|
-
function O() {
|
|
253
|
-
return Object.keys(o);
|
|
254
|
-
}
|
|
255
|
-
function A() {
|
|
256
|
-
p.clear();
|
|
257
|
-
}
|
|
258
225
|
export {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
D as getAvailableTemplates,
|
|
262
|
-
E as getTemplateMetadata,
|
|
263
|
-
v as loadTemplate,
|
|
264
|
-
S as resolveTemplateStep
|
|
226
|
+
b as loadTemplate,
|
|
227
|
+
E as resolveTemplateStep
|
|
265
228
|
};
|