@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,138 @@
1
+ "use client";
2
+ /* empty css */
3
+ import { isTemplateStep as d } from "../../../../../ui/src/lib/types/guards.js";
4
+ class u {
5
+ schemaBuilder;
6
+ constructor(t) {
7
+ this.schemaBuilder = t;
8
+ }
9
+ /**
10
+ * Validates a single field
11
+ */
12
+ async validateField(t, i) {
13
+ try {
14
+ const e = await i.parseAsync(t);
15
+ return {
16
+ isValid: !0,
17
+ errors: [],
18
+ value: e
19
+ };
20
+ } catch (e) {
21
+ let r = [];
22
+ return e && typeof e == "object" && "errors" in e ? r = e.errors.map((a) => a.message) : r = ["Validation failed"], {
23
+ isValid: !1,
24
+ errors: r,
25
+ value: t
26
+ };
27
+ }
28
+ }
29
+ /**
30
+ * Validates a single field synchronously
31
+ */
32
+ validateFieldSync(t, i) {
33
+ let e = t;
34
+ t == null && (e = ""), console.log("🔍 [ValidationExecutor] validateFieldSync input:", {
35
+ originalValue: t,
36
+ normalizedValue: e,
37
+ valueType: typeof t,
38
+ normalizedValueType: typeof e,
39
+ valueLength: typeof e == "string" ? e.length : "N/A",
40
+ schema: i._def
41
+ });
42
+ try {
43
+ const r = i.parse(e);
44
+ return console.log("🔍 [ValidationExecutor] validateFieldSync SUCCESS:", {
45
+ value: t,
46
+ result: r,
47
+ isValid: !0
48
+ }), {
49
+ isValid: !0,
50
+ errors: [],
51
+ value: r
52
+ };
53
+ } catch (r) {
54
+ console.log("🔍 [ValidationExecutor] validateFieldSync ERROR:", {
55
+ value: t,
56
+ error: r,
57
+ errorType: typeof r
58
+ });
59
+ let s = [];
60
+ if (r && typeof r == "object" && "errors" in r) {
61
+ const a = r;
62
+ s = a.errors.map((o) => o.message), console.log("🔍 [ValidationExecutor] DETAILED Zod errors:", {
63
+ fullZodError: a,
64
+ individualErrors: a.errors.map((o) => ({
65
+ message: o.message,
66
+ path: o.path,
67
+ code: o.code,
68
+ fullError: o
69
+ })),
70
+ inputValue: t,
71
+ inputType: typeof t,
72
+ schemaType: i._def?.typeName || "unknown"
73
+ });
74
+ } else
75
+ s = ["Validation failed"];
76
+ return {
77
+ isValid: !1,
78
+ errors: s,
79
+ value: e
80
+ };
81
+ }
82
+ }
83
+ /**
84
+ * Validates a step
85
+ */
86
+ async validateStep(t, i) {
87
+ try {
88
+ return await i.parseAsync(t), {
89
+ isValid: !0,
90
+ fieldErrors: {},
91
+ generalErrors: []
92
+ };
93
+ } catch (e) {
94
+ const r = {};
95
+ let s = [];
96
+ if (e && typeof e == "object" && "errors" in e) {
97
+ const a = e;
98
+ for (const o of a.errors)
99
+ if (o.path.length > 0) {
100
+ const l = o.path[0].toString();
101
+ r[l] || (r[l] = []), r[l].push(o.message);
102
+ } else
103
+ s.push(o.message);
104
+ } else
105
+ s = ["Step validation failed"];
106
+ return {
107
+ isValid: !1,
108
+ fieldErrors: r,
109
+ generalErrors: s
110
+ };
111
+ }
112
+ }
113
+ /**
114
+ * Validates a form
115
+ */
116
+ async validateForm(t, i) {
117
+ const e = {}, r = [];
118
+ let s = !0;
119
+ for (const a of t.steps) {
120
+ if (d(a)) {
121
+ r.push(
122
+ `Template step '${a.id}' needs to be resolved before validation`
123
+ ), s = !1;
124
+ continue;
125
+ }
126
+ const o = a, l = this.schemaBuilder.createStepSchema(o), n = await this.validateStep(i, l);
127
+ n.isValid || (s = !1, Object.assign(e, n.fieldErrors), r.push(...n.generalErrors));
128
+ }
129
+ return {
130
+ isValid: s,
131
+ fieldErrors: e,
132
+ generalErrors: r
133
+ };
134
+ }
135
+ }
136
+ export {
137
+ u as ValidationExecutor
138
+ };
@@ -0,0 +1,17 @@
1
+ "use client";
2
+ import { ValidationEngine as a, defaultValidationEngine as r } from "./ValidationEngine.js";
3
+ function c(e, n = "withLabel") {
4
+ return new a({ messageStyle: n }).getComponentSchema(e);
5
+ }
6
+ function u(e, n, t = "withLabel") {
7
+ const i = new a({ messageStyle: t }).validateField(e, n);
8
+ return i.isValid ? void 0 : i.errors[0];
9
+ }
10
+ function d(e, n) {
11
+ return r.validateField(e, n).errors;
12
+ }
13
+ export {
14
+ c as createTanStackSchema,
15
+ u as validateWithTanStack,
16
+ d as validateWithTanStackReturnArray
17
+ };
@@ -0,0 +1,74 @@
1
+ "use client";
2
+ import { ValidationEngine as c } from "./ValidationEngine.js";
3
+ const s = new c();
4
+ async function d(t, e) {
5
+ const n = await s.validateFieldDebounced(
6
+ t,
7
+ e
8
+ );
9
+ return n.isValid ? void 0 : n.errors[0];
10
+ }
11
+ async function l(t, e) {
12
+ return (await s.validateFieldDebounced(
13
+ t,
14
+ e
15
+ )).errors;
16
+ }
17
+ function a(t) {
18
+ return "sections" in t && Array.isArray(t.sections);
19
+ }
20
+ function f(t, e) {
21
+ for (const n of t.steps)
22
+ if (a(n))
23
+ for (const i of n.sections || []) {
24
+ const o = (i.components || []).find(
25
+ (r) => r.id === e
26
+ );
27
+ if (o) return o;
28
+ }
29
+ }
30
+ function p(t, e) {
31
+ const n = t.steps.find((o) => o.id === e);
32
+ if (!n || !a(n)) return [];
33
+ const i = [];
34
+ return n.sections?.forEach((o) => {
35
+ o.components?.forEach((r) => {
36
+ i.push(r);
37
+ });
38
+ }), i;
39
+ }
40
+ function m(t) {
41
+ const e = [];
42
+ return t.steps.forEach((n) => {
43
+ a(n) && n.sections?.forEach((i) => {
44
+ i.components?.forEach((o) => {
45
+ e.push(o);
46
+ });
47
+ });
48
+ }), e;
49
+ }
50
+ async function v(t, e, n) {
51
+ const i = t.steps.find((r) => r.id === e);
52
+ return !i || !a(i) ? {} : (await s.validateStep(i, n)).fieldErrors;
53
+ }
54
+ async function y(t, e, n) {
55
+ const i = t.steps.find((r) => r.id === e);
56
+ return !i || !a(i) ? !0 : (await s.validateStep(i, n)).isValid;
57
+ }
58
+ async function E(t, e) {
59
+ return (await s.validateForm(t, e)).fieldErrors;
60
+ }
61
+ async function F(t, e) {
62
+ return (await s.validateForm(t, e)).isValid;
63
+ }
64
+ export {
65
+ f as findComponentById,
66
+ m as getAllComponents,
67
+ p as getStepComponents,
68
+ F as isFormValid,
69
+ y as isStepValid,
70
+ d as validateField,
71
+ l as validateFieldReturnArray,
72
+ E as validateForm,
73
+ v as validateStep
74
+ };
@@ -0,0 +1,123 @@
1
+ "use client";
2
+ import { jsx as r, jsxs as p } from "react/jsx-runtime";
3
+ /* empty css */
4
+ import { Alert as c, AlertDescription as u } from "../../../ui/src/components/alert/alert.js";
5
+ import { Button as h } from "../../../ui/src/components/button/button.js";
6
+ import { Checkbox as y } from "../../../ui/src/components/checkbox/checkbox.js";
7
+ import { Input as b } from "../../../ui/src/components/input/input.js";
8
+ import { RadioGroup as f, RadioGroupItem as m } from "../../../ui/src/components/radio-group/radio-group.js";
9
+ import { Select as g, SelectTrigger as v, SelectValue as x, SelectContent as B, SelectItem as A } from "../../../ui/src/components/select/select.js";
10
+ import { Textarea as S } from "../../../ui/src/components/textarea/textarea.js";
11
+ import { ProgressLoaderBar as k } from "../../../ui/src/components/ProgressLoaderBar/ProgressLoaderBar.js";
12
+ const M = ({
13
+ component: n,
14
+ value: o,
15
+ onChange: d,
16
+ isFormView: l
17
+ }) => {
18
+ const e = n.properties ?? {};
19
+ switch (n.type) {
20
+ case "text":
21
+ case "email":
22
+ case "tel":
23
+ case "number":
24
+ case "date":
25
+ return /* @__PURE__ */ r(
26
+ b,
27
+ {
28
+ type: n.type,
29
+ value: typeof o == "string" ? o : "",
30
+ disabled: !!e.disabled,
31
+ readOnly: !!e.readOnly || !l,
32
+ placeholder: typeof e.placeholder == "string" ? e.placeholder : void 0,
33
+ onChange: l ? (a) => d(a.target.value) : void 0
34
+ }
35
+ );
36
+ case "textarea":
37
+ return /* @__PURE__ */ r(
38
+ S,
39
+ {
40
+ value: typeof o == "string" ? o : "",
41
+ disabled: !!e.disabled,
42
+ readOnly: !!e.readOnly || !l,
43
+ placeholder: typeof e.placeholder == "string" ? e.placeholder : void 0,
44
+ onChange: l ? (a) => d(a.target.value) : void 0
45
+ }
46
+ );
47
+ case "checkbox":
48
+ return /* @__PURE__ */ r(
49
+ y,
50
+ {
51
+ checked: !!o,
52
+ disabled: !!e.disabled,
53
+ onCheckedChange: l ? (a) => d(a === !0) : void 0
54
+ }
55
+ );
56
+ case "radioGroup": {
57
+ const a = Array.isArray(e.options) ? e.options : [];
58
+ return /* @__PURE__ */ r(
59
+ f,
60
+ {
61
+ value: typeof o == "string" ? o : "",
62
+ onValueChange: l ? (t) => d(t) : void 0,
63
+ disabled: !!e.disabled,
64
+ children: a.map((t) => /* @__PURE__ */ r(m, { value: t.value, children: t.label }, t.value))
65
+ }
66
+ );
67
+ }
68
+ case "dropdown": {
69
+ const a = Array.isArray(e.options) ? e.options : [];
70
+ return /* @__PURE__ */ p(
71
+ g,
72
+ {
73
+ value: typeof o == "string" ? o : "",
74
+ onValueChange: l ? (t) => d(t) : void 0,
75
+ disabled: !!e.disabled,
76
+ children: [
77
+ /* @__PURE__ */ r(v, { children: /* @__PURE__ */ r(
78
+ x,
79
+ {
80
+ placeholder: typeof e.placeholder == "string" ? e.placeholder : ""
81
+ }
82
+ ) }),
83
+ /* @__PURE__ */ r(B, { children: a.map((t) => /* @__PURE__ */ r(A, { value: t.value, children: t.label }, t.value)) })
84
+ ]
85
+ }
86
+ );
87
+ }
88
+ case "button":
89
+ return /* @__PURE__ */ r(
90
+ h,
91
+ {
92
+ type: "button",
93
+ disabled: !!e.disabled,
94
+ onClick: l ? () => d(null) : void 0,
95
+ children: typeof e.label == "string" ? e.label : "Submit"
96
+ }
97
+ );
98
+ case "heading": {
99
+ const a = typeof e.level == "number" ? e.level : void 0, t = a !== void 0 ? Math.min(6, Math.max(1, a)) : 2, i = typeof e.text == "string" ? e.text : "", s = `h${t}`;
100
+ return /* @__PURE__ */ r(s, { children: i });
101
+ }
102
+ case "paragraph":
103
+ return /* @__PURE__ */ r("p", { children: typeof e.text == "string" ? e.text : "" });
104
+ case "alert":
105
+ return /* @__PURE__ */ r(c, { variant: "default", children: /* @__PURE__ */ r(u, { children: typeof e.message == "string" ? e.message : "" }) });
106
+ case "progress-loader":
107
+ return /* @__PURE__ */ r(
108
+ k,
109
+ {
110
+ mode: typeof e.mode == "string" ? e.mode : "indeterminate",
111
+ status: "loading",
112
+ label: typeof e.label == "string" ? e.label : void 0
113
+ }
114
+ );
115
+ default:
116
+ return console.warn(
117
+ `[wizardRenderer] Unsupported component type: ${n.type}`
118
+ ), null;
119
+ }
120
+ };
121
+ export {
122
+ M as wizardDefaultRenderer
123
+ };
package/README.md DELETED
@@ -1,147 +0,0 @@
1
- # @digiform/wizard
2
-
3
- [![npm version](https://img.shields.io/npm/v/@digiform/wizard.svg)](https://www.npmjs.com/package/@digiform/wizard)
4
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
-
6
- React component for rendering configurable multi-step forms from a JSON config. Zero database dependencies.
7
-
8
- ---
9
-
10
- ## Installation
11
-
12
- ```bash
13
- npm install @digiform/wizard
14
- ```
15
-
16
- > Requires React 18+, XState 5+, TanStack Form 1+, Zod 3+, and Radix UI components as peer dependencies. See `peerDependencies` in package.json for exact versions.
17
-
18
- ---
19
-
20
- ## CSS Import
21
-
22
- > **Required:** You must import the wizard stylesheet before rendering any wizard component.
23
-
24
- ```ts
25
- import '@digiform/wizard/styles';
26
- ```
27
-
28
- Add this import once at your app entry point before rendering any wizard.
29
-
30
- ---
31
-
32
- ## Quick Start
33
-
34
- ```tsx
35
- import { FormWizard } from '@digiform/wizard';
36
- import '@digiform/wizard/styles';
37
-
38
- const config = { /* your FormWizardConfig */ };
39
-
40
- export function MyForm() {
41
- return (
42
- <FormWizard
43
- config={config}
44
- onSubmit={(data) => console.log(data)}
45
- />
46
- );
47
- }
48
- ```
49
-
50
- ---
51
-
52
- ## Framework Setup
53
-
54
- ### Vite
55
-
56
- 1. **Install** the package (see [Installation](#installation) above).
57
-
58
- 2. **Import styles** in `src/main.tsx` (or `src/index.tsx`) before `ReactDOM.createRoot`:
59
-
60
- ```tsx
61
- // src/main.tsx
62
- import React from 'react';
63
- import ReactDOM from 'react-dom/client';
64
- import '@digiform/wizard/styles'; // must come before App
65
- import App from './App';
66
-
67
- ReactDOM.createRoot(document.getElementById('root')!).render(
68
- <React.StrictMode>
69
- <App />
70
- </React.StrictMode>
71
- );
72
- ```
73
-
74
- 3. **Use `<FormWizard>`** in any component — no `vite.config.ts` changes required.
75
-
76
- ```tsx
77
- // src/components/MyForm.tsx
78
- import { FormWizard } from '@digiform/wizard';
79
- import type { FormWizardConfig } from '@digiform/wizard';
80
-
81
- const config: FormWizardConfig = {
82
- // your form configuration
83
- };
84
-
85
- export function MyForm() {
86
- return <FormWizard config={config} onSubmit={(data) => console.log(data)} />;
87
- }
88
- ```
89
-
90
- ---
91
-
92
- ### Next.js
93
-
94
- 1. **Install** the package (see [Installation](#installation) above).
95
-
96
- 2. **Import styles** in `app/layout.tsx` (App Router) or `pages/_app.tsx` (Pages Router):
97
-
98
- ```tsx
99
- // app/layout.tsx — App Router
100
- import '@digiform/wizard/styles';
101
-
102
- export default function RootLayout({ children }: { children: React.ReactNode }) {
103
- return (
104
- <html lang="en">
105
- <body>{children}</body>
106
- </html>
107
- );
108
- }
109
- ```
110
-
111
- ```tsx
112
- // pages/_app.tsx — Pages Router
113
- import '@digiform/wizard/styles';
114
- import type { AppProps } from 'next/app';
115
-
116
- export default function App({ Component, pageProps }: AppProps) {
117
- return <Component {...pageProps} />;
118
- }
119
- ```
120
-
121
- 3. **Mark the wrapping component with `'use client'`** — FormWizard is a client component.
122
-
123
- 4. Create a form page with the `'use client'` directive:
124
-
125
- ```tsx
126
- // app/forms/page.tsx
127
- 'use client';
128
-
129
- import { FormWizard } from '@digiform/wizard';
130
- import type { FormWizardConfig } from '@digiform/wizard';
131
-
132
- const config: FormWizardConfig = {
133
- // your form configuration
134
- };
135
-
136
- export default function FormsPage() {
137
- return <FormWizard config={config} onSubmit={(data) => console.log(data)} />;
138
- }
139
- ```
140
-
141
- 5. No `next.config.js` changes are required for CSS.
142
-
143
- ---
144
-
145
- ## Related
146
-
147
- Use [@digiform/builder](https://www.npmjs.com/package/@digiform/builder) to visually create and edit form configs.