@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.
Files changed (54) hide show
  1. package/features/form-runtime/components/FormFooter.d.ts +5 -0
  2. package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
  3. package/features/form-runtime/index.d.ts +0 -1
  4. package/features/state-management/machines/formMachine.d.ts +3 -0
  5. package/features/state-management/machines/types.d.ts +4 -0
  6. package/features/state-management/machines/useFormMachine.d.ts +24 -6
  7. package/package.json +31 -15
  8. package/styles.css +1 -1
  9. package/ui/src/lib/types/guards.js +1 -5
  10. package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
  11. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
  12. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
  13. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
  14. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +48 -95
  15. package/wizard/src/features/form-runtime/FormWizard/FormWizard.module.css.js +4 -12
  16. package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
  17. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +150 -194
  18. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +92 -108
  19. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
  20. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +44 -63
  21. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +26 -40
  22. package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
  23. package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
  24. package/wizard/src/features/form-runtime/utils/logger.js +12 -12
  25. package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
  26. package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
  27. package/wizard/src/features/state-management/machines/formMachine.js +558 -677
  28. package/wizard/src/features/state-management/machines/useFormMachine.js +173 -191
  29. package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
  30. package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
  31. package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
  32. package/wizard/src/features/validation-system/validation/ValidationExecutor.js +47 -87
  33. package/core/src/types/guards.js +0 -7
  34. package/features/form-runtime/config/configResolver.d.ts +0 -14
  35. package/features/form-runtime/config/index.d.ts +0 -9
  36. package/features/form-runtime/config/templateConfig.d.ts +0 -148
  37. package/features/form-runtime/config/templateLoader.d.ts +0 -25
  38. package/features/form-runtime/config/templateUtils.d.ts +0 -12
  39. package/features/form-runtime/utils/formSaver.d.ts +0 -22
  40. package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
  41. package/features/state-management/machines/__tests__/setup.d.ts +0 -0
  42. package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
  43. package/features/state-management/machines/actions/validationActions.d.ts +0 -68
  44. package/features/state-management/machines/lazyLoading.d.ts +0 -34
  45. package/features/state-management/machines/validation/index.d.ts +0 -5
  46. package/features/state-management/machines/validation/validateField.d.ts +0 -2
  47. package/features/state-management/machines/validation/validateForm.d.ts +0 -2
  48. package/features/state-management/machines/validation/validateSection.d.ts +0 -2
  49. package/features/state-management/machines/validation/validateStep.d.ts +0 -2
  50. package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
  51. package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
  52. package/ui/src/lib/utils/templateUtils.js +0 -20
  53. package/wizard/src/features/form-runtime/config/configResolver.js +0 -34
  54. package/wizard/src/features/form-runtime/config/templateLoader.js +0 -235
@@ -1,174 +1,137 @@
1
1
  "use client";
2
- const C = typeof process < "u" && process.env.NODE_ENV === "development", u = {
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
- }, m = {
8
+ }, p = {
8
9
  triggerResults: /* @__PURE__ */ new Map(),
9
10
  executionPlans: /* @__PURE__ */ new Map()
10
11
  };
11
- function I(t, e, n, i) {
12
- const o = `${t.id}-${e}-${n}-${JSON.stringify(i.data).slice(0, 100)}`, r = m.executionPlans.get(o);
13
- if (r?.timestamp && Date.now() - r.timestamp < 1e3)
14
- return r;
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 a = b(
17
+ const u = w(
17
18
  t,
18
19
  e,
19
20
  n,
20
- i
21
- ), s = {
21
+ s
22
+ ), r = {
22
23
  context: e,
23
- executions: a,
24
- totalActions: a.reduce(
25
- (c, g) => c + g.actions.length,
24
+ executions: u,
25
+ totalActions: u.reduce(
26
+ (l, a) => l + a.actions.length,
26
27
  0
27
28
  ),
28
- requiresUserInteraction: a.some(
29
- (c) => c.actions.some(
30
- (g) => g.type === "executeVerifyEmailDialog" || g.type === "executeVerifyDialog"
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 m.executionPlans.set(o, s), m.executionPlans.size > 100 && S(), s;
36
+ return p.executionPlans.set(o, r), p.executionPlans.size > 100 && V(), r;
36
37
  }
37
38
  function v(t) {
38
- if (u.lastConfigId !== t.id) {
39
- u.componentTriggers.clear(), u.componentActions.clear(), u.stepComponents.clear();
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 i = [];
44
+ const s = [];
44
45
  for (const o of n.sections || [])
45
- for (const r of o.components || []) {
46
- i.push(r.id);
47
- const a = r.triggerActions?.triggers || r.triggers || [];
48
- if (a.length > 0) {
49
- u.componentTriggers.set(r.id, a);
50
- const s = [];
51
- for (const c of a)
52
- c.actions && s.push(...c.actions);
53
- s.length > 0 && u.componentActions.set(r.id, s);
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
- u.stepComponents.set(e, i);
57
+ c.stepComponents.set(e, s);
57
58
  }
58
- u.lastConfigId = t.id;
59
+ c.lastConfigId = t.id;
59
60
  }
60
61
  }
61
- function S() {
62
+ function V() {
62
63
  const t = Date.now();
63
- for (const [e, n] of m.executionPlans)
64
- n.timestamp && t - n.timestamp > 1e3 * 10 && m.executionPlans.delete(e);
65
- for (const [e, n] of m.triggerResults)
66
- t - n.timestamp > 1e3 && m.triggerResults.delete(e);
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 b(t, e, n, i) {
69
- const o = [], r = t.steps[n];
70
- if (!r || !("sections" in r)) return o;
71
- C && console.log(
72
- `🔍 [ComponentTriggerEngine] findAllTriggersForContext for ${e}:`,
73
- {
74
- stepIndex: n,
75
- sectionsCount: r.sections?.length || 0
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 (!g.length) continue;
86
- const d = D(
79
+ if (!a.length) continue;
80
+ const g = b(
87
81
  t,
88
82
  n,
89
- s
83
+ r
90
84
  );
91
- if (!(e === "sectionSave" && d && !E(d)))
92
- for (const l of g) {
93
- const T = M(
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 (C && console.log(
99
- `🎯 [ComponentTriggerEngine] Evaluating trigger ${l.id} for ${s}:`,
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 && console.log(
113
- `✅ [ComponentTriggerEngine] Trigger ${l.id} should fire for ${s}:`,
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: f,
101
+ actions: C,
128
102
  timestamp: Date.now()
129
103
  });
130
- } else C && console.log(
131
- `❌ [ComponentTriggerEngine] Trigger ${l.id} should NOT fire for ${s}`
132
- );
104
+ }
133
105
  }
134
106
  }
135
- return C && console.log(
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 D(t, e, n) {
147
- const i = t.steps[e];
148
- if (!i || !("sections" in i)) return null;
149
- for (const o of i.sections || [])
150
- if (o.components?.some((r) => r.id === n))
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 w(t, e, n) {
155
- const i = u.componentTriggers.get(n);
156
- return i ? i.filter(
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 $(t, e) {
123
+ function T(t, e) {
161
124
  return t.filter((n) => {
162
125
  if (n.contexts && n.contexts.length > 0) {
163
- const i = P(e);
126
+ const s = F(e);
164
127
  return n.contexts.some(
165
- (o) => o === e || o === i || F(o, e)
128
+ (o) => o === e || o === s || I(o, e)
166
129
  );
167
130
  }
168
131
  return !0;
169
132
  });
170
133
  }
171
- function P(t) {
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 F(t, e) {
149
+ function I(t, e) {
187
150
  return e === "save" ? t === "sectionSave" || t === "stepSave" : !1;
188
151
  }
189
- function E(t) {
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 M(t, e, n) {
194
- let i = e.data[t];
195
- const o = e.componentOriginalValues[t], r = o?.value;
196
- return i === void 0 && o?.isPopulated && r !== void 0 && (console.log(
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: i,
218
- originalValue: r,
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 O(t, e) {
226
- const n = `${t.id}-${e.componentId}-${e.currentValue}-${e.originalValue}-${e.triggerContext}`, i = m.triggerResults.get(n);
227
- if (i && Date.now() - i.timestamp < 1e3)
228
- return i.result;
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 m.triggerResults.set(n, {
174
+ return p.triggerResults.set(n, {
231
175
  result: o,
232
176
  timestamp: Date.now()
233
- }), C && console.log(
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 k(t, e) {
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 _(t, e) {
261
- return y(t, e.componentId).map((i) => ({
262
- trigger: i,
263
- shouldFire: h(i, e)
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 y(t, e) {
267
- return v(t), u.componentTriggers.get(e) || [];
202
+ function d(t, e) {
203
+ return v(t), c.componentTriggers.get(e) || [];
268
204
  }
269
- function V(t, e) {
270
- return v(t), u.componentActions.get(e) || [];
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
- if (console.log(
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", console.log(
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", console.log(
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", console.log(
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, console.log(
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
- if (console.log(
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 B(t, e) {
419
- return t.every((n) => R(n, e));
230
+ function k(t, e) {
231
+ return t.every((n) => M(n, e));
420
232
  }
421
- function R(t, e) {
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 N(t, e, n) {
443
- return y(t, e);
254
+ function O(t, e, n) {
255
+ return d(t, e);
444
256
  }
445
- function L(t, e) {
446
- return y(t, e).length > 0;
257
+ function H(t, e) {
258
+ return d(t, e).length > 0;
447
259
  }
448
- function q(t, e) {
449
- return V(t, e).length > 0;
260
+ function L(t, e) {
261
+ return S(t, e).length > 0;
450
262
  }
451
- function A(t, e, n, i = "stepSave") {
452
- const o = [], r = t.steps[e];
453
- if (!r || !("sections" in r))
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
- console.log(
456
- `🔍 [ComponentTriggerEngine] Checking step ${e} for dirty components with ${i} context`,
457
- {
458
- stepId: r.id,
459
- sectionsCount: r.sections?.length || 0,
460
- triggerContext: i
461
- }
462
- );
463
- for (const a of r.sections || []) {
464
- if (i === "sectionSave" && !E(a)) {
465
- console.log(
466
- `🔍 [ComponentTriggerEngine] Skipping section ${a.id} - doesn't support sectionSave`,
467
- {
468
- sectionMode: a.mode,
469
- triggerContexts: a.triggerContexts
470
- }
471
- );
472
- continue;
473
- }
474
- console.log(
475
- `🔍 [ComponentTriggerEngine] Checking section ${a.id} with mode: ${a.mode}`,
476
- {
477
- componentsCount: a.components?.length || 0,
478
- sectionMode: a.mode,
479
- triggerContext: i
480
- }
481
- );
482
- for (const s of a.components || []) {
483
- const c = w(
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 H(t, e, n, i = "step") {
301
+ function N(t, e, n, s = "step") {
567
302
  return A(
568
303
  t,
569
304
  e,
570
305
  n,
571
- i === "section" ? "sectionSave" : "stepSave"
306
+ s === "section" ? "sectionSave" : "stepSave"
572
307
  );
573
308
  }
574
- const U = {
575
- createExecutionPlan: I,
576
- determineTriggerContext: k,
577
- evaluateComponentTriggers: _,
578
- findComponentTriggers: y,
579
- findComponentActions: V,
580
- getTriggersForAction: N,
581
- hasComponentTriggers: L,
582
- hasComponentActions: q,
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: H
319
+ findDirtyComponentsForNavigation: N
585
320
  };
586
321
  export {
587
- U as ComponentTriggerEngine,
588
- I as createExecutionPlan,
589
- k as determineTriggerContext,
590
- _ as evaluateComponentTriggers,
591
- V as findComponentActions,
592
- y as findComponentTriggers,
593
- H as findDirtyComponentsForNavigation,
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
- N as getTriggersForAction,
596
- q as hasComponentActions,
597
- L as hasComponentTriggers
330
+ O as getTriggersForAction,
331
+ L as hasComponentActions,
332
+ H as hasComponentTriggers
598
333
  };