@digiform/wizard 0.2.18 → 0.3.1

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 (58) hide show
  1. package/core/src/types/guards.js +0 -12
  2. package/core/src/utils/apiBodyUtils.js +43 -75
  3. package/index.d.ts +2 -8
  4. package/index.js +2 -108
  5. package/package.json +1 -28
  6. package/styles.css +1 -1
  7. package/ui/src/lib/utils/templateUtils.js +11 -43
  8. package/wizard/src/features/form-runtime/FormWizard/FormWizard.js +36 -33
  9. package/wizard/src/features/form-runtime/components/FormField.js +28 -28
  10. package/wizard/src/features/form-runtime/components/FormFooter.js +4 -4
  11. package/wizard/src/features/form-runtime/components/FormSection/FormSection.js +19 -19
  12. package/wizard/src/features/form-runtime/components/FormStep/FormStep.js +21 -21
  13. package/wizard/src/features/form-runtime/components/StepProgressIndicator/StepProgressIndicator.js +1 -1
  14. package/wizard/src/features/form-runtime/config/configResolver.js +10 -14
  15. package/wizard/src/features/form-runtime/config/templateLoader.js +82 -112
  16. package/wizard/src/features/form-runtime/hooks/useComponentTriggers.js +42 -66
  17. package/wizard/src/features/form-runtime/hooks/useFieldEventHandlers.js +3 -3
  18. package/wizard/src/features/form-runtime/hooks/useFormFieldState.js +5 -5
  19. package/wizard/src/features/form-runtime/utils/errorUtils.js +31 -42
  20. package/wizard/src/features/form-runtime/utils/validationUX.js +14 -55
  21. package/wizard/src/features/state-management/machines/useFormMachine.js +3 -3
  22. package/wizard/src/features/trigger-action-system/components/ActionManager.js +4 -4
  23. package/wizard/src/features/validation-system/validation/ValidationEngine.js +24 -29
  24. package/FormWizard.d.ts +0 -10
  25. package/core/src/types/api.js +0 -12
  26. package/core/src/types/form-config.js +0 -60
  27. package/core/src/types/form-wizard-config-schema.js +0 -113
  28. package/core/src/types/validation.js +0 -61
  29. package/features/api-integration.d.ts +0 -2
  30. package/features/api-integration.js +0 -17
  31. package/features/dialog-system.d.ts +0 -2
  32. package/features/dialog-system.js +0 -9
  33. package/features/form-runtime.d.ts +0 -2
  34. package/features/form-runtime.js +0 -63
  35. package/features/index.d.ts +0 -11
  36. package/features/state-management.d.ts +0 -2
  37. package/features/state-management.js +0 -21
  38. package/features/trigger-action-system.d.ts +0 -2
  39. package/features/trigger-action-system.js +0 -12
  40. package/features/validation-system.d.ts +0 -2
  41. package/features/validation-system.js +0 -23
  42. package/styles/index.d.ts +0 -0
  43. package/ui/src/components/badge/badge.js +0 -20
  44. package/ui/src/components/badge/badge.module.css.js +0 -12
  45. package/wizard/src/features/api-integration/services/ActionExecutor.js +0 -339
  46. package/wizard/src/features/api-integration/services/ApiCallExecutor.js +0 -6
  47. package/wizard/src/features/api-integration/services/DialogExecutor.js +0 -6
  48. package/wizard/src/features/api-integration/services/GenericTriggerService.js +0 -284
  49. package/wizard/src/features/api-integration/services/NavigationExecutor.js +0 -6
  50. package/wizard/src/features/form-runtime/config/templateConfig.js +0 -156
  51. package/wizard/src/features/form-runtime/config/templateUtils.js +0 -14
  52. package/wizard/src/features/form-runtime/utils/validation.js +0 -100
  53. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.js +0 -46
  54. package/wizard/src/features/trigger-action-system/components/ActionLoadingIndicator/ActionLoadingIndicator.module.css.js +0 -30
  55. package/wizard/src/features/trigger-action-system/utils/GenericTriggerEngine.js +0 -376
  56. package/wizard/src/features/validation-system/components/ValidationDebugger.js +0 -69
  57. package/wizard/src/features/validation-system/validation/tanstackSchemaAdapter.js +0 -17
  58. package/wizard/src/features/validation-system/validation/validationService.js +0 -74
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  /* empty css */
3
- import { isGenericTemplate as y, isTeamTemplate as b } from "../../../../../ui/src/lib/utils/templateUtils.js";
3
+ import { isGenericTemplate as v, isTeamTemplate as h } from "../../../../../ui/src/lib/utils/templateUtils.js";
4
4
  async function m() {
5
5
  try {
6
6
  const { templateStorageService: e } = await import("@formbuilder/builder");
@@ -9,22 +9,22 @@ async function m() {
9
9
  return console.warn("Template storage service not available:", e), null;
10
10
  }
11
11
  }
12
- async function u() {
12
+ async function y() {
13
13
  try {
14
14
  const e = await m();
15
15
  if (!e) return;
16
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);
17
+ const i = await fetch("/form.config.json");
18
+ if (i.ok) {
19
+ const r = (await i.json()).storage?.paths?.templates;
20
+ r && await e.initialize(r);
21
21
  }
22
22
  }
23
23
  } catch (e) {
24
24
  console.warn("Failed to initialize template storage service:", e);
25
25
  }
26
26
  }
27
- function f(e) {
27
+ function d(e) {
28
28
  return {
29
29
  metadata: e.metadata,
30
30
  stepsData: e.stepsData || [],
@@ -40,7 +40,7 @@ function f(e) {
40
40
  }
41
41
  };
42
42
  }
43
- const p = /* @__PURE__ */ new Map(), o = {
43
+ const f = /* @__PURE__ */ new Map(), c = {
44
44
  "generic-contact-information": async () => {
45
45
  const e = await fetch(
46
46
  "/src/packages/form-wizard/admin/templates/generic/contact-information.json"
@@ -82,100 +82,100 @@ const p = /* @__PURE__ */ new Map(), o = {
82
82
  return e.json();
83
83
  }
84
84
  };
85
- async function v(e) {
86
- if (p.has(e))
87
- return p.get(e);
85
+ async function b(e) {
86
+ if (f.has(e))
87
+ return f.get(e);
88
88
  try {
89
- let r;
90
- if (y(e)) {
91
- const i = o[e];
92
- if (!i) {
93
- const s = Object.keys(o);
89
+ let i;
90
+ if (v(e)) {
91
+ const a = c[e];
92
+ if (!a) {
93
+ const o = Object.keys(c);
94
94
  throw new Error(
95
- `Generic template '${e}' not found. Available generic templates: ${s.join(", ")}`
95
+ `Generic template '${e}' not found. Available generic templates: ${o.join(", ")}`
96
96
  );
97
97
  }
98
- const t = await i();
99
- r = f(
100
- t
98
+ const r = await a();
99
+ i = d(
100
+ r
101
101
  );
102
- } else if (b(e)) {
103
- await u();
104
- const i = await m();
105
- if (!i)
102
+ } else if (h(e)) {
103
+ await y();
104
+ const a = await m();
105
+ if (!a)
106
106
  throw new Error(
107
107
  `Team template '${e}' could not be loaded: template storage service is not available`
108
108
  );
109
- const t = await i.loadTemplate(
109
+ const r = await a.loadTemplate(
110
110
  e,
111
111
  "team"
112
112
  );
113
- if (!t.success)
113
+ if (!r.success)
114
114
  throw new Error(
115
- `Team template '${e}' not found: ${"error" in t && t.error?.message || "Unknown error"}`
115
+ `Team template '${e}' not found: ${"error" in r && r.error?.message || "Unknown error"}`
116
116
  );
117
- r = f(t.data);
117
+ i = d(r.data);
118
118
  } else {
119
- const i = o[e];
120
- if (i) {
121
- const t = await i();
122
- r = f(
123
- t
119
+ const a = c[e];
120
+ if (a) {
121
+ const r = await a();
122
+ i = d(
123
+ r
124
124
  );
125
125
  } else {
126
- const t = Object.keys(o);
126
+ const r = Object.keys(c);
127
127
  throw new Error(
128
- `Template '${e}' not found. Available generic templates: ${t.join(", ")}`
128
+ `Template '${e}' not found. Available generic templates: ${r.join(", ")}`
129
129
  );
130
130
  }
131
131
  }
132
- if (!r.metadata || !Array.isArray(r.stepsData))
132
+ if (!i.metadata || !Array.isArray(i.stepsData))
133
133
  throw new Error(
134
134
  `Invalid template structure for template: ${e}. Templates must have metadata and stepsData array.`
135
135
  );
136
- return p.set(e, r), r;
137
- } catch (r) {
136
+ return f.set(e, i), i;
137
+ } catch (i) {
138
138
  throw new Error(
139
- `Failed to load template '${e}': ${r instanceof Error ? r.message : "Unknown error"}`
139
+ `Failed to load template '${e}': ${i instanceof Error ? i.message : "Unknown error"}`
140
140
  );
141
141
  }
142
142
  }
143
- async function S(e, r, i) {
143
+ async function E(e, i, a) {
144
144
  console.log(
145
145
  "Resolving template step:",
146
146
  e,
147
147
  "stepIndex:",
148
- i
148
+ a
149
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`
150
+ const r = await b(e.templateId);
151
+ console.log("Loaded template:", r);
152
+ let o;
153
+ if (r.stepsData && Array.isArray(r.stepsData) && r.stepsData.length > 0)
154
+ a !== void 0 && a >= 0 && a < r.stepsData.length ? (o = r.stepsData[a], console.log(`Using template data for step ${a}:`, o)) : (o = r.stepsData[0], console.warn(
155
+ `Invalid stepIndex ${a} for template, using first step`
156
156
  ));
157
157
  else
158
158
  throw new Error(`Template ${e.templateId} has no steps data`);
159
- const h = s.sections?.map((w) => ({
159
+ const u = o.sections?.map((w) => ({
160
160
  ...w,
161
- components: w.components.map((a) => {
162
- const g = ((c) => `comp-${e.id}-${a.id || c}`)(a.id), n = {
161
+ components: w.components.map((t) => {
162
+ const g = ((l) => `comp-${e.id}-${t.id || l}`)(t.id), s = {
163
163
  id: g,
164
- type: a.type,
164
+ type: t.type,
165
165
  properties: {
166
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,
167
+ label: t.properties?.label || t.label || "",
168
+ placeholder: t.properties?.placeholder || t.placeholder || "",
169
+ description: t.properties?.description || t.description || "",
170
+ required: t.properties?.required || t.required || !1,
171
+ disabled: t.properties?.disabled || t.disabled || !1,
172
+ readOnly: t.properties?.readOnly || t.readOnly || !1,
173
+ invalid: t.properties?.invalid || !1,
174
174
  // Add type-specific properties
175
- type: a.properties?.type || a.type,
175
+ type: t.properties?.type || t.type,
176
176
  // Copy all other properties from component.properties if it exists
177
- ...a.properties && Object.keys(a.properties).reduce(
178
- (c, d) => ([
177
+ ...t.properties && Object.keys(t.properties).reduce(
178
+ (l, p) => ([
179
179
  "label",
180
180
  "placeholder",
181
181
  "description",
@@ -184,82 +184,52 @@ async function S(e, r, i) {
184
184
  "readOnly",
185
185
  "invalid",
186
186
  "type"
187
- ].includes(d) || (c[d] = a.properties[d]), c),
187
+ ].includes(p) || (l[p] = t.properties[p]), l),
188
188
  {}
189
189
  )
190
190
  },
191
191
  // Copy validation if it exists
192
- ...a.validation && { validation: a.validation }
193
- }, l = e.componentOverrides?.[g];
194
- return l ? {
192
+ ...t.validation && { validation: t.validation }
193
+ }, n = e.componentOverrides?.[g];
194
+ return n ? {
195
+ ...s,
195
196
  ...n,
196
- ...l,
197
197
  // Merge properties deeply to allow partial property updates
198
198
  properties: {
199
- ...n.properties,
200
- ...l.properties
199
+ ...s.properties,
200
+ ...n.properties
201
201
  },
202
202
  // Merge validation deeply if both exist
203
- ...n.validation && l.validation && {
203
+ ...s.validation && n.validation && {
204
204
  validation: {
205
- ...n.validation,
206
- ...l.validation
205
+ ...s.validation,
206
+ ...n.validation
207
207
  }
208
208
  }
209
- } : n;
209
+ } : s;
210
210
  })
211
211
  }));
212
212
  return {
213
213
  id: e.id,
214
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,
215
+ title: e.title || o.title,
216
+ displayTitle: o.displayTitle,
217
+ showStepNumber: e.showStepNumber !== void 0 ? e.showStepNumber : o.showStepNumber,
218
+ sections: u,
219
219
  navigation: {
220
220
  // Use default navigation, then template navigation if available, then step override
221
- ...r,
222
- ...s.navigation,
221
+ ...i,
222
+ ...o.navigation,
223
223
  // Cast since navigation might not exist in Omit type
224
224
  ...e.navigation
225
225
  },
226
226
  // Copy actions if they exist
227
- ...s.actions && {
228
- actions: s.actions
227
+ ...o.actions && {
228
+ actions: o.actions
229
229
  }
230
230
  };
231
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
232
  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
233
+ b as loadTemplate,
234
+ E as resolveTemplateStep
265
235
  };
@@ -1,102 +1,78 @@
1
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 = ({
2
+ import { useRef as C, useCallback as g } from "react";
3
+ import { useFormMachine as x } from "../../state-management/machines/useFormMachine.js";
4
+ const M = ({
5
5
  componentId: e,
6
- initialValue: o,
7
- onValueChange: l
6
+ initialValue: l,
7
+ onValueChange: i
8
8
  }) => {
9
- const [, , f] = M(), {
10
- evaluateComponentTriggers: a,
11
- setComponentOriginalValue: i,
9
+ const [, , T] = x(), {
10
+ evaluateComponentTriggers: n,
11
+ setComponentOriginalValue: u,
12
12
  getComponentAlerts: h,
13
- dismissComponentAlert: u,
13
+ dismissComponentAlert: c,
14
14
  hasComponentTriggers: A,
15
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) => {
16
+ getComponentTriggerState: p
17
+ } = T, f = C(!1), o = C(l);
18
+ l !== void 0 && !f.current && (u(e, l), o.current = l, f.current = !0);
19
+ const t = g(
20
+ (r, a) => {
21
21
  console.log(
22
22
  `🧪 [useComponentTriggers] evaluateTriggers called for ${e}:`,
23
23
  {
24
24
  eventType: r,
25
- value: c,
26
- evaluateComponentTriggers: !!a
25
+ value: a,
26
+ evaluateComponentTriggers: !!n
27
27
  }
28
- ), a(e, r, c);
28
+ ), n(e, r, a);
29
29
  },
30
- [e, a]
31
- ), p = n(
32
- (r, c = "api_populated") => {
33
- i(e, r, c), g.current = r;
30
+ [e, n]
31
+ ), $ = g(
32
+ (r, a = "api_populated") => {
33
+ u(e, r, a), o.current = r;
34
34
  },
35
- [e, i]
36
- ), $ = h(e), b = n(
35
+ [e, u]
36
+ ), b = h(e), R = g(
37
37
  (r) => {
38
- u(e, r);
38
+ c(e, r);
39
39
  },
40
- [e, u]
41
- ), s = A(e), B = m(e), O = F(e), R = n(
40
+ [e, c]
41
+ ), s = A(e), F = m(e), O = p(e), S = g(
42
42
  (r) => {
43
43
  console.log(
44
44
  `🧪 [useComponentTriggers] handleValueChange called for ${e}:`,
45
45
  {
46
46
  value: r,
47
- oldValue: g.current,
47
+ oldValue: o.current,
48
48
  hasTriggers: s,
49
- onValueChange: !!l
49
+ onValueChange: !!i
50
50
  }
51
- ), g.current = r, l && l(r), s ? (console.log(
51
+ ), o.current = r, i && i(r), s ? (console.log(
52
52
  `🧪 [useComponentTriggers] About to call evaluateTriggers for ${e}`
53
53
  ), t("valueChange", r)) : console.log(
54
54
  `🧪 [useComponentTriggers] hasTriggers is false for ${e}`
55
55
  );
56
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);
57
+ [t, s, i, e]
58
+ ), k = g(() => {
59
+ s && t("focus", o.current);
60
+ }, [t, s]), v = g(() => {
61
+ s && t("blur", o.current);
62
62
  }, [t, s]);
63
63
  return {
64
64
  evaluateTriggers: t,
65
- setOriginalValue: p,
66
- alerts: $,
67
- dismissAlert: b,
65
+ setOriginalValue: $,
66
+ alerts: b,
67
+ dismissAlert: R,
68
68
  hasTriggers: s,
69
- hasActions: B,
69
+ hasActions: F,
70
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
71
+ handleValueChange: S,
72
+ handleFocus: k,
73
+ handleBlur: v
97
74
  };
98
75
  };
99
76
  export {
100
- S as useComponentTriggers,
101
- x as useFieldTriggerMonitor
77
+ M as useComponentTriggers
102
78
  };
@@ -1,8 +1,8 @@
1
1
  "use client";
2
- import { useFormMachine as B } from "../../state-management/machines/useFormMachine.js";
3
2
  import { useCallback as g } from "react";
4
3
  import { markFieldAsUserInteracted as u } from "../utils/validationUX.js";
5
- import { useComponentTriggers as F } from "./useComponentTriggers.js";
4
+ import { useComponentTriggers as B } from "./useComponentTriggers.js";
5
+ import { useFormMachine as F } from "../../state-management/machines/useFormMachine.js";
6
6
  const E = ({
7
7
  componentId: s,
8
8
  hasIsDirtyTriggers: r,
@@ -10,7 +10,7 @@ const E = ({
10
10
  getEnhancedIsDirty: n,
11
11
  resetValidationState: f
12
12
  }) => {
13
- const [, , d] = B(), { setData: h } = d, t = F({ componentId: s }), C = g(
13
+ const [, , d] = F(), { setData: h } = d, t = B({ componentId: s }), C = g(
14
14
  (a) => (e) => {
15
15
  const l = a.state.value;
16
16
  if (console.log(
@@ -1,12 +1,12 @@
1
1
  "use client";
2
- import { useFormMachine as p } from "../../state-management/machines/useFormMachine.js";
3
- import { useRef as F, useCallback as u, useEffect as O } from "react";
4
- import { useFormContext as h } from "./useFormContext.js";
2
+ import { useRef as F, useCallback as u, useEffect as p } from "react";
3
+ import { useFormContext as O } from "./useFormContext.js";
4
+ import { useFormMachine as h } from "../../state-management/machines/useFormMachine.js";
5
5
  const b = ({
6
6
  componentId: r,
7
7
  hasIsDirtyTriggers: s
8
8
  }) => {
9
- const [V] = p(), t = h(), a = F(!1), c = F(), d = (e) => typeof e == "string" || typeof e == "boolean" || typeof e == "number" || e === null || e === void 0, f = V.context.componentOriginalValues[r]?.value, i = d(f) ? f : void 0, g = u(() => {
9
+ const [V] = h(), t = O(), a = F(!1), c = F(), d = (e) => typeof e == "string" || typeof e == "boolean" || typeof e == "number" || e === null || e === void 0, f = V.context.componentOriginalValues[r]?.value, i = d(f) ? f : void 0, g = u(() => {
10
10
  if (a.current) return;
11
11
  const e = t.getFieldValue(r);
12
12
  return a.current = !0, e;
@@ -26,7 +26,7 @@ const b = ({
26
26
  (e, l) => i !== void 0 ? e !== i : l,
27
27
  [i]
28
28
  );
29
- return O(() => {
29
+ return p(() => {
30
30
  o();
31
31
  }, [o]), {
32
32
  originalValueFromMachine: i,
@@ -1,6 +1,6 @@
1
1
  "use client";
2
- import { z as a } from "zod";
3
- const u = {
2
+ import { z as s } from "zod";
3
+ const l = {
4
4
  required: 10,
5
5
  minLength: 8,
6
6
  maxLength: 7,
@@ -10,19 +10,19 @@ const u = {
10
10
  email: 3,
11
11
  custom: 2,
12
12
  default: 1
13
- }, i = (t) => {
13
+ }, e = (t) => {
14
14
  if (typeof t == "string")
15
15
  return t.includes("verplicht") || t.includes("required") ? "required" : t.includes("minimaal") && t.includes("tekens") ? "minLength" : t.includes("maximaal") && t.includes("tekens") ? "maxLength" : t.includes("minimaal") && !t.includes("tekens") ? "min" : t.includes("maximaal") && !t.includes("tekens") ? "max" : t.includes("formaat") || t.includes("format") || t.includes("pattern") ? "pattern" : t.includes("e-mail") || t.includes("email") ? "email" : "default";
16
- if (t instanceof a.ZodError) {
17
- const e = t.errors[0];
18
- if (e?.code)
19
- switch (e.code) {
16
+ if (t instanceof s.ZodError) {
17
+ const i = t.errors[0];
18
+ if (i?.code)
19
+ switch (i.code) {
20
20
  case "too_small":
21
- return e.type === "string" ? "minLength" : "min";
21
+ return i.type === "string" ? "minLength" : "min";
22
22
  case "too_big":
23
- return e.type === "string" ? "maxLength" : "max";
23
+ return i.type === "string" ? "maxLength" : "max";
24
24
  case "invalid_string":
25
- return e.validation === "email" ? "email" : "pattern";
25
+ return i.validation === "email" ? "email" : "pattern";
26
26
  case "custom":
27
27
  return "custom";
28
28
  default:
@@ -30,27 +30,27 @@ const u = {
30
30
  }
31
31
  }
32
32
  if (typeof t == "object" && t !== null && "code" in t) {
33
- const e = t.code;
34
- if (e === "too_small") return "minLength";
35
- if (e === "too_big") return "maxLength";
36
- if (e === "invalid_string") return "email";
33
+ const i = t.code;
34
+ if (i === "too_small") return "minLength";
35
+ if (i === "too_big") return "maxLength";
36
+ if (i === "invalid_string") return "email";
37
37
  }
38
38
  return "default";
39
- }, s = (t) => {
39
+ }, a = (t) => {
40
40
  if (t == null) return "";
41
41
  if (typeof t == "string")
42
42
  return t;
43
- if (t instanceof a.ZodError)
44
- return t.errors.map((e) => e.message).join(", ");
43
+ if (t instanceof s.ZodError)
44
+ return t.errors.map((i) => i.message).join(", ");
45
45
  if (typeof t == "object" && t !== null) {
46
46
  if ("message" in t && typeof t.message == "string")
47
47
  return t.message;
48
48
  if ("_errors" in t && Array.isArray(t._errors))
49
49
  return t._errors.filter(Boolean).join(", ");
50
50
  if ("issues" in t && Array.isArray(t.issues))
51
- return t.issues.map((e) => e.message || "Validation error").join(", ");
51
+ return t.issues.map((i) => i.message || "Validation error").join(", ");
52
52
  if ("error" in t)
53
- return s(t.error);
53
+ return a(t.error);
54
54
  try {
55
55
  if (Object.keys(t).length > 0) {
56
56
  for (const n of ["message", "msg", "error", "description"])
@@ -61,33 +61,22 @@ const u = {
61
61
  }
62
62
  }
63
63
  try {
64
- const e = JSON.stringify(t);
65
- if (e.length < 200)
66
- return e;
64
+ const i = JSON.stringify(t);
65
+ if (i.length < 200)
66
+ return i;
67
67
  } catch {
68
68
  }
69
69
  return "Validation error occurred";
70
- }, c = (t) => t.filter((e) => e != null).map((e) => s(e)).filter((e) => e.length > 0), m = (t) => {
70
+ }, f = (t) => {
71
71
  if (!t || t.length === 0) return "";
72
- const e = t.filter((n) => n != null).map((n) => ({
73
- message: s(n),
74
- type: i(n),
75
- priority: u[i(n)]
72
+ const i = t.filter((n) => n != null).map((n) => ({
73
+ message: a(n),
74
+ type: e(n),
75
+ priority: l[e(n)]
76
76
  })).filter((n) => n.message.length > 0);
77
- return e.length === 0 ? "" : (e.sort((n, l) => l.priority - n.priority), e[0].message);
78
- }, g = (t) => c(t)[0] || "", d = (t) => t.map((e, n) => ({
79
- index: n,
80
- type: typeof e,
81
- constructor: e?.constructor?.name,
82
- raw: e,
83
- parsed: s(e),
84
- validationType: i(e),
85
- priority: u[i(e)]
86
- }));
77
+ return i.length === 0 ? "" : (i.sort((n, u) => u.priority - n.priority), i[0].message);
78
+ };
87
79
  export {
88
- d as getErrorDebugInfo,
89
- g as getFirstErrorMessage,
90
- m as getMostRelevantError,
91
- c as parseAllErrors,
92
- s as parseError
80
+ f as getMostRelevantError,
81
+ a as parseError
93
82
  };