@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,77 @@
1
+ "use client";
2
+ function d(e, s) {
3
+ if (!e || !e.conditions.length)
4
+ return !0;
5
+ const { action: u, logicalOperator: a, conditions: n } = e, r = n.map(
6
+ (i) => f(i, s)
7
+ );
8
+ let t;
9
+ return a === "and" ? t = r.every((i) => i) : t = r.some((i) => i), u === "show" ? t : !t;
10
+ }
11
+ function f(e, s) {
12
+ const { fieldId: u, operator: a, value: n, caseSensitive: r = !0 } = e, t = s[u];
13
+ switch (a) {
14
+ case "equals":
15
+ return o(t, n, r, "equals");
16
+ case "notEquals":
17
+ return !o(t, n, r, "equals");
18
+ case "contains":
19
+ return o(t, n, r, "contains");
20
+ case "notContains":
21
+ return !o(t, n, r, "contains");
22
+ case "isEmpty":
23
+ return l(t);
24
+ case "isNotEmpty":
25
+ return !l(t);
26
+ case "greaterThan":
27
+ return c(t, n, "greaterThan");
28
+ case "lessThan":
29
+ return c(t, n, "lessThan");
30
+ case "in":
31
+ return Array.isArray(n) && n.some((i) => o(t, i, r, "equals"));
32
+ case "notIn":
33
+ return !Array.isArray(n) || !n.some(
34
+ (i) => o(t, i, r, "equals")
35
+ );
36
+ default:
37
+ return console.warn(`Unknown visibility condition operator: ${a}`), !1;
38
+ }
39
+ }
40
+ function o(e, s, u, a) {
41
+ if (e == null && s == null)
42
+ return a === "equals";
43
+ if (e == null || s == null)
44
+ return !1;
45
+ let n = String(e), r = String(s);
46
+ switch (u || (n = n.toLowerCase(), r = r.toLowerCase()), a) {
47
+ case "equals":
48
+ return n === r;
49
+ case "contains":
50
+ return n.includes(r);
51
+ default:
52
+ return !1;
53
+ }
54
+ }
55
+ function c(e, s, u) {
56
+ const a = Number(e), n = Number(s);
57
+ if (isNaN(a) || isNaN(n))
58
+ return !1;
59
+ switch (u) {
60
+ case "greaterThan":
61
+ return a > n;
62
+ case "lessThan":
63
+ return a < n;
64
+ default:
65
+ return !1;
66
+ }
67
+ }
68
+ function l(e) {
69
+ return e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : typeof e == "object" ? Object.keys(e).length === 0 : !1;
70
+ }
71
+ function m(e) {
72
+ return e ? e.conditions.map((s) => s.fieldId) : [];
73
+ }
74
+ export {
75
+ d as evaluateVisibility,
76
+ m as getVisibilityDependencies
77
+ };
@@ -0,0 +1,215 @@
1
+ "use client";
2
+ import { findComponentActions as g } from "../helpers/triggerHelpers.js";
3
+ const C = ({
4
+ context: c,
5
+ event: l,
6
+ self: n
7
+ }) => {
8
+ if (l.type !== "TRIGGER_COMPONENT_ACTION") return;
9
+ const { componentId: e, actionId: s } = l, r = g(c.config, e).find((t) => t.id === s);
10
+ if (r) {
11
+ n.send({
12
+ type: "COMPONENT_ACTION_START",
13
+ componentId: e,
14
+ actionId: s
15
+ });
16
+ try {
17
+ switch (r.type) {
18
+ case "showAlert": {
19
+ const t = r.config, o = `${e}-${s}`, a = {
20
+ id: o,
21
+ componentId: e,
22
+ message: t.message,
23
+ type: t.type,
24
+ position: t.position,
25
+ dismissible: t.dismissible,
26
+ timestamp: Date.now(),
27
+ autoHide: t.autoHide,
28
+ autoHideDelay: t.autoHideDelay
29
+ };
30
+ n.send({
31
+ type: "SHOW_COMPONENT_ALERT",
32
+ componentId: e,
33
+ alert: a
34
+ }), t.autoHide && t.autoHideDelay && setTimeout(() => {
35
+ n.send({
36
+ type: "DISMISS_COMPONENT_ALERT",
37
+ componentId: e,
38
+ alertId: o
39
+ });
40
+ }, t.autoHideDelay), n.send({
41
+ type: "COMPONENT_ACTION_COMPLETE",
42
+ componentId: e,
43
+ actionId: s,
44
+ result: { alertId: o }
45
+ });
46
+ break;
47
+ }
48
+ case "executeVerifyDialog": {
49
+ const o = r.config.postAction || {
50
+ type: "close"
51
+ };
52
+ let a;
53
+ switch (o.type) {
54
+ case "close":
55
+ case "saveSection":
56
+ a = {
57
+ type: "custom",
58
+ handler: "updateOriginalValue",
59
+ componentId: e
60
+ };
61
+ break;
62
+ case "nextStep":
63
+ a = {
64
+ type: "navigate",
65
+ direction: "next",
66
+ updateOriginalValue: !0,
67
+ componentId: e
68
+ };
69
+ break;
70
+ case "navigate":
71
+ a = {
72
+ type: "navigate",
73
+ direction: o.direction,
74
+ targetStep: o.targetStep,
75
+ updateOriginalValue: !0,
76
+ componentId: e
77
+ };
78
+ break;
79
+ default:
80
+ a = {
81
+ type: "custom",
82
+ handler: "updateOriginalValue",
83
+ componentId: e
84
+ };
85
+ }
86
+ const d = {
87
+ title: "Verify Changes",
88
+ content: "Please verify your changes before continuing.",
89
+ type: "modal",
90
+ size: "small",
91
+ buttons: [
92
+ {
93
+ id: "cancel-btn",
94
+ label: "Cancel",
95
+ variant: "secondary",
96
+ action: { type: "close" }
97
+ },
98
+ {
99
+ id: "verify-btn",
100
+ label: "Verify",
101
+ variant: "primary",
102
+ action: { type: "close" }
103
+ // Will be overridden by onVerifiedAction
104
+ }
105
+ ],
106
+ dismissible: !0,
107
+ templateMetadata: {
108
+ typeId: "verify-dialog",
109
+ isGeneric: !0,
110
+ componentId: e,
111
+ onVerifiedAction: a
112
+ // This will be used by EmailVerificationDialog
113
+ }
114
+ };
115
+ n.send({
116
+ type: "SHOW_DIALOG",
117
+ dialog: d
118
+ }), n.send({
119
+ type: "COMPONENT_ACTION_COMPLETE",
120
+ componentId: e,
121
+ actionId: s,
122
+ result: { dialogConfig: d }
123
+ });
124
+ break;
125
+ }
126
+ case "executeVerifyEmailDialog": {
127
+ const t = r.config;
128
+ let o = {
129
+ ...t.templateConfig.onVerifiedAction,
130
+ componentId: e
131
+ // Set the current component ID
132
+ };
133
+ const a = c.config.steps[c.currentStepIndex];
134
+ ("sections" in a ? a.sections?.find(
135
+ (u) => u.components?.some(
136
+ (y) => y.id === e
137
+ )
138
+ ) : void 0)?.mode === "editable" && (o = {
139
+ type: "custom",
140
+ handler: "updateOriginalValue",
141
+ componentId: e
142
+ });
143
+ const i = {
144
+ ...t.templateConfig,
145
+ onVerifiedAction: o
146
+ }, p = {
147
+ title: i.title,
148
+ content: i.description,
149
+ type: "modal",
150
+ buttons: [
151
+ {
152
+ id: "cancel-btn",
153
+ label: i.cancelButtonLabel,
154
+ variant: "secondary",
155
+ action: i.onCancelAction || {
156
+ type: "close"
157
+ }
158
+ },
159
+ {
160
+ id: "verify-btn",
161
+ label: i.verifyButtonLabel,
162
+ variant: "primary",
163
+ action: { type: "custom", handler: "verifyEmail" }
164
+ }
165
+ ],
166
+ dismissible: !0,
167
+ templateMetadata: {
168
+ typeId: "verify-dialog",
169
+ codeLength: i.codeLength,
170
+ codeType: i.codeType,
171
+ enableAutoSubmit: i.enableAutoSubmit,
172
+ enableResend: i.enableResend,
173
+ resendTimer: i.resendTimer,
174
+ successTitle: i.successTitle,
175
+ successMessage: i.successMessage,
176
+ errorMessage: i.errorMessage,
177
+ continueButtonLabel: i.continueButtonLabel,
178
+ onVerifiedAction: i.onVerifiedAction || {
179
+ type: "navigate",
180
+ direction: "next"
181
+ }
182
+ }
183
+ };
184
+ n.send({
185
+ type: "SHOW_ACTION_DIALOG",
186
+ dialogConfig: p
187
+ }), n.send({
188
+ type: "COMPONENT_ACTION_COMPLETE",
189
+ componentId: e,
190
+ actionId: s,
191
+ result: { dialogShown: !0 }
192
+ });
193
+ break;
194
+ }
195
+ default:
196
+ n.send({
197
+ type: "COMPONENT_ACTION_FAILED",
198
+ componentId: e,
199
+ actionId: s,
200
+ error: new Error(`Unsupported action type: ${r.type}`)
201
+ });
202
+ }
203
+ } catch (t) {
204
+ n.send({
205
+ type: "COMPONENT_ACTION_FAILED",
206
+ componentId: e,
207
+ actionId: s,
208
+ error: t instanceof Error ? t : new Error(String(t))
209
+ });
210
+ }
211
+ }
212
+ };
213
+ export {
214
+ C as executeComponentAction
215
+ };
@@ -0,0 +1,122 @@
1
+ "use client";
2
+ import { assign as t } from "xstate";
3
+ t({
4
+ currentStepIndex: ({ context: e }) => Math.min(
5
+ e.currentStepIndex + 1,
6
+ e.config.steps.length - 1
7
+ ),
8
+ currentStepId: ({ context: e }) => {
9
+ const n = Math.min(
10
+ e.currentStepIndex + 1,
11
+ e.config.steps.length - 1
12
+ );
13
+ return e.config.steps[n]?.id || "";
14
+ },
15
+ pendingNavigation: null
16
+ });
17
+ t({
18
+ currentStepIndex: ({ context: e }) => Math.max(e.currentStepIndex - 1, 0),
19
+ currentStepId: ({ context: e }) => {
20
+ const n = Math.max(e.currentStepIndex - 1, 0);
21
+ return e.config.steps[n]?.id || "";
22
+ },
23
+ pendingNavigation: null
24
+ });
25
+ t({
26
+ currentStepIndex: ({ context: e, event: n }) => {
27
+ if (n.type !== "GO_TO_STEP") return e.currentStepIndex;
28
+ const i = e.config.steps.findIndex(
29
+ (r) => r.id === n.stepId
30
+ );
31
+ return i >= 0 ? i : e.currentStepIndex;
32
+ },
33
+ currentStepId: ({ context: e, event: n }) => n.type !== "GO_TO_STEP" ? e.currentStepId : n.stepId,
34
+ pendingNavigation: null
35
+ });
36
+ t({
37
+ currentStepIndex: ({ context: e }) => {
38
+ const n = e.config.steps.findIndex(
39
+ (i) => i.id === e.pendingNavigation?.stepId
40
+ );
41
+ return n >= 0 ? n : e.currentStepIndex;
42
+ },
43
+ currentStepId: ({ context: e }) => e.pendingNavigation?.stepId || e.currentStepId,
44
+ pendingNavigation: null,
45
+ canNavigate: !0
46
+ });
47
+ t({
48
+ pendingNavigation: { type: "next" }
49
+ });
50
+ t({
51
+ pendingNavigation: { type: "previous" }
52
+ });
53
+ t({
54
+ pendingNavigation: ({ event: e }) => e.type !== "GO_TO_STEP" ? null : {
55
+ type: "step",
56
+ stepId: e.stepId
57
+ }
58
+ });
59
+ t({
60
+ pendingNavigation: ({ event: e }) => {
61
+ if (e.type !== "REQUEST_NAVIGATION") return null;
62
+ const n = {
63
+ type: e.navigationType
64
+ };
65
+ return e.stepId !== void 0 && (n.stepId = e.stepId), n;
66
+ }
67
+ });
68
+ t({
69
+ pendingNavigation: null,
70
+ canNavigate: !0
71
+ });
72
+ t({
73
+ pendingNavigation: null,
74
+ canNavigate: !1
75
+ });
76
+ t({
77
+ currentStepIndex: 0,
78
+ currentStepId: ({ context: e }) => e.config.steps[0]?.id || "",
79
+ data: {},
80
+ errors: {},
81
+ dirtyFields: {},
82
+ touchedFields: {},
83
+ componentTriggerState: {},
84
+ activeComponentActions: {},
85
+ componentAlerts: {},
86
+ activeActions: {},
87
+ executingTrigger: null,
88
+ waitingForActions: !1,
89
+ canNavigate: !0,
90
+ pendingNavigation: null,
91
+ activeDialog: null,
92
+ componentOriginalValues: {},
93
+ fieldChangeState: {},
94
+ fieldValidationState: {
95
+ activeWarnings: [],
96
+ pendingVerifications: [],
97
+ verificationResults: {}
98
+ }
99
+ });
100
+ const p = ({
101
+ context: e,
102
+ self: n
103
+ }) => {
104
+ if (e.pendingNavigation)
105
+ switch (e.pendingNavigation.type) {
106
+ case "next":
107
+ n.send({ type: "NEXT" });
108
+ break;
109
+ case "previous":
110
+ n.send({ type: "PREVIOUS" });
111
+ break;
112
+ case "step":
113
+ n.send({
114
+ type: "GO_TO_STEP",
115
+ stepId: e.pendingNavigation.stepId
116
+ });
117
+ break;
118
+ }
119
+ };
120
+ export {
121
+ p as executePendingNavigation
122
+ };
@@ -0,0 +1,101 @@
1
+ "use client";
2
+ import { assign as t } from "xstate";
3
+ import { ComponentTriggerEngine as r } from "../componentTriggerEngine.js";
4
+ t({
5
+ saveState: ({
6
+ context: e,
7
+ event: a
8
+ }) => a.type !== "START_SAVE" ? e.saveState : {
9
+ ...e.saveState,
10
+ saveInProgress: !0,
11
+ saveInitiator: a.initiator,
12
+ savingSection: a.sectionId,
13
+ saveStartTimestamp: Date.now(),
14
+ pendingVerifications: [],
15
+ completedVerifications: [],
16
+ validationErrors: {}
17
+ }
18
+ });
19
+ t({
20
+ saveState: ({
21
+ context: e,
22
+ event: a
23
+ }) => a.type !== "SAVE_DIALOG_SHOWN" ? e.saveState : {
24
+ ...e.saveState,
25
+ pendingVerifications: [
26
+ ...e.saveState.pendingVerifications,
27
+ a.dialogId
28
+ ]
29
+ }
30
+ });
31
+ t({
32
+ saveState: ({ context: e }) => {
33
+ const a = r.createExecutionPlan(
34
+ e.config,
35
+ "save",
36
+ e.currentStepIndex,
37
+ e
38
+ );
39
+ return {
40
+ ...e.saveState,
41
+ executionPlan: a
42
+ };
43
+ }
44
+ });
45
+ const c = ({
46
+ context: e,
47
+ self: a
48
+ }) => {
49
+ const i = e.saveState.executionPlan;
50
+ i && (i.executions.forEach((n) => {
51
+ n.actions.forEach((s) => {
52
+ a.send({
53
+ type: "EXECUTE_CONTEXT_ACTION",
54
+ execution: n,
55
+ action: s
56
+ });
57
+ });
58
+ }), i.totalActions === 0 && a.send({
59
+ type: "SAVE_ACTIONS_COMPLETE",
60
+ sectionId: e.saveState.savingSection || "",
61
+ results: {}
62
+ }));
63
+ };
64
+ t({
65
+ activeDialog: null,
66
+ saveState: ({ context: e }) => ({
67
+ ...e.saveState,
68
+ completedVerifications: [
69
+ ...e.saveState.completedVerifications,
70
+ `${e.activeDialog?.templateMetadata?.componentId || "unknown"}`
71
+ ]
72
+ })
73
+ });
74
+ t({
75
+ activeDialog: null,
76
+ saveState: ({ context: e }) => ({
77
+ ...e.saveState,
78
+ saveInProgress: !1,
79
+ saveInitiator: null,
80
+ savingSection: null,
81
+ pendingVerifications: [],
82
+ completedVerifications: [],
83
+ validationErrors: {},
84
+ executionPlan: null
85
+ })
86
+ });
87
+ t({
88
+ saveState: ({ context: e }) => ({
89
+ ...e.saveState,
90
+ saveInProgress: !1,
91
+ saveInitiator: null,
92
+ savingSection: null,
93
+ pendingVerifications: [],
94
+ completedVerifications: [],
95
+ validationErrors: {},
96
+ executionPlan: null
97
+ })
98
+ });
99
+ export {
100
+ c as executeSaveActions
101
+ };