@digiform/wizard 0.3.0 → 0.3.2

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 (89) hide show
  1. package/core/src/types/guards.js +0 -12
  2. package/core/src/utils/apiBodyUtils.js +43 -75
  3. package/features/form-runtime/components/FormFooter.d.ts +5 -0
  4. package/features/form-runtime/hooks/useValidationEvents.d.ts +0 -1
  5. package/features/state-management/machines/formMachine.d.ts +3 -0
  6. package/features/state-management/machines/types.d.ts +4 -0
  7. package/features/state-management/machines/useFormMachine.d.ts +18 -0
  8. package/index.d.ts +2 -8
  9. package/index.js +2 -108
  10. package/package.json +1 -30
  11. package/styles.css +1 -1
  12. package/ui/src/lib/utils/templateUtils.js +11 -43
  13. package/wizard/src/features/api-integration/services/ApiCallService.js +65 -74
  14. package/wizard/src/features/dialog-system/components/ActionDialog/ActionDialog.js +39 -43
  15. package/wizard/src/features/dialog-system/components/ConfirmationDialog/ConfirmationDialog.js +37 -41
  16. package/wizard/src/features/dialog-system/components/EmailVerificationDialog/EmailVerificationDialog.js +44 -45
  17. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +56 -78
  18. package/wizard/src/features/form-runtime/components/FormField.js +28 -28
  19. package/wizard/src/features/form-runtime/components/FormFooter.js +53 -184
  20. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +152 -196
  21. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +82 -91
  22. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +24 -30
  23. package/wizard/src/features/form-runtime/config/configResolver.js +10 -14
  24. package/wizard/src/features/form-runtime/config/templateLoader.js +71 -108
  25. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +45 -88
  26. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +27 -41
  27. package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +5 -5
  28. package/wizard/src/features/form-runtime/hooks/useValidationEvents.js +22 -25
  29. package/wizard/src/features/form-runtime/utils/errorUtils.js +31 -42
  30. package/wizard/src/features/form-runtime/utils/formDirtyStateSync.js +26 -37
  31. package/wizard/src/features/form-runtime/utils/logger.js +12 -12
  32. package/wizard/src/features/form-runtime/utils/validationUX.js +14 -55
  33. package/wizard/src/features/state-management/machines/actions/navigationActions.js +13 -8
  34. package/wizard/src/features/state-management/machines/componentTriggerEngine.js +167 -432
  35. package/wizard/src/features/state-management/machines/formMachine.js +558 -677
  36. package/wizard/src/features/state-management/machines/useFormMachine.js +172 -190
  37. package/wizard/src/features/trigger-action-system/components/ActionManager.js +35 -86
  38. package/wizard/src/features/validation-system/validation/SchemaBuilder.js +28 -82
  39. package/wizard/src/features/validation-system/validation/ValidationCache.js +11 -27
  40. package/wizard/src/features/validation-system/validation/ValidationEngine.js +24 -29
  41. package/wizard/src/features/validation-system/validation/ValidationExecutor.js +26 -58
  42. package/FormWizard.d.ts +0 -10
  43. package/core/src/types/api.js +0 -12
  44. package/core/src/types/form-config.js +0 -60
  45. package/core/src/types/form-wizard-config-schema.js +0 -113
  46. package/core/src/types/validation.js +0 -61
  47. package/features/api-integration.d.ts +0 -2
  48. package/features/api-integration.js +0 -17
  49. package/features/dialog-system.d.ts +0 -2
  50. package/features/dialog-system.js +0 -9
  51. package/features/form-runtime/utils/formSaver.d.ts +0 -22
  52. package/features/form-runtime.d.ts +0 -2
  53. package/features/form-runtime.js +0 -63
  54. package/features/index.d.ts +0 -11
  55. package/features/state-management/components/ValidationBuilder/ValidationBuilder.d.ts +0 -9
  56. package/features/state-management/machines/__tests__/setup.d.ts +0 -0
  57. package/features/state-management/machines/__tests__/vitest.config.d.ts +0 -2
  58. package/features/state-management/machines/actions/validationActions.d.ts +0 -68
  59. package/features/state-management/machines/lazyLoading.d.ts +0 -34
  60. package/features/state-management/machines/validation/index.d.ts +0 -5
  61. package/features/state-management/machines/validation/validateField.d.ts +0 -2
  62. package/features/state-management/machines/validation/validateForm.d.ts +0 -2
  63. package/features/state-management/machines/validation/validateSection.d.ts +0 -2
  64. package/features/state-management/machines/validation/validateStep.d.ts +0 -2
  65. package/features/state-management/machines/validation/validationTypes.d.ts +0 -1
  66. package/features/state-management.d.ts +0 -2
  67. package/features/state-management.js +0 -21
  68. package/features/trigger-action-system/components/FieldWarning/FieldWarning.d.ts +0 -20
  69. package/features/trigger-action-system.d.ts +0 -2
  70. package/features/trigger-action-system.js +0 -12
  71. package/features/validation-system.d.ts +0 -2
  72. package/features/validation-system.js +0 -23
  73. package/styles/index.d.ts +0 -0
  74. package/ui/src/components/badge/badge.js +0 -20
  75. package/ui/src/components/badge/badge.module.css.js +0 -12
  76. package/wizard/src/features/api-integration/services/ActionExecutor.js +0 -339
  77. package/wizard/src/features/api-integration/services/ApiCallExecutor.js +0 -6
  78. package/wizard/src/features/api-integration/services/DialogExecutor.js +0 -6
  79. package/wizard/src/features/api-integration/services/GenericTriggerService.js +0 -284
  80. package/wizard/src/features/api-integration/services/NavigationExecutor.js +0 -6
  81. package/wizard/src/features/form-runtime/config/templateConfig.js +0 -156
  82. package/wizard/src/features/form-runtime/config/templateUtils.js +0 -14
  83. package/wizard/src/features/form-runtime/utils/validation.js +0 -100
  84. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +0 -46
  85. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +0 -30
  86. package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +0 -376
  87. package/wizard/src/features/validation-system/components/ValidationDebugger.js +0 -69
  88. package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +0 -17
  89. package/wizard/src/features/validation-system/validation/validationService.js +0 -74
@@ -1,156 +0,0 @@
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
- };
@@ -1,14 +0,0 @@
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
- };
@@ -1,100 +0,0 @@
1
- "use client";
2
- const o = (r) => r === void 0 ? { value: void 0 } : typeof r == "object" && r !== null && "value" in r ? {
3
- value: r.value,
4
- message: r.message
5
- } : { value: r }, y = (r, t, a) => {
6
- if (!r.validation)
7
- return [];
8
- const i = [], n = r.validation;
9
- if (n.required) {
10
- const { value: e, message: s } = o(
11
- n.required
12
- );
13
- e && !u(t) && i.push(s || "This field is required");
14
- }
15
- if (n.minLength) {
16
- const { value: e, message: s } = o(
17
- n.minLength
18
- );
19
- e !== void 0 && !d(t, e) && i.push(s || `Minimum length is ${e} characters`);
20
- }
21
- if (n.maxLength) {
22
- const { value: e, message: s } = o(
23
- n.maxLength
24
- );
25
- e !== void 0 && !m(t, e) && i.push(s || `Maximum length is ${e} characters`);
26
- }
27
- if (n.pattern) {
28
- const { value: e, message: s } = o(
29
- n.pattern
30
- );
31
- e && !c(t, e) && i.push(s || "Invalid format");
32
- }
33
- if (n.email) {
34
- const { value: e, message: s } = o(
35
- n.email
36
- );
37
- e && !l(t) && i.push(s || "Invalid email address");
38
- }
39
- if (n.min) {
40
- const { value: e, message: s } = o(n.min);
41
- e !== void 0 && !f(t, e) && i.push(s || `Minimum value is ${e}`);
42
- }
43
- if (n.max) {
44
- const { value: e, message: s } = o(n.max);
45
- e !== void 0 && !g(t, e) && i.push(s || `Maximum value is ${e}`);
46
- }
47
- if (n.rules && n.rules.length > 0)
48
- for (const e of n.rules)
49
- h(e, t, a) || i.push(e.message || "Validation failed");
50
- return i;
51
- }, h = (r, t, a) => {
52
- const i = r.params;
53
- switch (r.type) {
54
- case "required":
55
- return u(t);
56
- case "minLength":
57
- return d(t, i?.min);
58
- case "maxLength":
59
- return m(t, i?.max);
60
- case "pattern":
61
- return c(t, i?.pattern);
62
- case "email":
63
- return l(t);
64
- case "number":
65
- return p(t);
66
- case "min":
67
- return f(t, i?.min);
68
- case "max":
69
- return g(t, i?.max);
70
- case "custom":
71
- return x(t, i?.validator, a);
72
- default:
73
- return !0;
74
- }
75
- }, u = (r) => r == null ? !1 : typeof r == "string" ? r.trim() !== "" : Array.isArray(r) ? r.length > 0 : !0, d = (r, t) => t === void 0 || r === void 0 || r === null ? !0 : typeof r == "string" || Array.isArray(r) ? r.length >= t : !0, m = (r, t) => t === void 0 || r === void 0 || r === null ? !0 : typeof r == "string" || Array.isArray(r) ? r.length <= t : !0, c = (r, t) => {
76
- if (t === void 0 || r === void 0 || r === null || typeof r != "string") return !0;
77
- try {
78
- return new RegExp(t).test(r);
79
- } catch {
80
- return console.error("Invalid regex pattern:", t), !0;
81
- }
82
- }, l = (r) => r == null || r === "" ? !0 : typeof r != "string" ? !1 : /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r), p = (r) => r == null || r === "" ? !0 : !Number.isNaN(Number(r)), f = (r, t) => t === void 0 || r === void 0 || r === null || r === "" ? !0 : Number(r) >= t, g = (r, t) => t === void 0 || r === void 0 || r === null || r === "" ? !0 : Number(r) <= t, x = (r, t, a) => {
83
- if (!t) return !0;
84
- console.warn(
85
- "[DEPRECATED] String-based custom validators are deprecated and pose security risks. Please migrate to function-based validators using the ValidationEngine."
86
- );
87
- try {
88
- return new Function(
89
- "value",
90
- "formData",
91
- `return ${t}`
92
- )(r, a);
93
- } catch (i) {
94
- return console.error("Error in custom validator:", i), !1;
95
- }
96
- };
97
- export {
98
- y as validateComponentValue,
99
- h as validateRule
100
- };
@@ -1,46 +0,0 @@
1
- "use client";
2
- import { jsx as s, jsxs as r } from "react/jsx-runtime";
3
- /* empty css */
4
- import { Badge as c } from "../../../../../../ui/src/components/badge/badge.js";
5
- import { Card as o, CardContent as l } from "../../../../../../ui/src/components/card/card.js";
6
- import { clsx as d } from "clsx";
7
- import { Loader2 as m } from "lucide-react";
8
- import { memo as p } from "react";
9
- import e from "./ActionLoadingIndicator.module.css.js";
10
- const g = p(
11
- ({ activeActions: a, className: n }) => {
12
- const t = Object.values(a).filter(
13
- (i) => i.status === "executing"
14
- );
15
- return t.length === 0 ? null : /* @__PURE__ */ s(o, { className: d(e.card, n), children: /* @__PURE__ */ r(l, { className: e.cardContent, children: [
16
- /* @__PURE__ */ r("div", { className: e.contentRow, children: [
17
- /* @__PURE__ */ s(m, { className: e.spinner }),
18
- /* @__PURE__ */ r("div", { className: e.textContent, children: [
19
- /* @__PURE__ */ s("div", { className: e.title, children: "Executing Actions..." }),
20
- /* @__PURE__ */ s("div", { className: e.subtitle, children: t.length === 1 ? "1 action in progress" : `${t.length} actions in progress` })
21
- ] }),
22
- /* @__PURE__ */ s("div", { className: e.badgeList, children: t.map((i) => /* @__PURE__ */ s(
23
- c,
24
- {
25
- variant: "secondary",
26
- className: e.badgeText,
27
- children: i.actionId.split("-")[0]
28
- },
29
- i.actionId
30
- )) })
31
- ] }),
32
- /* @__PURE__ */ s("div", { className: e.progressSection, children: /* @__PURE__ */ s("div", { className: e.progressTrack, children: /* @__PURE__ */ s(
33
- "div",
34
- {
35
- className: e.progressBar,
36
- style: { width: "60%" }
37
- }
38
- ) }) })
39
- ] }) });
40
- }
41
- );
42
- g.displayName = "ActionLoadingIndicator";
43
- export {
44
- g as ActionLoadingIndicator,
45
- g as default
46
- };
@@ -1,30 +0,0 @@
1
- "use client";
2
- const t = "fb-card_jvOrv", e = "fb-cardContent_Cnf5t", s = "fb-contentRow_-lops", n = "fb-spinner_SkwMR", o = "fb-textContent_t3X2X", r = "fb-title_-fTQX", c = "fb-subtitle_wyptE", b = "fb-badgeList_xtoNn", a = "fb-badgeText_TZRdG", g = "fb-progressSection_XcPgJ", i = "fb-progressTrack_BUoRx", f = "fb-progressBar_5MELx", p = {
3
- card: t,
4
- cardContent: e,
5
- contentRow: s,
6
- spinner: n,
7
- textContent: o,
8
- title: r,
9
- subtitle: c,
10
- badgeList: b,
11
- badgeText: a,
12
- progressSection: g,
13
- progressTrack: i,
14
- progressBar: f
15
- };
16
- export {
17
- b as badgeList,
18
- a as badgeText,
19
- t as card,
20
- e as cardContent,
21
- s as contentRow,
22
- p as default,
23
- f as progressBar,
24
- g as progressSection,
25
- i as progressTrack,
26
- n as spinner,
27
- c as subtitle,
28
- o as textContent,
29
- r as title
30
- };