@digiform/wizard 0.2.9 → 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.
Files changed (153) hide show
  1. package/core/src/types/api.js +12 -0
  2. package/core/src/types/form-config.js +60 -0
  3. package/core/src/types/form-wizard-config-schema.js +113 -0
  4. package/core/src/types/guards.js +19 -0
  5. package/core/src/types/validation.js +61 -0
  6. package/core/src/utils/apiBodyUtils.js +95 -0
  7. package/features/api-integration.d.ts +2 -0
  8. package/features/api-integration.js +17 -0
  9. package/features/dialog-system.d.ts +2 -0
  10. package/features/dialog-system.js +9 -0
  11. package/features/form-runtime.d.ts +2 -0
  12. package/features/form-runtime.js +63 -0
  13. package/features/state-management.d.ts +2 -0
  14. package/features/state-management.js +21 -0
  15. package/features/trigger-action-system.d.ts +2 -0
  16. package/features/trigger-action-system.js +12 -0
  17. package/features/validation-system.d.ts +2 -0
  18. package/features/validation-system.js +23 -0
  19. package/index.js +108 -17470
  20. package/package.json +35 -30
  21. package/styles.css +1 -1
  22. package/ui/src/component-registry/renderComponent.js +11 -0
  23. package/ui/src/components/FormLayout/FormLayout.js +135 -0
  24. package/ui/src/components/FormLayout/FormLayout.module.css.js +20 -0
  25. package/ui/src/components/GridLayout/GridLayout.js +62 -0
  26. package/ui/src/components/GridLayout/GridLayout.module.css.js +16 -0
  27. package/ui/src/components/GridLayoutColumn/GridLayoutColumn.js +37 -0
  28. package/ui/src/components/GridLayoutColumn/GridLayoutColumn.module.css.js +10 -0
  29. package/ui/src/components/ProgressLoaderBar/ProgressLoaderBar.js +108 -0
  30. package/ui/src/components/ProgressLoaderBar/ProgressLoaderBar.module.css.js +20 -0
  31. package/ui/src/components/ProgressLoaderBar/useProgressAnimation.js +31 -0
  32. package/ui/src/components/ValidationCode/ValidationCode.js +198 -0
  33. package/ui/src/components/ValidationCode/ValidationCode.module.css.js +20 -0
  34. package/ui/src/components/alert/alert.js +30 -0
  35. package/ui/src/components/alert/alert.module.css.js +14 -0
  36. package/ui/src/components/badge/badge.js +20 -0
  37. package/ui/src/components/badge/badge.module.css.js +12 -0
  38. package/ui/src/components/box/box.js +8 -0
  39. package/ui/src/components/box/box.module.css.js +8 -0
  40. package/ui/src/components/button/button.js +25 -0
  41. package/ui/src/components/button/button.module.css.js +18 -0
  42. package/ui/src/components/card/card.js +106 -0
  43. package/ui/src/components/card/card.module.css.js +44 -0
  44. package/ui/src/components/checkbox/checkbox.js +20 -0
  45. package/ui/src/components/checkbox/checkbox.module.css.js +10 -0
  46. package/ui/src/components/dialog/dialog.js +67 -0
  47. package/ui/src/components/dialog/dialog.module.css.js +20 -0
  48. package/ui/src/components/form-header-base/form-header-base.js +59 -0
  49. package/ui/src/components/form-header-base/form-header-base.module.css.js +14 -0
  50. package/ui/src/components/input/input.js +20 -0
  51. package/ui/src/components/input/input.module.css.js +8 -0
  52. package/ui/src/components/radio-group/radio-group.js +30 -0
  53. package/ui/src/components/radio-group/radio-group.module.css.js +14 -0
  54. package/ui/src/components/select/select.js +115 -0
  55. package/ui/src/components/select/select.module.css.js +32 -0
  56. package/ui/src/components/sheet/sheet.js +71 -0
  57. package/ui/src/components/sheet/sheet.module.css.js +46 -0
  58. package/ui/src/components/textarea/textarea.js +19 -0
  59. package/ui/src/components/textarea/textarea.module.css.js +8 -0
  60. package/ui/src/design-system/components/FormFieldWrapper.js +16 -0
  61. package/ui/src/lib/assets/icons/Check.js +26 -0
  62. package/ui/src/lib/assets/icons/ChevronRight.js +26 -0
  63. package/ui/src/lib/error-boundaries/BaseErrorBoundary.js +155 -0
  64. package/ui/src/lib/error-boundaries/ComponentErrorBoundary.js +153 -0
  65. package/ui/src/lib/error-boundaries/FormWizardErrorBoundary.js +107 -0
  66. package/ui/src/lib/logger.js +106 -0
  67. package/ui/src/lib/providers/FormEditingContext.js +21 -0
  68. package/ui/src/lib/queryClient.js +26 -0
  69. package/ui/src/lib/types/guards.js +11 -0
  70. package/ui/src/lib/utils/componentUtils.js +38 -0
  71. package/ui/src/lib/utils/templateDialogResolver.js +85 -0
  72. package/ui/src/lib/utils/templateUtils.js +52 -0
  73. package/ui/src/theme/ThemeProvider.js +15 -0
  74. package/wizard/src/features/api-integration/components/EnhancedActionExecutor/EnhancedActionExecutor.js +370 -0
  75. package/wizard/src/features/api-integration/services/ActionExecutor.js +339 -0
  76. package/wizard/src/features/api-integration/services/ApiCallExecutor.js +6 -0
  77. package/wizard/src/features/api-integration/services/ApiCallService.js +309 -0
  78. package/wizard/src/features/api-integration/services/DialogExecutor.js +6 -0
  79. package/wizard/src/features/api-integration/services/GenericTriggerService.js +284 -0
  80. package/wizard/src/features/api-integration/services/NavigationExecutor.js +6 -0
  81. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +115 -0
  82. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.module.css.js +29 -0
  83. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +64 -0
  84. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.module.css.js +22 -0
  85. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +149 -0
  86. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.module.css.js +40 -0
  87. package/wizard/src/features/form-runtime/ComponentAdapterComplete/ComponentAdapterComplete.js +107 -0
  88. package/wizard/src/features/form-runtime/ComponentAdapterComplete/ComponentAdapterComplete.module.css.js +10 -0
  89. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +107 -0
  90. package/wizard/src/features/form-runtime/FormWizard/FormWizard.module.css.js +16 -0
  91. package/wizard/src/features/form-runtime/components/FormField.js +405 -0
  92. package/wizard/src/features/form-runtime/components/FormFooter.js +209 -0
  93. package/wizard/src/features/form-runtime/components/FormHeader.js +29 -0
  94. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +279 -0
  95. package/wizard/src/features/form-runtime/components/FormSection/FormSection.module.css.js +20 -0
  96. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +167 -0
  97. package/wizard/src/features/form-runtime/components/FormStep/FormStep.module.css.js +12 -0
  98. package/wizard/src/features/form-runtime/components/ProgressLoaderRuntime.js +88 -0
  99. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +61 -0
  100. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.module.css.js +34 -0
  101. package/wizard/src/features/form-runtime/components/displayValue/displayValue.js +21 -0
  102. package/wizard/src/features/form-runtime/components/displayValue/displayValue.module.css.js +10 -0
  103. package/wizard/src/features/form-runtime/components/renderers/DisplayModeRenderer/DisplayModeRenderer.js +28 -0
  104. package/wizard/src/features/form-runtime/components/renderers/DisplayModeRenderer/DisplayModeRenderer.module.css.js +8 -0
  105. package/wizard/src/features/form-runtime/components/renderers/InteractiveFieldRenderer/InteractiveFieldRenderer.js +56 -0
  106. package/wizard/src/features/form-runtime/components/renderers/InteractiveFieldRenderer/InteractiveFieldRenderer.module.css.js +8 -0
  107. package/wizard/src/features/form-runtime/config/configResolver.js +38 -0
  108. package/wizard/src/features/form-runtime/config/templateConfig.js +156 -0
  109. package/wizard/src/features/form-runtime/config/templateLoader.js +265 -0
  110. package/wizard/src/features/form-runtime/config/templateUtils.js +14 -0
  111. package/wizard/src/features/form-runtime/context/LoaderContext.js +36 -0
  112. package/wizard/src/features/form-runtime/hooks/useApiActions.js +60 -0
  113. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +102 -0
  114. package/wizard/src/features/form-runtime/hooks/useComponentVisibility.js +18 -0
  115. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +61 -0
  116. package/wizard/src/features/form-runtime/hooks/useFormContext.js +13 -0
  117. package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +40 -0
  118. package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +39 -0
  119. package/wizard/src/features/form-runtime/utils/componentDisplayValue.js +22 -0
  120. package/wizard/src/features/form-runtime/utils/errorUtils.js +93 -0
  121. package/wizard/src/features/form-runtime/utils/fieldHelpers.js +17 -0
  122. package/wizard/src/features/form-runtime/utils/formDataBuilder.js +10 -0
  123. package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +52 -0
  124. package/wizard/src/features/form-runtime/utils/logger.js +111 -0
  125. package/wizard/src/features/form-runtime/utils/validation.js +100 -0
  126. package/wizard/src/features/form-runtime/utils/validationUX.js +58 -0
  127. package/wizard/src/features/form-runtime/utils/visibilityUtils.js +77 -0
  128. package/wizard/src/features/state-management/machines/actions/componentActions.js +215 -0
  129. package/wizard/src/features/state-management/machines/actions/navigationActions.js +122 -0
  130. package/wizard/src/features/state-management/machines/actions/saveActions.js +101 -0
  131. package/wizard/src/features/state-management/machines/componentTriggerEngine.js +598 -0
  132. package/wizard/src/features/state-management/machines/formMachine.js +1565 -0
  133. package/wizard/src/features/state-management/machines/guards/navigationGuards.js +59 -0
  134. package/wizard/src/features/state-management/machines/guards/saveGuards.js +21 -0
  135. package/wizard/src/features/state-management/machines/guards/triggerGuards.js +11 -0
  136. package/wizard/src/features/state-management/machines/helpers/triggerHelpers.js +12 -0
  137. package/wizard/src/features/state-management/machines/performance.js +56 -0
  138. package/wizard/src/features/state-management/machines/useFormMachine.js +412 -0
  139. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +46 -0
  140. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +30 -0
  141. package/wizard/src/features/trigger-action-system/components/ActionManager.js +108 -0
  142. package/wizard/src/features/trigger-action-system/components/ComponentAlert/ComponentAlert.js +10 -0
  143. package/wizard/src/features/trigger-action-system/components/ComponentAlert/ComponentAlert.module.css.js +8 -0
  144. package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +376 -0
  145. package/wizard/src/features/validation-system/components/ValidationDebugger.js +69 -0
  146. package/wizard/src/features/validation-system/validation/ActionValidation.js +234 -0
  147. package/wizard/src/features/validation-system/validation/SchemaBuilder.js +239 -0
  148. package/wizard/src/features/validation-system/validation/ValidationCache.js +76 -0
  149. package/wizard/src/features/validation-system/validation/ValidationEngine.js +97 -0
  150. package/wizard/src/features/validation-system/validation/ValidationExecutor.js +138 -0
  151. package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +17 -0
  152. package/wizard/src/features/validation-system/validation/validationService.js +74 -0
  153. package/wizard/src/renderer/wizardRenderer.js +123 -0
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ import { jsxs as s, jsx as r } from "react/jsx-runtime";
3
+ import { ActionDialog as d } from "../../dialog-system/components/ActionDialog/ActionDialog.js";
4
+ import { useFormMachine as p } from "../../state-management/machines/useFormMachine.js";
5
+ import { memo as I } from "react";
6
+ const D = I(({ className: g = "" }) => {
7
+ const [i, a] = p(), { context: n } = i, l = (e) => {
8
+ switch (console.log("🔥 ActionManager: Dialog button clicked!", e), console.log("🔥 ActionManager: Button action type:", e.type), e.type) {
9
+ case "close":
10
+ console.log("🔥 ActionManager: Executing CLOSE action"), n.pendingNavigation ? (console.log(
11
+ "🔥 ActionManager: Dialog cancelled during navigation - sending DIALOG_CANCELLED"
12
+ ), a({ type: "DIALOG_CANCELLED" })) : a({ type: "HIDE_ACTION_DIALOG" });
13
+ break;
14
+ case "navigate":
15
+ e.type === "navigate" && console.log("🔥 ActionManager: Executing NAVIGATE action", {
16
+ direction: e.direction,
17
+ targetStep: e.targetStep,
18
+ currentStep: n.currentStepIndex,
19
+ updateOriginalValue: e.updateOriginalValue,
20
+ componentId: e.componentId
21
+ }), e.type === "navigate" && e.updateOriginalValue && e.componentId && (console.log(
22
+ "🔥 ActionManager: Updating original value before navigation"
23
+ ), a({
24
+ type: "UPDATE_COMPONENT_ORIGINAL_VALUE",
25
+ componentId: e.componentId
26
+ })), n.pendingNavigation ? (console.log(
27
+ "🔥 ActionManager: Dialog verified during navigation - sending DIALOG_VERIFIED"
28
+ ), a({ type: "DIALOG_VERIFIED" })) : e.type === "navigate" && (e.direction === "next" ? (console.log("🔥 ActionManager: Sending NEXT event to machine"), a({ type: "NEXT" })) : e.direction === "previous" ? (console.log(
29
+ "🔥 ActionManager: Sending PREVIOUS event to machine"
30
+ ), a({ type: "PREVIOUS" })) : e.targetStep && (console.log(
31
+ "🔥 ActionManager: Sending GO_TO_STEP event to machine"
32
+ ), a({ type: "GO_TO_STEP", stepId: e.targetStep })));
33
+ break;
34
+ case "custom":
35
+ console.log("🔥 ActionManager: Executing CUSTOM action", e), e.type === "custom" && e.handler === "updateOriginalValue" && e.componentId ? (console.log(
36
+ "🔥 ActionManager: Executing updateOriginalValue handler",
37
+ {
38
+ componentId: e.componentId,
39
+ pendingNavigation: n.pendingNavigation,
40
+ saveState: n.saveState,
41
+ isInSaveContext: n.saveState.savingSection !== null
42
+ }
43
+ ), a({
44
+ type: "UPDATE_COMPONENT_ORIGINAL_VALUE",
45
+ componentId: e.componentId
46
+ }), n.saveState.savingSection !== null ? (console.log(
47
+ "🔥 ActionManager: updateOriginalValue in SAVE context - hiding dialog without navigation"
48
+ ), a({ type: "HIDE_ACTION_DIALOG" })) : (console.log(
49
+ "🔥 ActionManager: updateOriginalValue in non-save context - hiding dialog"
50
+ ), a({ type: "HIDE_ACTION_DIALOG" }))) : (console.warn(
51
+ "Custom dialog action not implemented:",
52
+ e.handler
53
+ ), a({ type: "HIDE_ACTION_DIALOG" }));
54
+ break;
55
+ case "updateOriginalValue":
56
+ console.log(
57
+ "🔥 ActionManager: Executing UPDATE_ORIGINAL_VALUE action",
58
+ {
59
+ componentId: e.componentId,
60
+ pendingNavigation: n.pendingNavigation,
61
+ saveState: n.saveState,
62
+ isInSaveContext: n.saveState.savingSection !== null
63
+ }
64
+ ), a({
65
+ type: "UPDATE_COMPONENT_ORIGINAL_VALUE",
66
+ componentId: e.componentId
67
+ }), n.saveState.savingSection !== null ? (console.log(
68
+ "🔥 ActionManager: Update original value in SAVE context - hiding dialog without navigation"
69
+ ), a({ type: "HIDE_ACTION_DIALOG" })) : n.pendingNavigation ? (console.log(
70
+ "🔥 ActionManager: Update original value verified during navigation - sending DIALOG_VERIFIED"
71
+ ), a({ type: "DIALOG_VERIFIED" })) : a({ type: "HIDE_ACTION_DIALOG" });
72
+ break;
73
+ default:
74
+ console.log("🔥 ActionManager: Unknown action type, hiding dialog"), a({ type: "HIDE_ACTION_DIALOG" });
75
+ }
76
+ }, c = () => {
77
+ n.pendingNavigation ? (console.log(
78
+ "🔥 ActionManager: Dialog closed during navigation - sending DIALOG_CANCELLED"
79
+ ), a({ type: "DIALOG_CANCELLED" })) : a({ type: "HIDE_ACTION_DIALOG" });
80
+ }, o = i.matches("showingActionDialog") && n.activeDialog !== null, t = i.matches("executingActions");
81
+ return console.log(" ActionManager state:", {
82
+ currentState: i.value,
83
+ isDialogOpen: o,
84
+ isExecutingActions: t,
85
+ activeDialog: n.activeDialog,
86
+ executingTrigger: n.executingTrigger
87
+ }), i.matches("showingActionDialog") && console.log(" ActionManager: In showingActionDialog state!", {
88
+ activeDialog: n.activeDialog,
89
+ isDialogOpen: o
90
+ }), /* @__PURE__ */ s("div", { className: g, children: [
91
+ t && !1,
92
+ /* @__PURE__ */ r(
93
+ d,
94
+ {
95
+ config: n.activeDialog,
96
+ formData: n.data,
97
+ onButtonClick: l,
98
+ onClose: c,
99
+ isOpen: o
100
+ }
101
+ )
102
+ ] });
103
+ });
104
+ D.displayName = "ActionManager";
105
+ export {
106
+ D as ActionManager,
107
+ D as default
108
+ };
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import { jsx as t } from "react/jsx-runtime";
3
+ import n from "./ComponentAlert.module.css.js";
4
+ import { Alert as o } from "@rijkshuisstijl-community/components-react";
5
+ const s = ({ alert: e }) => /* @__PURE__ */ t(o, { type: "warning", children: e.message }), p = ({ alerts: e }) => e.length === 0 ? null : /* @__PURE__ */ t("div", { className: n.alertList, children: e.map((r) => /* @__PURE__ */ t(s, { alert: r }, r.id)) });
6
+ export {
7
+ s as ComponentAlert,
8
+ p as ComponentAlerts,
9
+ s as default
10
+ };
@@ -0,0 +1,8 @@
1
+ "use client";
2
+ const t = "fb-alertList_d0DxG", s = {
3
+ alertList: t
4
+ };
5
+ export {
6
+ t as alertList,
7
+ s as default
8
+ };
@@ -0,0 +1,376 @@
1
+ "use client";
2
+ class l {
3
+ constructor(e) {
4
+ this.services = e;
5
+ }
6
+ triggers = /* @__PURE__ */ new Map();
7
+ debounceTimers = /* @__PURE__ */ new Map();
8
+ throttleTimers = /* @__PURE__ */ new Map();
9
+ /**
10
+ * Register triggers for a specific context and target
11
+ */
12
+ registerTriggers(e, a) {
13
+ this.triggers.set(
14
+ e,
15
+ a.filter((i) => i.enabled !== !1)
16
+ );
17
+ }
18
+ /**
19
+ * Unregister triggers for a target
20
+ */
21
+ unregisterTriggers(e) {
22
+ this.triggers.delete(e), this.clearTimers(e);
23
+ }
24
+ /**
25
+ * Evaluate triggers for a given context
26
+ */
27
+ async evaluateTriggers(e) {
28
+ const a = this.triggers.get(e.targetId);
29
+ if (!a || a.length === 0)
30
+ return;
31
+ const i = a.filter(
32
+ (n) => n.type === e.triggerType
33
+ );
34
+ if (i.length === 0)
35
+ return;
36
+ const t = i.sort(
37
+ (n, o) => (n.order || 0) - (o.order || 0)
38
+ );
39
+ for (const n of t)
40
+ await this.executeTrigger(n, e);
41
+ }
42
+ /**
43
+ * Execute a single trigger
44
+ */
45
+ async executeTrigger(e, a) {
46
+ if (!(e.conditions && e.conditions.length > 0 && !this.evaluateConditions(
47
+ e.conditions,
48
+ a
49
+ ))) {
50
+ if (e.debounceMs && e.debounceMs > 0) {
51
+ this.handleDebounce(e, a);
52
+ return;
53
+ }
54
+ if (e.throttleMs && e.throttleMs > 0) {
55
+ if (this.isThrottled(e.id))
56
+ return;
57
+ this.setThrottle(e.id, e.throttleMs);
58
+ }
59
+ e.actions && await this.executeActions(e.actions, a);
60
+ }
61
+ }
62
+ /**
63
+ * Execute actions for a trigger
64
+ */
65
+ async executeActions(e, a) {
66
+ const i = e.filter((t) => t.enabled !== !1).sort((t, n) => (t.order || 0) - (n.order || 0));
67
+ for (const t of i)
68
+ await this.executeAction(t, a);
69
+ }
70
+ /**
71
+ * Execute a single action
72
+ */
73
+ async executeAction(e, a) {
74
+ if (e.condition && !this.evaluateConditions(
75
+ [e.condition],
76
+ a
77
+ ))
78
+ return;
79
+ e.delay && e.delay > 0 && await new Promise((t) => setTimeout(t, e.delay));
80
+ const i = {
81
+ action: e,
82
+ triggerContext: a,
83
+ formData: a.formData,
84
+ services: this.services
85
+ };
86
+ try {
87
+ await this.dispatchAction(i);
88
+ } catch (t) {
89
+ console.error(`Failed to execute action ${e.id}:`, t);
90
+ }
91
+ }
92
+ /**
93
+ * Dispatch action to appropriate handler based on type
94
+ */
95
+ async dispatchAction(e) {
96
+ const { action: a, services: i } = e, t = a.config;
97
+ if (!this.isTypedActionConfig(t)) {
98
+ console.warn("Action config is missing type property", t);
99
+ return;
100
+ }
101
+ switch (t.type) {
102
+ // UI Actions
103
+ case "ui:showAlert":
104
+ this.isUIShowAlertConfig(t) && i.ui.showAlert(t);
105
+ break;
106
+ case "ui:showDialog":
107
+ this.isUIShowDialogConfig(t) && i.ui.showDialog(t);
108
+ break;
109
+ case "ui:showNotification":
110
+ this.isUIShowNotificationConfig(t) && i.ui.showNotification(t);
111
+ break;
112
+ case "ui:hideDialog":
113
+ i.ui.hideDialog();
114
+ break;
115
+ // Navigation Actions
116
+ case "navigation:goToStep":
117
+ this.isNavigationGoToStepConfig(t) && i.navigation.goToStep(t.stepId, t.behavior);
118
+ break;
119
+ case "navigation:goNext":
120
+ this.isNavigationGoNextConfig(t) && i.navigation.goNext(t.skipValidation);
121
+ break;
122
+ case "navigation:goPrevious":
123
+ this.isNavigationGoPreviousConfig(t) && i.navigation.goPrevious(t.skipValidation);
124
+ break;
125
+ case "navigation:goToSection":
126
+ this.isNavigationGoToSectionConfig(t) && i.navigation.goToSection(t.sectionId, t.stepId);
127
+ break;
128
+ // Component Actions
129
+ case "component:enable":
130
+ this.isComponentEnableConfig(t) && this.handleComponentAction("enable", t.componentIds, e);
131
+ break;
132
+ case "component:disable":
133
+ this.isComponentDisableConfig(t) && this.handleComponentAction("disable", t.componentIds, e);
134
+ break;
135
+ case "component:show":
136
+ case "component:hide":
137
+ if (this.isComponentShowHideConfig(t)) {
138
+ const n = t.type === "component:show" ? "show" : "hide";
139
+ this.handleComponentAction(n, t.componentIds, e);
140
+ }
141
+ break;
142
+ case "component:setValue":
143
+ case "component:clearValue":
144
+ this.isComponentSetValueConfig(t) && (t.type === "component:setValue" ? i.data.setValue(
145
+ `component.${t.componentId}`,
146
+ t.value
147
+ ) : i.data.clearValue(`component.${t.componentId}`));
148
+ break;
149
+ case "component:updateOriginalValue":
150
+ this.isComponentUpdateOriginalValueConfig(t) && this.handleUpdateOriginalValue(t.componentId, e);
151
+ break;
152
+ // Data Actions
153
+ case "data:apiCall":
154
+ this.isDataApiCallConfig(t) && await i.data.apiCall(t);
155
+ break;
156
+ case "data:setValue":
157
+ case "data:clearValue":
158
+ this.isDataSetValueConfig(t) && (t.type === "data:setValue" ? i.data.setValue(t.fieldPath, t.value) : i.data.clearValue(t.fieldPath));
159
+ break;
160
+ case "data:validateField":
161
+ case "data:validateSection":
162
+ case "data:validateStep":
163
+ this.isDataValidationConfig(t) && (t.type === "data:validateField" ? i.validation.validateField(t.targetId) : t.type === "data:validateSection" ? i.validation.validateSection(t.targetId) : i.validation.validateStep(t.targetId));
164
+ break;
165
+ // Custom Actions
166
+ case "custom:execute":
167
+ this.isCustomActionConfig(t) && await this.handleCustomAction(t, e);
168
+ break;
169
+ default:
170
+ console.warn(`Unknown action type: ${t.type}`);
171
+ }
172
+ }
173
+ /**
174
+ * Evaluate trigger conditions
175
+ */
176
+ evaluateConditions(e, a) {
177
+ if (e.length === 0)
178
+ return !0;
179
+ let i = this.evaluateCondition(e[0], a);
180
+ for (let t = 1; t < e.length; t++) {
181
+ const n = e[t], o = this.evaluateCondition(n, a);
182
+ (e[t - 1].logicalOperator || "AND") === "AND" ? i = i && o : i = i || o;
183
+ }
184
+ return i;
185
+ }
186
+ /**
187
+ * Evaluate a single condition
188
+ */
189
+ evaluateCondition(e, a) {
190
+ let i;
191
+ switch (e.field ? i = this.services.data.getValue(e.field) : i = a.currentValue, e.operator) {
192
+ case "equals":
193
+ return i === e.value;
194
+ case "notEquals":
195
+ return i !== e.value;
196
+ case "contains":
197
+ return String(i || "").includes(String(e.value || ""));
198
+ case "notContains":
199
+ return !String(i || "").includes(String(e.value || ""));
200
+ case "empty":
201
+ return i == null || i === "";
202
+ case "notEmpty":
203
+ return i != null && i !== "";
204
+ case "greaterThan":
205
+ return Number(i) > Number(e.value);
206
+ case "lessThan":
207
+ return Number(i) < Number(e.value);
208
+ case "greaterThanOrEqual":
209
+ return Number(i) >= Number(e.value);
210
+ case "lessThanOrEqual":
211
+ return Number(i) <= Number(e.value);
212
+ case "in":
213
+ return e.values ? e.values.includes(i) : !1;
214
+ case "notIn":
215
+ return e.values ? !e.values.includes(i) : !0;
216
+ case "matches":
217
+ try {
218
+ return new RegExp(String(e.value), "i").test(String(i || ""));
219
+ } catch {
220
+ return !1;
221
+ }
222
+ case "custom":
223
+ return this.evaluateCustomCondition(e, a);
224
+ default:
225
+ return console.warn(`Unknown condition operator: ${e.operator}`), !1;
226
+ }
227
+ }
228
+ /**
229
+ * Handle debouncing for triggers
230
+ */
231
+ handleDebounce(e, a) {
232
+ const i = `${e.id}-${a.targetId}`, t = this.debounceTimers.get(i);
233
+ t && clearTimeout(t);
234
+ const n = setTimeout(async () => {
235
+ this.debounceTimers.delete(i), e.actions && await this.executeActions(e.actions, a);
236
+ }, e.debounceMs);
237
+ this.debounceTimers.set(i, n);
238
+ }
239
+ /**
240
+ * Check if trigger is currently throttled
241
+ */
242
+ isThrottled(e) {
243
+ return this.throttleTimers.has(e);
244
+ }
245
+ /**
246
+ * Set throttle timer for trigger
247
+ */
248
+ setThrottle(e, a) {
249
+ const i = setTimeout(() => {
250
+ this.throttleTimers.delete(e);
251
+ }, a);
252
+ this.throttleTimers.set(e, i);
253
+ }
254
+ /**
255
+ * Clear all timers for a target
256
+ */
257
+ clearTimers(e) {
258
+ for (const [a, i] of Array.from(this.debounceTimers.entries()))
259
+ a.includes(e) && (clearTimeout(i), this.debounceTimers.delete(a));
260
+ }
261
+ /**
262
+ * Handle component-specific actions
263
+ */
264
+ handleComponentAction(e, a, i) {
265
+ for (const t of a) {
266
+ const n = `component:${e}`;
267
+ this.emitEvent(n, { componentId: t, context: i });
268
+ }
269
+ }
270
+ /**
271
+ * Handle original value updates
272
+ */
273
+ handleUpdateOriginalValue(e, a) {
274
+ this.emitEvent("component:updateOriginalValue", { componentId: e, context: a });
275
+ }
276
+ /**
277
+ * Handle custom actions
278
+ */
279
+ async handleCustomAction(e, a) {
280
+ this.emitEvent("action:custom", { config: e, context: a });
281
+ }
282
+ /**
283
+ * Evaluate custom conditions
284
+ */
285
+ evaluateCustomCondition(e, a) {
286
+ return console.warn(
287
+ `Custom condition evaluator not implemented: ${e.customEvaluator}`
288
+ ), !1;
289
+ }
290
+ /**
291
+ * Emit events for external handling
292
+ */
293
+ emitEvent(e, a) {
294
+ typeof window < "u" && window.dispatchEvent(new CustomEvent(e, { detail: a }));
295
+ }
296
+ /**
297
+ * Type guards for action config validation
298
+ */
299
+ isTypedActionConfig(e) {
300
+ return typeof e == "object" && e !== null && "type" in e && typeof e.type == "string";
301
+ }
302
+ isUIShowAlertConfig(e) {
303
+ return this.isTypedActionConfig(e) && e.type === "ui:showAlert" && "message" in e;
304
+ }
305
+ isUIShowDialogConfig(e) {
306
+ return this.isTypedActionConfig(e) && e.type === "ui:showDialog" && "dialogType" in e;
307
+ }
308
+ isUIShowNotificationConfig(e) {
309
+ return this.isTypedActionConfig(e) && e.type === "ui:showNotification" && "message" in e;
310
+ }
311
+ isNavigationGoToStepConfig(e) {
312
+ return this.isTypedActionConfig(e) && e.type === "navigation:goToStep" && "stepId" in e;
313
+ }
314
+ isNavigationGoNextConfig(e) {
315
+ return this.isTypedActionConfig(e) && e.type === "navigation:goNext";
316
+ }
317
+ isNavigationGoPreviousConfig(e) {
318
+ return this.isTypedActionConfig(e) && e.type === "navigation:goPrevious";
319
+ }
320
+ isNavigationGoToSectionConfig(e) {
321
+ return this.isTypedActionConfig(e) && e.type === "navigation:goToSection" && "sectionId" in e;
322
+ }
323
+ isComponentEnableConfig(e) {
324
+ return this.isTypedActionConfig(e) && e.type === "component:enable" && "componentIds" in e;
325
+ }
326
+ isComponentDisableConfig(e) {
327
+ return this.isTypedActionConfig(e) && e.type === "component:disable" && "componentIds" in e;
328
+ }
329
+ isComponentShowHideConfig(e) {
330
+ return this.isTypedActionConfig(e) && (e.type === "component:show" || e.type === "component:hide") && "componentIds" in e;
331
+ }
332
+ isComponentSetValueConfig(e) {
333
+ return this.isTypedActionConfig(e) && (e.type === "component:setValue" || e.type === "component:clearValue") && "componentId" in e;
334
+ }
335
+ isComponentUpdateOriginalValueConfig(e) {
336
+ return this.isTypedActionConfig(e) && e.type === "component:updateOriginalValue" && "componentId" in e;
337
+ }
338
+ isDataApiCallConfig(e) {
339
+ return this.isTypedActionConfig(e) && e.type === "data:apiCall" && "url" in e;
340
+ }
341
+ isDataSetValueConfig(e) {
342
+ return this.isTypedActionConfig(e) && (e.type === "data:setValue" || e.type === "data:clearValue") && "fieldPath" in e;
343
+ }
344
+ isDataValidationConfig(e) {
345
+ return this.isTypedActionConfig(e) && (e.type === "data:validateField" || e.type === "data:validateSection" || e.type === "data:validateStep") && "targetId" in e;
346
+ }
347
+ isCustomActionConfig(e) {
348
+ return this.isTypedActionConfig(e) && e.type === "custom:execute" && "handler" in e;
349
+ }
350
+ /**
351
+ * Cleanup resources
352
+ */
353
+ dispose() {
354
+ for (const e of Array.from(this.debounceTimers.values()))
355
+ clearTimeout(e);
356
+ for (const e of Array.from(this.throttleTimers.values()))
357
+ clearTimeout(e);
358
+ this.debounceTimers.clear(), this.throttleTimers.clear(), this.triggers.clear();
359
+ }
360
+ }
361
+ function u(s, e, a, i = {}) {
362
+ return {
363
+ triggerType: s,
364
+ context: e,
365
+ targetId: a,
366
+ currentValue: i.currentValue,
367
+ previousValue: i.previousValue,
368
+ formData: i.formData || {},
369
+ metadata: i.metadata || {},
370
+ timestamp: Date.now()
371
+ };
372
+ }
373
+ export {
374
+ l as GenericTriggerEngine,
375
+ u as createTriggerContext
376
+ };
@@ -0,0 +1,69 @@
1
+ "use client";
2
+ import { jsxs as t, jsx as i } from "react/jsx-runtime";
3
+ import { useFormContext as l } from "../../form-runtime/hooks/useFormContext.js";
4
+ const p = () => {
5
+ const s = l();
6
+ return process.env.NODE_ENV !== "development" ? null : /* @__PURE__ */ t(
7
+ "div",
8
+ {
9
+ style: {
10
+ position: "fixed",
11
+ // bottom: "10px",
12
+ top: "50px",
13
+ right: "10px",
14
+ width: "400px",
15
+ maxHeight: "300px",
16
+ overflow: "auto",
17
+ backgroundColor: "#1a1a1a",
18
+ color: "#fff",
19
+ padding: "10px",
20
+ fontSize: "12px",
21
+ borderRadius: "4px",
22
+ zIndex: 9999,
23
+ fontFamily: "monospace"
24
+ },
25
+ children: [
26
+ /* @__PURE__ */ i("strong", { children: "🔍 Validation Debug" }),
27
+ /* @__PURE__ */ i(s.Subscribe, { selector: (e) => e, children: (e) => /* @__PURE__ */ t("div", { children: [
28
+ /* @__PURE__ */ i("h4", { children: "Form State:" }),
29
+ /* @__PURE__ */ i("pre", { style: { fontSize: "10px", whiteSpace: "pre-wrap" }, children: JSON.stringify(
30
+ {
31
+ isValid: e.isValid,
32
+ isSubmitted: e.isSubmitted,
33
+ canSubmit: e.canSubmit,
34
+ errors: e.errors,
35
+ values: e.values
36
+ },
37
+ null,
38
+ 2
39
+ ) }),
40
+ /* @__PURE__ */ i("h4", { children: "Field States:" }),
41
+ Object.keys(e.values || {}).map((o) => {
42
+ const r = s.getFieldApi?.(o)?.state;
43
+ return /* @__PURE__ */ t("details", { style: { marginBottom: "8px" }, children: [
44
+ /* @__PURE__ */ t("summary", { style: { cursor: "pointer", fontWeight: "bold" }, children: [
45
+ o,
46
+ " ",
47
+ r?.meta?.errors?.length ? `(${r.meta.errors.length} errors)` : ""
48
+ ] }),
49
+ /* @__PURE__ */ i("pre", { style: { fontSize: "10px", marginLeft: "10px" }, children: JSON.stringify(
50
+ {
51
+ value: r?.value,
52
+ isValid: r?.meta?.isValid,
53
+ isTouched: r?.meta?.isTouched,
54
+ errors: r?.meta?.errors,
55
+ errorMap: r?.meta?.errorMap
56
+ },
57
+ null,
58
+ 2
59
+ ) })
60
+ ] }, o);
61
+ })
62
+ ] }) })
63
+ ]
64
+ }
65
+ );
66
+ };
67
+ export {
68
+ p as default
69
+ };