@digiform/wizard 0.3.1 → 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/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/package.json +1 -3
- package/styles.css +1 -1
- 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 +54 -79
- 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 +83 -92
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
- package/wizard/src/features/form-runtime/config/templateLoader.js +48 -55
- 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 +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/ValidationExecutor.js +26 -58
- 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
|
@@ -1,56 +1,56 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { createMachine as I, assign as
|
|
3
|
-
import { executeComponentAction as
|
|
4
|
-
import { executePendingNavigation as
|
|
5
|
-
import { executeSaveActions as
|
|
6
|
-
import { ComponentTriggerEngine as
|
|
7
|
-
import { canNavigate as
|
|
8
|
-
import { isSectionEditable as
|
|
9
|
-
import { hasDirtyComponentsWithTriggers as
|
|
2
|
+
import { createMachine as I, assign as i } from "xstate";
|
|
3
|
+
import { executeComponentAction as d } from "./actions/componentActions.js";
|
|
4
|
+
import { executePendingNavigation as S } from "./actions/navigationActions.js";
|
|
5
|
+
import { executeSaveActions as f } from "./actions/saveActions.js";
|
|
6
|
+
import { ComponentTriggerEngine as l } from "./componentTriggerEngine.js";
|
|
7
|
+
import { canNavigate as c, isPendingNextNavigation as m, isPendingPreviousNavigation as A, isPendingStepNavigation as T, hasSaveContextActions as E, shouldProceedWithNormalNavigation as N, hasSaveTriggersForNext as O } from "./guards/navigationGuards.js";
|
|
8
|
+
import { isSectionEditable as v, canExecuteSaveActions as _ } from "./guards/saveGuards.js";
|
|
9
|
+
import { hasDirtyComponentsWithTriggers as C } from "./guards/triggerGuards.js";
|
|
10
10
|
import { findComponentTriggers as V } from "./helpers/triggerHelpers.js";
|
|
11
|
-
import { memoryUtils as
|
|
12
|
-
const
|
|
11
|
+
import { memoryUtils as R } from "./performance.js";
|
|
12
|
+
const x = I({
|
|
13
13
|
id: "formMachine",
|
|
14
14
|
types: {},
|
|
15
|
-
context: ({ input:
|
|
16
|
-
config:
|
|
17
|
-
currentStepId:
|
|
18
|
-
currentStepIndex:
|
|
19
|
-
data:
|
|
20
|
-
errors:
|
|
21
|
-
dirtyFields:
|
|
22
|
-
touchedFields:
|
|
23
|
-
isValid:
|
|
24
|
-
isSubmitting:
|
|
25
|
-
fieldStates:
|
|
26
|
-
sectionBackups:
|
|
27
|
-
activeActions:
|
|
28
|
-
actionResults:
|
|
29
|
-
activeDialog:
|
|
30
|
-
executingTrigger:
|
|
31
|
-
pendingNavigation:
|
|
32
|
-
canNavigate:
|
|
33
|
-
waitingForActions:
|
|
15
|
+
context: ({ input: t }) => ({
|
|
16
|
+
config: t.config || { id: "", title: "", steps: [] },
|
|
17
|
+
currentStepId: t.currentStepId || "",
|
|
18
|
+
currentStepIndex: t.currentStepIndex || 0,
|
|
19
|
+
data: t.data || {},
|
|
20
|
+
errors: t.errors || {},
|
|
21
|
+
dirtyFields: t.dirtyFields || {},
|
|
22
|
+
touchedFields: t.touchedFields || {},
|
|
23
|
+
isValid: t.isValid ?? !0,
|
|
24
|
+
isSubmitting: t.isSubmitting ?? !1,
|
|
25
|
+
fieldStates: t.fieldStates || {},
|
|
26
|
+
sectionBackups: t.sectionBackups || {},
|
|
27
|
+
activeActions: t.activeActions || {},
|
|
28
|
+
actionResults: t.actionResults || {},
|
|
29
|
+
activeDialog: t.activeDialog || null,
|
|
30
|
+
executingTrigger: t.executingTrigger || null,
|
|
31
|
+
pendingNavigation: t.pendingNavigation || null,
|
|
32
|
+
canNavigate: t.canNavigate ?? !0,
|
|
33
|
+
waitingForActions: t.waitingForActions ?? !1,
|
|
34
34
|
// Initialize field change validation state
|
|
35
|
-
fieldChangeState:
|
|
36
|
-
fieldValidationState:
|
|
35
|
+
fieldChangeState: t.fieldChangeState || {},
|
|
36
|
+
fieldValidationState: t.fieldValidationState || {
|
|
37
37
|
activeWarnings: [],
|
|
38
38
|
pendingVerifications: [],
|
|
39
39
|
verificationResults: {}
|
|
40
40
|
},
|
|
41
41
|
// Initialize component trigger-action system state
|
|
42
|
-
componentTriggerState:
|
|
43
|
-
activeComponentActions:
|
|
44
|
-
componentAlerts:
|
|
42
|
+
componentTriggerState: t.componentTriggerState || {},
|
|
43
|
+
activeComponentActions: t.activeComponentActions || {},
|
|
44
|
+
componentAlerts: t.componentAlerts || {},
|
|
45
45
|
// Enhanced original value tracking
|
|
46
|
-
componentOriginalValues:
|
|
46
|
+
componentOriginalValues: t.componentOriginalValues || {},
|
|
47
47
|
// New simplified state machine context
|
|
48
|
-
activeExecutionPlan:
|
|
49
|
-
executionResults:
|
|
48
|
+
activeExecutionPlan: t.activeExecutionPlan || null,
|
|
49
|
+
executionResults: t.executionResults || {},
|
|
50
50
|
// Track completed context actions
|
|
51
|
-
contextActionCompletions:
|
|
51
|
+
contextActionCompletions: t.contextActionCompletions || {},
|
|
52
52
|
// Initialize enhanced save state tracking
|
|
53
|
-
saveState:
|
|
53
|
+
saveState: t.saveState || {
|
|
54
54
|
saveInProgress: !1,
|
|
55
55
|
saveInitiator: null,
|
|
56
56
|
savingSection: null,
|
|
@@ -59,82 +59,41 @@ const W = I({
|
|
|
59
59
|
completedVerifications: [],
|
|
60
60
|
validationErrors: {},
|
|
61
61
|
saveStartTimestamp: null
|
|
62
|
-
}
|
|
62
|
+
},
|
|
63
|
+
forcedValidationFields: t.forcedValidationFields || []
|
|
63
64
|
}),
|
|
64
65
|
initial: "idle",
|
|
65
66
|
// Global events that should work in any state
|
|
66
67
|
on: {
|
|
68
|
+
TRIGGER_STEP_VALIDATION: {
|
|
69
|
+
actions: i({
|
|
70
|
+
forcedValidationFields: ({ event: t }) => t.fieldIds
|
|
71
|
+
})
|
|
72
|
+
},
|
|
67
73
|
EVALUATE_COMPONENT_TRIGGERS: {
|
|
68
74
|
actions: [
|
|
69
75
|
// Create execution plan for fieldChange context and execute if needed
|
|
70
|
-
({ context:
|
|
71
|
-
if (
|
|
76
|
+
({ context: t, event: e, self: n }) => {
|
|
77
|
+
if (e.type !== "EVALUATE_COMPONENT_TRIGGERS")
|
|
72
78
|
return;
|
|
73
|
-
const { componentId:
|
|
74
|
-
|
|
75
|
-
`🔥 [formMachine] EVALUATE_COMPONENT_TRIGGERS for ${i}:`,
|
|
76
|
-
{
|
|
77
|
-
value: o,
|
|
78
|
-
originalValue: r?.value,
|
|
79
|
-
isPopulated: r?.isPopulated,
|
|
80
|
-
isDirty: s,
|
|
81
|
-
hasAlerts: !!e.componentAlerts[i]?.length
|
|
82
|
-
}
|
|
83
|
-
), console.log(
|
|
84
|
-
`🔍 [formMachine] Checking alert dismissal condition for ${i}:`,
|
|
85
|
-
{
|
|
86
|
-
isDirty: s,
|
|
87
|
-
hasAlerts: !!e.componentAlerts[i]?.length,
|
|
88
|
-
alertsCount: e.componentAlerts[i]?.length,
|
|
89
|
-
allComponentAlerts: Object.keys(e.componentAlerts),
|
|
90
|
-
alertsForComponent: e.componentAlerts[i],
|
|
91
|
-
conditionMet: !s && e.componentAlerts[i]?.length
|
|
92
|
-
}
|
|
93
|
-
), !s && e.componentAlerts[i]?.length && (console.log(
|
|
94
|
-
`🧹 [formMachine] Clearing alerts for ${i} - field no longer dirty`
|
|
95
|
-
), console.log(
|
|
96
|
-
`🧹 [formMachine] Sending DISMISS_COMPONENT_ALERT for ${i}`,
|
|
97
|
-
{
|
|
98
|
-
alertsCount: e.componentAlerts[i]?.length,
|
|
99
|
-
currentState: "about to send"
|
|
100
|
-
}
|
|
101
|
-
), n.send({
|
|
79
|
+
const { componentId: a, value: o } = e, r = t.componentOriginalValues[a];
|
|
80
|
+
!(r?.isPopulated && r.value !== o) && t.componentAlerts[a]?.length && n.send({
|
|
102
81
|
type: "DISMISS_COMPONENT_ALERT",
|
|
103
|
-
componentId:
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const g = u.createExecutionPlan(
|
|
108
|
-
e.config,
|
|
82
|
+
componentId: a
|
|
83
|
+
});
|
|
84
|
+
const p = l.createExecutionPlan(
|
|
85
|
+
t.config,
|
|
109
86
|
"fieldChange",
|
|
110
|
-
|
|
111
|
-
|
|
87
|
+
t.currentStepIndex,
|
|
88
|
+
t
|
|
112
89
|
);
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
totalActions: g.totalActions,
|
|
117
|
-
executionsCount: g.executions.length,
|
|
118
|
-
executions: g.executions.map((c) => ({
|
|
119
|
-
componentId: c.componentId,
|
|
120
|
-
triggerId: c.trigger.id,
|
|
121
|
-
actionsCount: c.actions.length,
|
|
122
|
-
actions: c.actions.map((l) => ({
|
|
123
|
-
id: l.id,
|
|
124
|
-
type: l.type,
|
|
125
|
-
contexts: l.contexts
|
|
126
|
-
}))
|
|
127
|
-
}))
|
|
128
|
-
}
|
|
129
|
-
), g.totalActions > 0 && g.executions.forEach((c) => {
|
|
130
|
-
c.actions.forEach((l) => {
|
|
131
|
-
console.log(
|
|
132
|
-
`⚡ [formMachine] Executing fieldChange action ${l.id} for ${c.componentId}`
|
|
133
|
-
), n.send({
|
|
90
|
+
p.totalActions > 0 && p.executions.forEach((g) => {
|
|
91
|
+
g.actions.forEach((u) => {
|
|
92
|
+
n.send({
|
|
134
93
|
type: "TRIGGER_COMPONENT_ACTION",
|
|
135
|
-
componentId:
|
|
136
|
-
triggerId:
|
|
137
|
-
actionId:
|
|
94
|
+
componentId: g.componentId,
|
|
95
|
+
triggerId: g.trigger.id,
|
|
96
|
+
actionId: u.id,
|
|
138
97
|
eventType: "valueChange"
|
|
139
98
|
});
|
|
140
99
|
});
|
|
@@ -143,55 +102,47 @@ const W = I({
|
|
|
143
102
|
]
|
|
144
103
|
},
|
|
145
104
|
SET_COMPONENT_ORIGINAL_VALUE: {
|
|
146
|
-
actions:
|
|
147
|
-
componentOriginalValues: ({ context:
|
|
148
|
-
...
|
|
149
|
-
[
|
|
150
|
-
value:
|
|
105
|
+
actions: i({
|
|
106
|
+
componentOriginalValues: ({ context: t, event: e }) => ({
|
|
107
|
+
...t.componentOriginalValues,
|
|
108
|
+
[e.componentId]: {
|
|
109
|
+
value: e.value,
|
|
151
110
|
timestamp: Date.now(),
|
|
152
|
-
source:
|
|
153
|
-
isPopulated:
|
|
111
|
+
source: e.source || "initialized",
|
|
112
|
+
isPopulated: e.source !== "initialized"
|
|
154
113
|
}
|
|
155
114
|
}),
|
|
156
|
-
componentTriggerState: ({ context:
|
|
115
|
+
componentTriggerState: ({ context: t, event: e }) => {
|
|
157
116
|
const n = V(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
),
|
|
117
|
+
t.config,
|
|
118
|
+
e.componentId
|
|
119
|
+
), a = { ...t.componentTriggerState };
|
|
161
120
|
return n.forEach((o) => {
|
|
162
|
-
const r = `${
|
|
163
|
-
|
|
164
|
-
...
|
|
165
|
-
originalValue:
|
|
166
|
-
}) :
|
|
167
|
-
componentId:
|
|
121
|
+
const r = `${e.componentId}-${o.id}`;
|
|
122
|
+
a[r] ? a[r].originalValue === void 0 && (a[r] = {
|
|
123
|
+
...a[r],
|
|
124
|
+
originalValue: e.value
|
|
125
|
+
}) : a[r] = {
|
|
126
|
+
componentId: e.componentId,
|
|
168
127
|
triggerId: o.id,
|
|
169
128
|
isActive: !1,
|
|
170
|
-
originalValue:
|
|
129
|
+
originalValue: e.value,
|
|
171
130
|
lastEvaluated: Date.now()
|
|
172
131
|
};
|
|
173
|
-
}),
|
|
132
|
+
}), a;
|
|
174
133
|
}
|
|
175
134
|
})
|
|
176
135
|
},
|
|
177
136
|
MARK_COMPONENT_AS_POPULATED: {
|
|
178
|
-
actions:
|
|
137
|
+
actions: i({
|
|
179
138
|
componentOriginalValues: ({
|
|
180
|
-
context:
|
|
181
|
-
event:
|
|
182
|
-
}) => (
|
|
183
|
-
|
|
184
|
-
{
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
existingOriginalValue: e.componentOriginalValues[t.componentId]?.value,
|
|
188
|
-
isPopulated: e.componentOriginalValues[t.componentId]?.isPopulated
|
|
189
|
-
}
|
|
190
|
-
), {
|
|
191
|
-
...e.componentOriginalValues,
|
|
192
|
-
[t.componentId]: {
|
|
193
|
-
...e.componentOriginalValues[t.componentId],
|
|
194
|
-
value: t.value,
|
|
139
|
+
context: t,
|
|
140
|
+
event: e
|
|
141
|
+
}) => ({
|
|
142
|
+
...t.componentOriginalValues,
|
|
143
|
+
[e.componentId]: {
|
|
144
|
+
...t.componentOriginalValues[e.componentId],
|
|
145
|
+
value: e.value,
|
|
195
146
|
// Use event.value instead of currentValue from context.data
|
|
196
147
|
timestamp: Date.now(),
|
|
197
148
|
source: "api_populated",
|
|
@@ -202,24 +153,16 @@ const W = I({
|
|
|
202
153
|
},
|
|
203
154
|
UPDATE_COMPONENT_ORIGINAL_VALUE: {
|
|
204
155
|
actions: [
|
|
205
|
-
|
|
156
|
+
i({
|
|
206
157
|
componentOriginalValues: ({
|
|
207
|
-
context:
|
|
208
|
-
event:
|
|
158
|
+
context: t,
|
|
159
|
+
event: e
|
|
209
160
|
}) => {
|
|
210
|
-
const n =
|
|
211
|
-
return
|
|
212
|
-
|
|
213
|
-
{
|
|
214
|
-
|
|
215
|
-
currentValue: n,
|
|
216
|
-
oldOriginalValue: e.componentOriginalValues[t.componentId]?.value,
|
|
217
|
-
willUpdateTo: n
|
|
218
|
-
}
|
|
219
|
-
), {
|
|
220
|
-
...e.componentOriginalValues,
|
|
221
|
-
[t.componentId]: {
|
|
222
|
-
...e.componentOriginalValues[t.componentId],
|
|
161
|
+
const n = t.data[e.componentId];
|
|
162
|
+
return {
|
|
163
|
+
...t.componentOriginalValues,
|
|
164
|
+
[e.componentId]: {
|
|
165
|
+
...t.componentOriginalValues[e.componentId],
|
|
223
166
|
value: n,
|
|
224
167
|
// Update original value to current field value
|
|
225
168
|
timestamp: Date.now(),
|
|
@@ -230,13 +173,11 @@ const W = I({
|
|
|
230
173
|
}
|
|
231
174
|
}),
|
|
232
175
|
// Re-evaluate triggers after updating original value to clear alerts
|
|
233
|
-
({ context:
|
|
234
|
-
|
|
235
|
-
`🔄 [formMachine] Re-evaluating triggers after UPDATE_COMPONENT_ORIGINAL_VALUE for ${t.componentId}`
|
|
236
|
-
), n.send({
|
|
176
|
+
({ context: t, event: e, self: n }) => {
|
|
177
|
+
n.send({
|
|
237
178
|
type: "EVALUATE_COMPONENT_TRIGGERS",
|
|
238
|
-
componentId:
|
|
239
|
-
value:
|
|
179
|
+
componentId: e.componentId,
|
|
180
|
+
value: t.data[e.componentId],
|
|
240
181
|
eventType: "valueChange"
|
|
241
182
|
});
|
|
242
183
|
}
|
|
@@ -247,49 +188,49 @@ const W = I({
|
|
|
247
188
|
idle: {
|
|
248
189
|
on: {
|
|
249
190
|
SET_DATA: {
|
|
250
|
-
actions:
|
|
251
|
-
data: ({ context:
|
|
252
|
-
[
|
|
191
|
+
actions: i({
|
|
192
|
+
data: ({ context: t, event: e }) => t.data[e.key] === e.value ? t.data : Object.assign({}, t.data, {
|
|
193
|
+
[e.key]: e.value
|
|
253
194
|
}),
|
|
254
|
-
dirtyFields: ({ context:
|
|
255
|
-
[
|
|
195
|
+
dirtyFields: ({ context: t, event: e }) => t.dirtyFields[e.key] ? t.dirtyFields : Object.assign({}, t.dirtyFields, {
|
|
196
|
+
[e.key]: !0
|
|
256
197
|
})
|
|
257
198
|
})
|
|
258
199
|
},
|
|
259
200
|
SET_FIELD_STATE: {
|
|
260
|
-
actions:
|
|
261
|
-
fieldStates: ({ context:
|
|
262
|
-
const n =
|
|
201
|
+
actions: i({
|
|
202
|
+
fieldStates: ({ context: t, event: e }) => {
|
|
203
|
+
const n = t.fieldStates[e.componentId] || {
|
|
263
204
|
value: void 0,
|
|
264
205
|
error: null,
|
|
265
206
|
isDirty: !1,
|
|
266
207
|
isTouched: !1,
|
|
267
208
|
isValidating: !1
|
|
268
209
|
};
|
|
269
|
-
let
|
|
270
|
-
for (const r in
|
|
210
|
+
let a = !1;
|
|
211
|
+
for (const r in e.state) {
|
|
271
212
|
const s = r;
|
|
272
|
-
if (n[s] !==
|
|
273
|
-
|
|
213
|
+
if (n[s] !== e.state[s]) {
|
|
214
|
+
a = !0;
|
|
274
215
|
break;
|
|
275
216
|
}
|
|
276
217
|
}
|
|
277
|
-
if (!
|
|
278
|
-
return
|
|
279
|
-
const o = Object.assign({},
|
|
280
|
-
return o[
|
|
218
|
+
if (!a)
|
|
219
|
+
return t.fieldStates;
|
|
220
|
+
const o = Object.assign({}, t.fieldStates);
|
|
221
|
+
return o[e.componentId] = Object.assign(
|
|
281
222
|
{},
|
|
282
223
|
n,
|
|
283
|
-
|
|
224
|
+
e.state
|
|
284
225
|
), o;
|
|
285
226
|
}
|
|
286
227
|
})
|
|
287
228
|
},
|
|
288
229
|
VALIDATE_FIELD: {
|
|
289
230
|
actions: [
|
|
290
|
-
|
|
291
|
-
touchedFields: ({ context:
|
|
292
|
-
[
|
|
231
|
+
i({
|
|
232
|
+
touchedFields: ({ context: t, event: e }) => t.touchedFields[e.componentId] ? t.touchedFields : Object.assign({}, t.touchedFields, {
|
|
233
|
+
[e.componentId]: !0
|
|
293
234
|
})
|
|
294
235
|
})
|
|
295
236
|
]
|
|
@@ -304,77 +245,77 @@ const W = I({
|
|
|
304
245
|
actions: []
|
|
305
246
|
},
|
|
306
247
|
START_SECTION_EDIT: {
|
|
307
|
-
actions:
|
|
308
|
-
sectionBackups: ({ context:
|
|
309
|
-
if (
|
|
310
|
-
return
|
|
248
|
+
actions: i({
|
|
249
|
+
sectionBackups: ({ context: t, event: e }) => {
|
|
250
|
+
if (t.sectionBackups[e.sectionId])
|
|
251
|
+
return t.sectionBackups;
|
|
311
252
|
const n = {};
|
|
312
|
-
for (const
|
|
313
|
-
n[
|
|
314
|
-
return Object.assign({},
|
|
315
|
-
[
|
|
253
|
+
for (const a of e.componentIds)
|
|
254
|
+
n[a] = t.data[a];
|
|
255
|
+
return Object.assign({}, t.sectionBackups, {
|
|
256
|
+
[e.sectionId]: n
|
|
316
257
|
});
|
|
317
258
|
}
|
|
318
259
|
})
|
|
319
260
|
},
|
|
320
261
|
CANCEL_SECTION_EDIT: {
|
|
321
|
-
actions:
|
|
322
|
-
data: ({ context:
|
|
323
|
-
const n =
|
|
324
|
-
if (!n) return
|
|
325
|
-
let
|
|
262
|
+
actions: i({
|
|
263
|
+
data: ({ context: t, event: e }) => {
|
|
264
|
+
const n = t.sectionBackups[e.sectionId];
|
|
265
|
+
if (!n) return t.data;
|
|
266
|
+
let a = !1;
|
|
326
267
|
for (const [r, s] of Object.entries(n))
|
|
327
|
-
if (
|
|
328
|
-
|
|
268
|
+
if (t.data[r] !== s) {
|
|
269
|
+
a = !0;
|
|
329
270
|
break;
|
|
330
271
|
}
|
|
331
|
-
if (!
|
|
332
|
-
return
|
|
333
|
-
const o = Object.assign({},
|
|
272
|
+
if (!a)
|
|
273
|
+
return t.data;
|
|
274
|
+
const o = Object.assign({}, t.data);
|
|
334
275
|
for (const [r, s] of Object.entries(n))
|
|
335
276
|
o[r] = s;
|
|
336
277
|
return o;
|
|
337
278
|
},
|
|
338
279
|
// Clear the backup after restoring
|
|
339
|
-
sectionBackups: ({ context:
|
|
340
|
-
if (!
|
|
341
|
-
return
|
|
342
|
-
const n = Object.assign({},
|
|
343
|
-
return delete n[
|
|
280
|
+
sectionBackups: ({ context: t, event: e }) => {
|
|
281
|
+
if (!t.sectionBackups[e.sectionId])
|
|
282
|
+
return t.sectionBackups;
|
|
283
|
+
const n = Object.assign({}, t.sectionBackups);
|
|
284
|
+
return delete n[e.sectionId], n;
|
|
344
285
|
}
|
|
345
286
|
})
|
|
346
287
|
},
|
|
347
288
|
REQUEST_NAVIGATION: {
|
|
348
289
|
target: "evaluatingNavigation",
|
|
349
290
|
actions: [
|
|
350
|
-
|
|
351
|
-
pendingNavigation: ({ event:
|
|
352
|
-
if (
|
|
353
|
-
const
|
|
354
|
-
type:
|
|
291
|
+
i({
|
|
292
|
+
pendingNavigation: ({ event: t }) => {
|
|
293
|
+
if (t.type !== "REQUEST_NAVIGATION") return null;
|
|
294
|
+
const e = {
|
|
295
|
+
type: t.navigationType
|
|
355
296
|
};
|
|
356
|
-
return
|
|
297
|
+
return t.stepId !== void 0 && (e.stepId = t.stepId), e;
|
|
357
298
|
}
|
|
358
299
|
})
|
|
359
300
|
]
|
|
360
301
|
},
|
|
361
302
|
NEXT: [
|
|
362
303
|
{
|
|
363
|
-
guard:
|
|
304
|
+
guard: O,
|
|
364
305
|
target: "evaluatingNavigation",
|
|
365
306
|
actions: [
|
|
366
|
-
|
|
367
|
-
activeExecutionPlan: ({ context:
|
|
368
|
-
|
|
307
|
+
i({
|
|
308
|
+
activeExecutionPlan: ({ context: t }) => l.createExecutionPlan(
|
|
309
|
+
t.config,
|
|
369
310
|
"save",
|
|
370
|
-
|
|
371
|
-
|
|
311
|
+
t.currentStepIndex,
|
|
312
|
+
t
|
|
372
313
|
)
|
|
373
314
|
}),
|
|
374
|
-
|
|
315
|
+
i({
|
|
375
316
|
pendingNavigation: { type: "next" }
|
|
376
317
|
}),
|
|
377
|
-
|
|
318
|
+
i({
|
|
378
319
|
pendingNavigation: null,
|
|
379
320
|
canNavigate: !1
|
|
380
321
|
})
|
|
@@ -382,18 +323,18 @@ const W = I({
|
|
|
382
323
|
},
|
|
383
324
|
{
|
|
384
325
|
// Direct navigation if no triggers need execution
|
|
385
|
-
guard:
|
|
386
|
-
actions:
|
|
387
|
-
currentStepIndex: ({ context:
|
|
388
|
-
|
|
389
|
-
|
|
326
|
+
guard: c,
|
|
327
|
+
actions: i({
|
|
328
|
+
currentStepIndex: ({ context: t }) => Math.min(
|
|
329
|
+
t.currentStepIndex + 1,
|
|
330
|
+
t.config.steps.length - 1
|
|
390
331
|
),
|
|
391
|
-
currentStepId: ({ context:
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
|
|
332
|
+
currentStepId: ({ context: t }) => {
|
|
333
|
+
const e = Math.min(
|
|
334
|
+
t.currentStepIndex + 1,
|
|
335
|
+
t.config.steps.length - 1
|
|
395
336
|
);
|
|
396
|
-
return
|
|
337
|
+
return t.config.steps[e]?.id || "";
|
|
397
338
|
},
|
|
398
339
|
pendingNavigation: null
|
|
399
340
|
})
|
|
@@ -401,19 +342,19 @@ const W = I({
|
|
|
401
342
|
{
|
|
402
343
|
// Fallback - set pending navigation and transition to evaluation state
|
|
403
344
|
target: "evaluatingNavigation",
|
|
404
|
-
actions:
|
|
345
|
+
actions: i({
|
|
405
346
|
pendingNavigation: { type: "next" }
|
|
406
347
|
})
|
|
407
348
|
}
|
|
408
349
|
],
|
|
409
350
|
PREVIOUS: [
|
|
410
351
|
{
|
|
411
|
-
guard:
|
|
412
|
-
actions:
|
|
413
|
-
currentStepIndex: ({ context:
|
|
414
|
-
currentStepId: ({ context:
|
|
415
|
-
const
|
|
416
|
-
return
|
|
352
|
+
guard: c,
|
|
353
|
+
actions: i({
|
|
354
|
+
currentStepIndex: ({ context: t }) => Math.max(t.currentStepIndex - 1, 0),
|
|
355
|
+
currentStepId: ({ context: t }) => {
|
|
356
|
+
const e = Math.max(t.currentStepIndex - 1, 0);
|
|
357
|
+
return t.config.steps[e]?.id || "";
|
|
417
358
|
},
|
|
418
359
|
pendingNavigation: null
|
|
419
360
|
})
|
|
@@ -421,34 +362,34 @@ const W = I({
|
|
|
421
362
|
{
|
|
422
363
|
// Fallback - set pending navigation and transition to evaluation state
|
|
423
364
|
target: "evaluatingNavigation",
|
|
424
|
-
actions:
|
|
365
|
+
actions: i({
|
|
425
366
|
pendingNavigation: { type: "previous" }
|
|
426
367
|
})
|
|
427
368
|
}
|
|
428
369
|
],
|
|
429
370
|
GO_TO_STEP: [
|
|
430
371
|
{
|
|
431
|
-
guard:
|
|
432
|
-
actions:
|
|
433
|
-
currentStepIndex: ({ context:
|
|
434
|
-
if (
|
|
435
|
-
return
|
|
436
|
-
const n =
|
|
437
|
-
(
|
|
372
|
+
guard: c,
|
|
373
|
+
actions: i({
|
|
374
|
+
currentStepIndex: ({ context: t, event: e }) => {
|
|
375
|
+
if (e.type !== "GO_TO_STEP")
|
|
376
|
+
return t.currentStepIndex;
|
|
377
|
+
const n = t.config.steps.findIndex(
|
|
378
|
+
(a) => a.id === e.stepId
|
|
438
379
|
);
|
|
439
|
-
return n >= 0 ? n :
|
|
380
|
+
return n >= 0 ? n : t.currentStepIndex;
|
|
440
381
|
},
|
|
441
|
-
currentStepId: ({ context:
|
|
382
|
+
currentStepId: ({ context: t, event: e }) => e.type !== "GO_TO_STEP" ? t.currentStepId : e.stepId,
|
|
442
383
|
pendingNavigation: null
|
|
443
384
|
})
|
|
444
385
|
},
|
|
445
386
|
{
|
|
446
387
|
// Fallback - set pending navigation and transition to evaluation state
|
|
447
388
|
target: "evaluatingNavigation",
|
|
448
|
-
actions:
|
|
449
|
-
pendingNavigation: ({ event:
|
|
389
|
+
actions: i({
|
|
390
|
+
pendingNavigation: ({ event: t }) => t.type !== "GO_TO_STEP" ? null : {
|
|
450
391
|
type: "step",
|
|
451
|
-
stepId:
|
|
392
|
+
stepId: t.stepId
|
|
452
393
|
}
|
|
453
394
|
})
|
|
454
395
|
}
|
|
@@ -457,9 +398,9 @@ const W = I({
|
|
|
457
398
|
target: "submitting"
|
|
458
399
|
},
|
|
459
400
|
RESET: {
|
|
460
|
-
actions:
|
|
401
|
+
actions: i({
|
|
461
402
|
currentStepIndex: 0,
|
|
462
|
-
currentStepId: ({ context:
|
|
403
|
+
currentStepId: ({ context: t }) => t.config.steps[0]?.id || "",
|
|
463
404
|
data: {},
|
|
464
405
|
errors: {},
|
|
465
406
|
dirtyFields: {},
|
|
@@ -488,31 +429,31 @@ const W = I({
|
|
|
488
429
|
},
|
|
489
430
|
EXECUTE_TRIGGER: {
|
|
490
431
|
target: "executingActions",
|
|
491
|
-
actions:
|
|
492
|
-
executingTrigger: ({ event:
|
|
432
|
+
actions: i({
|
|
433
|
+
executingTrigger: ({ event: t }) => t.trigger,
|
|
493
434
|
waitingForActions: !0,
|
|
494
435
|
canNavigate: !1
|
|
495
436
|
})
|
|
496
437
|
},
|
|
497
438
|
EXECUTE_ACTIONS: {
|
|
498
439
|
target: "executingActions",
|
|
499
|
-
actions:
|
|
500
|
-
executingTrigger: ({ event:
|
|
440
|
+
actions: i({
|
|
441
|
+
executingTrigger: ({ event: t }) => t.trigger,
|
|
501
442
|
waitingForActions: !0,
|
|
502
443
|
canNavigate: !1
|
|
503
444
|
})
|
|
504
445
|
},
|
|
505
446
|
EXECUTE_CONTEXT_ACTIONS: {
|
|
506
447
|
target: "executingContextActions",
|
|
507
|
-
actions:
|
|
508
|
-
activeExecutionPlan: ({ event:
|
|
448
|
+
actions: i({
|
|
449
|
+
activeExecutionPlan: ({ event: t }) => t.executionPlan,
|
|
509
450
|
canNavigate: !1
|
|
510
451
|
})
|
|
511
452
|
},
|
|
512
453
|
SHOW_ACTION_DIALOG: {
|
|
513
454
|
target: "showingActionDialog",
|
|
514
|
-
actions:
|
|
515
|
-
activeDialog: ({ event:
|
|
455
|
+
actions: i({
|
|
456
|
+
activeDialog: ({ event: t }) => t.dialogConfig,
|
|
516
457
|
canNavigate: !0,
|
|
517
458
|
// Reset navigation permission when showing dialog
|
|
518
459
|
waitingForActions: !1
|
|
@@ -520,74 +461,74 @@ const W = I({
|
|
|
520
461
|
})
|
|
521
462
|
},
|
|
522
463
|
SHOW_FIELD_WARNING: {
|
|
523
|
-
actions:
|
|
524
|
-
fieldChangeState: ({ context:
|
|
525
|
-
...
|
|
526
|
-
[
|
|
527
|
-
...
|
|
464
|
+
actions: i({
|
|
465
|
+
fieldChangeState: ({ context: t, event: e }) => e.type !== "SHOW_FIELD_WARNING" ? t.fieldChangeState : {
|
|
466
|
+
...t.fieldChangeState,
|
|
467
|
+
[e.fieldId]: {
|
|
468
|
+
...t.fieldChangeState[e.fieldId],
|
|
528
469
|
validationWarnings: [
|
|
529
|
-
...
|
|
470
|
+
...t.fieldChangeState[e.fieldId]?.validationWarnings || [],
|
|
530
471
|
{
|
|
531
|
-
id:
|
|
532
|
-
fieldId:
|
|
533
|
-
message:
|
|
534
|
-
severity:
|
|
535
|
-
type:
|
|
472
|
+
id: e.warningId,
|
|
473
|
+
fieldId: e.fieldId,
|
|
474
|
+
message: e.message,
|
|
475
|
+
severity: e.warningType || "warning",
|
|
476
|
+
type: e.warningType || "warning",
|
|
536
477
|
timestamp: Date.now(),
|
|
537
478
|
dismissible: !0
|
|
538
479
|
}
|
|
539
480
|
]
|
|
540
481
|
}
|
|
541
482
|
},
|
|
542
|
-
fieldValidationState: ({ context:
|
|
543
|
-
...
|
|
544
|
-
activeWarnings:
|
|
545
|
-
|
|
546
|
-
) ?
|
|
547
|
-
...
|
|
548
|
-
|
|
483
|
+
fieldValidationState: ({ context: t, event: e }) => e.type !== "SHOW_FIELD_WARNING" ? t.fieldValidationState : {
|
|
484
|
+
...t.fieldValidationState,
|
|
485
|
+
activeWarnings: t.fieldValidationState.activeWarnings.includes(
|
|
486
|
+
e.fieldId
|
|
487
|
+
) ? t.fieldValidationState.activeWarnings : [
|
|
488
|
+
...t.fieldValidationState.activeWarnings,
|
|
489
|
+
e.fieldId
|
|
549
490
|
]
|
|
550
491
|
}
|
|
551
492
|
})
|
|
552
493
|
},
|
|
553
494
|
DISMISS_FIELD_WARNING: {
|
|
554
|
-
actions:
|
|
555
|
-
fieldChangeState: ({ context:
|
|
556
|
-
const n =
|
|
495
|
+
actions: i({
|
|
496
|
+
fieldChangeState: ({ context: t, event: e }) => {
|
|
497
|
+
const n = t.fieldChangeState[e.fieldId];
|
|
557
498
|
return n ? {
|
|
558
|
-
...
|
|
559
|
-
[
|
|
499
|
+
...t.fieldChangeState,
|
|
500
|
+
[e.fieldId]: {
|
|
560
501
|
...n,
|
|
561
502
|
validationWarnings: n.validationWarnings?.filter(
|
|
562
|
-
(
|
|
503
|
+
(a) => a.id !== e.warningId
|
|
563
504
|
) || []
|
|
564
505
|
}
|
|
565
|
-
} :
|
|
506
|
+
} : t.fieldChangeState;
|
|
566
507
|
},
|
|
567
|
-
fieldValidationState: ({ context:
|
|
568
|
-
const
|
|
508
|
+
fieldValidationState: ({ context: t, event: e }) => {
|
|
509
|
+
const a = t.fieldChangeState[e.fieldId]?.validationWarnings?.length > 0;
|
|
569
510
|
return {
|
|
570
|
-
...
|
|
571
|
-
activeWarnings:
|
|
572
|
-
(o) => o !==
|
|
511
|
+
...t.fieldValidationState,
|
|
512
|
+
activeWarnings: a ? t.fieldValidationState.activeWarnings : t.fieldValidationState.activeWarnings.filter(
|
|
513
|
+
(o) => o !== e.fieldId
|
|
573
514
|
)
|
|
574
515
|
};
|
|
575
516
|
}
|
|
576
517
|
})
|
|
577
518
|
},
|
|
578
519
|
START_FIELD_VERIFICATION: {
|
|
579
|
-
actions:
|
|
580
|
-
fieldValidationState: ({ context:
|
|
581
|
-
...
|
|
582
|
-
pendingVerifications:
|
|
583
|
-
|
|
584
|
-
) ?
|
|
585
|
-
...
|
|
586
|
-
|
|
520
|
+
actions: i({
|
|
521
|
+
fieldValidationState: ({ context: t, event: e }) => e.type !== "START_FIELD_VERIFICATION" ? t.fieldValidationState : {
|
|
522
|
+
...t.fieldValidationState,
|
|
523
|
+
pendingVerifications: t.fieldValidationState.pendingVerifications.includes(
|
|
524
|
+
e.fieldId
|
|
525
|
+
) ? t.fieldValidationState.pendingVerifications : [
|
|
526
|
+
...t.fieldValidationState.pendingVerifications,
|
|
527
|
+
e.fieldId
|
|
587
528
|
],
|
|
588
529
|
verificationResults: {
|
|
589
|
-
...
|
|
590
|
-
[
|
|
530
|
+
...t.fieldValidationState.verificationResults,
|
|
531
|
+
[e.fieldId]: {
|
|
591
532
|
status: "pending",
|
|
592
533
|
timestamp: Date.now()
|
|
593
534
|
}
|
|
@@ -596,47 +537,47 @@ const W = I({
|
|
|
596
537
|
})
|
|
597
538
|
},
|
|
598
539
|
FIELD_VERIFICATION_COMPLETE: {
|
|
599
|
-
actions:
|
|
540
|
+
actions: i({
|
|
600
541
|
fieldValidationState: ({
|
|
601
|
-
context:
|
|
602
|
-
event:
|
|
542
|
+
context: t,
|
|
543
|
+
event: e
|
|
603
544
|
}) => ({
|
|
604
|
-
...
|
|
605
|
-
pendingVerifications:
|
|
606
|
-
(n) => n !==
|
|
545
|
+
...t.fieldValidationState,
|
|
546
|
+
pendingVerifications: t.fieldValidationState.pendingVerifications.filter(
|
|
547
|
+
(n) => n !== e.fieldId
|
|
607
548
|
),
|
|
608
549
|
verificationResults: {
|
|
609
|
-
...
|
|
610
|
-
[
|
|
611
|
-
status:
|
|
550
|
+
...t.fieldValidationState.verificationResults,
|
|
551
|
+
[e.fieldId]: {
|
|
552
|
+
status: e.success ? "success" : "failed",
|
|
612
553
|
timestamp: Date.now(),
|
|
613
|
-
result:
|
|
554
|
+
result: e.result
|
|
614
555
|
}
|
|
615
556
|
}
|
|
616
557
|
})
|
|
617
558
|
})
|
|
618
559
|
},
|
|
619
560
|
CLEAR_FIELD_CHANGES: {
|
|
620
|
-
actions:
|
|
621
|
-
fieldChangeState: ({ context:
|
|
622
|
-
if (
|
|
623
|
-
const n = { ...
|
|
624
|
-
return delete n[
|
|
561
|
+
actions: i({
|
|
562
|
+
fieldChangeState: ({ context: t, event: e }) => {
|
|
563
|
+
if (e.fieldId) {
|
|
564
|
+
const n = { ...t.fieldChangeState };
|
|
565
|
+
return delete n[e.fieldId], n;
|
|
625
566
|
} else
|
|
626
567
|
return {};
|
|
627
568
|
},
|
|
628
|
-
fieldValidationState: ({ context:
|
|
629
|
-
...
|
|
630
|
-
activeWarnings:
|
|
631
|
-
(n) => n !==
|
|
569
|
+
fieldValidationState: ({ context: t, event: e }) => e.fieldId ? {
|
|
570
|
+
...t.fieldValidationState,
|
|
571
|
+
activeWarnings: t.fieldValidationState.activeWarnings.filter(
|
|
572
|
+
(n) => n !== e.fieldId
|
|
632
573
|
),
|
|
633
|
-
pendingVerifications:
|
|
634
|
-
(n) => n !==
|
|
574
|
+
pendingVerifications: t.fieldValidationState.pendingVerifications.filter(
|
|
575
|
+
(n) => n !== e.fieldId
|
|
635
576
|
),
|
|
636
577
|
verificationResults: Object.fromEntries(
|
|
637
578
|
Object.entries(
|
|
638
|
-
|
|
639
|
-
).filter(([n]) => n !==
|
|
579
|
+
t.fieldValidationState.verificationResults
|
|
580
|
+
).filter(([n]) => n !== e.fieldId)
|
|
640
581
|
)
|
|
641
582
|
} : {
|
|
642
583
|
activeWarnings: [],
|
|
@@ -646,73 +587,63 @@ const W = I({
|
|
|
646
587
|
})
|
|
647
588
|
},
|
|
648
589
|
SET_COMPONENT_ORIGINAL_VALUE: {
|
|
649
|
-
actions:
|
|
650
|
-
componentOriginalValues: ({ context:
|
|
651
|
-
const n =
|
|
652
|
-
value:
|
|
590
|
+
actions: i({
|
|
591
|
+
componentOriginalValues: ({ context: t, event: e }) => {
|
|
592
|
+
const n = t.componentOriginalValues[e.componentId], a = {
|
|
593
|
+
value: e.value,
|
|
653
594
|
timestamp: Date.now(),
|
|
654
|
-
source:
|
|
655
|
-
isPopulated:
|
|
595
|
+
source: e.source || "initialized",
|
|
596
|
+
isPopulated: e.source !== "initialized"
|
|
656
597
|
};
|
|
657
|
-
return n &&
|
|
658
|
-
[
|
|
598
|
+
return n && R.shallowEqual(n, a) ? t.componentOriginalValues : Object.assign({}, t.componentOriginalValues, {
|
|
599
|
+
[e.componentId]: a
|
|
659
600
|
});
|
|
660
601
|
}
|
|
661
602
|
})
|
|
662
603
|
},
|
|
663
604
|
TRIGGER_COMPONENT_ACTION: {
|
|
664
|
-
actions: [
|
|
605
|
+
actions: [d]
|
|
665
606
|
},
|
|
666
607
|
SHOW_COMPONENT_ALERT: {
|
|
667
|
-
actions:
|
|
668
|
-
componentAlerts: ({ context:
|
|
669
|
-
const
|
|
670
|
-
(o) => o.id !==
|
|
608
|
+
actions: i({
|
|
609
|
+
componentAlerts: ({ context: t, event: e }) => {
|
|
610
|
+
const a = (t.componentAlerts[e.componentId] || []).filter(
|
|
611
|
+
(o) => o.id !== e.alert.id
|
|
671
612
|
);
|
|
672
613
|
return {
|
|
673
|
-
...
|
|
674
|
-
[
|
|
614
|
+
...t.componentAlerts,
|
|
615
|
+
[e.componentId]: [...a, e.alert]
|
|
675
616
|
};
|
|
676
617
|
}
|
|
677
618
|
})
|
|
678
619
|
},
|
|
679
620
|
DISMISS_COMPONENT_ALERT: {
|
|
680
|
-
actions:
|
|
681
|
-
componentAlerts: ({ context:
|
|
682
|
-
const n =
|
|
683
|
-
return
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
alertId: t.alertId,
|
|
687
|
-
beforeCount: n.length,
|
|
688
|
-
afterCount: i.length,
|
|
689
|
-
clearedAll: !t.alertId && n.length > 0
|
|
690
|
-
}
|
|
691
|
-
), {
|
|
692
|
-
...e.componentAlerts,
|
|
693
|
-
[t.componentId]: i
|
|
621
|
+
actions: i({
|
|
622
|
+
componentAlerts: ({ context: t, event: e }) => {
|
|
623
|
+
const n = t.componentAlerts[e.componentId] || [], a = e.alertId ? n.filter((o) => o.id !== e.alertId) : [];
|
|
624
|
+
return {
|
|
625
|
+
...t.componentAlerts,
|
|
626
|
+
[e.componentId]: a
|
|
694
627
|
};
|
|
695
628
|
}
|
|
696
629
|
})
|
|
697
630
|
},
|
|
698
631
|
CLEAR_COMPONENT_ALERT: {
|
|
699
|
-
actions:
|
|
700
|
-
componentAlerts: ({ context:
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
...e.componentAlerts,
|
|
704
|
-
[t.componentId]: []
|
|
632
|
+
actions: i({
|
|
633
|
+
componentAlerts: ({ context: t, event: e }) => ({
|
|
634
|
+
...t.componentAlerts,
|
|
635
|
+
[e.componentId]: []
|
|
705
636
|
})
|
|
706
637
|
})
|
|
707
638
|
},
|
|
708
639
|
START_SAVE: {
|
|
709
640
|
target: "preparingSave",
|
|
710
|
-
actions:
|
|
711
|
-
saveState: ({ context:
|
|
712
|
-
...
|
|
641
|
+
actions: i({
|
|
642
|
+
saveState: ({ context: t, event: e }) => e.type !== "START_SAVE" ? t.saveState : {
|
|
643
|
+
...t.saveState,
|
|
713
644
|
saveInProgress: !0,
|
|
714
|
-
saveInitiator:
|
|
715
|
-
savingSection:
|
|
645
|
+
saveInitiator: e.initiator,
|
|
646
|
+
savingSection: e.sectionId,
|
|
716
647
|
saveStartTimestamp: Date.now(),
|
|
717
648
|
pendingVerifications: [],
|
|
718
649
|
completedVerifications: [],
|
|
@@ -721,12 +652,12 @@ const W = I({
|
|
|
721
652
|
})
|
|
722
653
|
},
|
|
723
654
|
SAVE_DIALOG_SHOWN: {
|
|
724
|
-
actions:
|
|
725
|
-
saveState: ({ context:
|
|
726
|
-
...
|
|
655
|
+
actions: i({
|
|
656
|
+
saveState: ({ context: t, event: e }) => e.type !== "SAVE_DIALOG_SHOWN" ? t.saveState : {
|
|
657
|
+
...t.saveState,
|
|
727
658
|
pendingVerifications: [
|
|
728
|
-
...
|
|
729
|
-
|
|
659
|
+
...t.saveState.pendingVerifications,
|
|
660
|
+
e.dialogId
|
|
730
661
|
]
|
|
731
662
|
}
|
|
732
663
|
})
|
|
@@ -737,19 +668,19 @@ const W = I({
|
|
|
737
668
|
executingContextActions: {
|
|
738
669
|
entry: [
|
|
739
670
|
// Execute all actions in the execution plan
|
|
740
|
-
({ context:
|
|
741
|
-
const n =
|
|
742
|
-
n && (n.executions.forEach((
|
|
743
|
-
|
|
744
|
-
|
|
671
|
+
({ context: t, self: e }) => {
|
|
672
|
+
const n = t.activeExecutionPlan;
|
|
673
|
+
n && (n.executions.forEach((a) => {
|
|
674
|
+
a.actions.forEach((o) => {
|
|
675
|
+
e.send({
|
|
745
676
|
type: "TRIGGER_COMPONENT_ACTION",
|
|
746
|
-
componentId:
|
|
747
|
-
triggerId:
|
|
677
|
+
componentId: a.componentId,
|
|
678
|
+
triggerId: a.trigger.id,
|
|
748
679
|
actionId: o.id,
|
|
749
680
|
eventType: "navigationAttempt"
|
|
750
681
|
});
|
|
751
682
|
});
|
|
752
|
-
}), n.totalActions === 0 &&
|
|
683
|
+
}), n.totalActions === 0 && e.send({
|
|
753
684
|
type: "CONTEXT_ACTIONS_COMPLETE",
|
|
754
685
|
results: {}
|
|
755
686
|
}));
|
|
@@ -758,48 +689,48 @@ const W = I({
|
|
|
758
689
|
on: {
|
|
759
690
|
REQUEST_NAVIGATION: {
|
|
760
691
|
actions: [
|
|
761
|
-
|
|
762
|
-
pendingNavigation: ({ event:
|
|
763
|
-
if (
|
|
764
|
-
const
|
|
765
|
-
type:
|
|
692
|
+
i({
|
|
693
|
+
pendingNavigation: ({ event: t }) => {
|
|
694
|
+
if (t.type !== "REQUEST_NAVIGATION") return null;
|
|
695
|
+
const e = {
|
|
696
|
+
type: t.navigationType
|
|
766
697
|
};
|
|
767
|
-
return
|
|
698
|
+
return t.stepId !== void 0 && (e.stepId = t.stepId), e;
|
|
768
699
|
}
|
|
769
700
|
})
|
|
770
701
|
]
|
|
771
702
|
},
|
|
772
703
|
TRIGGER_COMPONENT_ACTION: {
|
|
773
|
-
actions: [
|
|
704
|
+
actions: [d]
|
|
774
705
|
},
|
|
775
706
|
CONTEXT_ACTIONS_COMPLETE: {
|
|
776
707
|
target: "idle",
|
|
777
708
|
actions: [
|
|
778
|
-
|
|
709
|
+
i({
|
|
779
710
|
activeExecutionPlan: null,
|
|
780
|
-
executionResults: ({ context:
|
|
781
|
-
...
|
|
782
|
-
...
|
|
711
|
+
executionResults: ({ context: t, event: e }) => ({
|
|
712
|
+
...t.executionResults,
|
|
713
|
+
...e.results
|
|
783
714
|
})
|
|
784
715
|
}),
|
|
785
|
-
|
|
716
|
+
S
|
|
786
717
|
]
|
|
787
718
|
},
|
|
788
719
|
SHOW_ACTION_DIALOG: {
|
|
789
720
|
target: "showingActionDialog",
|
|
790
|
-
actions:
|
|
791
|
-
activeDialog: ({ event:
|
|
721
|
+
actions: i({
|
|
722
|
+
activeDialog: ({ event: t }) => t.dialogConfig
|
|
792
723
|
})
|
|
793
724
|
},
|
|
794
725
|
SHOW_COMPONENT_ALERT: {
|
|
795
|
-
actions:
|
|
796
|
-
componentAlerts: ({ context:
|
|
797
|
-
const
|
|
798
|
-
(o) => o.id !==
|
|
726
|
+
actions: i({
|
|
727
|
+
componentAlerts: ({ context: t, event: e }) => {
|
|
728
|
+
const a = (t.componentAlerts[e.componentId] || []).filter(
|
|
729
|
+
(o) => o.id !== e.alert.id
|
|
799
730
|
);
|
|
800
731
|
return {
|
|
801
|
-
...
|
|
802
|
-
[
|
|
732
|
+
...t.componentAlerts,
|
|
733
|
+
[e.componentId]: [...a, e.alert]
|
|
803
734
|
};
|
|
804
735
|
}
|
|
805
736
|
})
|
|
@@ -807,31 +738,31 @@ const W = I({
|
|
|
807
738
|
}
|
|
808
739
|
},
|
|
809
740
|
submitting: {
|
|
810
|
-
entry:
|
|
741
|
+
entry: i({ isSubmitting: !0 }),
|
|
811
742
|
on: {
|
|
812
743
|
SUBMIT_SUCCESS: {
|
|
813
744
|
target: "idle",
|
|
814
|
-
actions:
|
|
745
|
+
actions: i({ isSubmitting: !1 })
|
|
815
746
|
},
|
|
816
747
|
SUBMIT_ERROR: {
|
|
817
748
|
target: "idle",
|
|
818
|
-
actions:
|
|
749
|
+
actions: i({
|
|
819
750
|
isSubmitting: !1,
|
|
820
|
-
errors: ({ context:
|
|
821
|
-
...
|
|
822
|
-
_form: [
|
|
751
|
+
errors: ({ context: t, event: e }) => ({
|
|
752
|
+
...t.errors,
|
|
753
|
+
_form: [e.error.message]
|
|
823
754
|
})
|
|
824
755
|
})
|
|
825
756
|
},
|
|
826
757
|
SET_COMPONENT_ORIGINAL_VALUE: {
|
|
827
|
-
actions:
|
|
828
|
-
componentOriginalValues: ({ context:
|
|
829
|
-
...
|
|
830
|
-
[
|
|
831
|
-
value:
|
|
758
|
+
actions: i({
|
|
759
|
+
componentOriginalValues: ({ context: t, event: e }) => ({
|
|
760
|
+
...t.componentOriginalValues,
|
|
761
|
+
[e.componentId]: {
|
|
762
|
+
value: e.value,
|
|
832
763
|
timestamp: Date.now(),
|
|
833
|
-
source:
|
|
834
|
-
isPopulated:
|
|
764
|
+
source: e.source || "initialized",
|
|
765
|
+
isPopulated: e.source !== "initialized"
|
|
835
766
|
}
|
|
836
767
|
})
|
|
837
768
|
})
|
|
@@ -842,16 +773,16 @@ const W = I({
|
|
|
842
773
|
executingActions: {
|
|
843
774
|
on: {
|
|
844
775
|
COMPONENT_ACTION_START: {
|
|
845
|
-
actions:
|
|
846
|
-
activeComponentActions: ({ context:
|
|
847
|
-
const n =
|
|
776
|
+
actions: i({
|
|
777
|
+
activeComponentActions: ({ context: t, event: e }) => {
|
|
778
|
+
const n = t.activeComponentActions[e.componentId] || [];
|
|
848
779
|
return {
|
|
849
|
-
...
|
|
850
|
-
[
|
|
780
|
+
...t.activeComponentActions,
|
|
781
|
+
[e.componentId]: [
|
|
851
782
|
...n,
|
|
852
783
|
{
|
|
853
|
-
actionId:
|
|
854
|
-
componentId:
|
|
784
|
+
actionId: e.actionId,
|
|
785
|
+
componentId: e.componentId,
|
|
855
786
|
status: "executing",
|
|
856
787
|
startTime: Date.now()
|
|
857
788
|
}
|
|
@@ -861,54 +792,54 @@ const W = I({
|
|
|
861
792
|
})
|
|
862
793
|
},
|
|
863
794
|
COMPONENT_ACTION_COMPLETE: {
|
|
864
|
-
actions:
|
|
865
|
-
activeComponentActions: ({ context:
|
|
866
|
-
const n =
|
|
795
|
+
actions: i({
|
|
796
|
+
activeComponentActions: ({ context: t, event: e }) => {
|
|
797
|
+
const n = t.activeComponentActions[e.componentId] || [];
|
|
867
798
|
return {
|
|
868
|
-
...
|
|
869
|
-
[
|
|
870
|
-
(
|
|
799
|
+
...t.activeComponentActions,
|
|
800
|
+
[e.componentId]: n.map(
|
|
801
|
+
(a) => a.actionId === e.actionId ? { ...a, status: "completed" } : a
|
|
871
802
|
)
|
|
872
803
|
};
|
|
873
804
|
}
|
|
874
805
|
})
|
|
875
806
|
},
|
|
876
807
|
COMPONENT_ACTION_FAILED: {
|
|
877
|
-
actions:
|
|
878
|
-
activeComponentActions: ({ context:
|
|
879
|
-
const n =
|
|
808
|
+
actions: i({
|
|
809
|
+
activeComponentActions: ({ context: t, event: e }) => {
|
|
810
|
+
const n = t.activeComponentActions[e.componentId] || [];
|
|
880
811
|
return {
|
|
881
|
-
...
|
|
882
|
-
[
|
|
883
|
-
(
|
|
884
|
-
...
|
|
812
|
+
...t.activeComponentActions,
|
|
813
|
+
[e.componentId]: n.map(
|
|
814
|
+
(a) => a.actionId === e.actionId ? {
|
|
815
|
+
...a,
|
|
885
816
|
status: "failed",
|
|
886
|
-
error:
|
|
887
|
-
} :
|
|
817
|
+
error: e.error
|
|
818
|
+
} : a
|
|
888
819
|
)
|
|
889
820
|
};
|
|
890
821
|
}
|
|
891
822
|
})
|
|
892
823
|
},
|
|
893
824
|
SHOW_COMPONENT_ALERT: {
|
|
894
|
-
actions:
|
|
895
|
-
componentAlerts: ({ context:
|
|
896
|
-
const
|
|
897
|
-
(o) => o.id !==
|
|
825
|
+
actions: i({
|
|
826
|
+
componentAlerts: ({ context: t, event: e }) => {
|
|
827
|
+
const a = (t.componentAlerts[e.componentId] || []).filter(
|
|
828
|
+
(o) => o.id !== e.alert.id
|
|
898
829
|
);
|
|
899
830
|
return {
|
|
900
|
-
...
|
|
901
|
-
[
|
|
831
|
+
...t.componentAlerts,
|
|
832
|
+
[e.componentId]: [...a, e.alert]
|
|
902
833
|
};
|
|
903
834
|
}
|
|
904
835
|
})
|
|
905
836
|
},
|
|
906
837
|
ACTION_START: {
|
|
907
|
-
actions:
|
|
908
|
-
activeActions: ({ context:
|
|
909
|
-
...
|
|
910
|
-
[
|
|
911
|
-
actionId:
|
|
838
|
+
actions: i({
|
|
839
|
+
activeActions: ({ context: t, event: e }) => ({
|
|
840
|
+
...t.activeActions,
|
|
841
|
+
[e.actionId]: {
|
|
842
|
+
actionId: e.actionId,
|
|
912
843
|
status: "executing",
|
|
913
844
|
startTime: Date.now()
|
|
914
845
|
}
|
|
@@ -916,26 +847,26 @@ const W = I({
|
|
|
916
847
|
})
|
|
917
848
|
},
|
|
918
849
|
ACTION_SUCCESS: {
|
|
919
|
-
actions:
|
|
920
|
-
activeActions: ({ context:
|
|
921
|
-
...
|
|
922
|
-
[
|
|
923
|
-
...
|
|
850
|
+
actions: i({
|
|
851
|
+
activeActions: ({ context: t, event: e }) => ({
|
|
852
|
+
...t.activeActions,
|
|
853
|
+
[e.actionId]: {
|
|
854
|
+
...t.activeActions[e.actionId],
|
|
924
855
|
status: "success",
|
|
925
|
-
result:
|
|
856
|
+
result: e.result,
|
|
926
857
|
completedTime: Date.now()
|
|
927
858
|
}
|
|
928
859
|
})
|
|
929
860
|
})
|
|
930
861
|
},
|
|
931
862
|
ACTION_ERROR: {
|
|
932
|
-
actions:
|
|
933
|
-
activeActions: ({ context:
|
|
934
|
-
...
|
|
935
|
-
[
|
|
936
|
-
...
|
|
863
|
+
actions: i({
|
|
864
|
+
activeActions: ({ context: t, event: e }) => ({
|
|
865
|
+
...t.activeActions,
|
|
866
|
+
[e.actionId]: {
|
|
867
|
+
...t.activeActions[e.actionId],
|
|
937
868
|
status: "error",
|
|
938
|
-
error:
|
|
869
|
+
error: e.error,
|
|
939
870
|
completedTime: Date.now()
|
|
940
871
|
}
|
|
941
872
|
})
|
|
@@ -943,23 +874,23 @@ const W = I({
|
|
|
943
874
|
},
|
|
944
875
|
ACTIONS_COMPLETED: {
|
|
945
876
|
target: "executingPendingNavigation",
|
|
946
|
-
actions:
|
|
877
|
+
actions: i({
|
|
947
878
|
// Clear all action execution state
|
|
948
879
|
activeActions: {},
|
|
949
880
|
executingTrigger: null,
|
|
950
881
|
waitingForActions: !1,
|
|
951
882
|
canNavigate: !0,
|
|
952
883
|
// Store final results
|
|
953
|
-
actionResults: ({ context:
|
|
954
|
-
...
|
|
955
|
-
...
|
|
884
|
+
actionResults: ({ context: t, event: e }) => ({
|
|
885
|
+
...t.actionResults,
|
|
886
|
+
...e.results
|
|
956
887
|
})
|
|
957
888
|
})
|
|
958
889
|
},
|
|
959
890
|
SHOW_ACTION_DIALOG: {
|
|
960
891
|
target: "showingActionDialog",
|
|
961
|
-
actions:
|
|
962
|
-
activeDialog: ({ event:
|
|
892
|
+
actions: i({
|
|
893
|
+
activeDialog: ({ event: t }) => t.dialogConfig,
|
|
963
894
|
canNavigate: !1,
|
|
964
895
|
// Block navigation until dialog is resolved
|
|
965
896
|
waitingForActions: !1
|
|
@@ -967,24 +898,24 @@ const W = I({
|
|
|
967
898
|
})
|
|
968
899
|
},
|
|
969
900
|
TRIGGER_COMPONENT_ACTION: {
|
|
970
|
-
actions: [
|
|
901
|
+
actions: [d]
|
|
971
902
|
},
|
|
972
903
|
DISMISS_COMPONENT_ALERT: {
|
|
973
|
-
actions:
|
|
974
|
-
componentAlerts: ({ context:
|
|
975
|
-
const n =
|
|
904
|
+
actions: i({
|
|
905
|
+
componentAlerts: ({ context: t, event: e }) => {
|
|
906
|
+
const n = t.componentAlerts[e.componentId] || [], a = e.alertId ? n.filter((o) => o.id !== e.alertId) : [];
|
|
976
907
|
return {
|
|
977
|
-
...
|
|
978
|
-
[
|
|
908
|
+
...t.componentAlerts,
|
|
909
|
+
[e.componentId]: a
|
|
979
910
|
};
|
|
980
911
|
}
|
|
981
912
|
})
|
|
982
913
|
},
|
|
983
914
|
CLEAR_COMPONENT_ALERT: {
|
|
984
|
-
actions:
|
|
985
|
-
componentAlerts: ({ context:
|
|
986
|
-
...
|
|
987
|
-
[
|
|
915
|
+
actions: i({
|
|
916
|
+
componentAlerts: ({ context: t, event: e }) => ({
|
|
917
|
+
...t.componentAlerts,
|
|
918
|
+
[e.componentId]: []
|
|
988
919
|
})
|
|
989
920
|
})
|
|
990
921
|
}
|
|
@@ -999,63 +930,39 @@ const W = I({
|
|
|
999
930
|
guard: E,
|
|
1000
931
|
target: "executingContextActions",
|
|
1001
932
|
actions: [
|
|
1002
|
-
|
|
1003
|
-
activeExecutionPlan: ({ context:
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
"save",
|
|
1010
|
-
e.currentStepIndex,
|
|
1011
|
-
e
|
|
1012
|
-
);
|
|
1013
|
-
return console.log("🎯 [formMachine] Save context execution plan:", {
|
|
1014
|
-
totalActions: t.totalActions,
|
|
1015
|
-
executionsCount: t.executions.length,
|
|
1016
|
-
executions: t.executions.map((n) => ({
|
|
1017
|
-
componentId: n.componentId,
|
|
1018
|
-
triggerId: n.trigger.id,
|
|
1019
|
-
triggerType: n.trigger.type,
|
|
1020
|
-
actionsCount: n.actions.length,
|
|
1021
|
-
actions: n.actions.map((i) => ({
|
|
1022
|
-
id: i.id,
|
|
1023
|
-
type: i.type,
|
|
1024
|
-
contexts: i.contexts
|
|
1025
|
-
}))
|
|
1026
|
-
}))
|
|
1027
|
-
}), t;
|
|
1028
|
-
}
|
|
933
|
+
i({
|
|
934
|
+
activeExecutionPlan: ({ context: t }) => l.createExecutionPlan(
|
|
935
|
+
t.config,
|
|
936
|
+
"save",
|
|
937
|
+
t.currentStepIndex,
|
|
938
|
+
t
|
|
939
|
+
)
|
|
1029
940
|
})
|
|
1030
941
|
]
|
|
1031
942
|
},
|
|
1032
943
|
{
|
|
1033
944
|
// PRIORITY 2: Check for other dirty components with triggers for step navigation
|
|
1034
|
-
guard:
|
|
945
|
+
guard: C,
|
|
1035
946
|
target: "executingTriggerActions",
|
|
1036
947
|
actions: [
|
|
1037
|
-
|
|
948
|
+
i({
|
|
1038
949
|
executingTrigger: "onStepFinish",
|
|
1039
950
|
waitingForActions: !0,
|
|
1040
951
|
canNavigate: !1
|
|
1041
952
|
}),
|
|
1042
953
|
// Execute the component trigger actions
|
|
1043
|
-
({ context:
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
e.currentStepIndex,
|
|
1049
|
-
e,
|
|
954
|
+
({ context: t, self: e }) => {
|
|
955
|
+
l.findDirtyComponentsForNavigation(
|
|
956
|
+
t.config,
|
|
957
|
+
t.currentStepIndex,
|
|
958
|
+
t,
|
|
1050
959
|
"step"
|
|
1051
960
|
).forEach(
|
|
1052
|
-
({ componentId:
|
|
961
|
+
({ componentId: a, trigger: o, actions: r }) => {
|
|
1053
962
|
r.forEach((s) => {
|
|
1054
|
-
|
|
1055
|
-
`⚡ [formMachine] Executing step navigation action ${s.id} for ${i}`
|
|
1056
|
-
), t.send({
|
|
963
|
+
e.send({
|
|
1057
964
|
type: "TRIGGER_COMPONENT_ACTION",
|
|
1058
|
-
componentId:
|
|
965
|
+
componentId: a,
|
|
1059
966
|
triggerId: o.id,
|
|
1060
967
|
actionId: s.id,
|
|
1061
968
|
eventType: "navigationAttempt"
|
|
@@ -1068,40 +975,22 @@ const W = I({
|
|
|
1068
975
|
},
|
|
1069
976
|
{
|
|
1070
977
|
// PRIORITY 3: Execute step-level onStepFinish actions if this is a next navigation
|
|
1071
|
-
guard: ({ context:
|
|
1072
|
-
if (
|
|
1073
|
-
const
|
|
1074
|
-
|
|
1075
|
-
const n = t.actions || [], i = n.some(
|
|
978
|
+
guard: ({ context: t }) => {
|
|
979
|
+
if (t.pendingNavigation?.type !== "next") return !1;
|
|
980
|
+
const e = t.config.steps[t.currentStepIndex];
|
|
981
|
+
return !e || !("actions" in e) ? !1 : (e.actions || []).some(
|
|
1076
982
|
(o) => o.trigger === "onStepFinish"
|
|
1077
983
|
);
|
|
1078
|
-
return console.log(
|
|
1079
|
-
"🎯 [formMachine] Checking for step-level onStepFinish actions:",
|
|
1080
|
-
{
|
|
1081
|
-
stepIndex: e.currentStepIndex,
|
|
1082
|
-
stepId: t.id,
|
|
1083
|
-
hasFinishActions: i,
|
|
1084
|
-
stepActionsCount: n.length
|
|
1085
|
-
}
|
|
1086
|
-
), i;
|
|
1087
984
|
},
|
|
1088
985
|
target: "executingActions",
|
|
1089
986
|
actions: [
|
|
1090
|
-
|
|
987
|
+
i({
|
|
1091
988
|
executingTrigger: "onStepFinish",
|
|
1092
989
|
waitingForActions: !0,
|
|
1093
990
|
canNavigate: !1
|
|
1094
991
|
}),
|
|
1095
|
-
({
|
|
1096
|
-
|
|
1097
|
-
console.log(
|
|
1098
|
-
"🎯 [formMachine] Executing step-level onStepFinish actions:",
|
|
1099
|
-
{
|
|
1100
|
-
stepIndex: e.currentStepIndex,
|
|
1101
|
-
stepId: n.id,
|
|
1102
|
-
actionsCount: i.length
|
|
1103
|
-
}
|
|
1104
|
-
), t.send({
|
|
992
|
+
({ self: t }) => {
|
|
993
|
+
t.send({
|
|
1105
994
|
type: "EXECUTE_ACTIONS",
|
|
1106
995
|
trigger: "onStepFinish"
|
|
1107
996
|
});
|
|
@@ -1110,7 +999,7 @@ const W = I({
|
|
|
1110
999
|
},
|
|
1111
1000
|
{
|
|
1112
1001
|
// PRIORITY 4: Proceed with normal navigation evaluation
|
|
1113
|
-
guard:
|
|
1002
|
+
guard: N,
|
|
1114
1003
|
target: "executingPendingNavigation"
|
|
1115
1004
|
}
|
|
1116
1005
|
]
|
|
@@ -1120,26 +1009,26 @@ const W = I({
|
|
|
1120
1009
|
on: {
|
|
1121
1010
|
TRIGGER_COMPONENT_ACTION: {
|
|
1122
1011
|
actions: [
|
|
1123
|
-
|
|
1124
|
-
componentTriggerState: ({ context:
|
|
1125
|
-
...
|
|
1126
|
-
[`${
|
|
1127
|
-
...
|
|
1012
|
+
i({
|
|
1013
|
+
componentTriggerState: ({ context: t, event: e }) => ({
|
|
1014
|
+
...t.componentTriggerState,
|
|
1015
|
+
[`${e.componentId}-${e.triggerId}`]: {
|
|
1016
|
+
...t.componentTriggerState[`${e.componentId}-${e.triggerId}`],
|
|
1128
1017
|
isActive: !0,
|
|
1129
1018
|
lastTriggered: Date.now()
|
|
1130
1019
|
}
|
|
1131
1020
|
})
|
|
1132
1021
|
}),
|
|
1133
|
-
|
|
1134
|
-
activeComponentActions: ({ context:
|
|
1135
|
-
const n =
|
|
1022
|
+
i({
|
|
1023
|
+
activeComponentActions: ({ context: t, event: e }) => {
|
|
1024
|
+
const n = t.activeComponentActions[e.componentId] || [];
|
|
1136
1025
|
return {
|
|
1137
|
-
...
|
|
1138
|
-
[
|
|
1026
|
+
...t.activeComponentActions,
|
|
1027
|
+
[e.componentId]: [
|
|
1139
1028
|
...n,
|
|
1140
1029
|
{
|
|
1141
|
-
actionId:
|
|
1142
|
-
componentId:
|
|
1030
|
+
actionId: e.actionId,
|
|
1031
|
+
componentId: e.componentId,
|
|
1143
1032
|
status: "executing",
|
|
1144
1033
|
startTime: Date.now()
|
|
1145
1034
|
}
|
|
@@ -1147,40 +1036,40 @@ const W = I({
|
|
|
1147
1036
|
};
|
|
1148
1037
|
}
|
|
1149
1038
|
}),
|
|
1150
|
-
|
|
1039
|
+
d
|
|
1151
1040
|
]
|
|
1152
1041
|
},
|
|
1153
1042
|
TRIGGER_ACTIONS_COMPLETE: {
|
|
1154
1043
|
target: "executingPendingNavigation",
|
|
1155
|
-
actions:
|
|
1044
|
+
actions: i({
|
|
1156
1045
|
executingTrigger: null,
|
|
1157
1046
|
waitingForActions: !1,
|
|
1158
1047
|
canNavigate: !0
|
|
1159
1048
|
})
|
|
1160
1049
|
},
|
|
1161
1050
|
DISMISS_COMPONENT_ALERT: {
|
|
1162
|
-
actions:
|
|
1163
|
-
componentAlerts: ({ context:
|
|
1164
|
-
const n =
|
|
1051
|
+
actions: i({
|
|
1052
|
+
componentAlerts: ({ context: t, event: e }) => {
|
|
1053
|
+
const n = t.componentAlerts[e.componentId] || [], a = e.alertId ? n.filter((o) => o.id !== e.alertId) : [];
|
|
1165
1054
|
return {
|
|
1166
|
-
...
|
|
1167
|
-
[
|
|
1055
|
+
...t.componentAlerts,
|
|
1056
|
+
[e.componentId]: a
|
|
1168
1057
|
};
|
|
1169
1058
|
}
|
|
1170
1059
|
})
|
|
1171
1060
|
},
|
|
1172
1061
|
CLEAR_COMPONENT_ALERT: {
|
|
1173
|
-
actions:
|
|
1174
|
-
componentAlerts: ({ context:
|
|
1175
|
-
...
|
|
1176
|
-
[
|
|
1062
|
+
actions: i({
|
|
1063
|
+
componentAlerts: ({ context: t, event: e }) => ({
|
|
1064
|
+
...t.componentAlerts,
|
|
1065
|
+
[e.componentId]: []
|
|
1177
1066
|
})
|
|
1178
1067
|
})
|
|
1179
1068
|
},
|
|
1180
1069
|
SHOW_ACTION_DIALOG: {
|
|
1181
1070
|
target: "showingActionDialog",
|
|
1182
|
-
actions:
|
|
1183
|
-
activeDialog: ({ event:
|
|
1071
|
+
actions: i({
|
|
1072
|
+
activeDialog: ({ event: t }) => t.dialogConfig,
|
|
1184
1073
|
canNavigate: !1,
|
|
1185
1074
|
waitingForActions: !1
|
|
1186
1075
|
})
|
|
@@ -1191,19 +1080,19 @@ const W = I({
|
|
|
1191
1080
|
executingPendingNavigation: {
|
|
1192
1081
|
always: [
|
|
1193
1082
|
{
|
|
1194
|
-
guard:
|
|
1083
|
+
guard: m,
|
|
1195
1084
|
target: "idle",
|
|
1196
|
-
actions:
|
|
1197
|
-
currentStepIndex: ({ context:
|
|
1198
|
-
|
|
1199
|
-
|
|
1085
|
+
actions: i({
|
|
1086
|
+
currentStepIndex: ({ context: t }) => Math.min(
|
|
1087
|
+
t.currentStepIndex + 1,
|
|
1088
|
+
t.config.steps.length - 1
|
|
1200
1089
|
),
|
|
1201
|
-
currentStepId: ({ context:
|
|
1202
|
-
const
|
|
1203
|
-
|
|
1204
|
-
|
|
1090
|
+
currentStepId: ({ context: t }) => {
|
|
1091
|
+
const e = Math.min(
|
|
1092
|
+
t.currentStepIndex + 1,
|
|
1093
|
+
t.config.steps.length - 1
|
|
1205
1094
|
);
|
|
1206
|
-
return
|
|
1095
|
+
return t.config.steps[e]?.id || "";
|
|
1207
1096
|
},
|
|
1208
1097
|
pendingNavigation: null
|
|
1209
1098
|
})
|
|
@@ -1211,11 +1100,11 @@ const W = I({
|
|
|
1211
1100
|
{
|
|
1212
1101
|
guard: A,
|
|
1213
1102
|
target: "idle",
|
|
1214
|
-
actions:
|
|
1215
|
-
currentStepIndex: ({ context:
|
|
1216
|
-
currentStepId: ({ context:
|
|
1217
|
-
const
|
|
1218
|
-
return
|
|
1103
|
+
actions: i({
|
|
1104
|
+
currentStepIndex: ({ context: t }) => Math.max(t.currentStepIndex - 1, 0),
|
|
1105
|
+
currentStepId: ({ context: t }) => {
|
|
1106
|
+
const e = Math.max(t.currentStepIndex - 1, 0);
|
|
1107
|
+
return t.config.steps[e]?.id || "";
|
|
1219
1108
|
},
|
|
1220
1109
|
pendingNavigation: null
|
|
1221
1110
|
})
|
|
@@ -1223,21 +1112,21 @@ const W = I({
|
|
|
1223
1112
|
{
|
|
1224
1113
|
guard: T,
|
|
1225
1114
|
target: "idle",
|
|
1226
|
-
actions:
|
|
1227
|
-
currentStepIndex: ({ context:
|
|
1228
|
-
const
|
|
1229
|
-
(n) => n.id ===
|
|
1115
|
+
actions: i({
|
|
1116
|
+
currentStepIndex: ({ context: t }) => {
|
|
1117
|
+
const e = t.config.steps.findIndex(
|
|
1118
|
+
(n) => n.id === t.pendingNavigation?.stepId
|
|
1230
1119
|
);
|
|
1231
|
-
return
|
|
1120
|
+
return e >= 0 ? e : t.currentStepIndex;
|
|
1232
1121
|
},
|
|
1233
|
-
currentStepId: ({ context:
|
|
1122
|
+
currentStepId: ({ context: t }) => t.pendingNavigation?.stepId || t.currentStepId,
|
|
1234
1123
|
pendingNavigation: null,
|
|
1235
1124
|
canNavigate: !0
|
|
1236
1125
|
})
|
|
1237
1126
|
},
|
|
1238
1127
|
{
|
|
1239
1128
|
target: "idle",
|
|
1240
|
-
actions:
|
|
1129
|
+
actions: i({
|
|
1241
1130
|
pendingNavigation: null,
|
|
1242
1131
|
canNavigate: !0
|
|
1243
1132
|
})
|
|
@@ -1248,7 +1137,7 @@ const W = I({
|
|
|
1248
1137
|
on: {
|
|
1249
1138
|
HIDE_ACTION_DIALOG: {
|
|
1250
1139
|
target: "idle",
|
|
1251
|
-
actions:
|
|
1140
|
+
actions: i({
|
|
1252
1141
|
activeDialog: null,
|
|
1253
1142
|
canNavigate: !0,
|
|
1254
1143
|
// Allow navigation when dialog is hidden (cancelled)
|
|
@@ -1260,44 +1149,36 @@ const W = I({
|
|
|
1260
1149
|
DIALOG_VERIFIED: {
|
|
1261
1150
|
target: "executingPendingNavigation",
|
|
1262
1151
|
actions: [
|
|
1263
|
-
|
|
1152
|
+
i({
|
|
1264
1153
|
activeDialog: null,
|
|
1265
1154
|
canNavigate: !0
|
|
1266
1155
|
// Allow navigation after successful verification
|
|
1267
1156
|
}),
|
|
1268
1157
|
// Handle updateOriginalValue action from verified dialog
|
|
1269
|
-
({ context:
|
|
1270
|
-
const n =
|
|
1158
|
+
({ context: t, self: e }) => {
|
|
1159
|
+
const n = t.activeDialog;
|
|
1271
1160
|
if (!n) return;
|
|
1272
|
-
const
|
|
1273
|
-
if (
|
|
1274
|
-
const o =
|
|
1275
|
-
o &&
|
|
1276
|
-
`🔄 [formMachine] DIALOG_VERIFIED: Updating original value for ${o}`,
|
|
1277
|
-
{
|
|
1278
|
-
newValue: e.data[o],
|
|
1279
|
-
oldOriginalValue: e.componentOriginalValues[o]?.value
|
|
1280
|
-
}
|
|
1281
|
-
), t.send({
|
|
1161
|
+
const a = n;
|
|
1162
|
+
if (a.templateConfig?.onVerifiedAction?.type === "updateOriginalValue") {
|
|
1163
|
+
const o = a.componentId;
|
|
1164
|
+
o && t.data[o] !== void 0 && (e.send({
|
|
1282
1165
|
type: "SET_COMPONENT_ORIGINAL_VALUE",
|
|
1283
1166
|
componentId: o,
|
|
1284
|
-
value:
|
|
1167
|
+
value: t.data[o],
|
|
1285
1168
|
source: "user_verified"
|
|
1286
|
-
}),
|
|
1169
|
+
}), e.send({
|
|
1287
1170
|
type: "MARK_COMPONENT_AS_POPULATED",
|
|
1288
1171
|
componentId: o,
|
|
1289
|
-
value:
|
|
1290
|
-
}),
|
|
1172
|
+
value: t.data[o]
|
|
1173
|
+
}), e.send({
|
|
1291
1174
|
type: "DISMISS_COMPONENT_ALERT",
|
|
1292
1175
|
componentId: o
|
|
1293
|
-
}),
|
|
1176
|
+
}), e.send({
|
|
1294
1177
|
type: "EVALUATE_COMPONENT_TRIGGERS",
|
|
1295
1178
|
componentId: o,
|
|
1296
|
-
value:
|
|
1179
|
+
value: t.data[o],
|
|
1297
1180
|
eventType: "valueChange"
|
|
1298
|
-
})
|
|
1299
|
-
`🔄 [formMachine] Sending RESET_FIELD_TANSTACK_STATE event for ${o}`
|
|
1300
|
-
));
|
|
1181
|
+
}));
|
|
1301
1182
|
}
|
|
1302
1183
|
}
|
|
1303
1184
|
]
|
|
@@ -1305,7 +1186,7 @@ const W = I({
|
|
|
1305
1186
|
// Handle dialog cancellation
|
|
1306
1187
|
DIALOG_CANCELLED: {
|
|
1307
1188
|
target: "idle",
|
|
1308
|
-
actions:
|
|
1189
|
+
actions: i({
|
|
1309
1190
|
activeDialog: null,
|
|
1310
1191
|
canNavigate: !0,
|
|
1311
1192
|
// Reset navigation permission
|
|
@@ -1319,26 +1200,26 @@ const W = I({
|
|
|
1319
1200
|
},
|
|
1320
1201
|
NEXT: [
|
|
1321
1202
|
{
|
|
1322
|
-
guard:
|
|
1203
|
+
guard: c,
|
|
1323
1204
|
target: "idle",
|
|
1324
|
-
actions:
|
|
1325
|
-
currentStepIndex: ({ context:
|
|
1326
|
-
|
|
1327
|
-
|
|
1205
|
+
actions: i({
|
|
1206
|
+
currentStepIndex: ({ context: t }) => Math.min(
|
|
1207
|
+
t.currentStepIndex + 1,
|
|
1208
|
+
t.config.steps.length - 1
|
|
1328
1209
|
),
|
|
1329
|
-
currentStepId: ({ context:
|
|
1330
|
-
const
|
|
1331
|
-
|
|
1332
|
-
|
|
1210
|
+
currentStepId: ({ context: t }) => {
|
|
1211
|
+
const e = Math.min(
|
|
1212
|
+
t.currentStepIndex + 1,
|
|
1213
|
+
t.config.steps.length - 1
|
|
1333
1214
|
);
|
|
1334
|
-
return
|
|
1215
|
+
return t.config.steps[e]?.id || "";
|
|
1335
1216
|
},
|
|
1336
1217
|
pendingNavigation: null
|
|
1337
1218
|
})
|
|
1338
1219
|
},
|
|
1339
1220
|
{
|
|
1340
1221
|
target: "idle",
|
|
1341
|
-
actions:
|
|
1222
|
+
actions: i({
|
|
1342
1223
|
activeDialog: null,
|
|
1343
1224
|
pendingNavigation: { type: "next" }
|
|
1344
1225
|
})
|
|
@@ -1346,20 +1227,20 @@ const W = I({
|
|
|
1346
1227
|
],
|
|
1347
1228
|
PREVIOUS: [
|
|
1348
1229
|
{
|
|
1349
|
-
guard:
|
|
1230
|
+
guard: c,
|
|
1350
1231
|
target: "idle",
|
|
1351
|
-
actions:
|
|
1352
|
-
currentStepIndex: ({ context:
|
|
1353
|
-
currentStepId: ({ context:
|
|
1354
|
-
const
|
|
1355
|
-
return
|
|
1232
|
+
actions: i({
|
|
1233
|
+
currentStepIndex: ({ context: t }) => Math.max(t.currentStepIndex - 1, 0),
|
|
1234
|
+
currentStepId: ({ context: t }) => {
|
|
1235
|
+
const e = Math.max(t.currentStepIndex - 1, 0);
|
|
1236
|
+
return t.config.steps[e]?.id || "";
|
|
1356
1237
|
},
|
|
1357
1238
|
pendingNavigation: null
|
|
1358
1239
|
})
|
|
1359
1240
|
},
|
|
1360
1241
|
{
|
|
1361
1242
|
target: "idle",
|
|
1362
|
-
actions:
|
|
1243
|
+
actions: i({
|
|
1363
1244
|
activeDialog: null,
|
|
1364
1245
|
pendingNavigation: { type: "previous" }
|
|
1365
1246
|
})
|
|
@@ -1367,28 +1248,28 @@ const W = I({
|
|
|
1367
1248
|
],
|
|
1368
1249
|
GO_TO_STEP: [
|
|
1369
1250
|
{
|
|
1370
|
-
guard:
|
|
1251
|
+
guard: c,
|
|
1371
1252
|
target: "idle",
|
|
1372
|
-
actions:
|
|
1373
|
-
currentStepIndex: ({ context:
|
|
1374
|
-
if (
|
|
1375
|
-
return
|
|
1376
|
-
const n =
|
|
1377
|
-
(
|
|
1253
|
+
actions: i({
|
|
1254
|
+
currentStepIndex: ({ context: t, event: e }) => {
|
|
1255
|
+
if (e.type !== "GO_TO_STEP")
|
|
1256
|
+
return t.currentStepIndex;
|
|
1257
|
+
const n = t.config.steps.findIndex(
|
|
1258
|
+
(a) => a.id === e.stepId
|
|
1378
1259
|
);
|
|
1379
|
-
return n >= 0 ? n :
|
|
1260
|
+
return n >= 0 ? n : t.currentStepIndex;
|
|
1380
1261
|
},
|
|
1381
|
-
currentStepId: ({ context:
|
|
1262
|
+
currentStepId: ({ context: t, event: e }) => e.type !== "GO_TO_STEP" ? t.currentStepId : e.stepId,
|
|
1382
1263
|
pendingNavigation: null
|
|
1383
1264
|
})
|
|
1384
1265
|
},
|
|
1385
1266
|
{
|
|
1386
1267
|
target: "idle",
|
|
1387
|
-
actions:
|
|
1268
|
+
actions: i({
|
|
1388
1269
|
activeDialog: null,
|
|
1389
|
-
pendingNavigation: ({ event:
|
|
1270
|
+
pendingNavigation: ({ event: t }) => ({
|
|
1390
1271
|
type: "step",
|
|
1391
|
-
stepId:
|
|
1272
|
+
stepId: t.stepId
|
|
1392
1273
|
})
|
|
1393
1274
|
})
|
|
1394
1275
|
}
|
|
@@ -1401,19 +1282,19 @@ const W = I({
|
|
|
1401
1282
|
always: [
|
|
1402
1283
|
{
|
|
1403
1284
|
// Validate save fields and create execution plan
|
|
1404
|
-
guard:
|
|
1285
|
+
guard: _,
|
|
1405
1286
|
target: "executingSaveActions",
|
|
1406
|
-
actions:
|
|
1407
|
-
saveState: ({ context:
|
|
1408
|
-
const
|
|
1409
|
-
|
|
1287
|
+
actions: i({
|
|
1288
|
+
saveState: ({ context: t }) => {
|
|
1289
|
+
const e = l.createExecutionPlan(
|
|
1290
|
+
t.config,
|
|
1410
1291
|
"save",
|
|
1411
|
-
|
|
1412
|
-
|
|
1292
|
+
t.currentStepIndex,
|
|
1293
|
+
t
|
|
1413
1294
|
);
|
|
1414
1295
|
return {
|
|
1415
|
-
...
|
|
1416
|
-
executionPlan:
|
|
1296
|
+
...t.saveState,
|
|
1297
|
+
executionPlan: e
|
|
1417
1298
|
};
|
|
1418
1299
|
}
|
|
1419
1300
|
})
|
|
@@ -1422,9 +1303,9 @@ const W = I({
|
|
|
1422
1303
|
// Validation failed or no actions to execute
|
|
1423
1304
|
target: "idle",
|
|
1424
1305
|
actions: [
|
|
1425
|
-
|
|
1426
|
-
saveState: ({ context:
|
|
1427
|
-
...
|
|
1306
|
+
i({
|
|
1307
|
+
saveState: ({ context: t }) => ({
|
|
1308
|
+
...t.saveState,
|
|
1428
1309
|
saveInProgress: !1,
|
|
1429
1310
|
saveInitiator: null,
|
|
1430
1311
|
savingSection: null,
|
|
@@ -1439,15 +1320,15 @@ const W = I({
|
|
|
1439
1320
|
]
|
|
1440
1321
|
},
|
|
1441
1322
|
executingSaveActions: {
|
|
1442
|
-
entry: [
|
|
1323
|
+
entry: [f],
|
|
1443
1324
|
on: {
|
|
1444
1325
|
TRIGGER_COMPONENT_ACTION: {
|
|
1445
|
-
actions: [
|
|
1326
|
+
actions: [d]
|
|
1446
1327
|
},
|
|
1447
1328
|
SHOW_ACTION_DIALOG: {
|
|
1448
1329
|
target: "awaitingVerification",
|
|
1449
|
-
actions:
|
|
1450
|
-
activeDialog: ({ event:
|
|
1330
|
+
actions: i({
|
|
1331
|
+
activeDialog: ({ event: t }) => t.dialogConfig
|
|
1451
1332
|
})
|
|
1452
1333
|
},
|
|
1453
1334
|
SAVE_ACTIONS_COMPLETE: {
|
|
@@ -1460,20 +1341,20 @@ const W = I({
|
|
|
1460
1341
|
DIALOG_VERIFIED: {
|
|
1461
1342
|
target: "completingSave",
|
|
1462
1343
|
actions: [
|
|
1463
|
-
|
|
1344
|
+
i({
|
|
1464
1345
|
activeDialog: null,
|
|
1465
|
-
saveState: ({ context:
|
|
1466
|
-
...
|
|
1346
|
+
saveState: ({ context: t }) => ({
|
|
1347
|
+
...t.saveState,
|
|
1467
1348
|
completedVerifications: [
|
|
1468
|
-
...
|
|
1469
|
-
`${
|
|
1349
|
+
...t.saveState.completedVerifications,
|
|
1350
|
+
`${t.activeDialog?.templateMetadata?.componentId || "unknown"}`
|
|
1470
1351
|
]
|
|
1471
1352
|
})
|
|
1472
1353
|
}),
|
|
1473
|
-
({ context:
|
|
1474
|
-
|
|
1354
|
+
({ context: t, self: e }) => {
|
|
1355
|
+
t.saveState.pendingVerifications.length <= t.saveState.completedVerifications.length + 1 && e.send({
|
|
1475
1356
|
type: "SAVE_ACTIONS_COMPLETE",
|
|
1476
|
-
sectionId:
|
|
1357
|
+
sectionId: t.saveState.savingSection || "",
|
|
1477
1358
|
results: {}
|
|
1478
1359
|
});
|
|
1479
1360
|
}
|
|
@@ -1482,10 +1363,10 @@ const W = I({
|
|
|
1482
1363
|
DIALOG_CANCELLED: {
|
|
1483
1364
|
target: "idle",
|
|
1484
1365
|
actions: [
|
|
1485
|
-
|
|
1366
|
+
i({
|
|
1486
1367
|
activeDialog: null,
|
|
1487
|
-
saveState: ({ context:
|
|
1488
|
-
...
|
|
1368
|
+
saveState: ({ context: t }) => ({
|
|
1369
|
+
...t.saveState,
|
|
1489
1370
|
saveInProgress: !1,
|
|
1490
1371
|
saveInitiator: null,
|
|
1491
1372
|
savingSection: null,
|
|
@@ -1504,12 +1385,12 @@ const W = I({
|
|
|
1504
1385
|
always: [
|
|
1505
1386
|
{
|
|
1506
1387
|
// Handle section mode transitions after successful save
|
|
1507
|
-
guard:
|
|
1388
|
+
guard: v,
|
|
1508
1389
|
target: "idle",
|
|
1509
1390
|
actions: [
|
|
1510
|
-
|
|
1511
|
-
saveState: ({ context:
|
|
1512
|
-
...
|
|
1391
|
+
i({
|
|
1392
|
+
saveState: ({ context: t }) => ({
|
|
1393
|
+
...t.saveState,
|
|
1513
1394
|
saveInProgress: !1,
|
|
1514
1395
|
saveInitiator: null,
|
|
1515
1396
|
savingSection: null,
|
|
@@ -1525,9 +1406,9 @@ const W = I({
|
|
|
1525
1406
|
// Default completion
|
|
1526
1407
|
target: "idle",
|
|
1527
1408
|
actions: [
|
|
1528
|
-
|
|
1529
|
-
saveState: ({ context:
|
|
1530
|
-
...
|
|
1409
|
+
i({
|
|
1410
|
+
saveState: ({ context: t }) => ({
|
|
1411
|
+
...t.saveState,
|
|
1531
1412
|
saveInProgress: !1,
|
|
1532
1413
|
saveInitiator: null,
|
|
1533
1414
|
savingSection: null,
|
|
@@ -1537,19 +1418,19 @@ const W = I({
|
|
|
1537
1418
|
executionPlan: null
|
|
1538
1419
|
})
|
|
1539
1420
|
}),
|
|
1540
|
-
({ context:
|
|
1541
|
-
if (
|
|
1542
|
-
switch (
|
|
1421
|
+
({ context: t, self: e }) => {
|
|
1422
|
+
if (t.saveState.saveInitiator === "navigation" && t.pendingNavigation)
|
|
1423
|
+
switch (t.pendingNavigation.type) {
|
|
1543
1424
|
case "next":
|
|
1544
|
-
|
|
1425
|
+
e.send({ type: "NEXT" });
|
|
1545
1426
|
break;
|
|
1546
1427
|
case "previous":
|
|
1547
|
-
|
|
1428
|
+
e.send({ type: "PREVIOUS" });
|
|
1548
1429
|
break;
|
|
1549
1430
|
case "step":
|
|
1550
|
-
|
|
1431
|
+
e.send({
|
|
1551
1432
|
type: "GO_TO_STEP",
|
|
1552
|
-
stepId:
|
|
1433
|
+
stepId: t.pendingNavigation.stepId
|
|
1553
1434
|
});
|
|
1554
1435
|
break;
|
|
1555
1436
|
}
|
|
@@ -1561,5 +1442,5 @@ const W = I({
|
|
|
1561
1442
|
}
|
|
1562
1443
|
});
|
|
1563
1444
|
export {
|
|
1564
|
-
|
|
1445
|
+
x as formMachine
|
|
1565
1446
|
};
|