@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,20 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { jsx as a } from "react/jsx-runtime";
|
|
3
|
-
import { clsx as i } from "clsx";
|
|
4
|
-
import r from "./badge.module.css.js";
|
|
5
|
-
function l({ className: t, variant: e, ...o }) {
|
|
6
|
-
return /* @__PURE__ */ a(
|
|
7
|
-
"div",
|
|
8
|
-
{
|
|
9
|
-
className: i(
|
|
10
|
-
r.badge,
|
|
11
|
-
r[`variant-${e ?? "default"}`],
|
|
12
|
-
t
|
|
13
|
-
),
|
|
14
|
-
...o
|
|
15
|
-
}
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
l as Badge
|
|
20
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
const a = "fb-badge_Q1h-y", t = {
|
|
3
|
-
badge: a,
|
|
4
|
-
"variant-default": "fb-variant-default_7HL-r",
|
|
5
|
-
"variant-secondary": "fb-variant-secondary_knrZF",
|
|
6
|
-
"variant-destructive": "fb-variant-destructive_YUruN",
|
|
7
|
-
"variant-outline": "fb-variant-outline_EHC5j"
|
|
8
|
-
};
|
|
9
|
-
export {
|
|
10
|
-
a as badge,
|
|
11
|
-
t as default
|
|
12
|
-
};
|
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
/* empty css */
|
|
3
|
-
import { isTemplateDialogConfig as m } from "../../../../../ui/src/lib/types/guards.js";
|
|
4
|
-
import { ActionValidator as v, ActionValidationError as C } from "../../validation-system/validation/ActionValidation.js";
|
|
5
|
-
import { memo as A, useCallback as E, useEffect as D } from "react";
|
|
6
|
-
import { ApiCallService as S } from "./ApiCallService.js";
|
|
7
|
-
import { resolveTemplateDialog as T } from "../../../../../ui/src/lib/utils/templateDialogResolver.js";
|
|
8
|
-
const I = A(
|
|
9
|
-
({
|
|
10
|
-
actions: s,
|
|
11
|
-
trigger: e,
|
|
12
|
-
formData: t,
|
|
13
|
-
onComplete: i,
|
|
14
|
-
onError: n,
|
|
15
|
-
onFieldUpdate: l,
|
|
16
|
-
onShowDialog: a,
|
|
17
|
-
onNavigate: f,
|
|
18
|
-
machineRef: r
|
|
19
|
-
}) => {
|
|
20
|
-
const y = E(async () => {
|
|
21
|
-
console.log("ActionExecutor: Starting action execution", {
|
|
22
|
-
actions: s,
|
|
23
|
-
trigger: e
|
|
24
|
-
});
|
|
25
|
-
const u = s.filter(
|
|
26
|
-
(o) => o.trigger === e
|
|
27
|
-
);
|
|
28
|
-
if (console.log("ActionExecutor: Filtered actions", {
|
|
29
|
-
triggeredActions: u,
|
|
30
|
-
trigger: e
|
|
31
|
-
}), u.length === 0) {
|
|
32
|
-
console.log("ActionExecutor: No actions to execute"), r?.send({
|
|
33
|
-
type: "ACTIONS_COMPLETED",
|
|
34
|
-
results: {}
|
|
35
|
-
}), i({});
|
|
36
|
-
return;
|
|
37
|
-
}
|
|
38
|
-
const d = [];
|
|
39
|
-
for (const o of u) {
|
|
40
|
-
const c = v.validateAction(o);
|
|
41
|
-
c.isValid || d.push(
|
|
42
|
-
`Action '${o.id}': ${c.errors.join(", ")}`
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
if (d.length > 0) {
|
|
46
|
-
const o = new C(
|
|
47
|
-
"validation-error",
|
|
48
|
-
"validation",
|
|
49
|
-
`Action validation failed: ${d.join("; ")}`,
|
|
50
|
-
{ validationErrors: d }
|
|
51
|
-
);
|
|
52
|
-
r?.send({
|
|
53
|
-
type: "ACTIONS_COMPLETED",
|
|
54
|
-
results: {}
|
|
55
|
-
}), n(o);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
const x = [...u].sort(
|
|
59
|
-
(o, c) => o.order - c.order
|
|
60
|
-
), g = {};
|
|
61
|
-
try {
|
|
62
|
-
for (const o of x)
|
|
63
|
-
r?.send({ type: "ACTION_START", actionId: o.id });
|
|
64
|
-
for (const o of x)
|
|
65
|
-
try {
|
|
66
|
-
let c = null;
|
|
67
|
-
switch (o.type) {
|
|
68
|
-
case "apiCall": {
|
|
69
|
-
console.log("ActionExecutor: Executing API call", {
|
|
70
|
-
action: o,
|
|
71
|
-
config: o.config
|
|
72
|
-
}), c = await new S({ onFieldUpdate: l }).executeApiCall(
|
|
73
|
-
o.config,
|
|
74
|
-
t
|
|
75
|
-
), console.log("ActionExecutor: API call completed", { result: c });
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
case "showDialog": {
|
|
79
|
-
console.log("🎯 ActionExecutor: Executing showDialog", {
|
|
80
|
-
action: o,
|
|
81
|
-
config: o.config
|
|
82
|
-
}), console.log(
|
|
83
|
-
"🔧 ActionExecutor: Creating DialogExecutorService"
|
|
84
|
-
);
|
|
85
|
-
const p = new b();
|
|
86
|
-
console.log("🚀 ActionExecutor: Calling executor.execute"), c = await p.execute(
|
|
87
|
-
o.config,
|
|
88
|
-
t,
|
|
89
|
-
a
|
|
90
|
-
), console.log("✅ ActionExecutor: showDialog completed", {
|
|
91
|
-
result: c
|
|
92
|
-
});
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "navigate": {
|
|
96
|
-
c = await new w().execute(
|
|
97
|
-
o.config,
|
|
98
|
-
f
|
|
99
|
-
);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
case "executeVerifyDialog": {
|
|
103
|
-
console.log(
|
|
104
|
-
"🔧 ActionExecutor: Executing executeVerifyDialog",
|
|
105
|
-
{
|
|
106
|
-
action: o,
|
|
107
|
-
config: o.config
|
|
108
|
-
}
|
|
109
|
-
), c = await new O().execute(
|
|
110
|
-
o.config,
|
|
111
|
-
t,
|
|
112
|
-
a
|
|
113
|
-
), console.log(
|
|
114
|
-
"✅ ActionExecutor: executeVerifyDialog completed",
|
|
115
|
-
{
|
|
116
|
-
result: c
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
default:
|
|
122
|
-
throw new Error(`Unknown action type: ${o.type}`);
|
|
123
|
-
}
|
|
124
|
-
g[o.id] = c, r?.send({
|
|
125
|
-
type: "ACTION_SUCCESS",
|
|
126
|
-
actionId: o.id,
|
|
127
|
-
result: c
|
|
128
|
-
});
|
|
129
|
-
} catch (c) {
|
|
130
|
-
r?.send({
|
|
131
|
-
type: "ACTION_ERROR",
|
|
132
|
-
actionId: o.id,
|
|
133
|
-
error: c
|
|
134
|
-
}), g[o.id] = { error: c.message };
|
|
135
|
-
}
|
|
136
|
-
r?.send({
|
|
137
|
-
type: "ACTIONS_COMPLETED",
|
|
138
|
-
results: g
|
|
139
|
-
}), i(g);
|
|
140
|
-
} catch (o) {
|
|
141
|
-
r?.send({
|
|
142
|
-
type: "ACTIONS_COMPLETED",
|
|
143
|
-
results: g
|
|
144
|
-
}), n(o);
|
|
145
|
-
}
|
|
146
|
-
}, [
|
|
147
|
-
s,
|
|
148
|
-
e,
|
|
149
|
-
t,
|
|
150
|
-
i,
|
|
151
|
-
n,
|
|
152
|
-
l,
|
|
153
|
-
a,
|
|
154
|
-
f,
|
|
155
|
-
r
|
|
156
|
-
]);
|
|
157
|
-
return D(() => {
|
|
158
|
-
y();
|
|
159
|
-
}, [y]), null;
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
I.displayName = "ActionExecutor";
|
|
163
|
-
class b {
|
|
164
|
-
async execute(e, t, i) {
|
|
165
|
-
console.log("🚀 DialogExecutorService.execute STARTED", {
|
|
166
|
-
config: e,
|
|
167
|
-
formData: t
|
|
168
|
-
});
|
|
169
|
-
const n = this.resolveDialogConfig(e, t);
|
|
170
|
-
return console.log("🔄 DialogExecutorService: Config resolved", {
|
|
171
|
-
resolvedConfig: n
|
|
172
|
-
}), console.log("📞 DialogExecutorService: Calling onShowDialog", {
|
|
173
|
-
resolvedConfig: n
|
|
174
|
-
}), i(n), console.log("✅ DialogExecutorService.execute COMPLETED", {
|
|
175
|
-
resolvedConfig: n
|
|
176
|
-
}), n;
|
|
177
|
-
}
|
|
178
|
-
resolveDialogConfig(e, t) {
|
|
179
|
-
if (console.log("🔍 DialogExecutorService.resolveDialogConfig input:", {
|
|
180
|
-
config: e,
|
|
181
|
-
formData: t
|
|
182
|
-
}), m(e)) {
|
|
183
|
-
console.log("✅ Detected as TemplateDialogConfig");
|
|
184
|
-
const n = this.resolveTemplateDialogWithActions(e);
|
|
185
|
-
console.log("🔄 Resolved template config:", { baseConfig: n });
|
|
186
|
-
const l = this.interpolateDialogConfig(n, t);
|
|
187
|
-
return console.log("✨ Final interpolated config:", { finalConfig: l }), l;
|
|
188
|
-
}
|
|
189
|
-
console.log("✅ Treating as direct DialogConfig");
|
|
190
|
-
const i = this.interpolateDialogConfig(
|
|
191
|
-
e,
|
|
192
|
-
t
|
|
193
|
-
);
|
|
194
|
-
return console.log("✨ Final direct config:", { finalConfig: i }), i;
|
|
195
|
-
}
|
|
196
|
-
interpolateDialogConfig(e, t) {
|
|
197
|
-
return {
|
|
198
|
-
...e,
|
|
199
|
-
content: this.interpolateTemplate(e.content, t),
|
|
200
|
-
title: this.interpolateTemplate(e.title, t)
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
resolveTemplateDialogWithActions(e) {
|
|
204
|
-
console.log("🔄 Resolving template with actions:", e);
|
|
205
|
-
const t = e.template, i = t.config;
|
|
206
|
-
if (t.typeId === "confirmation-dialog") {
|
|
207
|
-
console.log(
|
|
208
|
-
"✅ Processing confirmation-dialog template:",
|
|
209
|
-
i
|
|
210
|
-
);
|
|
211
|
-
const n = {
|
|
212
|
-
title: i.title || "Confirm Action",
|
|
213
|
-
content: i.message || i.content || "Are you sure you want to proceed?",
|
|
214
|
-
type: "modal",
|
|
215
|
-
size: "medium",
|
|
216
|
-
dismissible: !0,
|
|
217
|
-
buttons: [
|
|
218
|
-
{
|
|
219
|
-
id: "cancel-btn",
|
|
220
|
-
label: i.cancelButtonLabel || "Cancel",
|
|
221
|
-
variant: "secondary",
|
|
222
|
-
action: i.onCancelAction || { type: "close" }
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
id: "confirm-btn",
|
|
226
|
-
label: i.confirmButtonLabel || "Confirm",
|
|
227
|
-
variant: i.confirmButtonVariant || "primary",
|
|
228
|
-
action: i.onConfirmAction || {
|
|
229
|
-
type: "navigate",
|
|
230
|
-
direction: "next"
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
],
|
|
234
|
-
// Add template metadata for runtime behavior
|
|
235
|
-
templateMetadata: {
|
|
236
|
-
typeId: "confirmation-dialog",
|
|
237
|
-
showIcon: i.showIcon,
|
|
238
|
-
iconType: i.iconType
|
|
239
|
-
}
|
|
240
|
-
};
|
|
241
|
-
return console.log("✨ Resolved confirmation dialog config:", n), n;
|
|
242
|
-
}
|
|
243
|
-
return console.log(
|
|
244
|
-
"🔄 Falling back to resolveTemplateDialog for typeId:",
|
|
245
|
-
t.typeId
|
|
246
|
-
), T(e);
|
|
247
|
-
}
|
|
248
|
-
interpolateTemplate(e, t) {
|
|
249
|
-
return e.replace(/\$\{data\.([^}]+)\}/g, (i, n) => {
|
|
250
|
-
const l = t[n];
|
|
251
|
-
return l != null ? String(l) : i;
|
|
252
|
-
});
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
class w {
|
|
256
|
-
async execute(e, t) {
|
|
257
|
-
return t(e), e;
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
class O {
|
|
261
|
-
async execute(e, t, i) {
|
|
262
|
-
console.log("🚀 GenericVerifyDialogService.execute STARTED", {
|
|
263
|
-
config: e,
|
|
264
|
-
formData: t
|
|
265
|
-
});
|
|
266
|
-
const n = e.postAction || { type: "close" };
|
|
267
|
-
let l;
|
|
268
|
-
switch (n.type) {
|
|
269
|
-
case "close":
|
|
270
|
-
case "saveSection":
|
|
271
|
-
l = {
|
|
272
|
-
type: "updateOriginalValue",
|
|
273
|
-
componentId: e.componentId
|
|
274
|
-
};
|
|
275
|
-
break;
|
|
276
|
-
case "nextStep":
|
|
277
|
-
l = {
|
|
278
|
-
type: "navigate",
|
|
279
|
-
direction: "next",
|
|
280
|
-
updateOriginalValue: !0,
|
|
281
|
-
componentId: e.componentId
|
|
282
|
-
};
|
|
283
|
-
break;
|
|
284
|
-
case "navigate":
|
|
285
|
-
l = {
|
|
286
|
-
type: "navigate",
|
|
287
|
-
direction: n.direction,
|
|
288
|
-
targetStep: n.targetStep,
|
|
289
|
-
updateOriginalValue: !0,
|
|
290
|
-
componentId: e.componentId
|
|
291
|
-
};
|
|
292
|
-
break;
|
|
293
|
-
default:
|
|
294
|
-
l = {
|
|
295
|
-
type: "updateOriginalValue",
|
|
296
|
-
componentId: e.componentId
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
const a = {
|
|
300
|
-
title: "Verify Changes",
|
|
301
|
-
content: "Please verify your changes before continuing.",
|
|
302
|
-
type: "modal",
|
|
303
|
-
size: "medium",
|
|
304
|
-
dismissible: !0,
|
|
305
|
-
buttons: [
|
|
306
|
-
{
|
|
307
|
-
id: "cancel-btn",
|
|
308
|
-
label: "Cancel",
|
|
309
|
-
variant: "secondary",
|
|
310
|
-
action: { type: "close" }
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
id: "verify-btn",
|
|
314
|
-
label: "Verify",
|
|
315
|
-
variant: "primary",
|
|
316
|
-
action: { type: "close" }
|
|
317
|
-
// This will be overridden by templateMetadata.onVerifiedAction
|
|
318
|
-
}
|
|
319
|
-
],
|
|
320
|
-
// Add template metadata to identify this as a verification dialog
|
|
321
|
-
templateMetadata: {
|
|
322
|
-
typeId: "verify-dialog",
|
|
323
|
-
isGeneric: !0,
|
|
324
|
-
componentId: e.componentId,
|
|
325
|
-
onVerifiedAction: l
|
|
326
|
-
// This will be used by EmailVerificationDialog
|
|
327
|
-
}
|
|
328
|
-
};
|
|
329
|
-
return console.log("📞 GenericVerifyDialogService: Calling onShowDialog", {
|
|
330
|
-
defaultDialogConfig: a
|
|
331
|
-
}), i(a), console.log("✅ GenericVerifyDialogService.execute COMPLETED", {
|
|
332
|
-
defaultDialogConfig: a
|
|
333
|
-
}), a;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
export {
|
|
337
|
-
I as ActionExecutor,
|
|
338
|
-
I as default
|
|
339
|
-
};
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { GenericTriggerEngine as l, createTriggerContext as a } from "../../trigger-action-system/utils/GenericTriggerEngine.js";
|
|
3
|
-
class g {
|
|
4
|
-
constructor(e) {
|
|
5
|
-
this.formMachine = e;
|
|
6
|
-
}
|
|
7
|
-
goToStep(e, t) {
|
|
8
|
-
this.formMachine.send({ type: "GO_TO_STEP", stepId: e, behavior: t });
|
|
9
|
-
}
|
|
10
|
-
goNext(e) {
|
|
11
|
-
this.formMachine.send({ type: "NEXT", skipValidation: e });
|
|
12
|
-
}
|
|
13
|
-
goPrevious(e) {
|
|
14
|
-
this.formMachine.send({ type: "PREVIOUS", skipValidation: e });
|
|
15
|
-
}
|
|
16
|
-
goToSection(e, t) {
|
|
17
|
-
t && this.goToStep(t);
|
|
18
|
-
const i = document.getElementById(e);
|
|
19
|
-
i && i.scrollIntoView({ behavior: "smooth" });
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
class p {
|
|
23
|
-
constructor(e) {
|
|
24
|
-
this.formMachine = e;
|
|
25
|
-
}
|
|
26
|
-
showAlert(e) {
|
|
27
|
-
const t = e;
|
|
28
|
-
t.targetId ? this.formMachine.send({
|
|
29
|
-
type: "SHOW_COMPONENT_ALERT",
|
|
30
|
-
componentId: t.targetId,
|
|
31
|
-
alert: {
|
|
32
|
-
message: e.message,
|
|
33
|
-
type: e.alertType,
|
|
34
|
-
position: e.position === "toast" ? "inline" : e.position,
|
|
35
|
-
dismissible: e.dismissible ?? !1,
|
|
36
|
-
autoHide: e.autoHide,
|
|
37
|
-
autoHideDelay: e.autoHideDelay
|
|
38
|
-
}
|
|
39
|
-
}) : this.showNotification({
|
|
40
|
-
type: "ui:showNotification",
|
|
41
|
-
message: e.message,
|
|
42
|
-
notificationType: e.alertType,
|
|
43
|
-
position: e.position === "toast" ? "top-right" : "top"
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
showDialog(e) {
|
|
47
|
-
let t;
|
|
48
|
-
e.dialogType === "email-verification" ? t = {
|
|
49
|
-
type: "email-verification",
|
|
50
|
-
title: typeof e.title == "string" ? e.title : e.templateConfig?.title,
|
|
51
|
-
content: typeof e.content == "string" ? e.content : e.templateConfig?.description,
|
|
52
|
-
templateMetadata: e.templateConfig
|
|
53
|
-
} : e.dialogType === "confirmation" ? t = {
|
|
54
|
-
type: "confirmation",
|
|
55
|
-
title: e.title,
|
|
56
|
-
content: e.content,
|
|
57
|
-
buttons: e.buttons?.map((i) => ({
|
|
58
|
-
label: i.label,
|
|
59
|
-
variant: i.variant ?? "default",
|
|
60
|
-
action: i.action.type || "close"
|
|
61
|
-
}))
|
|
62
|
-
} : t = {
|
|
63
|
-
type: "custom",
|
|
64
|
-
title: e.title,
|
|
65
|
-
content: e.content,
|
|
66
|
-
templateMetadata: e.templateConfig
|
|
67
|
-
}, this.formMachine.send({
|
|
68
|
-
type: "SHOW_ACTION_DIALOG",
|
|
69
|
-
dialogConfig: t
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
showNotification(e) {
|
|
73
|
-
console.log(
|
|
74
|
-
`🔔 Notification [${e.notificationType}]: ${e.message}`
|
|
75
|
-
), typeof window < "u" && window.dispatchEvent(
|
|
76
|
-
new CustomEvent("form:notification", {
|
|
77
|
-
detail: e
|
|
78
|
-
})
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
hideDialog() {
|
|
82
|
-
this.formMachine.send({ type: "HIDE_ACTION_DIALOG" });
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
class d {
|
|
86
|
-
constructor(e) {
|
|
87
|
-
this.formMachine = e;
|
|
88
|
-
}
|
|
89
|
-
async apiCall(e) {
|
|
90
|
-
try {
|
|
91
|
-
const t = await fetch(e.url, {
|
|
92
|
-
method: e.method,
|
|
93
|
-
headers: {
|
|
94
|
-
"Content-Type": "application/json",
|
|
95
|
-
...e.headers
|
|
96
|
-
},
|
|
97
|
-
body: e.body ? JSON.stringify(e.body) : void 0,
|
|
98
|
-
signal: e.timeout ? AbortSignal.timeout(e.timeout) : void 0
|
|
99
|
-
});
|
|
100
|
-
if (!t.ok)
|
|
101
|
-
throw new Error(
|
|
102
|
-
`API call failed: ${t.status} ${t.statusText}`
|
|
103
|
-
);
|
|
104
|
-
const i = await t.json();
|
|
105
|
-
if (e.fieldMappings)
|
|
106
|
-
for (const [s, o] of Object.entries(
|
|
107
|
-
e.fieldMappings
|
|
108
|
-
)) {
|
|
109
|
-
const r = this.getNestedValue(i, s);
|
|
110
|
-
r !== void 0 && this.setValue(o, r);
|
|
111
|
-
}
|
|
112
|
-
return e.onSuccess && console.log(
|
|
113
|
-
"API call succeeded, executing success actions",
|
|
114
|
-
e.onSuccess
|
|
115
|
-
), i;
|
|
116
|
-
} catch (t) {
|
|
117
|
-
throw console.error("API call failed:", t), e.onError && console.log("API call failed, executing error actions", e.onError), t;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
setValue(e, t) {
|
|
121
|
-
const [i, s] = e.split(".");
|
|
122
|
-
i === "component" ? this.formMachine.send({
|
|
123
|
-
type: "UPDATE_COMPONENT_VALUE",
|
|
124
|
-
componentId: s,
|
|
125
|
-
value: t
|
|
126
|
-
}) : this.formMachine.send({
|
|
127
|
-
type: "UPDATE_FIELD",
|
|
128
|
-
field: e,
|
|
129
|
-
value: t
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
getValue(e) {
|
|
133
|
-
const i = this.formMachine.getSnapshot().context.data;
|
|
134
|
-
return this.getNestedValue(i, e);
|
|
135
|
-
}
|
|
136
|
-
clearValue(e) {
|
|
137
|
-
this.setValue(e, "");
|
|
138
|
-
}
|
|
139
|
-
getNestedValue(e, t) {
|
|
140
|
-
return t.split(".").reduce((i, s) => i && typeof i == "object" && i !== null ? i[s] : void 0, e);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
class h {
|
|
144
|
-
constructor(e) {
|
|
145
|
-
this.formMachine = e;
|
|
146
|
-
}
|
|
147
|
-
validateField(e) {
|
|
148
|
-
const i = this.formMachine.getSnapshot().context.errors;
|
|
149
|
-
return this.formMachine.send({
|
|
150
|
-
type: "VALIDATE_FIELD",
|
|
151
|
-
fieldId: e
|
|
152
|
-
}), !i[e] || i[e].length === 0;
|
|
153
|
-
}
|
|
154
|
-
validateSection(e) {
|
|
155
|
-
return this.formMachine.send({
|
|
156
|
-
type: "VALIDATE_SECTION",
|
|
157
|
-
sectionId: e
|
|
158
|
-
}), !0;
|
|
159
|
-
}
|
|
160
|
-
validateStep(e) {
|
|
161
|
-
return this.formMachine.send({
|
|
162
|
-
type: "VALIDATE_STEP",
|
|
163
|
-
stepId: e
|
|
164
|
-
}), !0;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
class u {
|
|
168
|
-
engine;
|
|
169
|
-
services;
|
|
170
|
-
constructor(e) {
|
|
171
|
-
this.services = {
|
|
172
|
-
navigation: new g(e),
|
|
173
|
-
ui: new p(e),
|
|
174
|
-
data: new d(e),
|
|
175
|
-
validation: new h(e)
|
|
176
|
-
}, this.engine = new l(this.services);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Initialize triggers from form configuration
|
|
180
|
-
*/
|
|
181
|
-
initializeFromConfig(e) {
|
|
182
|
-
e.genericTriggerActions?.triggers && this.engine.registerTriggers(
|
|
183
|
-
`form:${e.id}`,
|
|
184
|
-
e.genericTriggerActions.triggers
|
|
185
|
-
);
|
|
186
|
-
for (const t of e.steps) {
|
|
187
|
-
"genericTriggerActions" in t && t.genericTriggerActions?.triggers && this.engine.registerTriggers(
|
|
188
|
-
`step:${t.id}`,
|
|
189
|
-
t.genericTriggerActions.triggers
|
|
190
|
-
);
|
|
191
|
-
const i = "sections" in t ? t : null;
|
|
192
|
-
if (i?.sections)
|
|
193
|
-
for (const s of i.sections) {
|
|
194
|
-
s.genericTriggerActions?.triggers && this.engine.registerTriggers(
|
|
195
|
-
`section:${s.id}`,
|
|
196
|
-
s.genericTriggerActions.triggers
|
|
197
|
-
);
|
|
198
|
-
for (const o of s.components)
|
|
199
|
-
o.genericTriggerActions?.triggers && this.engine.registerTriggers(
|
|
200
|
-
`component:${o.id}`,
|
|
201
|
-
o.genericTriggerActions.triggers
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Trigger evaluation for form events
|
|
208
|
-
*/
|
|
209
|
-
async evaluateFormTrigger(e, t, i, s) {
|
|
210
|
-
const o = a(
|
|
211
|
-
e,
|
|
212
|
-
"form",
|
|
213
|
-
`form:${t}`,
|
|
214
|
-
{
|
|
215
|
-
formData: i,
|
|
216
|
-
metadata: s
|
|
217
|
-
}
|
|
218
|
-
);
|
|
219
|
-
await this.engine.evaluateTriggers(o);
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
|
-
* Trigger evaluation for step events
|
|
223
|
-
*/
|
|
224
|
-
async evaluateStepTrigger(e, t, i, s) {
|
|
225
|
-
const o = a(
|
|
226
|
-
e,
|
|
227
|
-
"step",
|
|
228
|
-
`step:${t}`,
|
|
229
|
-
{
|
|
230
|
-
formData: i,
|
|
231
|
-
metadata: s
|
|
232
|
-
}
|
|
233
|
-
);
|
|
234
|
-
await this.engine.evaluateTriggers(o);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Trigger evaluation for section events
|
|
238
|
-
*/
|
|
239
|
-
async evaluateSectionTrigger(e, t, i, s) {
|
|
240
|
-
const o = a(
|
|
241
|
-
e,
|
|
242
|
-
"section",
|
|
243
|
-
`section:${t}`,
|
|
244
|
-
{
|
|
245
|
-
formData: i,
|
|
246
|
-
metadata: s
|
|
247
|
-
}
|
|
248
|
-
);
|
|
249
|
-
await this.engine.evaluateTriggers(o);
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Trigger evaluation for component events
|
|
253
|
-
*/
|
|
254
|
-
async evaluateComponentTrigger(e, t, i, s, o, r) {
|
|
255
|
-
const c = a(
|
|
256
|
-
e,
|
|
257
|
-
"component",
|
|
258
|
-
`component:${t}`,
|
|
259
|
-
{
|
|
260
|
-
currentValue: i,
|
|
261
|
-
previousValue: s,
|
|
262
|
-
formData: o,
|
|
263
|
-
metadata: r
|
|
264
|
-
}
|
|
265
|
-
);
|
|
266
|
-
await this.engine.evaluateTriggers(c);
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Register additional triggers dynamically
|
|
270
|
-
*/
|
|
271
|
-
registerTriggers(e, t) {
|
|
272
|
-
t.triggers && this.engine.registerTriggers(e, t.triggers);
|
|
273
|
-
}
|
|
274
|
-
/**
|
|
275
|
-
* Cleanup resources
|
|
276
|
-
*/
|
|
277
|
-
dispose() {
|
|
278
|
-
this.engine.dispose();
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
export {
|
|
282
|
-
u as GenericTriggerService,
|
|
283
|
-
u as default
|
|
284
|
-
};
|