@digiform/wizard 0.2.10 → 0.2.16

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 (154) 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 +41 -30
  21. package/styles.css +1 -4
  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
  154. package/README.md +0 -147
@@ -0,0 +1,284 @@
1
+ "use client";
2
+ import { GenericTriggerEngine as l, createTriggerContext as a } from "../../trigger-action-system/utils/GenericTriggerEngine.js";
3
+ class g {
4
+ constructor(e) {
5
+ this.formMachine = e;
6
+ }
7
+ goToStep(e, t) {
8
+ this.formMachine.send({ type: "GO_TO_STEP", stepId: e, behavior: t });
9
+ }
10
+ goNext(e) {
11
+ this.formMachine.send({ type: "NEXT", skipValidation: e });
12
+ }
13
+ goPrevious(e) {
14
+ this.formMachine.send({ type: "PREVIOUS", skipValidation: e });
15
+ }
16
+ goToSection(e, t) {
17
+ t && this.goToStep(t);
18
+ const i = document.getElementById(e);
19
+ i && i.scrollIntoView({ behavior: "smooth" });
20
+ }
21
+ }
22
+ class p {
23
+ constructor(e) {
24
+ this.formMachine = e;
25
+ }
26
+ showAlert(e) {
27
+ const t = e;
28
+ t.targetId ? this.formMachine.send({
29
+ type: "SHOW_COMPONENT_ALERT",
30
+ componentId: t.targetId,
31
+ alert: {
32
+ message: e.message,
33
+ type: e.alertType,
34
+ position: e.position === "toast" ? "inline" : e.position,
35
+ dismissible: e.dismissible ?? !1,
36
+ autoHide: e.autoHide,
37
+ autoHideDelay: e.autoHideDelay
38
+ }
39
+ }) : this.showNotification({
40
+ type: "ui:showNotification",
41
+ message: e.message,
42
+ notificationType: e.alertType,
43
+ position: e.position === "toast" ? "top-right" : "top"
44
+ });
45
+ }
46
+ showDialog(e) {
47
+ let t;
48
+ e.dialogType === "email-verification" ? t = {
49
+ type: "email-verification",
50
+ title: typeof e.title == "string" ? e.title : e.templateConfig?.title,
51
+ content: typeof e.content == "string" ? e.content : e.templateConfig?.description,
52
+ templateMetadata: e.templateConfig
53
+ } : e.dialogType === "confirmation" ? t = {
54
+ type: "confirmation",
55
+ title: e.title,
56
+ content: e.content,
57
+ buttons: e.buttons?.map((i) => ({
58
+ label: i.label,
59
+ variant: i.variant ?? "default",
60
+ action: i.action.type || "close"
61
+ }))
62
+ } : t = {
63
+ type: "custom",
64
+ title: e.title,
65
+ content: e.content,
66
+ templateMetadata: e.templateConfig
67
+ }, this.formMachine.send({
68
+ type: "SHOW_ACTION_DIALOG",
69
+ dialogConfig: t
70
+ });
71
+ }
72
+ showNotification(e) {
73
+ console.log(
74
+ `🔔 Notification [${e.notificationType}]: ${e.message}`
75
+ ), typeof window < "u" && window.dispatchEvent(
76
+ new CustomEvent("form:notification", {
77
+ detail: e
78
+ })
79
+ );
80
+ }
81
+ hideDialog() {
82
+ this.formMachine.send({ type: "HIDE_ACTION_DIALOG" });
83
+ }
84
+ }
85
+ class d {
86
+ constructor(e) {
87
+ this.formMachine = e;
88
+ }
89
+ async apiCall(e) {
90
+ try {
91
+ const t = await fetch(e.url, {
92
+ method: e.method,
93
+ headers: {
94
+ "Content-Type": "application/json",
95
+ ...e.headers
96
+ },
97
+ body: e.body ? JSON.stringify(e.body) : void 0,
98
+ signal: e.timeout ? AbortSignal.timeout(e.timeout) : void 0
99
+ });
100
+ if (!t.ok)
101
+ throw new Error(
102
+ `API call failed: ${t.status} ${t.statusText}`
103
+ );
104
+ const i = await t.json();
105
+ if (e.fieldMappings)
106
+ for (const [s, o] of Object.entries(
107
+ e.fieldMappings
108
+ )) {
109
+ const r = this.getNestedValue(i, s);
110
+ r !== void 0 && this.setValue(o, r);
111
+ }
112
+ return e.onSuccess && console.log(
113
+ "API call succeeded, executing success actions",
114
+ e.onSuccess
115
+ ), i;
116
+ } catch (t) {
117
+ throw console.error("API call failed:", t), e.onError && console.log("API call failed, executing error actions", e.onError), t;
118
+ }
119
+ }
120
+ setValue(e, t) {
121
+ const [i, s] = e.split(".");
122
+ i === "component" ? this.formMachine.send({
123
+ type: "UPDATE_COMPONENT_VALUE",
124
+ componentId: s,
125
+ value: t
126
+ }) : this.formMachine.send({
127
+ type: "UPDATE_FIELD",
128
+ field: e,
129
+ value: t
130
+ });
131
+ }
132
+ getValue(e) {
133
+ const i = this.formMachine.getSnapshot().context.data;
134
+ return this.getNestedValue(i, e);
135
+ }
136
+ clearValue(e) {
137
+ this.setValue(e, "");
138
+ }
139
+ getNestedValue(e, t) {
140
+ return t.split(".").reduce((i, s) => i && typeof i == "object" && i !== null ? i[s] : void 0, e);
141
+ }
142
+ }
143
+ class h {
144
+ constructor(e) {
145
+ this.formMachine = e;
146
+ }
147
+ validateField(e) {
148
+ const i = this.formMachine.getSnapshot().context.errors;
149
+ return this.formMachine.send({
150
+ type: "VALIDATE_FIELD",
151
+ fieldId: e
152
+ }), !i[e] || i[e].length === 0;
153
+ }
154
+ validateSection(e) {
155
+ return this.formMachine.send({
156
+ type: "VALIDATE_SECTION",
157
+ sectionId: e
158
+ }), !0;
159
+ }
160
+ validateStep(e) {
161
+ return this.formMachine.send({
162
+ type: "VALIDATE_STEP",
163
+ stepId: e
164
+ }), !0;
165
+ }
166
+ }
167
+ class u {
168
+ engine;
169
+ services;
170
+ constructor(e) {
171
+ this.services = {
172
+ navigation: new g(e),
173
+ ui: new p(e),
174
+ data: new d(e),
175
+ validation: new h(e)
176
+ }, this.engine = new l(this.services);
177
+ }
178
+ /**
179
+ * Initialize triggers from form configuration
180
+ */
181
+ initializeFromConfig(e) {
182
+ e.genericTriggerActions?.triggers && this.engine.registerTriggers(
183
+ `form:${e.id}`,
184
+ e.genericTriggerActions.triggers
185
+ );
186
+ for (const t of e.steps) {
187
+ "genericTriggerActions" in t && t.genericTriggerActions?.triggers && this.engine.registerTriggers(
188
+ `step:${t.id}`,
189
+ t.genericTriggerActions.triggers
190
+ );
191
+ const i = "sections" in t ? t : null;
192
+ if (i?.sections)
193
+ for (const s of i.sections) {
194
+ s.genericTriggerActions?.triggers && this.engine.registerTriggers(
195
+ `section:${s.id}`,
196
+ s.genericTriggerActions.triggers
197
+ );
198
+ for (const o of s.components)
199
+ o.genericTriggerActions?.triggers && this.engine.registerTriggers(
200
+ `component:${o.id}`,
201
+ o.genericTriggerActions.triggers
202
+ );
203
+ }
204
+ }
205
+ }
206
+ /**
207
+ * Trigger evaluation for form events
208
+ */
209
+ async evaluateFormTrigger(e, t, i, s) {
210
+ const o = a(
211
+ e,
212
+ "form",
213
+ `form:${t}`,
214
+ {
215
+ formData: i,
216
+ metadata: s
217
+ }
218
+ );
219
+ await this.engine.evaluateTriggers(o);
220
+ }
221
+ /**
222
+ * Trigger evaluation for step events
223
+ */
224
+ async evaluateStepTrigger(e, t, i, s) {
225
+ const o = a(
226
+ e,
227
+ "step",
228
+ `step:${t}`,
229
+ {
230
+ formData: i,
231
+ metadata: s
232
+ }
233
+ );
234
+ await this.engine.evaluateTriggers(o);
235
+ }
236
+ /**
237
+ * Trigger evaluation for section events
238
+ */
239
+ async evaluateSectionTrigger(e, t, i, s) {
240
+ const o = a(
241
+ e,
242
+ "section",
243
+ `section:${t}`,
244
+ {
245
+ formData: i,
246
+ metadata: s
247
+ }
248
+ );
249
+ await this.engine.evaluateTriggers(o);
250
+ }
251
+ /**
252
+ * Trigger evaluation for component events
253
+ */
254
+ async evaluateComponentTrigger(e, t, i, s, o, r) {
255
+ const c = a(
256
+ e,
257
+ "component",
258
+ `component:${t}`,
259
+ {
260
+ currentValue: i,
261
+ previousValue: s,
262
+ formData: o,
263
+ metadata: r
264
+ }
265
+ );
266
+ await this.engine.evaluateTriggers(c);
267
+ }
268
+ /**
269
+ * Register additional triggers dynamically
270
+ */
271
+ registerTriggers(e, t) {
272
+ t.triggers && this.engine.registerTriggers(e, t.triggers);
273
+ }
274
+ /**
275
+ * Cleanup resources
276
+ */
277
+ dispose() {
278
+ this.engine.dispose();
279
+ }
280
+ }
281
+ export {
282
+ u as GenericTriggerService,
283
+ u as default
284
+ };
@@ -0,0 +1,6 @@
1
+ "use client";
2
+ const t = () => null;
3
+ export {
4
+ t as NavigationExecutor,
5
+ t as default
6
+ };
@@ -0,0 +1,115 @@
1
+ "use client";
2
+ import { jsx as e, jsxs as r } from "react/jsx-runtime";
3
+ /* empty css */
4
+ import { Button as N } from "../../../../../../ui/src/components/button/button.js";
5
+ import { Dialog as g, DialogContent as D, DialogHeader as S, DialogTitle as f, DialogDescription as I } from "../../../../../../ui/src/components/dialog/dialog.js";
6
+ import { Sheet as T, SheetContent as M, SheetHeader as _, SheetTitle as B } from "../../../../../../ui/src/components/sheet/sheet.js";
7
+ import { memo as H, useState as x } from "react";
8
+ import { ConfirmationDialog as $ } from "../ConfirmationDialog/ConfirmationDialog.js";
9
+ import { EmailVerificationDialog as b } from "../EmailVerificationDialog/EmailVerificationDialog.js";
10
+ import l from "./ActionDialog.module.css.js";
11
+ const w = H(
12
+ ({ config: t, formData: n, onButtonClick: s, onClose: o, isOpen: i }) => {
13
+ const [c, h] = x(!1);
14
+ if (!t) return null;
15
+ if (console.log("🔍 ActionDialog config:", {
16
+ config: t,
17
+ typeId: t.templateMetadata?.typeId,
18
+ title: t.title
19
+ }), t.templateMetadata?.typeId === "verify-dialog")
20
+ return /* @__PURE__ */ e(
21
+ b,
22
+ {
23
+ config: t,
24
+ formData: n,
25
+ onButtonClick: s,
26
+ onClose: o,
27
+ isOpen: i
28
+ }
29
+ );
30
+ if (t.templateMetadata?.typeId === "confirmation-dialog")
31
+ return /* @__PURE__ */ e(
32
+ $,
33
+ {
34
+ config: t,
35
+ formData: n,
36
+ onButtonClick: s,
37
+ onClose: o,
38
+ isOpen: i
39
+ }
40
+ );
41
+ const y = async (a) => {
42
+ h(!0);
43
+ try {
44
+ s(a.action);
45
+ } finally {
46
+ h(!1);
47
+ }
48
+ }, u = () => {
49
+ t.dismissible !== !1 && !c && o();
50
+ }, v = (a) => {
51
+ switch (a) {
52
+ case "primary":
53
+ return "default";
54
+ case "secondary":
55
+ return "secondary";
56
+ case "danger":
57
+ return "destructive";
58
+ default:
59
+ return "secondary";
60
+ }
61
+ }, d = t.content.replace(
62
+ /\$\{data\.([^}]+)\}/g,
63
+ (a, C) => {
64
+ const p = n[C];
65
+ return p != null ? String(p) : a;
66
+ }
67
+ ), m = () => /* @__PURE__ */ e("div", { className: l.buttonRow, children: t.buttons.map((a) => /* @__PURE__ */ e(
68
+ N,
69
+ {
70
+ variant: v(a.variant),
71
+ onClick: () => y(a),
72
+ disabled: c,
73
+ className: l.minWidthButton,
74
+ children: a.label
75
+ },
76
+ `${a.label}-${a.action}`
77
+ )) });
78
+ return t.type === "toast" ? i ? /* @__PURE__ */ e("div", { className: l.toastContainer, children: /* @__PURE__ */ r("div", { className: l.toastCard, children: [
79
+ /* @__PURE__ */ r("div", { children: [
80
+ /* @__PURE__ */ e("h3", { className: l.toastTitle, children: t.title }),
81
+ /* @__PURE__ */ e(
82
+ "div",
83
+ {
84
+ className: l.toastContent,
85
+ dangerouslySetInnerHTML: { __html: d }
86
+ }
87
+ )
88
+ ] }),
89
+ /* @__PURE__ */ e(m, {})
90
+ ] }) }) : null : t.type === "sidebar" ? /* @__PURE__ */ e(T, { open: i, onOpenChange: (a) => !a && u(), children: /* @__PURE__ */ r(M, { className: l.sheetContent, children: [
91
+ /* @__PURE__ */ e(_, { children: /* @__PURE__ */ e(B, { children: t.title }) }),
92
+ /* @__PURE__ */ r("div", { className: l.sheetBody, children: [
93
+ /* @__PURE__ */ e(
94
+ "div",
95
+ {
96
+ className: l.sheetText,
97
+ dangerouslySetInnerHTML: { __html: d }
98
+ }
99
+ ),
100
+ /* @__PURE__ */ e(m, {})
101
+ ] })
102
+ ] }) }) : /* @__PURE__ */ e(g, { open: i, onOpenChange: (a) => !a && u(), children: /* @__PURE__ */ r(D, { className: l[`size-${t.size || "medium"}`], children: [
103
+ /* @__PURE__ */ r(S, { children: [
104
+ /* @__PURE__ */ e(f, { children: t.title }),
105
+ /* @__PURE__ */ e(I, { asChild: !0, children: /* @__PURE__ */ e("div", { dangerouslySetInnerHTML: { __html: d } }) })
106
+ ] }),
107
+ /* @__PURE__ */ e("div", { className: l.modalButtonRow, children: /* @__PURE__ */ e(m, {}) })
108
+ ] }) });
109
+ }
110
+ );
111
+ w.displayName = "ActionDialog";
112
+ export {
113
+ w as ActionDialog,
114
+ w as default
115
+ };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ const t = "fb-buttonRow_IpMPI", o = "fb-minWidthButton_Ggq-E", e = "fb-toastContainer_iL55M", s = "fb-toastCard_EslQ-", n = "fb-toastTitle_W3izr", a = "fb-toastContent_h6A9y", i = "fb-sheetContent_Ccs86", b = "fb-sheetBody_XqkvA", d = "fb-sheetText_yRGd-", l = "fb-modalButtonRow_c7V4P", c = {
3
+ buttonRow: t,
4
+ minWidthButton: o,
5
+ toastContainer: e,
6
+ toastCard: s,
7
+ toastTitle: n,
8
+ toastContent: a,
9
+ sheetContent: i,
10
+ sheetBody: b,
11
+ sheetText: d,
12
+ "size-small": "fb-size-small_YcmVE",
13
+ "size-medium": "fb-size-medium_auCiA",
14
+ "size-large": "fb-size-large_8EHM7",
15
+ modalButtonRow: l
16
+ };
17
+ export {
18
+ t as buttonRow,
19
+ c as default,
20
+ o as minWidthButton,
21
+ l as modalButtonRow,
22
+ b as sheetBody,
23
+ i as sheetContent,
24
+ d as sheetText,
25
+ s as toastCard,
26
+ e as toastContainer,
27
+ a as toastContent,
28
+ n as toastTitle
29
+ };
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { jsx as o, jsxs as a, Fragment as f } from "react/jsx-runtime";
3
+ /* empty css */
4
+ import { Button as p } from "../../../../../../ui/src/components/button/button.js";
5
+ import { Dialog as h, DialogContent as u, DialogHeader as C, DialogTitle as c, DialogDescription as s } from "../../../../../../ui/src/components/dialog/dialog.js";
6
+ import { HelpCircle as m, Info as D, AlertTriangle as N } from "lucide-react";
7
+ import { memo as v } from "react";
8
+ import e from "./ConfirmationDialog.module.css.js";
9
+ const y = v(
10
+ ({
11
+ config: i,
12
+ formData: I,
13
+ onButtonClick: d,
14
+ onClose: w,
15
+ isOpen: t
16
+ }) => {
17
+ console.log("🔍 ConfirmationDialog rendering!", { isOpen: t, config: i });
18
+ const l = i.templateMetadata, g = (n) => {
19
+ console.log("🔥 ConfirmationDialog: Button clicked with action:", n), console.log("🔥 ConfirmationDialog: Action type:", n.type), console.log(
20
+ "🔥 ConfirmationDialog: Action details:",
21
+ JSON.stringify(n, null, 2)
22
+ ), d(n), console.log("🔥 ConfirmationDialog: onButtonClick called");
23
+ }, r = (() => {
24
+ if (!l?.showIcon) return null;
25
+ switch (l?.iconType) {
26
+ case "warning":
27
+ return /* @__PURE__ */ o(N, { className: e.iconWarning });
28
+ case "question":
29
+ return /* @__PURE__ */ o(m, { className: e.iconInfo });
30
+ case "info":
31
+ return /* @__PURE__ */ o(D, { className: e.iconInfo });
32
+ default:
33
+ return /* @__PURE__ */ o(m, { className: e.iconInfo });
34
+ }
35
+ })();
36
+ return /* @__PURE__ */ o(h, { open: t, onOpenChange: () => !1, children: /* @__PURE__ */ a(u, { className: e.dialogContent, children: [
37
+ /* @__PURE__ */ o(C, { children: r ? /* @__PURE__ */ a("div", { className: e.iconRow, children: [
38
+ /* @__PURE__ */ o("div", { className: e.iconCircle, children: r }),
39
+ /* @__PURE__ */ a("div", { children: [
40
+ /* @__PURE__ */ o(c, { children: i.title }),
41
+ /* @__PURE__ */ o(s, { className: e.descriptionSpaced, children: i.content })
42
+ ] })
43
+ ] }) : /* @__PURE__ */ a(f, { children: [
44
+ /* @__PURE__ */ o(c, { children: i.title }),
45
+ /* @__PURE__ */ o(s, { children: i.content })
46
+ ] }) }),
47
+ /* @__PURE__ */ o("div", { className: e.buttonRow, children: i.buttons.map((n) => /* @__PURE__ */ o(
48
+ p,
49
+ {
50
+ variant: n.variant === "danger" ? "destructive" : n.variant === "secondary" ? "outline" : "default",
51
+ onClick: () => g(n.action),
52
+ className: e.minWidthButton,
53
+ children: n.label
54
+ },
55
+ n.id
56
+ )) })
57
+ ] }) });
58
+ }
59
+ );
60
+ y.displayName = "ConfirmationDialog";
61
+ export {
62
+ y as ConfirmationDialog,
63
+ y as default
64
+ };
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ const n = "fb-dialogContent_MQjVY", o = "fb-iconRow_zoQXV", t = "fb-iconCircle_UvpAZ", i = "fb-descriptionSpaced_AmH9W", c = "fb-buttonRow_lfgxL", e = "fb-minWidthButton_maffF", s = "fb-iconWarning_OcS7O", f = "fb-iconInfo_xQhjd", d = {
3
+ dialogContent: n,
4
+ iconRow: o,
5
+ iconCircle: t,
6
+ descriptionSpaced: i,
7
+ buttonRow: c,
8
+ minWidthButton: e,
9
+ iconWarning: s,
10
+ iconInfo: f
11
+ };
12
+ export {
13
+ c as buttonRow,
14
+ d as default,
15
+ i as descriptionSpaced,
16
+ n as dialogContent,
17
+ t as iconCircle,
18
+ f as iconInfo,
19
+ o as iconRow,
20
+ s as iconWarning,
21
+ e as minWidthButton
22
+ };
@@ -0,0 +1,149 @@
1
+ "use client";
2
+ import { jsx as e, jsxs as o } from "react/jsx-runtime";
3
+ /* empty css */
4
+ import { Alert as E, AlertDescription as $ } from "../../../../../../ui/src/components/alert/alert.js";
5
+ import { Button as m } from "../../../../../../ui/src/components/button/button.js";
6
+ import { Dialog as D, DialogContent as V, DialogHeader as x, DialogTitle as A, DialogDescription as L } from "../../../../../../ui/src/components/dialog/dialog.js";
7
+ import { ValidationCode as P } from "../../../../../../ui/src/components/ValidationCode/ValidationCode.js";
8
+ import { CheckCircle as _, Mail as j, AlertCircle as q } from "lucide-react";
9
+ import { memo as H, useState as f, useEffect as I, useCallback as W } from "react";
10
+ import i from "./EmailVerificationDialog.module.css.js";
11
+ const Y = H(
12
+ ({
13
+ config: h,
14
+ formData: z,
15
+ onButtonClick: g,
16
+ onClose: F,
17
+ isOpen: u
18
+ }) => {
19
+ console.log("🔥 EmailVerificationDialog rendering!", { isOpen: u, config: h });
20
+ const t = h.templateMetadata, [c, C] = f(""), [n, r] = f("idle"), [p, l] = f(""), [d, v] = f(0), [b, k] = f(0);
21
+ I(() => {
22
+ if (d > 0) {
23
+ const a = setTimeout(() => v(d - 1), 1e3);
24
+ return () => clearTimeout(a);
25
+ }
26
+ }, [d]);
27
+ const N = W(async () => {
28
+ r("verifying");
29
+ const a = b + 1;
30
+ k(a);
31
+ try {
32
+ if (await new Promise((s) => setTimeout(s, 1500)), c === "123456" || c === "000000" || c === "111111")
33
+ r("success");
34
+ else {
35
+ const s = t?.maxAttempts;
36
+ if (s && a >= s)
37
+ r("blocked"), l(
38
+ "Maximum verification attempts exceeded. Please request a new verification code."
39
+ );
40
+ else {
41
+ r("error");
42
+ const M = s ? s - a : null, R = t?.errorMessage || "Invalid code. Please try again.", S = M ? ` (${M} attempts remaining)` : "";
43
+ l(R + S);
44
+ }
45
+ }
46
+ } catch {
47
+ r("error"), l(
48
+ t?.errorMessage || "Verification failed. Please try again."
49
+ );
50
+ }
51
+ }, [
52
+ c,
53
+ t?.errorMessage,
54
+ t?.maxAttempts,
55
+ b
56
+ ]), w = (a) => {
57
+ C(a), (n === "error" || n === "blocked") && (r("idle"), l(""));
58
+ }, T = (a) => {
59
+ console.log("completedCode", a), t?.enableAutoSubmit && n === "idle" && N();
60
+ }, y = () => {
61
+ v(t?.resendTimer || 60), C(""), r("idle"), l(""), k(0);
62
+ }, B = () => {
63
+ g({ type: "close" });
64
+ };
65
+ return n === "success" ? /* @__PURE__ */ e(D, { open: u, onOpenChange: () => !1, children: /* @__PURE__ */ o(V, { className: i.dialogContent, children: [
66
+ /* @__PURE__ */ o(x, { children: [
67
+ /* @__PURE__ */ o("div", { className: i.headerRow, children: [
68
+ /* @__PURE__ */ e(_, { className: `${i.iconMd} ${i.iconSuccess}` }),
69
+ /* @__PURE__ */ e(A, { children: t?.successTitle || "Verification Successful" })
70
+ ] }),
71
+ /* @__PURE__ */ e(L, { children: t?.successMessage || "Your email has been verified successfully." })
72
+ ] }),
73
+ /* @__PURE__ */ e("div", { className: i.successButtonRow, children: /* @__PURE__ */ e(
74
+ m,
75
+ {
76
+ onClick: () => g(
77
+ t?.onVerifiedAction || {
78
+ type: "navigate",
79
+ direction: "next"
80
+ }
81
+ ),
82
+ className: i.minWidthButton,
83
+ children: t?.continueButtonLabel || "Continue"
84
+ }
85
+ ) })
86
+ ] }) }) : /* @__PURE__ */ e(D, { open: u, onOpenChange: () => !1, children: /* @__PURE__ */ o(V, { className: i.dialogContent, children: [
87
+ /* @__PURE__ */ o(x, { children: [
88
+ /* @__PURE__ */ o("div", { className: i.headerRow, children: [
89
+ /* @__PURE__ */ e(j, { className: `${i.iconMd} ${i.iconMail}` }),
90
+ /* @__PURE__ */ e(A, { children: h.title })
91
+ ] }),
92
+ /* @__PURE__ */ e(L, { children: h.content })
93
+ ] }),
94
+ /* @__PURE__ */ o("div", { className: i.formContent, children: [
95
+ /* @__PURE__ */ o("div", { className: i.codeSection, children: [
96
+ /* @__PURE__ */ e("div", { className: i.codeLabel, children: "Verification Code" }),
97
+ /* @__PURE__ */ e("div", { className: i.codeCenter, children: /* @__PURE__ */ e(
98
+ P,
99
+ {
100
+ maxLength: t?.codeLength || 6,
101
+ value: c,
102
+ onChange: w,
103
+ onComplete: T,
104
+ disabled: n === "verifying" || n === "blocked"
105
+ }
106
+ ) })
107
+ ] }),
108
+ (n === "error" || n === "blocked") && p && /* @__PURE__ */ o(E, { variant: "destructive", children: [
109
+ /* @__PURE__ */ e(q, { className: i.iconSm }),
110
+ /* @__PURE__ */ e($, { children: p })
111
+ ] }),
112
+ t?.enableResend && n !== "blocked" && /* @__PURE__ */ e("div", { className: i.resendText, children: d > 0 ? `Resend code in ${d}s` : /* @__PURE__ */ e(
113
+ m,
114
+ {
115
+ variant: "link",
116
+ onClick: y,
117
+ className: i.resendLinkDefault,
118
+ children: t?.resendButtonLabel || "Send new code"
119
+ }
120
+ ) }),
121
+ n === "blocked" && /* @__PURE__ */ e("div", { className: i.blockedText, children: /* @__PURE__ */ e(
122
+ m,
123
+ {
124
+ variant: "link",
125
+ onClick: y,
126
+ className: i.resendLink,
127
+ children: t?.resendButtonLabel || "Request new verification code"
128
+ }
129
+ ) })
130
+ ] }),
131
+ /* @__PURE__ */ o("div", { className: i.footerButtonRow, children: [
132
+ /* @__PURE__ */ e(m, { variant: "secondary", onClick: B, children: t?.cancelButtonLabel || "Cancel" }),
133
+ /* @__PURE__ */ e(
134
+ m,
135
+ {
136
+ onClick: N,
137
+ disabled: c.length !== (t?.codeLength || 6) || n === "verifying" || n === "blocked",
138
+ children: n === "verifying" ? "Verifying..." : n === "blocked" ? "Blocked" : t?.verifyButtonLabel || "Verify Email"
139
+ }
140
+ )
141
+ ] })
142
+ ] }) });
143
+ }
144
+ );
145
+ Y.displayName = "EmailVerificationDialog";
146
+ export {
147
+ Y as EmailVerificationDialog,
148
+ Y as default
149
+ };