@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,85 @@
1
+ "use client";
2
+ function n(t) {
3
+ if (t.template?.typeId === "verify-dialog") {
4
+ const e = t.template.config;
5
+ return {
6
+ title: e.title,
7
+ content: e.description,
8
+ type: "modal",
9
+ buttons: [
10
+ {
11
+ id: "cancel-btn",
12
+ label: e.cancelButtonLabel,
13
+ variant: "secondary",
14
+ action: e.onCancelAction || { type: "close" }
15
+ },
16
+ {
17
+ id: "verify-btn",
18
+ label: e.verifyButtonLabel,
19
+ variant: "primary",
20
+ action: { type: "custom", handler: "verifyEmail" }
21
+ }
22
+ ],
23
+ dismissible: !0,
24
+ // Add template metadata for runtime behavior
25
+ templateMetadata: {
26
+ typeId: "verify-dialog",
27
+ codeLength: e.codeLength,
28
+ codeType: e.codeType,
29
+ enableAutoSubmit: e.enableAutoSubmit,
30
+ enableResend: e.enableResend,
31
+ resendTimer: e.resendTimer,
32
+ successTitle: e.successTitle,
33
+ successMessage: e.successMessage,
34
+ errorMessage: e.errorMessage,
35
+ continueButtonLabel: e.continueButtonLabel,
36
+ // Store configurable action for verification success
37
+ onVerifiedAction: e.onVerifiedAction || {
38
+ type: "navigate",
39
+ direction: "next"
40
+ }
41
+ }
42
+ };
43
+ }
44
+ if (t.template?.typeId === "confirmation-dialog") {
45
+ const e = t.template.config;
46
+ return {
47
+ title: e.title,
48
+ content: e.content,
49
+ type: "modal",
50
+ buttons: [
51
+ {
52
+ id: "cancel-btn",
53
+ label: e.cancelButtonLabel,
54
+ variant: "secondary",
55
+ action: e.onCancelAction || { type: "close" }
56
+ },
57
+ {
58
+ id: "confirm-btn",
59
+ label: e.confirmButtonLabel,
60
+ variant: e.confirmButtonVariant || "primary",
61
+ action: e.onConfirmAction || {
62
+ type: "navigate",
63
+ direction: "next"
64
+ }
65
+ }
66
+ ],
67
+ dismissible: !0,
68
+ // Add template metadata for runtime behavior
69
+ templateMetadata: {
70
+ typeId: "confirmation-dialog",
71
+ showIcon: e.showIcon,
72
+ iconType: e.iconType
73
+ }
74
+ };
75
+ }
76
+ return t.templateTypeId === "verify-dialog" && t.templateConfig ? n({
77
+ template: {
78
+ typeId: t.templateTypeId,
79
+ config: t.templateConfig
80
+ }
81
+ }) : t;
82
+ }
83
+ export {
84
+ n as resolveTemplateDialog
85
+ };
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { isTemplateStep as l } from "../../../../core/src/types/guards.js";
3
+ const r = {
4
+ GENERIC: "generic-",
5
+ TEAM: "team-"
6
+ };
7
+ function i(e) {
8
+ return e.startsWith(r.GENERIC) ? "generic" : e.startsWith(r.TEAM) ? "team" : null;
9
+ }
10
+ function p(e) {
11
+ return i(e) === "generic";
12
+ }
13
+ function m(e) {
14
+ return i(e) === "team";
15
+ }
16
+ function T(e) {
17
+ return {
18
+ /**
19
+ * Lists all available generic templates
20
+ */
21
+ getAvailableGenericTemplatesSync() {
22
+ return e.getAvailableGenericTemplates();
23
+ },
24
+ /**
25
+ * Gets metadata for a template without loading the full template
26
+ */
27
+ async getTemplateInfo(a) {
28
+ return await e.getTemplateMetadata(a);
29
+ },
30
+ /**
31
+ * Validates that all template references in a configuration are valid
32
+ */
33
+ async validateTemplateReferences(a) {
34
+ const n = [], s = await e.getAvailableTemplates();
35
+ for (const t of a.steps)
36
+ l(t) && (s.includes(t.templateId) || n.push(
37
+ `Template '${t.templateId}' referenced in step '${t.id}' does not exist`
38
+ ));
39
+ return {
40
+ isValid: n.length === 0,
41
+ errors: n
42
+ };
43
+ }
44
+ };
45
+ }
46
+ export {
47
+ r as TEMPLATE_PREFIXES,
48
+ T as createAsyncTemplateFunctions,
49
+ i as getTemplateTypeFromId,
50
+ p as isGenericTemplate,
51
+ m as isTeamTemplate
52
+ };
@@ -0,0 +1,15 @@
1
+ "use client";
2
+ import { jsx as r } from "react/jsx-runtime";
3
+ import { createContext as m } from "react";
4
+ let e = null;
5
+ const i = () => (e || (e = m(void 0)), e), l = ({ children: t }) => {
6
+ const o = { theme: "eva-light", setTheme: () => {
7
+ } }, n = i();
8
+ return /* @__PURE__ */ r(n.Provider, { value: o, children: t });
9
+ }, u = () => ({
10
+ name: "eva-light"
11
+ });
12
+ export {
13
+ l as ThemeProvider,
14
+ u as useThemeConfig
15
+ };
@@ -0,0 +1,370 @@
1
+ "use client";
2
+ import { jsxs as k, Fragment as D, jsx as B } from "react/jsx-runtime";
3
+ /* empty css */
4
+ import { logger as O } from "../../../../../../ui/src/lib/logger.js";
5
+ import { useApiAction as z } from "../../../form-runtime/hooks/useApiActions.js";
6
+ import { ActionValidator as q, ActionValidationError as R } from "../../../validation-system/validation/ActionValidation.js";
7
+ import { memo as L, useState as N, useRef as I, useMemo as h, useEffect as m, useCallback as w } from "react";
8
+ const F = L(
9
+ ({
10
+ actions: i,
11
+ trigger: r,
12
+ formData: e,
13
+ onComplete: s,
14
+ onError: o,
15
+ onFieldUpdate: c,
16
+ onShowDialog: v,
17
+ onNavigate: p,
18
+ machineRef: a
19
+ }) => {
20
+ const [f, g] = N({}), [d, x] = N(0), A = I(""), b = I(!1), l = h(() => i.filter((t) => t.trigger === r).sort((t, n) => t.order - n.order), [i, r]), E = h(() => l.reduce((t, n) => {
21
+ const u = q.validateAction(n);
22
+ return u.isValid || t.push(`Action '${n.id}': ${u.errors.join(", ")}`), t;
23
+ }, []), [l]), C = h(() => l.map((t) => t.id).sort().join(","), [l]);
24
+ m(() => {
25
+ if (b.current && A.current === C)
26
+ return;
27
+ if (l.length === 0) {
28
+ b.current = !0, A.current = C, a?.send({ type: "ACTIONS_COMPLETED", results: {} }), s({});
29
+ return;
30
+ }
31
+ if (E.length > 0) {
32
+ b.current = !0, A.current = C;
33
+ const n = new R(
34
+ "validation-error",
35
+ "validation",
36
+ `Action validation failed: ${E.join("; ")}`,
37
+ { validationErrors: E }
38
+ );
39
+ O.error(
40
+ "Action validation failed",
41
+ { errors: E },
42
+ n
43
+ ), a?.send({ type: "ACTIONS_COMPLETED", results: {} }), o(n);
44
+ return;
45
+ }
46
+ const t = {};
47
+ for (const n of l)
48
+ t[n.id] = {
49
+ action: n,
50
+ status: "pending"
51
+ };
52
+ g(t), b.current = !0, A.current = C;
53
+ for (const n of l)
54
+ a?.send({ type: "ACTION_START", actionId: n.id });
55
+ x(0);
56
+ }, [
57
+ C,
58
+ l,
59
+ E,
60
+ a,
61
+ s,
62
+ o
63
+ ]), m(() => () => {
64
+ b.current = !1, A.current = "";
65
+ }, []);
66
+ const y = l[d], S = y ? f[y.id] : null;
67
+ m(() => {
68
+ const t = Object.values(f);
69
+ if (t.length > 0 && t.every(
70
+ (u) => u.status === "completed" || u.status === "error"
71
+ )) {
72
+ const u = {};
73
+ for (const [$, T] of Object.entries(f))
74
+ u[$] = T.error ? { error: T.error.message } : T.result;
75
+ a?.send({ type: "ACTIONS_COMPLETED", results: u }), s(u);
76
+ }
77
+ }, [f, a, s]), m(() => {
78
+ if (S?.status === "completed" || S?.status === "error") {
79
+ const t = d + 1;
80
+ t < l.length && x(t);
81
+ }
82
+ }, [S?.status, d, l.length]);
83
+ const j = w(
84
+ (t, n) => {
85
+ g((u) => ({
86
+ ...u,
87
+ [t]: { ...u[t], ...n }
88
+ }));
89
+ },
90
+ []
91
+ ), _ = w(
92
+ (t, n) => {
93
+ a?.send({
94
+ type: "ACTION_SUCCESS",
95
+ actionId: t,
96
+ result: n
97
+ });
98
+ },
99
+ [a]
100
+ ), P = w(
101
+ (t, n) => {
102
+ a?.send({
103
+ type: "ACTION_ERROR",
104
+ actionId: t,
105
+ error: n
106
+ });
107
+ },
108
+ [a]
109
+ );
110
+ return /* @__PURE__ */ k(D, { children: [
111
+ process.env.NODE_ENV === "development" && !1,
112
+ l.filter((t) => t.type === "apiCall").map((t) => /* @__PURE__ */ B(
113
+ M,
114
+ {
115
+ action: t,
116
+ formData: e,
117
+ onFieldUpdate: c,
118
+ execution: f[t.id],
119
+ onExecutionUpdate: j,
120
+ onResult: _,
121
+ onError: P
122
+ },
123
+ t.id
124
+ )),
125
+ y && y.type !== "apiCall" && S?.status === "pending" && /* @__PURE__ */ B(
126
+ V,
127
+ {
128
+ action: y,
129
+ formData: e,
130
+ onComplete: (t) => {
131
+ g((n) => ({
132
+ ...n,
133
+ [y.id]: {
134
+ ...n[y.id],
135
+ status: "completed",
136
+ result: t
137
+ }
138
+ }));
139
+ },
140
+ onError: (t) => {
141
+ g((n) => ({
142
+ ...n,
143
+ [y.id]: {
144
+ ...n[y.id],
145
+ status: "error",
146
+ error: t
147
+ }
148
+ }));
149
+ },
150
+ onShowDialog: v,
151
+ onNavigate: p
152
+ }
153
+ )
154
+ ] });
155
+ }
156
+ ), M = L(
157
+ ({
158
+ action: i,
159
+ formData: r,
160
+ onFieldUpdate: e,
161
+ execution: s,
162
+ onExecutionUpdate: o,
163
+ onResult: c,
164
+ onError: v
165
+ }) => {
166
+ const p = i.config, a = I(!1), f = I(!1);
167
+ m(() => {
168
+ a.current = !1, f.current = !1;
169
+ }, []);
170
+ const { data: g, error: d, isSuccess: x, isError: A, execute: b } = z({
171
+ config: p,
172
+ formData: r,
173
+ onFieldUpdate: e,
174
+ enabled: !1
175
+ // We'll trigger manually
176
+ });
177
+ return m(() => {
178
+ s?.status === "pending" && !a.current && (a.current = !0, o(i.id, { status: "executing" }), b());
179
+ }, [s?.status, i.id, o, b]), m(() => {
180
+ x && g !== void 0 && s?.status === "executing" && !f.current && (f.current = !0, o(i.id, { status: "completed", result: g }), c(i.id, g));
181
+ }, [
182
+ x,
183
+ g,
184
+ s?.status,
185
+ i.id,
186
+ o,
187
+ c
188
+ ]), m(() => {
189
+ A && d && s?.status === "executing" && (O.error(
190
+ "API execution failed",
191
+ { actionId: i.id, error: d.message },
192
+ d
193
+ ), o(i.id, {
194
+ status: "error",
195
+ error: d
196
+ }), v(i.id, d));
197
+ }, [
198
+ A,
199
+ d,
200
+ s?.status,
201
+ i.id,
202
+ o,
203
+ v
204
+ ]), null;
205
+ }
206
+ ), V = L(
207
+ ({ action: i, formData: r, onComplete: e, onError: s, onShowDialog: o, onNavigate: c }) => (m(() => {
208
+ (async () => {
209
+ try {
210
+ let p = null;
211
+ switch (i.type) {
212
+ case "showDialog": {
213
+ p = await new K().execute(
214
+ i.config,
215
+ r,
216
+ o
217
+ );
218
+ break;
219
+ }
220
+ case "navigate": {
221
+ p = await new G().execute(
222
+ i.config,
223
+ c
224
+ );
225
+ break;
226
+ }
227
+ default:
228
+ throw new Error(`Unknown non-API action type: ${i.type}`);
229
+ }
230
+ e(p);
231
+ } catch (p) {
232
+ s(p);
233
+ }
234
+ })();
235
+ }, [i, r, e, s, o, c]), null)
236
+ );
237
+ class K {
238
+ async execute(r, e, s) {
239
+ let o;
240
+ if (r.template?.typeId)
241
+ o = this.resolveDialogTemplate(r.template);
242
+ else if (r.content && r.title)
243
+ o = r;
244
+ else
245
+ throw new Error(
246
+ "Invalid dialog configuration: missing required template or content properties"
247
+ );
248
+ const c = {
249
+ ...o,
250
+ content: this.interpolateTemplate(o.content, e)
251
+ };
252
+ return s(c), c;
253
+ }
254
+ resolveDialogTemplate(r) {
255
+ if (r.typeId === "verify-dialog") {
256
+ const e = r.config || {};
257
+ return {
258
+ title: String(e.title || "Verification Required"),
259
+ content: String(
260
+ e.description || "Please verify your information."
261
+ ),
262
+ type: "modal",
263
+ size: "medium",
264
+ dismissible: !0,
265
+ buttons: [
266
+ {
267
+ id: "cancel-btn",
268
+ label: String(e.cancelButtonLabel || "Cancel"),
269
+ variant: "secondary",
270
+ action: e.onCancelAction || {
271
+ type: "close"
272
+ }
273
+ },
274
+ {
275
+ id: "verify-btn",
276
+ label: String(e.verifyButtonLabel || "Verify"),
277
+ variant: "primary",
278
+ action: e.onVerifiedAction || {
279
+ type: "custom",
280
+ handler: "verifyEmail"
281
+ }
282
+ }
283
+ ],
284
+ // Add template metadata for runtime behavior
285
+ templateMetadata: {
286
+ typeId: "verify-dialog",
287
+ codeLength: e.codeLength,
288
+ codeType: e.codeType,
289
+ enableAutoSubmit: e.enableAutoSubmit,
290
+ enableResend: e.enableResend,
291
+ resendTimer: e.resendTimer,
292
+ successTitle: e.successTitle,
293
+ successMessage: e.successMessage,
294
+ errorMessage: e.errorMessage,
295
+ continueButtonLabel: e.continueButtonLabel,
296
+ cancelButtonLabel: e.cancelButtonLabel,
297
+ verifyButtonLabel: e.verifyButtonLabel,
298
+ resendButtonLabel: e.resendButtonLabel
299
+ }
300
+ };
301
+ }
302
+ if (r.typeId === "confirmation-dialog") {
303
+ const e = r.config || {};
304
+ return {
305
+ title: String(e.title || "Confirm Action"),
306
+ content: String(
307
+ e.message || e.content || "Are you sure you want to proceed?"
308
+ ),
309
+ type: "modal",
310
+ size: "medium",
311
+ dismissible: !0,
312
+ buttons: [
313
+ {
314
+ id: "cancel-btn",
315
+ label: String(e.cancelButtonLabel || "Cancel"),
316
+ variant: "secondary",
317
+ action: e.onCancelAction || {
318
+ type: "close"
319
+ }
320
+ },
321
+ {
322
+ id: "confirm-btn",
323
+ label: String(e.confirmButtonLabel || "Confirm"),
324
+ variant: this.mapButtonVariant(e.confirmButtonVariant),
325
+ action: e.onConfirmAction || {
326
+ type: "navigate",
327
+ direction: "next"
328
+ }
329
+ }
330
+ ],
331
+ // Add template metadata for runtime behavior
332
+ templateMetadata: {
333
+ typeId: "confirmation-dialog",
334
+ showIcon: e.showIcon,
335
+ iconType: e.iconType
336
+ }
337
+ };
338
+ }
339
+ throw new Error(`Unknown dialog template type: ${r.typeId}`);
340
+ }
341
+ interpolateTemplate(r, e) {
342
+ return r.replace(/\$\{data\.([^}]+)\}/g, (s, o) => {
343
+ const c = e[o];
344
+ return c != null ? String(c) : s;
345
+ });
346
+ }
347
+ mapButtonVariant(r) {
348
+ switch (String(r || "primary").toLowerCase()) {
349
+ case "secondary":
350
+ return "secondary";
351
+ case "danger":
352
+ case "destructive":
353
+ return "danger";
354
+ default:
355
+ return "primary";
356
+ }
357
+ }
358
+ }
359
+ class G {
360
+ async execute(r, e) {
361
+ return e(r), r;
362
+ }
363
+ }
364
+ F.displayName = "EnhancedActionExecutor";
365
+ M.displayName = "ActionApiExecutor";
366
+ V.displayName = "ActionNonApiExecutor";
367
+ export {
368
+ F as EnhancedActionExecutor,
369
+ F as default
370
+ };