@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,156 @@
1
+ "use client";
2
+ /* empty css */
3
+ import { getTemplateTypeFromId as o } from "../../../../../ui/src/lib/utils/templateUtils.js";
4
+ const a = {
5
+ generic: {
6
+ permissions: {
7
+ // Generic templates are completely locked - only navigation and step title can be changed
8
+ canAddComponents: !1,
9
+ canRemoveComponents: !1,
10
+ canEditComponentProperties: !1,
11
+ canAddSections: !1,
12
+ canRemoveSections: !1,
13
+ canEditSectionProperties: !1,
14
+ canEditStepTitle: !0,
15
+ // Allow title customization for generic templates
16
+ canEditNavigation: !0,
17
+ // Allow navigation customization
18
+ canEditActions: !1,
19
+ canDuplicate: !1,
20
+ // Generic templates cannot be duplicated
21
+ canDelete: !0
22
+ // But they can be removed from forms
23
+ },
24
+ display: {
25
+ type: "generic",
26
+ isReadonly: !0,
27
+ showLockIcon: !0,
28
+ themeClass: "bg-indigo-50 border-indigo-200 text-indigo-900 hover:bg-indigo-100",
29
+ iconColor: "text-indigo-600",
30
+ lockTooltip: "Generic template - Only title and navigation can be customized",
31
+ badgeText: "Generic"
32
+ },
33
+ rules: {
34
+ lockMessage: "This is a generic template. Only the step title and navigation settings can be modified.",
35
+ supportsMultipleSteps: !0,
36
+ defaultNavigation: {
37
+ next: { label: "Next", enabled: !0 },
38
+ previous: { label: "Previous", enabled: !0 }
39
+ }
40
+ }
41
+ },
42
+ team: {
43
+ permissions: {
44
+ // Team templates allow full editing like normal steps
45
+ canAddComponents: !0,
46
+ canRemoveComponents: !0,
47
+ canEditComponentProperties: !0,
48
+ canAddSections: !0,
49
+ canRemoveSections: !0,
50
+ canEditSectionProperties: !0,
51
+ canEditStepTitle: !0,
52
+ canEditNavigation: !0,
53
+ canEditActions: !0,
54
+ canDuplicate: !0,
55
+ canDelete: !0
56
+ },
57
+ display: {
58
+ type: "team",
59
+ isReadonly: !1,
60
+ showLockIcon: !1,
61
+ themeClass: "bg-emerald-50 border-emerald-200 text-emerald-900 hover:bg-emerald-100",
62
+ iconColor: "text-emerald-600",
63
+ badgeText: "Team"
64
+ },
65
+ rules: {
66
+ lockMessage: "",
67
+ // No restrictions for team templates
68
+ supportsMultipleSteps: !0,
69
+ defaultNavigation: {
70
+ next: { label: "Next", enabled: !0 },
71
+ previous: { label: "Previous", enabled: !0 }
72
+ }
73
+ }
74
+ }
75
+ }, s = {
76
+ permissions: {
77
+ canAddComponents: !0,
78
+ canRemoveComponents: !0,
79
+ canEditComponentProperties: !0,
80
+ canAddSections: !0,
81
+ canRemoveSections: !0,
82
+ canEditSectionProperties: !0,
83
+ canEditStepTitle: !0,
84
+ canEditNavigation: !0,
85
+ canEditActions: !0,
86
+ canDuplicate: !0,
87
+ canDelete: !0
88
+ },
89
+ display: {
90
+ type: null,
91
+ isReadonly: !1,
92
+ showLockIcon: !1,
93
+ themeClass: "bg-white border-muted",
94
+ iconColor: "text-muted-foreground"
95
+ },
96
+ rules: {
97
+ lockMessage: "",
98
+ supportsMultipleSteps: !1,
99
+ defaultNavigation: {
100
+ next: { label: "Next", enabled: !0 },
101
+ previous: { label: "Previous", enabled: !0 }
102
+ }
103
+ }
104
+ };
105
+ function i(e) {
106
+ let t = null;
107
+ if (typeof e == "string" ? t = e : "templateId" in e && (t = e.templateId), !t)
108
+ return s;
109
+ const n = o(t);
110
+ return n && a[n] ? a[n] : s;
111
+ }
112
+ function u(e) {
113
+ return i(e).permissions;
114
+ }
115
+ function g(e) {
116
+ return i(e).display;
117
+ }
118
+ function d(e, t) {
119
+ return u(e)[t];
120
+ }
121
+ function T(e, t) {
122
+ return "templateId" in e ? i(e).display.isReadonly : t ? i(t.templateId).display.isReadonly : !1;
123
+ }
124
+ function p(e) {
125
+ return i(e).rules.lockMessage;
126
+ }
127
+ function y(e, t) {
128
+ if (d(e, t))
129
+ return { allowed: !0 };
130
+ const l = p(e), c = i(e);
131
+ return {
132
+ allowed: !1,
133
+ message: l || `This action is not allowed for ${c.display.badgeText || "this"} templates.`
134
+ };
135
+ }
136
+ function r(e) {
137
+ return typeof e == "string" ? o(e) : "templateId" in e ? o(e.templateId) : null;
138
+ }
139
+ function b(e) {
140
+ return r(e) === "generic";
141
+ }
142
+ function v(e) {
143
+ return r(e) === "team";
144
+ }
145
+ export {
146
+ p as getLockMessage,
147
+ i as getTemplateConfig,
148
+ g as getTemplateDisplayConfig,
149
+ u as getTemplatePermissions,
150
+ r as getTemplateTypeFromInput,
151
+ d as isActionAllowed,
152
+ b as isGenericTemplateInput,
153
+ T as isStepLocked,
154
+ v as isTeamTemplateInput,
155
+ y as validateTemplateAction
156
+ };
@@ -0,0 +1,265 @@
1
+ "use client";
2
+ /* empty css */
3
+ import { isGenericTemplate as y, isTeamTemplate as b } from "../../../../../ui/src/lib/utils/templateUtils.js";
4
+ async function m() {
5
+ try {
6
+ const { templateStorageService: e } = await import("@formbuilder/builder");
7
+ return e;
8
+ } catch (e) {
9
+ return console.warn("Template storage service not available:", e), null;
10
+ }
11
+ }
12
+ async function u() {
13
+ try {
14
+ const e = await m();
15
+ if (!e) return;
16
+ if (!e.isReady()) {
17
+ const r = await fetch("/form.config.json");
18
+ if (r.ok) {
19
+ const t = (await r.json()).storage?.paths?.templates;
20
+ t && await e.initialize(t);
21
+ }
22
+ }
23
+ } catch (e) {
24
+ console.warn("Failed to initialize template storage service:", e);
25
+ }
26
+ }
27
+ function f(e) {
28
+ return {
29
+ metadata: e.metadata,
30
+ stepsData: e.stepsData || [],
31
+ // Default to empty array if no steps
32
+ preview: {
33
+ componentCount: e.preview?.componentCount || 0,
34
+ sectionCount: e.preview?.sectionCount || 0
35
+ },
36
+ governance: e.governance || {
37
+ approved: !1,
38
+ complianceTags: [],
39
+ deprecated: !1
40
+ }
41
+ };
42
+ }
43
+ const p = /* @__PURE__ */ new Map(), o = {
44
+ "generic-contact-information": async () => {
45
+ const e = await fetch(
46
+ "/src/packages/form-wizard/admin/templates/generic/contact-information.json"
47
+ );
48
+ if (!e.ok)
49
+ throw new Error(
50
+ `Failed to fetch generic-contact-information template: ${e.status}`
51
+ );
52
+ return e.json();
53
+ },
54
+ "generic-consent-agreement": async () => {
55
+ const e = await fetch(
56
+ "/src/packages/form-wizard/admin/templates/generic/consent-agreement.json"
57
+ );
58
+ if (!e.ok)
59
+ throw new Error(
60
+ `Failed to fetch generic-consent-agreement template: ${e.status}`
61
+ );
62
+ return e.json();
63
+ },
64
+ "generic-feedback-form": async () => {
65
+ const e = await fetch(
66
+ "/src/packages/form-wizard/admin/templates/generic/feedback-form.json"
67
+ );
68
+ if (!e.ok)
69
+ throw new Error(
70
+ `Failed to fetch generic-feedback-form template: ${e.status}`
71
+ );
72
+ return e.json();
73
+ },
74
+ "generic-incident-registration": async () => {
75
+ const e = await fetch(
76
+ "/src/packages/form-wizard/admin/templates/generic/incident-registration.json"
77
+ );
78
+ if (!e.ok)
79
+ throw new Error(
80
+ `Failed to fetch generic-incident-registration template: ${e.status}`
81
+ );
82
+ return e.json();
83
+ }
84
+ };
85
+ async function v(e) {
86
+ if (p.has(e))
87
+ return p.get(e);
88
+ try {
89
+ let r;
90
+ if (y(e)) {
91
+ const i = o[e];
92
+ if (!i) {
93
+ const s = Object.keys(o);
94
+ throw new Error(
95
+ `Generic template '${e}' not found. Available generic templates: ${s.join(", ")}`
96
+ );
97
+ }
98
+ const t = await i();
99
+ r = f(
100
+ t
101
+ );
102
+ } else if (b(e)) {
103
+ await u();
104
+ const i = await m();
105
+ if (!i)
106
+ throw new Error(
107
+ `Team template '${e}' could not be loaded: template storage service is not available`
108
+ );
109
+ const t = await i.loadTemplate(
110
+ e,
111
+ "team"
112
+ );
113
+ if (!t.success)
114
+ throw new Error(
115
+ `Team template '${e}' not found: ${"error" in t && t.error?.message || "Unknown error"}`
116
+ );
117
+ r = f(t.data);
118
+ } else {
119
+ const i = o[e];
120
+ if (i) {
121
+ const t = await i();
122
+ r = f(
123
+ t
124
+ );
125
+ } else {
126
+ const t = Object.keys(o);
127
+ throw new Error(
128
+ `Template '${e}' not found. Available generic templates: ${t.join(", ")}`
129
+ );
130
+ }
131
+ }
132
+ if (!r.metadata || !Array.isArray(r.stepsData))
133
+ throw new Error(
134
+ `Invalid template structure for template: ${e}. Templates must have metadata and stepsData array.`
135
+ );
136
+ return p.set(e, r), r;
137
+ } catch (r) {
138
+ throw new Error(
139
+ `Failed to load template '${e}': ${r instanceof Error ? r.message : "Unknown error"}`
140
+ );
141
+ }
142
+ }
143
+ async function S(e, r, i) {
144
+ console.log(
145
+ "Resolving template step:",
146
+ e,
147
+ "stepIndex:",
148
+ i
149
+ );
150
+ const t = await v(e.templateId);
151
+ console.log("Loaded template:", t);
152
+ let s;
153
+ if (t.stepsData && Array.isArray(t.stepsData) && t.stepsData.length > 0)
154
+ i !== void 0 && i >= 0 && i < t.stepsData.length ? (s = t.stepsData[i], console.log(`Using template data for step ${i}:`, s)) : (s = t.stepsData[0], console.warn(
155
+ `Invalid stepIndex ${i} for template, using first step`
156
+ ));
157
+ else
158
+ throw new Error(`Template ${e.templateId} has no steps data`);
159
+ const h = s.sections?.map((w) => ({
160
+ ...w,
161
+ components: w.components.map((a) => {
162
+ const g = ((c) => `comp-${e.id}-${a.id || c}`)(a.id), n = {
163
+ id: g,
164
+ type: a.type,
165
+ properties: {
166
+ // Use properties from component.properties if it exists, otherwise fallback to root level
167
+ label: a.properties?.label || a.label || "",
168
+ placeholder: a.properties?.placeholder || a.placeholder || "",
169
+ description: a.properties?.description || a.description || "",
170
+ required: a.properties?.required || a.required || !1,
171
+ disabled: a.properties?.disabled || a.disabled || !1,
172
+ readOnly: a.properties?.readOnly || a.readOnly || !1,
173
+ invalid: a.properties?.invalid || !1,
174
+ // Add type-specific properties
175
+ type: a.properties?.type || a.type,
176
+ // Copy all other properties from component.properties if it exists
177
+ ...a.properties && Object.keys(a.properties).reduce(
178
+ (c, d) => ([
179
+ "label",
180
+ "placeholder",
181
+ "description",
182
+ "required",
183
+ "disabled",
184
+ "readOnly",
185
+ "invalid",
186
+ "type"
187
+ ].includes(d) || (c[d] = a.properties[d]), c),
188
+ {}
189
+ )
190
+ },
191
+ // Copy validation if it exists
192
+ ...a.validation && { validation: a.validation }
193
+ }, l = e.componentOverrides?.[g];
194
+ return l ? {
195
+ ...n,
196
+ ...l,
197
+ // Merge properties deeply to allow partial property updates
198
+ properties: {
199
+ ...n.properties,
200
+ ...l.properties
201
+ },
202
+ // Merge validation deeply if both exist
203
+ ...n.validation && l.validation && {
204
+ validation: {
205
+ ...n.validation,
206
+ ...l.validation
207
+ }
208
+ }
209
+ } : n;
210
+ })
211
+ }));
212
+ return {
213
+ id: e.id,
214
+ // Use the step ID from the form config
215
+ title: e.title || s.title,
216
+ displayTitle: s.displayTitle,
217
+ showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber : s.showStepNumber,
218
+ sections: h,
219
+ navigation: {
220
+ // Use default navigation, then template navigation if available, then step override
221
+ ...r,
222
+ ...s.navigation,
223
+ // Cast since navigation might not exist in Omit type
224
+ ...e.navigation
225
+ },
226
+ // Copy actions if they exist
227
+ ...s.actions && {
228
+ actions: s.actions
229
+ }
230
+ };
231
+ }
232
+ async function E(e) {
233
+ return (await v(e)).metadata;
234
+ }
235
+ async function D() {
236
+ const e = Object.keys(o);
237
+ try {
238
+ await u();
239
+ const r = await m();
240
+ if (r) {
241
+ const i = await r.listTemplates("team");
242
+ if (i.success && i.data) {
243
+ const t = i.data.map((s) => s.metadata.id);
244
+ return [...e, ...t];
245
+ }
246
+ }
247
+ } catch (r) {
248
+ console.warn("Failed to load team templates:", r);
249
+ }
250
+ return e;
251
+ }
252
+ function O() {
253
+ return Object.keys(o);
254
+ }
255
+ function A() {
256
+ p.clear();
257
+ }
258
+ export {
259
+ A as clearTemplateCache,
260
+ O as getAvailableGenericTemplates,
261
+ D as getAvailableTemplates,
262
+ E as getTemplateMetadata,
263
+ v as loadTemplate,
264
+ S as resolveTemplateStep
265
+ };
@@ -0,0 +1,14 @@
1
+ "use client";
2
+ /* empty css */
3
+ import { getTemplateMetadata as t, getAvailableGenericTemplates as a, getAvailableTemplates as l } from "./templateLoader.js";
4
+ import { createAsyncTemplateFunctions as n } from "../../../../../ui/src/lib/utils/templateUtils.js";
5
+ const e = n({
6
+ getAvailableTemplates: l,
7
+ getAvailableGenericTemplates: a,
8
+ getTemplateMetadata: t
9
+ }), s = e.getAvailableGenericTemplatesSync, o = e.getTemplateInfo, p = e.validateTemplateReferences;
10
+ export {
11
+ s as getAvailableGenericTemplatesSync,
12
+ o as getTemplateInfo,
13
+ p as validateTemplateReferences
14
+ };
@@ -0,0 +1,36 @@
1
+ "use client";
2
+ import { jsx as m } from "react/jsx-runtime";
3
+ import { memo as c, useState as u, useCallback as r, useMemo as L, createContext as C, useContext as p } from "react";
4
+ const a = C(null), g = c(
5
+ ({ children: e, initialComplete: i = !1 }) => {
6
+ const [o, t] = u(i), s = r((l) => {
7
+ t(l);
8
+ }, []), n = r(() => {
9
+ t(!1);
10
+ }, []), d = L(
11
+ () => ({
12
+ isLoadingComplete: o,
13
+ setLoadingComplete: s,
14
+ resetLoading: n
15
+ }),
16
+ [o, s, n]
17
+ );
18
+ return /* @__PURE__ */ m(a.Provider, { value: d, children: e });
19
+ }
20
+ );
21
+ g.displayName = "LoaderProvider";
22
+ const v = () => {
23
+ const e = p(a);
24
+ return e || {
25
+ isLoadingComplete: !0,
26
+ setLoadingComplete: () => {
27
+ },
28
+ resetLoading: () => {
29
+ }
30
+ };
31
+ };
32
+ export {
33
+ a as LoaderContext,
34
+ g as LoaderProvider,
35
+ v as useLoaderContext
36
+ };
@@ -0,0 +1,60 @@
1
+ "use client";
2
+ import { ApiCallService as c } from "../../api-integration/services/ApiCallService.js";
3
+ import { useQuery as p, useMutation as f } from "@tanstack/react-query";
4
+ function m(i) {
5
+ const { config: e, formData: t, onFieldUpdate: r, enabled: a = !0 } = i, u = e.fieldMappings ? Object.values(e.fieldMappings).reduce(
6
+ (o, l) => {
7
+ const n = String(l), s = n.startsWith("${") && n.endsWith("}") && n.slice(2, -1).split(".").pop() || n;
8
+ return o[s] = t[s], o;
9
+ },
10
+ {}
11
+ ) : {}, d = new c({ onFieldUpdate: r }).createQueryOptions(e, t);
12
+ return p({
13
+ ...d,
14
+ queryKey: ["api-action-get", e.url, e.method, u],
15
+ enabled: a && e.method === "GET",
16
+ refetchOnWindowFocus: !1,
17
+ refetchOnReconnect: !1
18
+ });
19
+ }
20
+ function g(i) {
21
+ const { config: e, formData: t, onFieldUpdate: r } = i, a = new c({ onFieldUpdate: r });
22
+ return f({
23
+ mutationKey: ["api-action-mutate", e.url, e.method],
24
+ mutationFn: async () => await a.executeApiCall(e, t),
25
+ retry: e.retryCount || 0
26
+ });
27
+ }
28
+ function A(i) {
29
+ const { config: e } = i, t = m({
30
+ ...i,
31
+ enabled: i.enabled && e.method === "GET"
32
+ }), r = g(i);
33
+ return e.method === "GET" ? {
34
+ data: t.data,
35
+ error: t.error,
36
+ isLoading: t.isLoading,
37
+ isSuccess: t.isSuccess,
38
+ isError: t.isError,
39
+ execute: () => {
40
+ t.refetch();
41
+ },
42
+ refetch: t.refetch
43
+ } : {
44
+ data: r.data,
45
+ error: r.error,
46
+ isLoading: r.isPending,
47
+ isSuccess: r.isSuccess,
48
+ isError: r.isError,
49
+ execute: () => {
50
+ r.mutate();
51
+ },
52
+ mutate: r.mutate,
53
+ reset: r.reset
54
+ };
55
+ }
56
+ export {
57
+ A as useApiAction,
58
+ m as useGetApiAction,
59
+ g as useMutateApiAction
60
+ };
@@ -0,0 +1,102 @@
1
+ "use client";
2
+ import { useFormMachine as M } from "../../state-management/machines/useFormMachine.js";
3
+ import { useRef as T, useCallback as n } from "react";
4
+ const S = ({
5
+ componentId: e,
6
+ initialValue: o,
7
+ onValueChange: l
8
+ }) => {
9
+ const [, , f] = M(), {
10
+ evaluateComponentTriggers: a,
11
+ setComponentOriginalValue: i,
12
+ getComponentAlerts: h,
13
+ dismissComponentAlert: u,
14
+ hasComponentTriggers: A,
15
+ hasComponentActions: m,
16
+ getComponentTriggerState: F
17
+ } = f, C = T(!1), g = T(o);
18
+ o !== void 0 && !C.current && (i(e, o), g.current = o, C.current = !0);
19
+ const t = n(
20
+ (r, c) => {
21
+ console.log(
22
+ `🧪 [useComponentTriggers] evaluateTriggers called for ${e}:`,
23
+ {
24
+ eventType: r,
25
+ value: c,
26
+ evaluateComponentTriggers: !!a
27
+ }
28
+ ), a(e, r, c);
29
+ },
30
+ [e, a]
31
+ ), p = n(
32
+ (r, c = "api_populated") => {
33
+ i(e, r, c), g.current = r;
34
+ },
35
+ [e, i]
36
+ ), $ = h(e), b = n(
37
+ (r) => {
38
+ u(e, r);
39
+ },
40
+ [e, u]
41
+ ), s = A(e), B = m(e), O = F(e), R = n(
42
+ (r) => {
43
+ console.log(
44
+ `🧪 [useComponentTriggers] handleValueChange called for ${e}:`,
45
+ {
46
+ value: r,
47
+ oldValue: g.current,
48
+ hasTriggers: s,
49
+ onValueChange: !!l
50
+ }
51
+ ), g.current = r, l && l(r), s ? (console.log(
52
+ `🧪 [useComponentTriggers] About to call evaluateTriggers for ${e}`
53
+ ), t("valueChange", r)) : console.log(
54
+ `🧪 [useComponentTriggers] hasTriggers is false for ${e}`
55
+ );
56
+ },
57
+ [t, s, l, e]
58
+ ), V = n(() => {
59
+ s && t("focus", g.current);
60
+ }, [t, s]), d = n(() => {
61
+ s && t("blur", g.current);
62
+ }, [t, s]);
63
+ return {
64
+ evaluateTriggers: t,
65
+ setOriginalValue: p,
66
+ alerts: $,
67
+ dismissAlert: b,
68
+ hasTriggers: s,
69
+ hasActions: B,
70
+ triggerState: O,
71
+ handleValueChange: R,
72
+ handleFocus: V,
73
+ handleBlur: d
74
+ };
75
+ }, x = (e, o) => {
76
+ const {
77
+ handleValueChange: l,
78
+ handleFocus: f,
79
+ handleBlur: a,
80
+ alerts: i,
81
+ dismissAlert: h,
82
+ setOriginalValue: u
83
+ } = S({
84
+ componentId: e,
85
+ initialValue: o
86
+ });
87
+ return {
88
+ // Event handlers to attach to form fields
89
+ onChange: l,
90
+ onFocus: f,
91
+ onBlur: a,
92
+ // Alert management
93
+ alerts: i,
94
+ dismissAlert: h,
95
+ // For setting original value after API population
96
+ setOriginalValue: u
97
+ };
98
+ };
99
+ export {
100
+ S as useComponentTriggers,
101
+ x as useFieldTriggerMonitor
102
+ };
@@ -0,0 +1,18 @@
1
+ "use client";
2
+ import { useMemo as s } from "react";
3
+ import { useLoaderContext as n } from "../context/LoaderContext.js";
4
+ import { getVisibilityDependencies as o, evaluateVisibility as m } from "../utils/visibilityUtils.js";
5
+ const f = ({
6
+ visibilityConditions: e,
7
+ formData: r
8
+ }) => {
9
+ const { isLoadingComplete: u } = n(), t = s(() => o(e), [e]);
10
+ return {
11
+ isVisible: s(() => e ? m(e, r) : !0, [e, r, t]),
12
+ dependencies: t,
13
+ isLoadingComplete: u
14
+ };
15
+ };
16
+ export {
17
+ f as useComponentVisibility
18
+ };