@digiform/wizard 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/core/src/types/api.js +12 -0
- package/core/src/types/form-config.js +60 -0
- package/core/src/types/form-wizard-config-schema.js +113 -0
- package/core/src/types/guards.js +19 -0
- package/core/src/types/validation.js +61 -0
- package/core/src/utils/apiBodyUtils.js +95 -0
- package/features/api-integration.d.ts +2 -0
- package/features/api-integration.js +17 -0
- package/features/dialog-system.d.ts +2 -0
- package/features/dialog-system.js +9 -0
- package/features/form-runtime.d.ts +2 -0
- package/features/form-runtime.js +63 -0
- package/features/state-management.d.ts +2 -0
- package/features/state-management.js +21 -0
- package/features/trigger-action-system.d.ts +2 -0
- package/features/trigger-action-system.js +12 -0
- package/features/validation-system.d.ts +2 -0
- package/features/validation-system.js +23 -0
- package/index.js +108 -17470
- package/package.json +35 -30
- package/styles.css +1 -1
- package/ui/src/component-registry/renderComponent.js +11 -0
- package/ui/src/components/FormLayout/FormLayout.js +135 -0
- package/ui/src/components/FormLayout/FormLayout.module.css.js +20 -0
- package/ui/src/components/GridLayout/GridLayout.js +62 -0
- package/ui/src/components/GridLayout/GridLayout.module.css.js +16 -0
- package/ui/src/components/GridLayoutColumn/GridLayoutColumn.js +37 -0
- package/ui/src/components/GridLayoutColumn/GridLayoutColumn.module.css.js +10 -0
- package/ui/src/components/ProgressLoaderBar/ProgressLoaderBar.js +108 -0
- package/ui/src/components/ProgressLoaderBar/ProgressLoaderBar.module.css.js +20 -0
- package/ui/src/components/ProgressLoaderBar/useProgressAnimation.js +31 -0
- package/ui/src/components/ValidationCode/ValidationCode.js +198 -0
- package/ui/src/components/ValidationCode/ValidationCode.module.css.js +20 -0
- package/ui/src/components/alert/alert.js +30 -0
- package/ui/src/components/alert/alert.module.css.js +14 -0
- package/ui/src/components/badge/badge.js +20 -0
- package/ui/src/components/badge/badge.module.css.js +12 -0
- package/ui/src/components/box/box.js +8 -0
- package/ui/src/components/box/box.module.css.js +8 -0
- package/ui/src/components/button/button.js +25 -0
- package/ui/src/components/button/button.module.css.js +18 -0
- package/ui/src/components/card/card.js +106 -0
- package/ui/src/components/card/card.module.css.js +44 -0
- package/ui/src/components/checkbox/checkbox.js +20 -0
- package/ui/src/components/checkbox/checkbox.module.css.js +10 -0
- package/ui/src/components/dialog/dialog.js +67 -0
- package/ui/src/components/dialog/dialog.module.css.js +20 -0
- package/ui/src/components/form-header-base/form-header-base.js +59 -0
- package/ui/src/components/form-header-base/form-header-base.module.css.js +14 -0
- package/ui/src/components/input/input.js +20 -0
- package/ui/src/components/input/input.module.css.js +8 -0
- package/ui/src/components/radio-group/radio-group.js +30 -0
- package/ui/src/components/radio-group/radio-group.module.css.js +14 -0
- package/ui/src/components/select/select.js +115 -0
- package/ui/src/components/select/select.module.css.js +32 -0
- package/ui/src/components/sheet/sheet.js +71 -0
- package/ui/src/components/sheet/sheet.module.css.js +46 -0
- package/ui/src/components/textarea/textarea.js +19 -0
- package/ui/src/components/textarea/textarea.module.css.js +8 -0
- package/ui/src/design-system/components/FormFieldWrapper.js +16 -0
- package/ui/src/lib/assets/icons/Check.js +26 -0
- package/ui/src/lib/assets/icons/ChevronRight.js +26 -0
- package/ui/src/lib/error-boundaries/BaseErrorBoundary.js +155 -0
- package/ui/src/lib/error-boundaries/ComponentErrorBoundary.js +153 -0
- package/ui/src/lib/error-boundaries/FormWizardErrorBoundary.js +107 -0
- package/ui/src/lib/logger.js +106 -0
- package/ui/src/lib/providers/FormEditingContext.js +21 -0
- package/ui/src/lib/queryClient.js +26 -0
- package/ui/src/lib/types/guards.js +11 -0
- package/ui/src/lib/utils/componentUtils.js +38 -0
- package/ui/src/lib/utils/templateDialogResolver.js +85 -0
- package/ui/src/lib/utils/templateUtils.js +52 -0
- package/ui/src/theme/ThemeProvider.js +15 -0
- package/wizard/src/features/api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js +370 -0
- package/wizard/src/features/api-integration/services/ActionExecutor.js +339 -0
- package/wizard/src/features/api-integration/services/ApiCallExecutor.js +6 -0
- package/wizard/src/features/api-integration/services/ApiCallService.js +309 -0
- package/wizard/src/features/api-integration/services/DialogExecutor.js +6 -0
- package/wizard/src/features/api-integration/services/GenericTriggerService.js +284 -0
- package/wizard/src/features/api-integration/services/NavigationExecutor.js +6 -0
- package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +115 -0
- package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.module.css.js +29 -0
- package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +64 -0
- package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.module.css.js +22 -0
- package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +149 -0
- package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.module.css.js +40 -0
- package/wizard/src/features/form-runtime/ComponentAdapterComplete/ComponentAdapterComplete.js +107 -0
- package/wizard/src/features/form-runtime/ComponentAdapterComplete/ComponentAdapterComplete.module.css.js +10 -0
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +107 -0
- package/wizard/src/features/form-runtime/FormWizard/FormWizard.module.css.js +16 -0
- package/wizard/src/features/form-runtime/components/FormField.js +405 -0
- package/wizard/src/features/form-runtime/components/FormFooter.js +209 -0
- package/wizard/src/features/form-runtime/components/FormHeader.js +29 -0
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +279 -0
- package/wizard/src/features/form-runtime/components/FormSection/FormSection.module.css.js +20 -0
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +167 -0
- package/wizard/src/features/form-runtime/components/FormStep/FormStep.module.css.js +12 -0
- package/wizard/src/features/form-runtime/components/ProgressLoaderRuntime.js +88 -0
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +61 -0
- package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.module.css.js +34 -0
- package/wizard/src/features/form-runtime/components/displayValue/displayValue.js +21 -0
- package/wizard/src/features/form-runtime/components/displayValue/displayValue.module.css.js +10 -0
- package/wizard/src/features/form-runtime/components/renderers/DisplayModeRenderer/DisplayModeRenderer.js +28 -0
- package/wizard/src/features/form-runtime/components/renderers/DisplayModeRenderer/DisplayModeRenderer.module.css.js +8 -0
- package/wizard/src/features/form-runtime/components/renderers/InteractiveFieldRenderer/InteractiveFieldRenderer.js +56 -0
- package/wizard/src/features/form-runtime/components/renderers/InteractiveFieldRenderer/InteractiveFieldRenderer.module.css.js +8 -0
- package/wizard/src/features/form-runtime/config/configResolver.js +38 -0
- package/wizard/src/features/form-runtime/config/templateConfig.js +156 -0
- package/wizard/src/features/form-runtime/config/templateLoader.js +265 -0
- package/wizard/src/features/form-runtime/config/templateUtils.js +14 -0
- package/wizard/src/features/form-runtime/context/LoaderContext.js +36 -0
- package/wizard/src/features/form-runtime/hooks/useApiActions.js +60 -0
- package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +102 -0
- package/wizard/src/features/form-runtime/hooks/useComponentVisibility.js +18 -0
- package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +61 -0
- package/wizard/src/features/form-runtime/hooks/useFormContext.js +13 -0
- package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +40 -0
- package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +39 -0
- package/wizard/src/features/form-runtime/utils/componentDisplayValue.js +22 -0
- package/wizard/src/features/form-runtime/utils/errorUtils.js +93 -0
- package/wizard/src/features/form-runtime/utils/fieldHelpers.js +17 -0
- package/wizard/src/features/form-runtime/utils/formDataBuilder.js +10 -0
- package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +52 -0
- package/wizard/src/features/form-runtime/utils/logger.js +111 -0
- package/wizard/src/features/form-runtime/utils/validation.js +100 -0
- package/wizard/src/features/form-runtime/utils/validationUX.js +58 -0
- package/wizard/src/features/form-runtime/utils/visibilityUtils.js +77 -0
- package/wizard/src/features/state-management/machines/actions/componentActions.js +215 -0
- package/wizard/src/features/state-management/machines/actions/navigationActions.js +122 -0
- package/wizard/src/features/state-management/machines/actions/saveActions.js +101 -0
- package/wizard/src/features/state-management/machines/componentTriggerEngine.js +598 -0
- package/wizard/src/features/state-management/machines/formMachine.js +1565 -0
- package/wizard/src/features/state-management/machines/guards/navigationGuards.js +59 -0
- package/wizard/src/features/state-management/machines/guards/saveGuards.js +21 -0
- package/wizard/src/features/state-management/machines/guards/triggerGuards.js +11 -0
- package/wizard/src/features/state-management/machines/helpers/triggerHelpers.js +12 -0
- package/wizard/src/features/state-management/machines/performance.js +56 -0
- package/wizard/src/features/state-management/machines/useFormMachine.js +412 -0
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +46 -0
- package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +30 -0
- package/wizard/src/features/trigger-action-system/components/ActionManager.js +108 -0
- package/wizard/src/features/trigger-action-system/components/ComponentAlert/ComponentAlert.js +10 -0
- package/wizard/src/features/trigger-action-system/components/ComponentAlert/ComponentAlert.module.css.js +8 -0
- package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +376 -0
- package/wizard/src/features/validation-system/components/ValidationDebugger.js +69 -0
- package/wizard/src/features/validation-system/validation/ActionValidation.js +234 -0
- package/wizard/src/features/validation-system/validation/SchemaBuilder.js +239 -0
- package/wizard/src/features/validation-system/validation/ValidationCache.js +76 -0
- package/wizard/src/features/validation-system/validation/ValidationEngine.js +97 -0
- package/wizard/src/features/validation-system/validation/ValidationExecutor.js +138 -0
- package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +17 -0
- package/wizard/src/features/validation-system/validation/validationService.js +74 -0
- package/wizard/src/renderer/wizardRenderer.js +123 -0
|
@@ -0,0 +1,598 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
const C = typeof process < "u" && process.env.NODE_ENV === "development", u = {
|
|
3
|
+
componentTriggers: /* @__PURE__ */ new Map(),
|
|
4
|
+
componentActions: /* @__PURE__ */ new Map(),
|
|
5
|
+
stepComponents: /* @__PURE__ */ new Map(),
|
|
6
|
+
lastConfigId: ""
|
|
7
|
+
}, m = {
|
|
8
|
+
triggerResults: /* @__PURE__ */ new Map(),
|
|
9
|
+
executionPlans: /* @__PURE__ */ new Map()
|
|
10
|
+
};
|
|
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;
|
|
15
|
+
v(t);
|
|
16
|
+
const a = b(
|
|
17
|
+
t,
|
|
18
|
+
e,
|
|
19
|
+
n,
|
|
20
|
+
i
|
|
21
|
+
), s = {
|
|
22
|
+
context: e,
|
|
23
|
+
executions: a,
|
|
24
|
+
totalActions: a.reduce(
|
|
25
|
+
(c, g) => c + g.actions.length,
|
|
26
|
+
0
|
|
27
|
+
),
|
|
28
|
+
requiresUserInteraction: a.some(
|
|
29
|
+
(c) => c.actions.some(
|
|
30
|
+
(g) => g.type === "executeVerifyEmailDialog" || g.type === "executeVerifyDialog"
|
|
31
|
+
)
|
|
32
|
+
),
|
|
33
|
+
timestamp: Date.now()
|
|
34
|
+
};
|
|
35
|
+
return m.executionPlans.set(o, s), m.executionPlans.size > 100 && S(), s;
|
|
36
|
+
}
|
|
37
|
+
function v(t) {
|
|
38
|
+
if (u.lastConfigId !== t.id) {
|
|
39
|
+
u.componentTriggers.clear(), u.componentActions.clear(), u.stepComponents.clear();
|
|
40
|
+
for (let e = 0; e < t.steps.length; e++) {
|
|
41
|
+
const n = t.steps[e];
|
|
42
|
+
if (!n || !("sections" in n)) continue;
|
|
43
|
+
const i = [];
|
|
44
|
+
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);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
u.stepComponents.set(e, i);
|
|
57
|
+
}
|
|
58
|
+
u.lastConfigId = t.id;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function S() {
|
|
62
|
+
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);
|
|
67
|
+
}
|
|
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)
|
|
84
|
+
);
|
|
85
|
+
if (!g.length) continue;
|
|
86
|
+
const d = D(
|
|
87
|
+
t,
|
|
88
|
+
n,
|
|
89
|
+
s
|
|
90
|
+
);
|
|
91
|
+
if (!(e === "sectionSave" && d && !E(d)))
|
|
92
|
+
for (const l of g) {
|
|
93
|
+
const T = M(
|
|
94
|
+
s,
|
|
95
|
+
i,
|
|
96
|
+
e
|
|
97
|
+
);
|
|
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,
|
|
110
|
+
e
|
|
111
|
+
);
|
|
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,
|
|
126
|
+
context: e,
|
|
127
|
+
actions: f,
|
|
128
|
+
timestamp: Date.now()
|
|
129
|
+
});
|
|
130
|
+
} else C && console.log(
|
|
131
|
+
`❌ [ComponentTriggerEngine] Trigger ${l.id} should NOT fire for ${s}`
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
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;
|
|
145
|
+
}
|
|
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))
|
|
151
|
+
return o;
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
function w(t, e, n) {
|
|
155
|
+
const i = u.componentTriggers.get(n);
|
|
156
|
+
return i ? i.filter(
|
|
157
|
+
(o) => !o.contexts || o.contexts.length === 0 || o.contexts.includes(e)
|
|
158
|
+
) : [];
|
|
159
|
+
}
|
|
160
|
+
function $(t, e) {
|
|
161
|
+
return t.filter((n) => {
|
|
162
|
+
if (n.contexts && n.contexts.length > 0) {
|
|
163
|
+
const i = P(e);
|
|
164
|
+
return n.contexts.some(
|
|
165
|
+
(o) => o === e || o === i || F(o, e)
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
return !0;
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function P(t) {
|
|
172
|
+
switch (t) {
|
|
173
|
+
case "fieldChange":
|
|
174
|
+
return "fieldChange";
|
|
175
|
+
case "save":
|
|
176
|
+
return "sectionSave";
|
|
177
|
+
// Map "save" to "sectionSave" primarily
|
|
178
|
+
case "stepSave":
|
|
179
|
+
return "stepSave";
|
|
180
|
+
case "sectionSave":
|
|
181
|
+
return "sectionSave";
|
|
182
|
+
default:
|
|
183
|
+
return t;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
function F(t, e) {
|
|
187
|
+
return e === "save" ? t === "sectionSave" || t === "stepSave" : !1;
|
|
188
|
+
}
|
|
189
|
+
function E(t) {
|
|
190
|
+
const e = t;
|
|
191
|
+
return e.triggerContexts?.supportsSectionSave || e.mode === "edit" || e.mode === "editable";
|
|
192
|
+
}
|
|
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
|
+
), {
|
|
216
|
+
componentId: t,
|
|
217
|
+
currentValue: i,
|
|
218
|
+
originalValue: r,
|
|
219
|
+
eventType: n === "stepSave" || n === "sectionSave" ? "navigationAttempt" : "valueChange",
|
|
220
|
+
triggerContext: n,
|
|
221
|
+
formData: e.data,
|
|
222
|
+
formContext: e
|
|
223
|
+
};
|
|
224
|
+
}
|
|
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;
|
|
229
|
+
const o = h(t, e);
|
|
230
|
+
return m.triggerResults.set(n, {
|
|
231
|
+
result: o,
|
|
232
|
+
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;
|
|
242
|
+
}
|
|
243
|
+
function k(t, e) {
|
|
244
|
+
switch (t) {
|
|
245
|
+
case "valueChange":
|
|
246
|
+
case "focus":
|
|
247
|
+
case "blur":
|
|
248
|
+
return "fieldChange";
|
|
249
|
+
case "navigationAttempt":
|
|
250
|
+
case "stepNavigation":
|
|
251
|
+
return "stepSave";
|
|
252
|
+
case "sectionSave":
|
|
253
|
+
return "sectionSave";
|
|
254
|
+
case "immediate":
|
|
255
|
+
return "immediate";
|
|
256
|
+
default:
|
|
257
|
+
return "fieldChange";
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
function _(t, e) {
|
|
261
|
+
return y(t, e.componentId).map((i) => ({
|
|
262
|
+
trigger: i,
|
|
263
|
+
shouldFire: h(i, e)
|
|
264
|
+
}));
|
|
265
|
+
}
|
|
266
|
+
function y(t, e) {
|
|
267
|
+
return v(t), u.componentTriggers.get(e) || [];
|
|
268
|
+
}
|
|
269
|
+
function V(t, e) {
|
|
270
|
+
return v(t), u.componentActions.get(e) || [];
|
|
271
|
+
}
|
|
272
|
+
function h(t, e) {
|
|
273
|
+
let n = !1;
|
|
274
|
+
switch (t.type) {
|
|
275
|
+
case "isDirty": {
|
|
276
|
+
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
|
+
}
|
|
325
|
+
break;
|
|
326
|
+
}
|
|
327
|
+
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
|
+
);
|
|
335
|
+
break;
|
|
336
|
+
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
|
+
);
|
|
344
|
+
break;
|
|
345
|
+
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
|
+
);
|
|
353
|
+
break;
|
|
354
|
+
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
|
+
);
|
|
363
|
+
}
|
|
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;
|
|
417
|
+
}
|
|
418
|
+
function B(t, e) {
|
|
419
|
+
return t.every((n) => R(n, e));
|
|
420
|
+
}
|
|
421
|
+
function R(t, e) {
|
|
422
|
+
let n;
|
|
423
|
+
switch (t.field ? n = e.formData[t.field] : n = e.currentValue, t.operator) {
|
|
424
|
+
case "equals":
|
|
425
|
+
return n === t.value;
|
|
426
|
+
case "notEquals":
|
|
427
|
+
return n !== t.value;
|
|
428
|
+
case "contains":
|
|
429
|
+
return typeof n == "string" && typeof t.value == "string" && n.includes(t.value);
|
|
430
|
+
case "empty":
|
|
431
|
+
return n == null || n === "" || Array.isArray(n) && n.length === 0;
|
|
432
|
+
case "notEmpty":
|
|
433
|
+
return n != null && n !== "" && !(Array.isArray(n) && n.length === 0);
|
|
434
|
+
case "greaterThan":
|
|
435
|
+
return typeof n == "number" && typeof t.value == "number" && n > t.value;
|
|
436
|
+
case "lessThan":
|
|
437
|
+
return typeof n == "number" && typeof t.value == "number" && n < t.value;
|
|
438
|
+
default:
|
|
439
|
+
return !1;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
function N(t, e, n) {
|
|
443
|
+
return y(t, e);
|
|
444
|
+
}
|
|
445
|
+
function L(t, e) {
|
|
446
|
+
return y(t, e).length > 0;
|
|
447
|
+
}
|
|
448
|
+
function q(t, e) {
|
|
449
|
+
return V(t, e).length > 0;
|
|
450
|
+
}
|
|
451
|
+
function A(t, e, n, i = "stepSave") {
|
|
452
|
+
const o = [], r = t.steps[e];
|
|
453
|
+
if (!r || !("sections" in r))
|
|
454
|
+
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
|
|
514
|
+
}
|
|
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
|
+
}
|
|
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;
|
|
565
|
+
}
|
|
566
|
+
function H(t, e, n, i = "step") {
|
|
567
|
+
return A(
|
|
568
|
+
t,
|
|
569
|
+
e,
|
|
570
|
+
n,
|
|
571
|
+
i === "section" ? "sectionSave" : "stepSave"
|
|
572
|
+
);
|
|
573
|
+
}
|
|
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,
|
|
583
|
+
findDirtyComponentsWithTriggers: A,
|
|
584
|
+
findDirtyComponentsForNavigation: H
|
|
585
|
+
};
|
|
586
|
+
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,
|
|
594
|
+
A as findDirtyComponentsWithTriggers,
|
|
595
|
+
N as getTriggersForAction,
|
|
596
|
+
q as hasComponentActions,
|
|
597
|
+
L as hasComponentTriggers
|
|
598
|
+
};
|