@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,174 +1,137 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
2
|
+
typeof process < "u" && process.env.NODE_ENV;
|
|
3
|
+
const c = {
|
|
3
4
|
componentTriggers: /* @__PURE__ */ new Map(),
|
|
4
5
|
componentActions: /* @__PURE__ */ new Map(),
|
|
5
6
|
stepComponents: /* @__PURE__ */ new Map(),
|
|
6
7
|
lastConfigId: ""
|
|
7
|
-
},
|
|
8
|
+
}, p = {
|
|
8
9
|
triggerResults: /* @__PURE__ */ new Map(),
|
|
9
10
|
executionPlans: /* @__PURE__ */ new Map()
|
|
10
11
|
};
|
|
11
|
-
function
|
|
12
|
-
const o = `${t.id}-${e}-${n}-${JSON.stringify(
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
12
|
+
function D(t, e, n, s) {
|
|
13
|
+
const o = `${t.id}-${e}-${n}-${JSON.stringify(s.data).slice(0, 100)}`, i = p.executionPlans.get(o);
|
|
14
|
+
if (i?.timestamp && Date.now() - i.timestamp < 1e3)
|
|
15
|
+
return i;
|
|
15
16
|
v(t);
|
|
16
|
-
const
|
|
17
|
+
const u = w(
|
|
17
18
|
t,
|
|
18
19
|
e,
|
|
19
20
|
n,
|
|
20
|
-
|
|
21
|
-
),
|
|
21
|
+
s
|
|
22
|
+
), r = {
|
|
22
23
|
context: e,
|
|
23
|
-
executions:
|
|
24
|
-
totalActions:
|
|
25
|
-
(
|
|
24
|
+
executions: u,
|
|
25
|
+
totalActions: u.reduce(
|
|
26
|
+
(l, a) => l + a.actions.length,
|
|
26
27
|
0
|
|
27
28
|
),
|
|
28
|
-
requiresUserInteraction:
|
|
29
|
-
(
|
|
30
|
-
(
|
|
29
|
+
requiresUserInteraction: u.some(
|
|
30
|
+
(l) => l.actions.some(
|
|
31
|
+
(a) => a.type === "executeVerifyEmailDialog" || a.type === "executeVerifyDialog"
|
|
31
32
|
)
|
|
32
33
|
),
|
|
33
34
|
timestamp: Date.now()
|
|
34
35
|
};
|
|
35
|
-
return
|
|
36
|
+
return p.executionPlans.set(o, r), p.executionPlans.size > 100 && V(), r;
|
|
36
37
|
}
|
|
37
38
|
function v(t) {
|
|
38
|
-
if (
|
|
39
|
-
|
|
39
|
+
if (c.lastConfigId !== t.id) {
|
|
40
|
+
c.componentTriggers.clear(), c.componentActions.clear(), c.stepComponents.clear();
|
|
40
41
|
for (let e = 0; e < t.steps.length; e++) {
|
|
41
42
|
const n = t.steps[e];
|
|
42
43
|
if (!n || !("sections" in n)) continue;
|
|
43
|
-
const
|
|
44
|
+
const s = [];
|
|
44
45
|
for (const o of n.sections || [])
|
|
45
|
-
for (const
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
for (const
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
for (const i of o.components || []) {
|
|
47
|
+
s.push(i.id);
|
|
48
|
+
const u = i.triggerActions?.triggers || i.triggers || [];
|
|
49
|
+
if (u.length > 0) {
|
|
50
|
+
c.componentTriggers.set(i.id, u);
|
|
51
|
+
const r = [];
|
|
52
|
+
for (const l of u)
|
|
53
|
+
l.actions && r.push(...l.actions);
|
|
54
|
+
r.length > 0 && c.componentActions.set(i.id, r);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
c.stepComponents.set(e, s);
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
+
c.lastConfigId = t.id;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
function
|
|
62
|
+
function V() {
|
|
62
63
|
const t = Date.now();
|
|
63
|
-
for (const [e, n] of
|
|
64
|
-
n.timestamp && t - n.timestamp > 1e3 * 10 &&
|
|
65
|
-
for (const [e, n] of
|
|
66
|
-
t - n.timestamp > 1e3 &&
|
|
64
|
+
for (const [e, n] of p.executionPlans)
|
|
65
|
+
n.timestamp && t - n.timestamp > 1e3 * 10 && p.executionPlans.delete(e);
|
|
66
|
+
for (const [e, n] of p.triggerResults)
|
|
67
|
+
t - n.timestamp > 1e3 && p.triggerResults.delete(e);
|
|
67
68
|
}
|
|
68
|
-
function
|
|
69
|
-
const o = [],
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
);
|
|
78
|
-
const a = u.stepComponents.get(n) || [];
|
|
79
|
-
for (const s of a) {
|
|
80
|
-
const c = u.componentTriggers.get(s);
|
|
81
|
-
if (!c?.length) continue;
|
|
82
|
-
const g = c.filter(
|
|
83
|
-
(l) => !l.contexts || l.contexts.length === 0 || l.contexts.includes(e)
|
|
69
|
+
function w(t, e, n, s) {
|
|
70
|
+
const o = [], i = t.steps[n];
|
|
71
|
+
if (!i || !("sections" in i)) return o;
|
|
72
|
+
const u = c.stepComponents.get(n) || [];
|
|
73
|
+
for (const r of u) {
|
|
74
|
+
const l = c.componentTriggers.get(r);
|
|
75
|
+
if (!l?.length) continue;
|
|
76
|
+
const a = l.filter(
|
|
77
|
+
(f) => !f.contexts || f.contexts.length === 0 || f.contexts.includes(e)
|
|
84
78
|
);
|
|
85
|
-
if (!
|
|
86
|
-
const
|
|
79
|
+
if (!a.length) continue;
|
|
80
|
+
const g = b(
|
|
87
81
|
t,
|
|
88
82
|
n,
|
|
89
|
-
|
|
83
|
+
r
|
|
90
84
|
);
|
|
91
|
-
if (!(e === "sectionSave" &&
|
|
92
|
-
for (const
|
|
93
|
-
const
|
|
85
|
+
if (!(e === "sectionSave" && g && !y(g)))
|
|
86
|
+
for (const f of a) {
|
|
87
|
+
const m = P(
|
|
88
|
+
r,
|
|
94
89
|
s,
|
|
95
|
-
i,
|
|
96
90
|
e
|
|
97
91
|
);
|
|
98
|
-
if (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
triggerType: l.type,
|
|
102
|
-
triggerContexts: l.contexts,
|
|
103
|
-
currentContext: e,
|
|
104
|
-
originalValue: T.originalValue,
|
|
105
|
-
currentValue: T.currentValue
|
|
106
|
-
}
|
|
107
|
-
), O(l, T)) {
|
|
108
|
-
const f = $(
|
|
109
|
-
l.actions,
|
|
92
|
+
if (_(f, m)) {
|
|
93
|
+
const C = T(
|
|
94
|
+
f.actions,
|
|
110
95
|
e
|
|
111
96
|
);
|
|
112
|
-
C &&
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
allActionsCount: l.actions.length,
|
|
116
|
-
contextActionsCount: f.length,
|
|
117
|
-
contextActions: f.map((p) => ({
|
|
118
|
-
id: p.id,
|
|
119
|
-
type: p.type,
|
|
120
|
-
contexts: p.contexts
|
|
121
|
-
}))
|
|
122
|
-
}
|
|
123
|
-
), f.length > 0 && o.push({
|
|
124
|
-
trigger: l,
|
|
125
|
-
componentId: s,
|
|
97
|
+
C.length > 0 && o.push({
|
|
98
|
+
trigger: f,
|
|
99
|
+
componentId: r,
|
|
126
100
|
context: e,
|
|
127
|
-
actions:
|
|
101
|
+
actions: C,
|
|
128
102
|
timestamp: Date.now()
|
|
129
103
|
});
|
|
130
|
-
}
|
|
131
|
-
`❌ [ComponentTriggerEngine] Trigger ${l.id} should NOT fire for ${s}`
|
|
132
|
-
);
|
|
104
|
+
}
|
|
133
105
|
}
|
|
134
106
|
}
|
|
135
|
-
return
|
|
136
|
-
`🎯 [ComponentTriggerEngine] Found ${o.length} executions for ${e}`,
|
|
137
|
-
{
|
|
138
|
-
executions: o.map((s) => ({
|
|
139
|
-
componentId: s.componentId,
|
|
140
|
-
triggerId: s.trigger.id,
|
|
141
|
-
actionsCount: s.actions.length
|
|
142
|
-
}))
|
|
143
|
-
}
|
|
144
|
-
), o;
|
|
107
|
+
return o;
|
|
145
108
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
if (!
|
|
149
|
-
for (const o of
|
|
150
|
-
if (o.components?.some((
|
|
109
|
+
function b(t, e, n) {
|
|
110
|
+
const s = t.steps[e];
|
|
111
|
+
if (!s || !("sections" in s)) return null;
|
|
112
|
+
for (const o of s.sections || [])
|
|
113
|
+
if (o.components?.some((i) => i.id === n))
|
|
151
114
|
return o;
|
|
152
115
|
return null;
|
|
153
116
|
}
|
|
154
|
-
function
|
|
155
|
-
const
|
|
156
|
-
return
|
|
117
|
+
function E(t, e, n) {
|
|
118
|
+
const s = c.componentTriggers.get(n);
|
|
119
|
+
return s ? s.filter(
|
|
157
120
|
(o) => !o.contexts || o.contexts.length === 0 || o.contexts.includes(e)
|
|
158
121
|
) : [];
|
|
159
122
|
}
|
|
160
|
-
function
|
|
123
|
+
function T(t, e) {
|
|
161
124
|
return t.filter((n) => {
|
|
162
125
|
if (n.contexts && n.contexts.length > 0) {
|
|
163
|
-
const
|
|
126
|
+
const s = F(e);
|
|
164
127
|
return n.contexts.some(
|
|
165
|
-
(o) => o === e || o ===
|
|
128
|
+
(o) => o === e || o === s || I(o, e)
|
|
166
129
|
);
|
|
167
130
|
}
|
|
168
131
|
return !0;
|
|
169
132
|
});
|
|
170
133
|
}
|
|
171
|
-
function
|
|
134
|
+
function F(t) {
|
|
172
135
|
switch (t) {
|
|
173
136
|
case "fieldChange":
|
|
174
137
|
return "fieldChange";
|
|
@@ -183,64 +146,37 @@ function P(t) {
|
|
|
183
146
|
return t;
|
|
184
147
|
}
|
|
185
148
|
}
|
|
186
|
-
function
|
|
149
|
+
function I(t, e) {
|
|
187
150
|
return e === "save" ? t === "sectionSave" || t === "stepSave" : !1;
|
|
188
151
|
}
|
|
189
|
-
function
|
|
152
|
+
function y(t) {
|
|
190
153
|
const e = t;
|
|
191
154
|
return e.triggerContexts?.supportsSectionSave || e.mode === "edit" || e.mode === "editable";
|
|
192
155
|
}
|
|
193
|
-
function
|
|
194
|
-
let
|
|
195
|
-
const o = e.componentOriginalValues[t],
|
|
196
|
-
return
|
|
197
|
-
`🔧 [ComponentTriggerEngine] Field ${t} was API-populated but user hasn't touched it. Using original value as current value.`,
|
|
198
|
-
{
|
|
199
|
-
originalValue: r,
|
|
200
|
-
triggerContext: n,
|
|
201
|
-
isPopulated: o.isPopulated
|
|
202
|
-
}
|
|
203
|
-
), i = r), console.log(
|
|
204
|
-
`🔥 [ComponentTriggerEngine] createEvaluationContext for ${t}:`,
|
|
205
|
-
{
|
|
206
|
-
componentId: t,
|
|
207
|
-
triggerContext: n,
|
|
208
|
-
currentValue: i,
|
|
209
|
-
currentValueType: typeof i,
|
|
210
|
-
originalValue: r,
|
|
211
|
-
originalValueType: typeof r,
|
|
212
|
-
originalValueInfo: o,
|
|
213
|
-
isDirty: o?.isPopulated && o.value !== i
|
|
214
|
-
}
|
|
215
|
-
), {
|
|
156
|
+
function P(t, e, n) {
|
|
157
|
+
let s = e.data[t];
|
|
158
|
+
const o = e.componentOriginalValues[t], i = o?.value;
|
|
159
|
+
return s === void 0 && o?.isPopulated && i !== void 0 && (s = i), {
|
|
216
160
|
componentId: t,
|
|
217
|
-
currentValue:
|
|
218
|
-
originalValue:
|
|
161
|
+
currentValue: s,
|
|
162
|
+
originalValue: i,
|
|
219
163
|
eventType: n === "stepSave" || n === "sectionSave" ? "navigationAttempt" : "valueChange",
|
|
220
164
|
triggerContext: n,
|
|
221
165
|
formData: e.data,
|
|
222
166
|
formContext: e
|
|
223
167
|
};
|
|
224
168
|
}
|
|
225
|
-
function
|
|
226
|
-
const n = `${t.id}-${e.componentId}-${e.currentValue}-${e.originalValue}-${e.triggerContext}`,
|
|
227
|
-
if (
|
|
228
|
-
return
|
|
169
|
+
function _(t, e) {
|
|
170
|
+
const n = `${t.id}-${e.componentId}-${e.currentValue}-${e.originalValue}-${e.triggerContext}`, s = p.triggerResults.get(n);
|
|
171
|
+
if (s && Date.now() - s.timestamp < 1e3)
|
|
172
|
+
return s.result;
|
|
229
173
|
const o = h(t, e);
|
|
230
|
-
return
|
|
174
|
+
return p.triggerResults.set(n, {
|
|
231
175
|
result: o,
|
|
232
176
|
timestamp: Date.now()
|
|
233
|
-
}),
|
|
234
|
-
`🎆 [ComponentTriggerEngine] shouldTriggerFire result for ${e.componentId}:`,
|
|
235
|
-
{
|
|
236
|
-
triggerId: t.id,
|
|
237
|
-
triggerType: t.type,
|
|
238
|
-
result: o,
|
|
239
|
-
triggerContext: e.triggerContext
|
|
240
|
-
}
|
|
241
|
-
), o;
|
|
177
|
+
}), o;
|
|
242
178
|
}
|
|
243
|
-
function
|
|
179
|
+
function $(t, e) {
|
|
244
180
|
switch (t) {
|
|
245
181
|
case "valueChange":
|
|
246
182
|
case "focus":
|
|
@@ -257,168 +193,44 @@ function k(t, e) {
|
|
|
257
193
|
return "fieldChange";
|
|
258
194
|
}
|
|
259
195
|
}
|
|
260
|
-
function
|
|
261
|
-
return
|
|
262
|
-
trigger:
|
|
263
|
-
shouldFire: h(
|
|
196
|
+
function R(t, e) {
|
|
197
|
+
return d(t, e.componentId).map((s) => ({
|
|
198
|
+
trigger: s,
|
|
199
|
+
shouldFire: h(s, e)
|
|
264
200
|
}));
|
|
265
201
|
}
|
|
266
|
-
function
|
|
267
|
-
return v(t),
|
|
202
|
+
function d(t, e) {
|
|
203
|
+
return v(t), c.componentTriggers.get(e) || [];
|
|
268
204
|
}
|
|
269
|
-
function
|
|
270
|
-
return v(t),
|
|
205
|
+
function S(t, e) {
|
|
206
|
+
return v(t), c.componentActions.get(e) || [];
|
|
271
207
|
}
|
|
272
208
|
function h(t, e) {
|
|
273
209
|
let n = !1;
|
|
274
210
|
switch (t.type) {
|
|
275
211
|
case "isDirty": {
|
|
276
212
|
const o = e.formContext.componentOriginalValues[e.componentId];
|
|
277
|
-
|
|
278
|
-
`🔥🔥🔥 [ComponentTriggerEngine] isDirty trigger evaluation STARTED for ${e.componentId}:`,
|
|
279
|
-
{
|
|
280
|
-
originalValueInfo: o,
|
|
281
|
-
currentValue: e.currentValue,
|
|
282
|
-
hasOriginalValueInfo: !!o,
|
|
283
|
-
isPopulated: o?.isPopulated,
|
|
284
|
-
triggerContext: e.triggerContext,
|
|
285
|
-
eventType: e.eventType,
|
|
286
|
-
allOriginalValues: Object.keys(
|
|
287
|
-
e.formContext.componentOriginalValues
|
|
288
|
-
).map((r) => ({
|
|
289
|
-
key: r,
|
|
290
|
-
value: e.formContext.componentOriginalValues[r]?.value,
|
|
291
|
-
isPopulated: e.formContext.componentOriginalValues[r]?.isPopulated,
|
|
292
|
-
timestamp: e.formContext.componentOriginalValues[r]?.timestamp
|
|
293
|
-
}))
|
|
294
|
-
}
|
|
295
|
-
), !o || !o.isPopulated)
|
|
296
|
-
n = !1, console.log(
|
|
297
|
-
`🎯 [ComponentTriggerEngine] isDirty evaluation for ${e.componentId}: Not populated from API, cannot be dirty`,
|
|
298
|
-
{
|
|
299
|
-
originalValueInfo: o,
|
|
300
|
-
currentValue: e.currentValue,
|
|
301
|
-
isPopulated: o?.isPopulated || !1,
|
|
302
|
-
baseTriggerMet: !1
|
|
303
|
-
}
|
|
304
|
-
);
|
|
305
|
-
else {
|
|
306
|
-
const r = o.value !== e.currentValue;
|
|
307
|
-
n = r, console.log(
|
|
308
|
-
`🎯 [ComponentTriggerEngine] isDirty evaluation for ${e.componentId}:`,
|
|
309
|
-
{
|
|
310
|
-
originalValue: o.value,
|
|
311
|
-
originalValueType: typeof o.value,
|
|
312
|
-
currentValue: e.currentValue,
|
|
313
|
-
currentValueType: typeof e.currentValue,
|
|
314
|
-
strictComparison: o.value === e.currentValue,
|
|
315
|
-
isDifferent: r,
|
|
316
|
-
baseTriggerMet: n,
|
|
317
|
-
triggerContext: e.triggerContext,
|
|
318
|
-
eventType: e.eventType,
|
|
319
|
-
isPopulated: !0,
|
|
320
|
-
timestamp: o.timestamp,
|
|
321
|
-
assignedBaseTriggerMet: n
|
|
322
|
-
}
|
|
323
|
-
);
|
|
324
|
-
}
|
|
213
|
+
!o || !o.isPopulated ? n = !1 : n = o.value !== e.currentValue;
|
|
325
214
|
break;
|
|
326
215
|
}
|
|
327
216
|
case "onValueChange":
|
|
328
|
-
n = e.eventType === "valueChange"
|
|
329
|
-
`🔥🔥🔥 [ComponentTriggerEngine] onValueChange case for ${e.componentId}:`,
|
|
330
|
-
{
|
|
331
|
-
eventType: e.eventType,
|
|
332
|
-
baseTriggerMet: n
|
|
333
|
-
}
|
|
334
|
-
);
|
|
217
|
+
n = e.eventType === "valueChange";
|
|
335
218
|
break;
|
|
336
219
|
case "onFocus":
|
|
337
|
-
n = e.eventType === "focus"
|
|
338
|
-
`🔥🔥🔥 [ComponentTriggerEngine] onFocus case for ${e.componentId}:`,
|
|
339
|
-
{
|
|
340
|
-
eventType: e.eventType,
|
|
341
|
-
baseTriggerMet: n
|
|
342
|
-
}
|
|
343
|
-
);
|
|
220
|
+
n = e.eventType === "focus";
|
|
344
221
|
break;
|
|
345
222
|
case "onBlur":
|
|
346
|
-
n = e.eventType === "blur"
|
|
347
|
-
`🔥🔥🔥 [ComponentTriggerEngine] onBlur case for ${e.componentId}:`,
|
|
348
|
-
{
|
|
349
|
-
eventType: e.eventType,
|
|
350
|
-
baseTriggerMet: n
|
|
351
|
-
}
|
|
352
|
-
);
|
|
223
|
+
n = e.eventType === "blur";
|
|
353
224
|
break;
|
|
354
225
|
default:
|
|
355
|
-
n = !1
|
|
356
|
-
`🔥🔥🔥 [ComponentTriggerEngine] DEFAULT case for ${e.componentId}:`,
|
|
357
|
-
{
|
|
358
|
-
triggerType: t.type,
|
|
359
|
-
baseTriggerMet: n,
|
|
360
|
-
note: "This should not happen for known trigger types"
|
|
361
|
-
}
|
|
362
|
-
);
|
|
226
|
+
n = !1;
|
|
363
227
|
}
|
|
364
|
-
|
|
365
|
-
`🔥🔥🔥 [ComponentTriggerEngine] Base trigger evaluation complete for ${e.componentId}:`,
|
|
366
|
-
{
|
|
367
|
-
triggerType: t.type,
|
|
368
|
-
triggerContext: e.triggerContext,
|
|
369
|
-
baseTriggerMet: n,
|
|
370
|
-
baseTriggerMetType: typeof n,
|
|
371
|
-
baseTriggerMetValue: n,
|
|
372
|
-
triggerId: t.id,
|
|
373
|
-
aboutToCheckBaseTrigger: !0,
|
|
374
|
-
booleanCheck: !n,
|
|
375
|
-
willReturn: !n
|
|
376
|
-
}
|
|
377
|
-
), !n)
|
|
378
|
-
return console.log(
|
|
379
|
-
`❌ [ComponentTriggerEngine] Base trigger not met for ${e.componentId}, returning false:`,
|
|
380
|
-
{
|
|
381
|
-
triggerType: t.type,
|
|
382
|
-
triggerContext: e.triggerContext,
|
|
383
|
-
baseTriggerMet: n,
|
|
384
|
-
baseTriggerMetType: typeof n,
|
|
385
|
-
baseTriggerMetValue: n,
|
|
386
|
-
triggerId: t.id
|
|
387
|
-
}
|
|
388
|
-
), !1;
|
|
389
|
-
if (console.log(
|
|
390
|
-
`🔥🔥🔥 [ComponentTriggerEngine] Base trigger WAS met for ${e.componentId}, continuing:`,
|
|
391
|
-
{
|
|
392
|
-
triggerType: t.type,
|
|
393
|
-
triggerContext: e.triggerContext,
|
|
394
|
-
baseTriggerMet: n,
|
|
395
|
-
baseTriggerMetType: typeof n,
|
|
396
|
-
baseTriggerMetValue: n,
|
|
397
|
-
triggerId: t.id
|
|
398
|
-
}
|
|
399
|
-
), !t.conditions || t.conditions.length === 0)
|
|
400
|
-
return console.log(
|
|
401
|
-
`✅ [ComponentTriggerEngine] Trigger fires (no conditions) for ${e.componentId}:`,
|
|
402
|
-
{
|
|
403
|
-
triggerType: t.type,
|
|
404
|
-
triggerContext: e.triggerContext
|
|
405
|
-
}
|
|
406
|
-
), !0;
|
|
407
|
-
const i = B(t.conditions, e);
|
|
408
|
-
return console.log(
|
|
409
|
-
`🎯 [ComponentTriggerEngine] Conditions evaluation for ${e.componentId}:`,
|
|
410
|
-
{
|
|
411
|
-
triggerType: t.type,
|
|
412
|
-
triggerContext: e.triggerContext,
|
|
413
|
-
conditionsCount: t.conditions.length,
|
|
414
|
-
conditionsResult: i
|
|
415
|
-
}
|
|
416
|
-
), i;
|
|
228
|
+
return n ? !t.conditions || t.conditions.length === 0 ? !0 : k(t.conditions, e) : !1;
|
|
417
229
|
}
|
|
418
|
-
function
|
|
419
|
-
return t.every((n) =>
|
|
230
|
+
function k(t, e) {
|
|
231
|
+
return t.every((n) => M(n, e));
|
|
420
232
|
}
|
|
421
|
-
function
|
|
233
|
+
function M(t, e) {
|
|
422
234
|
let n;
|
|
423
235
|
switch (t.field ? n = e.formData[t.field] : n = e.currentValue, t.operator) {
|
|
424
236
|
case "equals":
|
|
@@ -439,160 +251,83 @@ function R(t, e) {
|
|
|
439
251
|
return !1;
|
|
440
252
|
}
|
|
441
253
|
}
|
|
442
|
-
function
|
|
443
|
-
return
|
|
254
|
+
function O(t, e, n) {
|
|
255
|
+
return d(t, e);
|
|
444
256
|
}
|
|
445
|
-
function
|
|
446
|
-
return
|
|
257
|
+
function H(t, e) {
|
|
258
|
+
return d(t, e).length > 0;
|
|
447
259
|
}
|
|
448
|
-
function
|
|
449
|
-
return
|
|
260
|
+
function L(t, e) {
|
|
261
|
+
return S(t, e).length > 0;
|
|
450
262
|
}
|
|
451
|
-
function A(t, e, n,
|
|
452
|
-
const o = [],
|
|
453
|
-
if (!
|
|
263
|
+
function A(t, e, n, s = "stepSave") {
|
|
264
|
+
const o = [], i = t.steps[e];
|
|
265
|
+
if (!i || !("sections" in i))
|
|
454
266
|
return o;
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
t,
|
|
485
|
-
i,
|
|
486
|
-
s.id
|
|
487
|
-
);
|
|
488
|
-
console.log(
|
|
489
|
-
`🔍 [ComponentTriggerEngine] Component ${s.id} has ${c.length} triggers for ${i}`,
|
|
490
|
-
{
|
|
491
|
-
componentId: s.id,
|
|
492
|
-
triggersCount: c.length,
|
|
493
|
-
triggerContext: i
|
|
494
|
-
}
|
|
495
|
-
);
|
|
496
|
-
for (const g of c)
|
|
497
|
-
if (g.type === "isDirty" && g.actions) {
|
|
498
|
-
const d = n.componentOriginalValues[s.id]?.value, l = n.data[s.id], T = {
|
|
499
|
-
componentId: s.id,
|
|
500
|
-
currentValue: l,
|
|
501
|
-
eventType: "navigationAttempt",
|
|
502
|
-
triggerContext: i,
|
|
503
|
-
formData: n.data,
|
|
504
|
-
formContext: n
|
|
505
|
-
};
|
|
506
|
-
if (console.log(
|
|
507
|
-
`🎯 [ComponentTriggerEngine] Evaluating isDirty trigger for ${s.id}`,
|
|
508
|
-
{
|
|
509
|
-
originalValue: d,
|
|
510
|
-
currentValue: l,
|
|
511
|
-
isDirty: d !== void 0 && d !== l,
|
|
512
|
-
triggerContexts: g.contexts,
|
|
513
|
-
requiredContext: i
|
|
267
|
+
for (const u of i.sections || [])
|
|
268
|
+
if (!(s === "sectionSave" && !y(u)))
|
|
269
|
+
for (const r of u.components || []) {
|
|
270
|
+
const l = E(
|
|
271
|
+
t,
|
|
272
|
+
s,
|
|
273
|
+
r.id
|
|
274
|
+
);
|
|
275
|
+
for (const a of l)
|
|
276
|
+
if (a.type === "isDirty" && a.actions) {
|
|
277
|
+
n.componentOriginalValues[r.id]?.value;
|
|
278
|
+
const g = n.data[r.id], f = {
|
|
279
|
+
componentId: r.id,
|
|
280
|
+
currentValue: g,
|
|
281
|
+
eventType: "navigationAttempt",
|
|
282
|
+
formData: n.data,
|
|
283
|
+
formContext: n
|
|
284
|
+
};
|
|
285
|
+
if (h(a, f)) {
|
|
286
|
+
const m = T(
|
|
287
|
+
a.actions,
|
|
288
|
+
s
|
|
289
|
+
);
|
|
290
|
+
m.length > 0 && o.push({
|
|
291
|
+
componentId: r.id,
|
|
292
|
+
trigger: a,
|
|
293
|
+
actions: m
|
|
294
|
+
// Use filtered actions
|
|
295
|
+
});
|
|
514
296
|
}
|
|
515
|
-
), h(g, T)) {
|
|
516
|
-
const f = $(
|
|
517
|
-
g.actions,
|
|
518
|
-
i
|
|
519
|
-
);
|
|
520
|
-
f.length > 0 ? (console.log(
|
|
521
|
-
`🎯 [ComponentTriggerEngine] Found dirty component with ${i} triggers: ${s.id}`,
|
|
522
|
-
{
|
|
523
|
-
originalValue: d,
|
|
524
|
-
currentValue: l,
|
|
525
|
-
trigger: g.type,
|
|
526
|
-
triggerContext: i,
|
|
527
|
-
triggerContexts: g.contexts,
|
|
528
|
-
allActionsCount: g.actions.length,
|
|
529
|
-
contextActionsCount: f.length,
|
|
530
|
-
contextActions: f.map((p) => ({
|
|
531
|
-
id: p.id,
|
|
532
|
-
type: p.type,
|
|
533
|
-
contexts: p.contexts
|
|
534
|
-
}))
|
|
535
|
-
}
|
|
536
|
-
), o.push({
|
|
537
|
-
componentId: s.id,
|
|
538
|
-
trigger: g,
|
|
539
|
-
actions: f
|
|
540
|
-
// Use filtered actions
|
|
541
|
-
})) : console.log(
|
|
542
|
-
`🔍 [ComponentTriggerEngine] Component ${s.id} trigger has no actions for context ${i}`,
|
|
543
|
-
{
|
|
544
|
-
allActions: g.actions.map((p) => ({
|
|
545
|
-
id: p.id,
|
|
546
|
-
type: p.type,
|
|
547
|
-
contexts: p.contexts
|
|
548
|
-
})),
|
|
549
|
-
requiredContext: i
|
|
550
|
-
}
|
|
551
|
-
);
|
|
552
297
|
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
}
|
|
556
|
-
return console.log(
|
|
557
|
-
`🎯 [ComponentTriggerEngine] Found ${o.length} dirty components with ${i} triggers`,
|
|
558
|
-
{
|
|
559
|
-
components: o.map((a) => ({
|
|
560
|
-
id: a.componentId,
|
|
561
|
-
actionsCount: a.actions.length
|
|
562
|
-
}))
|
|
563
|
-
}
|
|
564
|
-
), o;
|
|
298
|
+
}
|
|
299
|
+
return o;
|
|
565
300
|
}
|
|
566
|
-
function
|
|
301
|
+
function N(t, e, n, s = "step") {
|
|
567
302
|
return A(
|
|
568
303
|
t,
|
|
569
304
|
e,
|
|
570
305
|
n,
|
|
571
|
-
|
|
306
|
+
s === "section" ? "sectionSave" : "stepSave"
|
|
572
307
|
);
|
|
573
308
|
}
|
|
574
|
-
const
|
|
575
|
-
createExecutionPlan:
|
|
576
|
-
determineTriggerContext:
|
|
577
|
-
evaluateComponentTriggers:
|
|
578
|
-
findComponentTriggers:
|
|
579
|
-
findComponentActions:
|
|
580
|
-
getTriggersForAction:
|
|
581
|
-
hasComponentTriggers:
|
|
582
|
-
hasComponentActions:
|
|
309
|
+
const q = {
|
|
310
|
+
createExecutionPlan: D,
|
|
311
|
+
determineTriggerContext: $,
|
|
312
|
+
evaluateComponentTriggers: R,
|
|
313
|
+
findComponentTriggers: d,
|
|
314
|
+
findComponentActions: S,
|
|
315
|
+
getTriggersForAction: O,
|
|
316
|
+
hasComponentTriggers: H,
|
|
317
|
+
hasComponentActions: L,
|
|
583
318
|
findDirtyComponentsWithTriggers: A,
|
|
584
|
-
findDirtyComponentsForNavigation:
|
|
319
|
+
findDirtyComponentsForNavigation: N
|
|
585
320
|
};
|
|
586
321
|
export {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
322
|
+
q as ComponentTriggerEngine,
|
|
323
|
+
D as createExecutionPlan,
|
|
324
|
+
$ as determineTriggerContext,
|
|
325
|
+
R as evaluateComponentTriggers,
|
|
326
|
+
S as findComponentActions,
|
|
327
|
+
d as findComponentTriggers,
|
|
328
|
+
N as findDirtyComponentsForNavigation,
|
|
594
329
|
A as findDirtyComponentsWithTriggers,
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
330
|
+
O as getTriggersForAction,
|
|
331
|
+
L as hasComponentActions,
|
|
332
|
+
H as hasComponentTriggers
|
|
598
333
|
};
|