@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,23 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useMachine as
|
|
3
|
-
import
|
|
2
|
+
import { useMachine as gt } from "@xstate/react";
|
|
3
|
+
import ft, { useMemo as g, useCallback as o, createContext as Et, useContext as Ct } from "react";
|
|
4
4
|
import { ComponentTriggerEngine as V } from "./componentTriggerEngine.js";
|
|
5
|
-
import { formMachine as
|
|
6
|
-
import { ValidationEngine as
|
|
7
|
-
const
|
|
5
|
+
import { formMachine as ht } from "./formMachine.js";
|
|
6
|
+
import { ValidationEngine as Tt } from "../../validation-system/validation/ValidationEngine.js";
|
|
7
|
+
const vt = ({
|
|
8
8
|
config: i,
|
|
9
|
-
initialData:
|
|
9
|
+
initialData: m = {},
|
|
10
10
|
onSubmit: p
|
|
11
11
|
}) => {
|
|
12
|
-
const d =
|
|
12
|
+
const d = g(() => new Tt({
|
|
13
13
|
messageStyle: i.validationMessageStyle || "withLabel",
|
|
14
14
|
debounceMs: 300
|
|
15
|
-
}), [i.validationMessageStyle]), [
|
|
15
|
+
}), [i.validationMessageStyle]), [f, n] = gt(ht, {
|
|
16
16
|
input: {
|
|
17
17
|
config: i,
|
|
18
18
|
currentStepId: i.steps[0]?.id || "",
|
|
19
19
|
currentStepIndex: 0,
|
|
20
|
-
data:
|
|
20
|
+
data: m,
|
|
21
21
|
errors: {},
|
|
22
22
|
dirtyFields: {},
|
|
23
23
|
touchedFields: {},
|
|
@@ -25,16 +25,16 @@ const ve = ({
|
|
|
25
25
|
isSubmitting: !1
|
|
26
26
|
}
|
|
27
27
|
// Reduced inspection logging for performance
|
|
28
|
-
}), { context: s } =
|
|
28
|
+
}), { context: s } = f, v = s.currentStepId, E = s.currentStepIndex, u = s.data, I = s.errors, h = s.isValid, O = s.isSubmitting, M = s.dirtyFields, R = s.touchedFields, N = g(
|
|
29
29
|
() => i.steps[E],
|
|
30
30
|
[i.steps, E]
|
|
31
|
-
), D =
|
|
32
|
-
(
|
|
33
|
-
for (const
|
|
34
|
-
const r =
|
|
35
|
-
for (const
|
|
36
|
-
const a =
|
|
37
|
-
(
|
|
31
|
+
), D = g(() => i.steps, [i.steps]), L = E === 0, P = E === i.steps.length - 1, T = o(
|
|
32
|
+
(t) => {
|
|
33
|
+
for (const e of i.steps) {
|
|
34
|
+
const r = e.sections || [];
|
|
35
|
+
for (const l of r || []) {
|
|
36
|
+
const a = l.components?.find(
|
|
37
|
+
(c) => c.id === t
|
|
38
38
|
);
|
|
39
39
|
if (a)
|
|
40
40
|
return a;
|
|
@@ -44,121 +44,121 @@ const ve = ({
|
|
|
44
44
|
},
|
|
45
45
|
[i.steps]
|
|
46
46
|
), S = o(
|
|
47
|
-
(
|
|
47
|
+
(t, e) => {
|
|
48
48
|
n({
|
|
49
49
|
type: "SET_FIELD_STATE",
|
|
50
|
-
componentId:
|
|
51
|
-
state: { error:
|
|
50
|
+
componentId: t,
|
|
51
|
+
state: { error: e }
|
|
52
52
|
});
|
|
53
53
|
},
|
|
54
54
|
[n]
|
|
55
55
|
), C = o(
|
|
56
|
-
(
|
|
56
|
+
(t) => {
|
|
57
57
|
n({
|
|
58
58
|
type: "SET_FIELD_STATE",
|
|
59
|
-
componentId:
|
|
59
|
+
componentId: t,
|
|
60
60
|
state: { error: null }
|
|
61
61
|
});
|
|
62
62
|
},
|
|
63
63
|
[n]
|
|
64
64
|
), x = o(
|
|
65
|
-
(
|
|
66
|
-
n({ type: "SET_DATA", key:
|
|
65
|
+
(t, e) => {
|
|
66
|
+
n({ type: "SET_DATA", key: t, value: e });
|
|
67
67
|
},
|
|
68
68
|
[n]
|
|
69
|
-
),
|
|
70
|
-
(
|
|
71
|
-
const
|
|
72
|
-
if (!
|
|
69
|
+
), F = o(
|
|
70
|
+
(t) => {
|
|
71
|
+
const e = T(t);
|
|
72
|
+
if (!e) return !0;
|
|
73
73
|
const r = d.validateField(
|
|
74
|
-
|
|
75
|
-
u[
|
|
74
|
+
e,
|
|
75
|
+
u[t]
|
|
76
76
|
);
|
|
77
77
|
if (!r.isValid) {
|
|
78
|
-
const
|
|
79
|
-
return S(
|
|
78
|
+
const l = r.errors?.[0] || "Validation error";
|
|
79
|
+
return S(t, l), !1;
|
|
80
80
|
}
|
|
81
|
-
return C(
|
|
81
|
+
return C(t), !0;
|
|
82
82
|
},
|
|
83
|
-
[u,
|
|
83
|
+
[u, T, S, C, d]
|
|
84
84
|
), w = o(
|
|
85
|
-
(
|
|
86
|
-
let
|
|
85
|
+
(t) => {
|
|
86
|
+
let e = !0;
|
|
87
87
|
for (const r of i.steps) {
|
|
88
|
-
const a = (
|
|
89
|
-
(
|
|
88
|
+
const a = (r.sections || []).find(
|
|
89
|
+
(c) => c.id === t
|
|
90
90
|
);
|
|
91
91
|
if (a) {
|
|
92
|
-
for (const
|
|
93
|
-
|
|
92
|
+
for (const c of a.components || [])
|
|
93
|
+
F(c.id) || (e = !1);
|
|
94
94
|
break;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
-
return
|
|
97
|
+
return e;
|
|
98
98
|
},
|
|
99
|
-
[i.steps,
|
|
100
|
-
),
|
|
101
|
-
async (
|
|
102
|
-
const
|
|
103
|
-
if (!
|
|
104
|
-
const r = await d.validateStep(
|
|
105
|
-
for (const [a,
|
|
99
|
+
[i.steps, F]
|
|
100
|
+
), W = o(
|
|
101
|
+
async (t) => {
|
|
102
|
+
const e = i.steps.find((a) => a.id === t);
|
|
103
|
+
if (!e) return !0;
|
|
104
|
+
const r = await d.validateStep(e, u);
|
|
105
|
+
for (const [a, c] of Object.entries(
|
|
106
106
|
r.fieldErrors
|
|
107
107
|
))
|
|
108
|
-
|
|
109
|
-
const
|
|
108
|
+
c.length > 0 && S(a, c[0]);
|
|
109
|
+
const l = e.sections?.flatMap(
|
|
110
110
|
(a) => a.components || []
|
|
111
111
|
) || [];
|
|
112
|
-
for (const a of
|
|
112
|
+
for (const a of l)
|
|
113
113
|
r.fieldErrors[a.id] || C(a.id);
|
|
114
114
|
return r.isValid;
|
|
115
115
|
},
|
|
116
116
|
[i.steps, d, u, S, C]
|
|
117
|
-
),
|
|
118
|
-
const
|
|
119
|
-
for (const [
|
|
120
|
-
|
|
117
|
+
), b = o(async () => {
|
|
118
|
+
const t = await d.validateForm(i, u);
|
|
119
|
+
for (const [e, r] of Object.entries(
|
|
120
|
+
t.fieldErrors
|
|
121
121
|
))
|
|
122
|
-
r.length > 0 && S(
|
|
123
|
-
return
|
|
124
|
-
}, [i, d, u, S]),
|
|
122
|
+
r.length > 0 && S(e, r[0]);
|
|
123
|
+
return t.isValid;
|
|
124
|
+
}, [i, d, u, S]), G = o(() => {
|
|
125
125
|
n({ type: "NEXT" });
|
|
126
126
|
}, [n]), U = o(() => {
|
|
127
127
|
n({ type: "PREVIOUS" });
|
|
128
128
|
}, [n]), k = o(
|
|
129
|
-
(
|
|
130
|
-
n({ type: "GO_TO_STEP", stepId:
|
|
129
|
+
(t) => {
|
|
130
|
+
n({ type: "GO_TO_STEP", stepId: t });
|
|
131
131
|
},
|
|
132
132
|
[n]
|
|
133
|
-
),
|
|
133
|
+
), j = o(async () => {
|
|
134
134
|
if (n({ type: "SUBMIT" }), h && p)
|
|
135
135
|
try {
|
|
136
136
|
await p(u), n({ type: "SUBMIT_SUCCESS" });
|
|
137
|
-
} catch (
|
|
137
|
+
} catch (t) {
|
|
138
138
|
n({
|
|
139
139
|
type: "SUBMIT_ERROR",
|
|
140
|
-
error:
|
|
140
|
+
error: t instanceof Error ? t : new Error("Unknown error occurred")
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
}, [n, h, p, u]),
|
|
143
|
+
}, [n, h, p, u]), B = o(() => {
|
|
144
144
|
n({ type: "RESET" });
|
|
145
|
-
}, [n]),
|
|
146
|
-
(
|
|
147
|
-
n({ type: "START_SECTION_EDIT", sectionId:
|
|
145
|
+
}, [n]), z = o(
|
|
146
|
+
(t, e) => {
|
|
147
|
+
n({ type: "START_SECTION_EDIT", sectionId: t, componentIds: e });
|
|
148
148
|
},
|
|
149
149
|
[n]
|
|
150
|
-
),
|
|
151
|
-
(
|
|
152
|
-
n({ type: "CANCEL_SECTION_EDIT", sectionId:
|
|
150
|
+
), H = o(
|
|
151
|
+
(t) => {
|
|
152
|
+
n({ type: "CANCEL_SECTION_EDIT", sectionId: t });
|
|
153
153
|
},
|
|
154
154
|
[n]
|
|
155
|
-
),
|
|
156
|
-
(
|
|
157
|
-
n({ type: "FIELD_CHANGED", fieldId:
|
|
155
|
+
), $ = o(
|
|
156
|
+
(t, e, r) => {
|
|
157
|
+
n({ type: "FIELD_CHANGED", fieldId: t, oldValue: e, newValue: r });
|
|
158
158
|
},
|
|
159
159
|
[n]
|
|
160
160
|
), K = o(
|
|
161
|
-
(
|
|
161
|
+
(t) => t ? s.fieldChangeState[t] || {
|
|
162
162
|
originalValue: void 0,
|
|
163
163
|
currentValue: void 0,
|
|
164
164
|
hasChanged: !1,
|
|
@@ -166,146 +166,128 @@ const ve = ({
|
|
|
166
166
|
} : s.fieldChangeState,
|
|
167
167
|
[s.fieldChangeState]
|
|
168
168
|
), X = o(
|
|
169
|
-
(
|
|
170
|
-
n({ type: "CLEAR_FIELD_CHANGES", fieldId:
|
|
169
|
+
(t) => {
|
|
170
|
+
n({ type: "CLEAR_FIELD_CHANGES", fieldId: t });
|
|
171
171
|
},
|
|
172
172
|
[n]
|
|
173
173
|
), q = o(
|
|
174
|
-
(
|
|
175
|
-
n({ type: "TRIGGER_FIELD_WARNING", fieldId:
|
|
174
|
+
(t, e) => {
|
|
175
|
+
n({ type: "TRIGGER_FIELD_WARNING", fieldId: t, warning: e });
|
|
176
176
|
},
|
|
177
177
|
[n]
|
|
178
178
|
), J = o(
|
|
179
|
-
(
|
|
180
|
-
n({ type: "DISMISS_FIELD_WARNING", fieldId:
|
|
179
|
+
(t, e) => {
|
|
180
|
+
n({ type: "DISMISS_FIELD_WARNING", fieldId: t, warningId: e });
|
|
181
181
|
},
|
|
182
182
|
[n]
|
|
183
183
|
), Q = o(
|
|
184
|
-
(
|
|
184
|
+
(t) => s.fieldChangeState[t]?.validationWarnings || [],
|
|
185
185
|
[s.fieldChangeState]
|
|
186
186
|
), Y = o(
|
|
187
|
-
async (
|
|
187
|
+
async (t, e) => (n({ type: "START_FIELD_VERIFICATION", fieldId: t, config: e }), new Promise((r) => {
|
|
188
188
|
setTimeout(() => {
|
|
189
|
-
const
|
|
189
|
+
const l = {
|
|
190
190
|
status: "success",
|
|
191
191
|
timestamp: Date.now(),
|
|
192
192
|
result: { verified: !0 }
|
|
193
193
|
};
|
|
194
194
|
n({
|
|
195
195
|
type: "FIELD_VERIFICATION_COMPLETE",
|
|
196
|
-
fieldId:
|
|
197
|
-
result:
|
|
196
|
+
fieldId: t,
|
|
197
|
+
result: l,
|
|
198
198
|
success: !0
|
|
199
|
-
}), r(
|
|
199
|
+
}), r(l);
|
|
200
200
|
}, 1e3);
|
|
201
201
|
})),
|
|
202
202
|
[n]
|
|
203
203
|
), Z = o(
|
|
204
|
-
(
|
|
204
|
+
(t) => s.fieldValidationState.verificationResults[t] || null,
|
|
205
205
|
[s.fieldValidationState.verificationResults]
|
|
206
|
-
),
|
|
207
|
-
(
|
|
208
|
-
|
|
209
|
-
`🚀 [useFormMachine] evaluateComponentTriggers called for ${e}:`,
|
|
210
|
-
{
|
|
211
|
-
eventType: t,
|
|
212
|
-
value: r,
|
|
213
|
-
componentId: e,
|
|
214
|
-
sendFunction: !!n,
|
|
215
|
-
currentState: m.value
|
|
216
|
-
}
|
|
217
|
-
);
|
|
218
|
-
const c = {
|
|
206
|
+
), tt = g(() => s.fieldValidationState.activeWarnings.length > 0, [s.fieldValidationState.activeWarnings]), et = g(() => s.fieldValidationState.pendingVerifications.length > 0, [s.fieldValidationState.pendingVerifications]), nt = g(() => Object.keys(s.fieldChangeState).length > 0, [s.fieldChangeState]), st = o(
|
|
207
|
+
(t, e, r) => {
|
|
208
|
+
n({
|
|
219
209
|
type: "EVALUATE_COMPONENT_TRIGGERS",
|
|
220
|
-
componentId:
|
|
221
|
-
eventType:
|
|
210
|
+
componentId: t,
|
|
211
|
+
eventType: e,
|
|
222
212
|
value: r
|
|
223
|
-
};
|
|
224
|
-
console.log("🚀 [useFormMachine] About to send event:", c), n(c), console.log(
|
|
225
|
-
`🚀 [useFormMachine] EVALUATE_COMPONENT_TRIGGERS event sent for ${e}`
|
|
226
|
-
);
|
|
213
|
+
});
|
|
227
214
|
},
|
|
228
|
-
[n,
|
|
229
|
-
),
|
|
230
|
-
(
|
|
215
|
+
[n, f.value]
|
|
216
|
+
), rt = o(
|
|
217
|
+
(t, e, r = "initialized") => {
|
|
231
218
|
n({
|
|
232
219
|
type: "SET_COMPONENT_ORIGINAL_VALUE",
|
|
233
|
-
componentId:
|
|
234
|
-
value:
|
|
220
|
+
componentId: t,
|
|
221
|
+
value: e,
|
|
235
222
|
source: r
|
|
236
223
|
});
|
|
237
224
|
},
|
|
238
225
|
[n]
|
|
239
|
-
),
|
|
240
|
-
(
|
|
226
|
+
), ot = o(
|
|
227
|
+
(t, e) => {
|
|
241
228
|
n({
|
|
242
229
|
type: "MARK_COMPONENT_AS_POPULATED",
|
|
243
|
-
componentId:
|
|
244
|
-
value:
|
|
230
|
+
componentId: t,
|
|
231
|
+
value: e
|
|
245
232
|
});
|
|
246
233
|
},
|
|
247
234
|
[n]
|
|
248
|
-
),
|
|
249
|
-
(
|
|
235
|
+
), it = o(
|
|
236
|
+
(t) => s.componentOriginalValues[t]?.value,
|
|
250
237
|
[s.componentOriginalValues]
|
|
251
|
-
),
|
|
252
|
-
(
|
|
253
|
-
const r = s.componentOriginalValues[
|
|
254
|
-
return !r || !r.isPopulated ? !1 : r.value !==
|
|
238
|
+
), at = o(
|
|
239
|
+
(t, e) => {
|
|
240
|
+
const r = s.componentOriginalValues[t];
|
|
241
|
+
return !r || !r.isPopulated ? !1 : r.value !== e;
|
|
255
242
|
},
|
|
256
243
|
[s.componentOriginalValues]
|
|
257
|
-
),
|
|
258
|
-
(
|
|
244
|
+
), ct = o(
|
|
245
|
+
(t) => s.componentAlerts[t] || [],
|
|
259
246
|
[s.componentAlerts]
|
|
260
|
-
),
|
|
261
|
-
(
|
|
247
|
+
), lt = o(
|
|
248
|
+
(t, e) => {
|
|
262
249
|
n({
|
|
263
250
|
type: "DISMISS_COMPONENT_ALERT",
|
|
264
|
-
componentId:
|
|
265
|
-
alertId:
|
|
251
|
+
componentId: t,
|
|
252
|
+
alertId: e
|
|
266
253
|
});
|
|
267
254
|
},
|
|
268
255
|
[n]
|
|
269
|
-
),
|
|
270
|
-
(
|
|
256
|
+
), dt = o(
|
|
257
|
+
(t, e) => {
|
|
271
258
|
try {
|
|
272
|
-
const r =
|
|
273
|
-
|
|
274
|
-
`🔄 [useFormMachine] Resetting dirty state for field ${t}:`,
|
|
275
|
-
{ currentValue: r }
|
|
276
|
-
), e.resetField(t), r != null && r !== "" && e.setFieldValue(t, r, {
|
|
259
|
+
const r = t.getFieldValue(e);
|
|
260
|
+
t.resetField(e), r != null && r !== "" && t.setFieldValue(e, r, {
|
|
277
261
|
dontUpdateMeta: !0
|
|
278
262
|
// This prevents marking as dirty/touched
|
|
279
|
-
})
|
|
280
|
-
`✅ [useFormMachine] Field ${t} dirty state reset complete`
|
|
281
|
-
);
|
|
263
|
+
});
|
|
282
264
|
} catch (r) {
|
|
283
265
|
console.error(
|
|
284
|
-
`❌ [useFormMachine] Error resetting dirty state for field ${
|
|
266
|
+
`❌ [useFormMachine] Error resetting dirty state for field ${e}:`,
|
|
285
267
|
r
|
|
286
268
|
);
|
|
287
269
|
}
|
|
288
270
|
},
|
|
289
271
|
[]
|
|
290
|
-
),
|
|
291
|
-
(
|
|
272
|
+
), ut = o(
|
|
273
|
+
(t) => V.hasComponentTriggers(i, t),
|
|
292
274
|
[i]
|
|
293
|
-
),
|
|
294
|
-
(
|
|
275
|
+
), pt = o(
|
|
276
|
+
(t) => V.hasComponentActions(i, t),
|
|
295
277
|
[i]
|
|
296
|
-
),
|
|
297
|
-
(
|
|
298
|
-
const
|
|
278
|
+
), St = o(
|
|
279
|
+
(t) => {
|
|
280
|
+
const e = V.findComponentTriggers(
|
|
299
281
|
i,
|
|
300
|
-
|
|
301
|
-
), r = Object.entries(s.componentTriggerState).filter(([
|
|
302
|
-
(
|
|
282
|
+
t
|
|
283
|
+
), r = Object.entries(s.componentTriggerState).filter(([c]) => c.startsWith(`${t}-`)).reduce(
|
|
284
|
+
(c, [A, mt]) => (c[A] = mt, c),
|
|
303
285
|
{}
|
|
304
|
-
),
|
|
286
|
+
), l = s.activeComponentActions[t] || [], a = s.componentAlerts[t] || [];
|
|
305
287
|
return {
|
|
306
|
-
triggers:
|
|
288
|
+
triggers: e,
|
|
307
289
|
triggerStates: r,
|
|
308
|
-
activeActions:
|
|
290
|
+
activeActions: l,
|
|
309
291
|
alerts: a
|
|
310
292
|
};
|
|
311
293
|
},
|
|
@@ -318,17 +300,17 @@ const ve = ({
|
|
|
318
300
|
);
|
|
319
301
|
return {
|
|
320
302
|
// XState primitives - for direct machine access
|
|
321
|
-
state:
|
|
303
|
+
state: f,
|
|
322
304
|
send: n,
|
|
323
305
|
// Computed state values
|
|
324
306
|
currentStep: N,
|
|
325
307
|
currentStepId: v,
|
|
326
308
|
currentStepIndex: E,
|
|
327
309
|
data: u,
|
|
328
|
-
errors:
|
|
310
|
+
errors: I,
|
|
329
311
|
isValid: h,
|
|
330
312
|
isSubmitting: O,
|
|
331
|
-
dirtyFields:
|
|
313
|
+
dirtyFields: M,
|
|
332
314
|
touchedFields: R,
|
|
333
315
|
isFirstStep: L,
|
|
334
316
|
isLastStep: P,
|
|
@@ -337,24 +319,24 @@ const ve = ({
|
|
|
337
319
|
// Shared validation engine
|
|
338
320
|
validationEngine: d,
|
|
339
321
|
// Helper functions
|
|
340
|
-
findComponentById:
|
|
322
|
+
findComponentById: T,
|
|
341
323
|
setFieldError: S,
|
|
342
324
|
clearFieldError: C,
|
|
343
325
|
// Actions
|
|
344
326
|
setData: x,
|
|
345
|
-
validateField:
|
|
327
|
+
validateField: F,
|
|
346
328
|
validateSection: w,
|
|
347
|
-
validateStep:
|
|
348
|
-
validateForm:
|
|
349
|
-
nextStep:
|
|
329
|
+
validateStep: W,
|
|
330
|
+
validateForm: b,
|
|
331
|
+
nextStep: G,
|
|
350
332
|
previousStep: U,
|
|
351
333
|
goToStep: k,
|
|
352
|
-
submitForm:
|
|
353
|
-
resetForm:
|
|
354
|
-
startSectionEdit:
|
|
355
|
-
cancelSectionEdit:
|
|
334
|
+
submitForm: j,
|
|
335
|
+
resetForm: B,
|
|
336
|
+
startSectionEdit: z,
|
|
337
|
+
cancelSectionEdit: H,
|
|
356
338
|
// Field change validation helpers
|
|
357
|
-
trackFieldChange:
|
|
339
|
+
trackFieldChange: $,
|
|
358
340
|
getFieldChanges: K,
|
|
359
341
|
clearFieldChanges: X,
|
|
360
342
|
showFieldWarning: q,
|
|
@@ -363,50 +345,50 @@ const ve = ({
|
|
|
363
345
|
startFieldVerification: Y,
|
|
364
346
|
getVerificationStatus: Z,
|
|
365
347
|
// Computed validation state
|
|
366
|
-
hasActiveWarnings:
|
|
367
|
-
hasPendingVerifications:
|
|
368
|
-
hasFieldChanges:
|
|
348
|
+
hasActiveWarnings: tt,
|
|
349
|
+
hasPendingVerifications: et,
|
|
350
|
+
hasFieldChanges: nt,
|
|
369
351
|
fieldChangeState: s.fieldChangeState,
|
|
370
352
|
fieldValidationState: s.fieldValidationState,
|
|
371
353
|
// Component trigger-action system
|
|
372
|
-
evaluateComponentTriggers:
|
|
373
|
-
setComponentOriginalValue:
|
|
374
|
-
markComponentAsPopulated:
|
|
375
|
-
getComponentOriginalValue:
|
|
376
|
-
isComponentDirty:
|
|
377
|
-
getComponentAlerts:
|
|
378
|
-
dismissComponentAlert:
|
|
379
|
-
resetFieldDirtyState:
|
|
380
|
-
hasComponentTriggers:
|
|
381
|
-
hasComponentActions:
|
|
382
|
-
getComponentTriggerState:
|
|
354
|
+
evaluateComponentTriggers: st,
|
|
355
|
+
setComponentOriginalValue: rt,
|
|
356
|
+
markComponentAsPopulated: ot,
|
|
357
|
+
getComponentOriginalValue: it,
|
|
358
|
+
isComponentDirty: at,
|
|
359
|
+
getComponentAlerts: ct,
|
|
360
|
+
dismissComponentAlert: lt,
|
|
361
|
+
resetFieldDirtyState: dt,
|
|
362
|
+
hasComponentTriggers: ut,
|
|
363
|
+
hasComponentActions: pt,
|
|
364
|
+
getComponentTriggerState: St,
|
|
383
365
|
componentTriggerState: s.componentTriggerState,
|
|
384
366
|
activeComponentActions: s.activeComponentActions,
|
|
385
367
|
componentAlerts: s.componentAlerts,
|
|
386
368
|
componentOriginalValues: s.componentOriginalValues
|
|
387
369
|
};
|
|
388
370
|
};
|
|
389
|
-
let
|
|
390
|
-
const _ = () => (
|
|
371
|
+
let y = null;
|
|
372
|
+
const _ = () => (y || (y = Et(null)), y), It = {
|
|
391
373
|
Provider: ({
|
|
392
374
|
children: i,
|
|
393
|
-
value:
|
|
375
|
+
value: m
|
|
394
376
|
}) => {
|
|
395
377
|
const p = _();
|
|
396
|
-
return
|
|
378
|
+
return ft.createElement(p.Provider, { value: m }, i);
|
|
397
379
|
}
|
|
398
|
-
},
|
|
399
|
-
const i = _(),
|
|
400
|
-
if (!
|
|
380
|
+
}, Ot = () => {
|
|
381
|
+
const i = _(), m = Ct(i);
|
|
382
|
+
if (!m)
|
|
401
383
|
throw new Error(
|
|
402
384
|
"useFormMachine must be used within a FormWizard component"
|
|
403
385
|
);
|
|
404
|
-
const { state: p, send: d, ...
|
|
405
|
-
return [p, d,
|
|
386
|
+
const { state: p, send: d, ...f } = m;
|
|
387
|
+
return [p, d, f];
|
|
406
388
|
};
|
|
407
389
|
export {
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
390
|
+
It as FormMachineContext,
|
|
391
|
+
Ot as default,
|
|
392
|
+
Ot as useFormMachine,
|
|
393
|
+
vt as useFormMachineProvider
|
|
412
394
|
};
|