impact-nova 2.3.0 → 2.4.0

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 (147) hide show
  1. package/dist/filter-shell/index.d.ts +12 -0
  2. package/dist/filter-shell/index.js +9 -0
  3. package/dist/filter-shell/utils/buildFilterFieldValidationRules.d.ts +1 -0
  4. package/dist/filter-shell/utils/validateVisibleRequiredFilterFields.d.ts +1 -0
  5. package/dist/filter-shell/utils/validationNavigation.utils.d.ts +26 -0
  6. package/dist/filter-shell/utils/validationNavigation.utils.js +38 -0
  7. package/dist/form-engine/field-dependency-graph.d.ts +17 -0
  8. package/dist/form-engine/field-dependency-graph.js +90 -0
  9. package/dist/form-engine/index.d.ts +9 -0
  10. package/dist/form-engine/index.js +16 -0
  11. package/dist/form-engine/is-empty-value.d.ts +1 -0
  12. package/dist/form-engine/is-empty-value.js +8 -0
  13. package/dist/form-engine/types.d.ts +17 -0
  14. package/dist/form-react/Fields/ButtonsGroupField.d.ts +3 -0
  15. package/dist/form-react/Fields/ButtonsGroupField.js +52 -0
  16. package/dist/form-react/Fields/CheckboxField.d.ts +3 -0
  17. package/dist/form-react/Fields/CheckboxField.js +46 -0
  18. package/dist/form-react/Fields/ChipsField.d.ts +3 -0
  19. package/dist/form-react/Fields/ChipsField.js +146 -0
  20. package/dist/form-react/Fields/DateInputField.d.ts +8 -0
  21. package/dist/form-react/Fields/DateInputField.js +134 -0
  22. package/dist/form-react/Fields/DateRangeField.d.ts +8 -0
  23. package/dist/form-react/Fields/DateRangeField.js +57 -0
  24. package/dist/form-react/Fields/DividerField.d.ts +3 -0
  25. package/dist/form-react/Fields/DividerField.js +9 -0
  26. package/dist/form-react/Fields/DividerWithLabelField.d.ts +3 -0
  27. package/dist/form-react/Fields/DividerWithLabelField.js +31 -0
  28. package/dist/form-react/Fields/FileUploadField.d.ts +3 -0
  29. package/dist/form-react/Fields/FileUploadField.js +42 -0
  30. package/dist/form-react/Fields/FillFormByFileUploadField.d.ts +3 -0
  31. package/dist/form-react/Fields/FillFormByFileUploadField.js +65 -0
  32. package/dist/form-react/Fields/FillFormByPasteField.d.ts +3 -0
  33. package/dist/form-react/Fields/FillFormByPasteField.js +106 -0
  34. package/dist/form-react/Fields/LabelField.d.ts +3 -0
  35. package/dist/form-react/Fields/LabelField.js +14 -0
  36. package/dist/form-react/Fields/MonthRangeField.d.ts +8 -0
  37. package/dist/form-react/Fields/MonthRangeField.js +72 -0
  38. package/dist/form-react/Fields/MultiMonthPickerField.d.ts +8 -0
  39. package/dist/form-react/Fields/MultiMonthPickerField.js +46 -0
  40. package/dist/form-react/Fields/MultiWeekPickerField.d.ts +8 -0
  41. package/dist/form-react/Fields/MultiWeekPickerField.js +47 -0
  42. package/dist/form-react/Fields/NumericComboboxField.d.ts +18 -0
  43. package/dist/form-react/Fields/NumericComboboxField.js +51 -0
  44. package/dist/form-react/Fields/RadioField.d.ts +3 -0
  45. package/dist/form-react/Fields/RadioField.js +68 -0
  46. package/dist/form-react/Fields/SelectField.d.ts +3 -0
  47. package/dist/form-react/Fields/SelectField.js +76 -0
  48. package/dist/form-react/Fields/SwitchField.d.ts +3 -0
  49. package/dist/form-react/Fields/SwitchField.js +47 -0
  50. package/dist/form-react/Fields/TextAreaField.d.ts +3 -0
  51. package/dist/form-react/Fields/TextAreaField.js +41 -0
  52. package/dist/form-react/Fields/TextField.d.ts +3 -0
  53. package/dist/form-react/Fields/TextField.js +75 -0
  54. package/dist/form-react/Fields/TextFieldWithBackendValidation.d.ts +3 -0
  55. package/dist/form-react/Fields/TextFieldWithBackendValidation.js +117 -0
  56. package/dist/form-react/Fields/WeekRangePicker.d.ts +8 -0
  57. package/dist/form-react/Fields/WeekRangePicker.js +71 -0
  58. package/dist/form-react/ReactHooksForm.d.ts +3 -0
  59. package/dist/form-react/ReactHooksForm.js +132 -0
  60. package/dist/form-react/components/ArrayFieldRenderer.d.ts +13 -0
  61. package/dist/form-react/components/ArrayFieldRenderer.js +90 -0
  62. package/dist/form-react/components/FieldRenderer.d.ts +16 -0
  63. package/dist/form-react/components/FieldRenderer.js +68 -0
  64. package/dist/form-react/components/FormFieldRow.d.ts +13 -0
  65. package/dist/form-react/components/FormFieldRow.js +47 -0
  66. package/dist/form-react/components/FormFileUploadWrapper.d.ts +22 -0
  67. package/dist/form-react/components/FormFileUploadWrapper.js +88 -0
  68. package/dist/form-react/components/ObjectFieldRenderer.d.ts +13 -0
  69. package/dist/form-react/components/ObjectFieldRenderer.js +46 -0
  70. package/dist/form-react/components/SetToEmptyWrapper.d.ts +16 -0
  71. package/dist/form-react/components/SetToEmptyWrapper.js +49 -0
  72. package/dist/form-react/fields.d.ts +23 -0
  73. package/dist/form-react/fields.js +40 -0
  74. package/dist/form-react/hooks/useCascadingForm.d.ts +17 -0
  75. package/dist/form-react/hooks/useCascadingForm.js +122 -0
  76. package/dist/form-react/hooks/useFieldVisibility.d.ts +14 -0
  77. package/dist/form-react/hooks/useFieldVisibility.js +60 -0
  78. package/dist/form-react/hooks/useFillFormByFileUpload.d.ts +33 -0
  79. package/dist/form-react/hooks/useFillFormByFileUpload.js +199 -0
  80. package/dist/form-react/hooks/useFillFormByPaste.d.ts +33 -0
  81. package/dist/form-react/hooks/useFillFormByPaste.js +104 -0
  82. package/dist/form-react/hooks/useFormFieldChangeSubscription.d.ts +13 -0
  83. package/dist/form-react/hooks/useFormFieldChangeSubscription.js +42 -0
  84. package/dist/form-react/hooks/useReactHookForm.d.ts +3 -0
  85. package/dist/form-react/hooks/useReactHookForm.js +161 -0
  86. package/dist/form-react/hooks/useSelectOptions.d.ts +8 -0
  87. package/dist/form-react/hooks/useSelectOptions.js +116 -0
  88. package/dist/form-react/index.d.ts +62 -0
  89. package/dist/form-react/index.js +97 -0
  90. package/dist/form-react/registry/defaultFieldRegistrations.d.ts +2 -0
  91. package/dist/form-react/registry/defaultFieldRegistrations.js +30 -0
  92. package/dist/form-react/registry/fieldRegistry.d.ts +14 -0
  93. package/dist/form-react/registry/fieldRegistry.js +19 -0
  94. package/dist/form-react/registry/resolveFieldComponent.d.ts +10 -0
  95. package/dist/form-react/registry/resolveFieldComponent.js +137 -0
  96. package/dist/form-react/types/fields.types.d.ts +402 -0
  97. package/dist/form-react/types/fieldsOutput.types.d.ts +73 -0
  98. package/dist/form-react/types/reactHookForm.types.d.ts +196 -0
  99. package/dist/form-react/utils/batchFormFieldUpdates.d.ts +14 -0
  100. package/dist/form-react/utils/batchFormFieldUpdates.js +13 -0
  101. package/dist/form-react/utils/buildFieldValidationRules.d.ts +6 -0
  102. package/dist/form-react/utils/buildFieldValidationRules.js +13 -0
  103. package/dist/form-react/utils/buildSelectRemountKey.d.ts +14 -0
  104. package/dist/form-react/utils/buildSelectRemountKey.js +14 -0
  105. package/dist/form-react/utils/calendar-boundary.d.ts +3 -0
  106. package/dist/form-react/utils/calendar-boundary.js +33 -0
  107. package/dist/form-react/utils/date.utils.d.ts +31 -0
  108. package/dist/form-react/utils/date.utils.js +86 -0
  109. package/dist/form-react/utils/evaluateFieldValidation.d.ts +19 -0
  110. package/dist/form-react/utils/evaluateFieldValidation.js +53 -0
  111. package/dist/form-react/utils/fieldDefaults.utils.d.ts +6 -0
  112. package/dist/form-react/utils/fieldDefaults.utils.js +25 -0
  113. package/dist/form-react/utils/fieldPath.utils.d.ts +23 -0
  114. package/dist/form-react/utils/fieldPath.utils.js +26 -0
  115. package/dist/form-react/utils/fieldRangeValidation.utils.d.ts +3 -0
  116. package/dist/form-react/utils/fieldRangeValidation.utils.js +24 -0
  117. package/dist/form-react/utils/fieldRendererUtils.d.ts +10 -0
  118. package/dist/form-react/utils/fieldRendererUtils.js +47 -0
  119. package/dist/form-react/utils/fieldTestIds.d.ts +3 -0
  120. package/dist/form-react/utils/fieldTestIds.js +13 -0
  121. package/dist/form-react/utils/formDate.utils.d.ts +13 -0
  122. package/dist/form-react/utils/formDate.utils.js +9 -0
  123. package/dist/form-react/utils/formValidationFeedback.utils.d.ts +32 -0
  124. package/dist/form-react/utils/formValidationFeedback.utils.js +153 -0
  125. package/dist/form-react/utils/icons.d.ts +5 -0
  126. package/dist/form-react/utils/icons.js +10 -0
  127. package/dist/form-react/utils/optionFlag.d.ts +11 -0
  128. package/dist/form-react/utils/optionFlag.js +17 -0
  129. package/dist/form-react/utils/pastedValues.d.ts +1 -0
  130. package/dist/form-react/utils/resolveFormSubmittable.d.ts +18 -0
  131. package/dist/form-react/utils/resolveFormSubmittable.js +32 -0
  132. package/dist/form-react/utils/select-option-filter-values.d.ts +5 -0
  133. package/dist/form-react/utils/select-option-filter-values.js +30 -0
  134. package/dist/form-react/utils/serializeFormStateForQueryKey.d.ts +1 -0
  135. package/dist/form-react/utils/serializeFormStateForQueryKey.js +21 -0
  136. package/dist/form-react/utils/stableSerialize.d.ts +5 -0
  137. package/dist/form-react/utils/stableSerialize.js +11 -0
  138. package/dist/form-react/utils/validateVisibleRequiredFormFields.d.ts +21 -0
  139. package/dist/form-react/utils/validateVisibleRequiredFormFields.js +64 -0
  140. package/dist/form-react/utils/validationUtils.d.ts +3 -0
  141. package/dist/form-react/utils/validationUtils.js +77 -0
  142. package/dist/impact-nova.css +1 -1
  143. package/dist/lib/primitives/use-field-chrome.js +16 -16
  144. package/dist/llms/rules/installation.js +1 -1
  145. package/dist/llms/rules/real-world-patterns.js +1 -1
  146. package/dist/llms/rules/requirements.js +1 -1
  147. package/package.json +21 -2
@@ -0,0 +1,153 @@
1
+ import { getFieldTestId as F } from "./fieldTestIds.js";
2
+ import { isRangeIncompleteValidationMessage as q } from "./fieldRangeValidation.utils.js";
3
+ const E = /* @__PURE__ */ new Set([
4
+ "date_range",
5
+ "week_range",
6
+ "month_range"
7
+ ]);
8
+ function h(e, s) {
9
+ return s === `${e} is required`;
10
+ }
11
+ function p(e) {
12
+ return q(e);
13
+ }
14
+ function b(e) {
15
+ switch (e) {
16
+ case "select":
17
+ return "select";
18
+ case "radio":
19
+ case "button_group":
20
+ case "chips":
21
+ return "choose";
22
+ case "text":
23
+ case "text_area":
24
+ return "enter";
25
+ case "date_range":
26
+ case "week_range":
27
+ case "month_range":
28
+ return "complete";
29
+ case "file_upload":
30
+ case "fill_form_by_file_upload":
31
+ return "upload";
32
+ case "fill_form_by_paste":
33
+ case "fill_form_by_multi_paste":
34
+ return "provide";
35
+ default:
36
+ return "complete";
37
+ }
38
+ }
39
+ function $(e) {
40
+ return e.length <= 1 ? e[0] ?? "" : e.length === 2 ? `${e[0]} and ${e[1]}` : `${e.slice(0, -1).join(", ")}, and ${e[e.length - 1]}`;
41
+ }
42
+ function T(e, s, o) {
43
+ if (!e?.fieldType)
44
+ return `${s} is required to ${o}.`;
45
+ const l = b(e.fieldType);
46
+ return `${l.charAt(0).toUpperCase()}${l.slice(1)} ${s} to ${o}.`;
47
+ }
48
+ function I(e, s, o = {}) {
49
+ const l = o.actionSuffix ?? "continue", n = o.entityNoun ?? "field", r = n.endsWith("s") ? n : `${n}s`, _ = new Map(s.map((t) => [t.id, t])), a = Object.entries(e).filter(([, t]) => !!t?.message).map(([t, c]) => {
50
+ const f = _.get(t), m = f?.label || t;
51
+ return {
52
+ fieldId: t,
53
+ label: m,
54
+ message: c.message,
55
+ field: f
56
+ };
57
+ });
58
+ if (a.length === 0)
59
+ return {
60
+ title: `Required ${r} missing`,
61
+ description: "Please fill in all required fields."
62
+ };
63
+ const d = a.filter(
64
+ (t) => p(t.message) || (t.field?.fieldType ? E.has(t.field.fieldType) : !1)
65
+ ), g = a.filter(
66
+ (t) => h(t.label, t.message)
67
+ ), u = a.filter(
68
+ (t) => !h(t.label, t.message) && !p(t.message)
69
+ ), i = g.map((t) => t.label);
70
+ if ((d.length > 0 || u.length > 0) && i.length > 0) {
71
+ const t = d.length > 0 ? `Fix ${d[0].label.toLowerCase()}` : u[0].message, c = g.length === 1 ? `${b(g[0].field?.fieldType)} ${i[0]}` : `complete ${$(i)}`;
72
+ return {
73
+ title: `${r.charAt(0).toUpperCase()}${r.slice(1)} need attention`,
74
+ description: `${t} and ${c}.`
75
+ };
76
+ }
77
+ if (d.length === 1 && i.length === 0 && u.length === 0)
78
+ return {
79
+ title: "Incomplete date range",
80
+ description: `${d[0].label} needs both start and end dates.`
81
+ };
82
+ if (i.length === 1 && d.length === 0 && u.length === 0)
83
+ return {
84
+ title: `Required ${n} missing`,
85
+ description: T(
86
+ g[0].field,
87
+ i[0],
88
+ l
89
+ )
90
+ };
91
+ if (i.length >= 2 && d.length === 0 && u.length === 0) {
92
+ const t = i.length, c = `${t} required ${r} missing`;
93
+ if (t <= 3)
94
+ return {
95
+ title: c,
96
+ description: `${$(i)} are required.`
97
+ };
98
+ const f = i.slice(0, t - 1), m = t - f.length;
99
+ return {
100
+ title: c,
101
+ description: `${t} required ${r} missing: ${f.join(", ")}, and ${m} more.`
102
+ };
103
+ }
104
+ return a.length === 1 ? {
105
+ title: `${r.charAt(0).toUpperCase()}${r.slice(1)} need attention`,
106
+ description: a[0].message
107
+ } : {
108
+ title: `${r.charAt(0).toUpperCase()}${r.slice(1)} need attention`,
109
+ description: a.map((t) => t.message).join(" ")
110
+ };
111
+ }
112
+ function y(e) {
113
+ const s = e.getFieldTestId ?? F, o = e.fieldsInOrder.find(
114
+ (n) => e.fieldErrors[n.id]?.message
115
+ );
116
+ if (!o)
117
+ return null;
118
+ const l = () => {
119
+ const n = document.querySelector(
120
+ `[data-testid="${s(o.id)}"]`
121
+ );
122
+ if (!n)
123
+ return !1;
124
+ n.scrollIntoView({ block: "nearest", behavior: "smooth" });
125
+ const r = n.querySelector(
126
+ 'input:not([disabled]):not([type="hidden"]), textarea:not([disabled]), button:not([disabled]), [role="combobox"]:not([aria-disabled="true"])'
127
+ ) ?? n;
128
+ return typeof r.focus == "function" && r.focus({ preventScroll: !0 }), !0;
129
+ };
130
+ return requestAnimationFrame(() => {
131
+ requestAnimationFrame(() => {
132
+ l() || setTimeout(() => l(), 0);
133
+ });
134
+ }), o.id;
135
+ }
136
+ function R(e) {
137
+ y({
138
+ fieldErrors: e.fieldErrors,
139
+ fieldsInOrder: e.fieldsInOrder,
140
+ getFieldTestId: e.getFieldTestId
141
+ }), e.showToast(
142
+ I(
143
+ e.fieldErrors,
144
+ e.fieldsInOrder,
145
+ e.toastMessageOptions
146
+ )
147
+ );
148
+ }
149
+ export {
150
+ I as buildFormValidationToastMessage,
151
+ y as focusFirstFormValidationError,
152
+ R as showFormValidationFailureFeedback
153
+ };
@@ -0,0 +1,5 @@
1
+ import { ReactNode } from 'react';
2
+ export declare function getAppIcon(iconName: string, iconProps?: {
3
+ className?: string;
4
+ size?: number | string;
5
+ }): ReactNode;
@@ -0,0 +1,10 @@
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import * as r from "impact-nova-icons";
3
+ const s = r;
4
+ function m(n, t) {
5
+ const o = s[n];
6
+ return o ? /* @__PURE__ */ c(o, { className: t?.className }) : null;
7
+ }
8
+ export {
9
+ m as getAppIcon
10
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Reads a boolean flag from a form-state value that may be:
3
+ * - an Array<Option> (how `SelectField` stores values, even in single-select mode), or
4
+ * - a single option-like object.
5
+ *
6
+ * The flag is read from `option.metadata[flagKey]` when `metadata` is present;
7
+ * otherwise from `option[flagKey]` for backward compatibility.
8
+ *
9
+ * Returns `false` when the value is empty, null, or the flag is missing.
10
+ */
11
+ export declare const readOptionFlag: (fieldValue: unknown, flagKey: string) => boolean;
@@ -0,0 +1,17 @@
1
+ const o = (t, n) => {
2
+ const r = t.metadata;
3
+ return r && typeof r == "object" && n in r ? !!r[n] : n in t ? !!t[n] : !1;
4
+ }, e = (t, n) => {
5
+ if (Array.isArray(t)) {
6
+ if (t.length === 0) return !1;
7
+ const r = t[0];
8
+ return r && typeof r == "object" ? o(r, n) : !1;
9
+ }
10
+ return t && typeof t == "object" ? o(
11
+ t,
12
+ n
13
+ ) : !1;
14
+ };
15
+ export {
16
+ e as readOptionFlag
17
+ };
@@ -0,0 +1 @@
1
+ export declare function cleanPastedValues(values: string): string[];
@@ -0,0 +1,18 @@
1
+ import { IField } from '../types/fields.types';
2
+ import { FormContext } from '../types/reactHookForm.types';
3
+ import { UseReactHookFormReturn } from '../hooks/useReactHookForm';
4
+ interface ResolveFormSubmittableParams {
5
+ formConfigFields: IField[];
6
+ formHelpers: UseReactHookFormReturn;
7
+ formContext?: FormContext;
8
+ }
9
+ export declare function resolveFormSubmittable({ formConfigFields, formHelpers, formContext, }: ResolveFormSubmittableParams): boolean;
10
+ export declare function mergeFormValidationFieldErrors(requiredFieldErrors: Record<string, {
11
+ type: string;
12
+ message: string;
13
+ }>, customFieldErrors?: Record<string, {
14
+ message: string;
15
+ }>): Record<string, {
16
+ message: string;
17
+ }>;
18
+ export {};
@@ -0,0 +1,32 @@
1
+ import { evaluateVisibleRequiredFormFields as r } from "./validateVisibleRequiredFormFields.js";
2
+ function F({
3
+ formConfigFields: t,
4
+ formHelpers: i,
5
+ formContext: e
6
+ }) {
7
+ const s = i.form.getValues(), l = t.filter(
8
+ (o) => i.isFieldVisible(o)
9
+ ), d = r(
10
+ s,
11
+ l,
12
+ {
13
+ isFieldDisabled: i.isFieldDisabled,
14
+ isFieldDisabledForValidation: i.isFieldDisabledForSubmitValidation,
15
+ formHelpers: i
16
+ }
17
+ ), a = e?.validateForm?.({
18
+ formValues: s,
19
+ visibleFields: l
20
+ });
21
+ return d.isValid && (a?.isValid ?? !0);
22
+ }
23
+ function u(t, i) {
24
+ const e = {};
25
+ for (const [s, l] of Object.entries(t))
26
+ e[s] = { message: l.message };
27
+ return i && Object.assign(e, i), e;
28
+ }
29
+ export {
30
+ u as mergeFormValidationFieldErrors,
31
+ F as resolveFormSubmittable
32
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Normalizes multi-select / cascaded form values into a string[] for filter payloads
3
+ * (label preferred, then value, then primitive; Dates → YMD).
4
+ */
5
+ export declare function toCascadedFilterValues(raw: unknown): string[];
@@ -0,0 +1,30 @@
1
+ function r(n) {
2
+ if (n == null) return null;
3
+ if (typeof n == "string" || typeof n == "number" || typeof n == "boolean") {
4
+ const e = String(n).trim();
5
+ return e === "" ? null : e;
6
+ }
7
+ return null;
8
+ }
9
+ function o(n) {
10
+ const e = r(n);
11
+ if (e) return e;
12
+ if (n && typeof n == "object" && !Array.isArray(n)) {
13
+ const t = n, i = r(t.value);
14
+ if (i) return i;
15
+ const u = r(t.label);
16
+ if (u) return u;
17
+ }
18
+ return null;
19
+ }
20
+ function l(n) {
21
+ if (n == null || n === "") return [];
22
+ if (n instanceof Date) {
23
+ const t = n.toISOString().slice(0, 10);
24
+ return t ? [t] : [];
25
+ }
26
+ return (Array.isArray(n) ? n : [n]).map(o).filter((t) => t != null && t !== "");
27
+ }
28
+ export {
29
+ l as toCascadedFilterValues
30
+ };
@@ -0,0 +1 @@
1
+ export declare function serializeFormStateForQueryKey(formState?: Record<string, unknown>): string;
@@ -0,0 +1,21 @@
1
+ const s = (r) => {
2
+ if (Array.isArray(r)) {
3
+ if (r.length > 1e3) {
4
+ const t = r[0], n = r[r.length - 1], o = t && typeof t == "object" && "label" in t ? t.label : String(t), e = n && typeof n == "object" && "label" in n ? n.label : String(n);
5
+ return `${r.length}:${o}:${e}`;
6
+ }
7
+ return r.map((t) => typeof t == "string" ? t : t && typeof t == "object" && "label" in t ? t.label : t);
8
+ }
9
+ return r && typeof r == "object" && "label" in r ? r.label : r;
10
+ };
11
+ function l(r) {
12
+ if (!r || Object.keys(r).length === 0)
13
+ return "";
14
+ const t = Object.keys(r), n = {}, o = t.length <= 10 ? t.sort() : t;
15
+ for (const e of o)
16
+ n[e] = s(r[e]);
17
+ return JSON.stringify(n);
18
+ }
19
+ export {
20
+ l as serializeFormStateForQueryKey
21
+ };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Deterministic JSON-like string for stable cache keys (e.g. TanStack Query) when
3
+ * objects have unordered keys or nested structures.
4
+ */
5
+ export declare function stableSerialize(value: unknown): string;
@@ -0,0 +1,11 @@
1
+ function n(r) {
2
+ if (r === null || typeof r != "object")
3
+ return JSON.stringify(r);
4
+ if (Array.isArray(r))
5
+ return `[${r.map(n).join(",")}]`;
6
+ const t = r;
7
+ return `{${Object.keys(t).sort().map((i) => `${JSON.stringify(i)}:${n(t[i])}`).join(",")}}`;
8
+ }
9
+ export {
10
+ n as stableSerialize
11
+ };
@@ -0,0 +1,21 @@
1
+ import { UseFormReturn } from 'react-hook-form';
2
+ import { FieldVisibilityBase } from '../../form-engine';
3
+ import { EvaluateFieldValidationOptions } from './evaluateFieldValidation';
4
+ import { UseReactHookFormReturn } from '../hooks/useReactHookForm';
5
+ export type FormValidationValues = Record<string, unknown>;
6
+ interface EvaluateVisibleRequiredFormFieldsOptions {
7
+ isFieldDisabled: (field: FieldVisibilityBase) => boolean;
8
+ isFieldDisabledForValidation?: (field: FieldVisibilityBase) => boolean;
9
+ formHelpers?: Pick<UseReactHookFormReturn, 'getPreviousFieldValue' | 'formContext'>;
10
+ fieldValidationEvaluationOptions?: EvaluateFieldValidationOptions;
11
+ }
12
+ export interface ValidateVisibleRequiredFormFieldsResult {
13
+ isValid: boolean;
14
+ fieldErrors: Record<string, {
15
+ type: string;
16
+ message: string;
17
+ }>;
18
+ }
19
+ export declare function evaluateVisibleRequiredFormFields(formValues: FormValidationValues, fields: FieldVisibilityBase[], options: EvaluateVisibleRequiredFormFieldsOptions): ValidateVisibleRequiredFormFieldsResult;
20
+ export declare function validateVisibleRequiredFormFields(form: UseFormReturn<FormValidationValues>, fields: FieldVisibilityBase[], options: EvaluateVisibleRequiredFormFieldsOptions): ValidateVisibleRequiredFormFieldsResult;
21
+ export {};
@@ -0,0 +1,64 @@
1
+ import { computeIsFieldVisible as n } from "../../form-engine/field-dependency-graph.js";
2
+ import { evaluateFieldValidation as c, buildEvaluateFieldValidationOptions as F } from "./evaluateFieldValidation.js";
3
+ const u = /* @__PURE__ */ new Set([
4
+ "label",
5
+ "divider",
6
+ "divider_with_label"
7
+ ]);
8
+ function V(e, l) {
9
+ if (l.fieldValidationEvaluationOptions)
10
+ return l.fieldValidationEvaluationOptions;
11
+ if (l.formHelpers)
12
+ return F(l.formHelpers, e.id);
13
+ }
14
+ function E(e, l, r) {
15
+ return c(
16
+ e,
17
+ l,
18
+ V(e, r)
19
+ );
20
+ }
21
+ function b(e, l, r) {
22
+ let t = !0;
23
+ const a = {};
24
+ for (const i of l) {
25
+ if (u.has(i.fieldType))
26
+ continue;
27
+ const o = n(i, e), s = r.isFieldDisabledForValidation?.(i) ?? r.isFieldDisabled(i);
28
+ if (!o || s)
29
+ continue;
30
+ const d = E(
31
+ i,
32
+ e[i.id],
33
+ r
34
+ );
35
+ if (d) {
36
+ const f = { type: "validate", message: d };
37
+ a[i.id] = f, t = !1;
38
+ }
39
+ }
40
+ return { isValid: t, fieldErrors: a };
41
+ }
42
+ function m(e, l, r) {
43
+ const t = e.getValues(), a = b(
44
+ t,
45
+ l,
46
+ r
47
+ );
48
+ for (const i of l) {
49
+ if (u.has(i.fieldType))
50
+ continue;
51
+ const o = n(i, t), s = r.isFieldDisabledForValidation?.(i) ?? r.isFieldDisabled(i);
52
+ if (!o || s) {
53
+ e.clearErrors(i.id);
54
+ continue;
55
+ }
56
+ const d = a.fieldErrors[i.id];
57
+ d ? e.setError(i.id, d) : e.clearErrors(i.id);
58
+ }
59
+ return a;
60
+ }
61
+ export {
62
+ b as evaluateVisibleRequiredFormFields,
63
+ m as validateVisibleRequiredFormFields
64
+ };
@@ -0,0 +1,3 @@
1
+ import { ValidationRule } from '../types/fields.types';
2
+ import { FormContextFieldChangeParams, FormContextValidator } from '../types/reactHookForm.types';
3
+ export declare function runFieldValidation(rules: ValidationRule[], fieldChangeParams: FormContextFieldChangeParams, contextValidators?: Record<string, FormContextValidator>): string | true;
@@ -0,0 +1,77 @@
1
+ import { z as l } from "zod";
2
+ const c = /* @__PURE__ */ new Set([
3
+ "email",
4
+ "url",
5
+ "uuid",
6
+ "cuid",
7
+ "cuid2",
8
+ "ulid",
9
+ "regex",
10
+ "min",
11
+ "max",
12
+ "length",
13
+ "startsWith",
14
+ "endsWith",
15
+ "includes",
16
+ "ip",
17
+ "emoji",
18
+ "nanoid",
19
+ "trim",
20
+ "toLowerCase",
21
+ "toUpperCase",
22
+ "datetime",
23
+ "date",
24
+ "time"
25
+ ]);
26
+ function f(n) {
27
+ const t = n.filter((o) => o.zod);
28
+ if (t.length === 0) return null;
29
+ let i = l.string();
30
+ for (const o of t) {
31
+ const a = o.zod;
32
+ if (!c.has(a)) continue;
33
+ const e = i[a];
34
+ if (typeof e != "function") continue;
35
+ const s = o.zodArgs ?? [];
36
+ i = e.apply(
37
+ i,
38
+ s
39
+ );
40
+ }
41
+ return i;
42
+ }
43
+ function m(n, t) {
44
+ try {
45
+ return new RegExp(t).test(n);
46
+ } catch {
47
+ return !0;
48
+ }
49
+ }
50
+ function z(n, t, i) {
51
+ const o = t.newValue == null ? "" : String(t.newValue);
52
+ for (const e of n) {
53
+ if (e.regex && !m(o, e.regex))
54
+ return e.message || "Validation failed";
55
+ if (e.validatorName && i?.[e.validatorName]) {
56
+ const s = i[e.validatorName](t);
57
+ if (s !== !0)
58
+ return s || e.message || "Validation failed";
59
+ }
60
+ }
61
+ const a = f(n);
62
+ if (a) {
63
+ const e = a.safeParse(o);
64
+ if (!e.success) {
65
+ const s = n.filter((r) => r.zod), u = e.error.issues[0];
66
+ return s.find((r) => {
67
+ if (!u) return !1;
68
+ const d = u.code;
69
+ return d === "too_small" && (r.zod === "min" || r.zod === "length") || d === "too_big" && (r.zod === "max" || r.zod === "length") || d === "invalid_format" && "format" in u && r.zod === u.format;
70
+ })?.message || u?.message || "Validation failed";
71
+ }
72
+ }
73
+ return !0;
74
+ }
75
+ export {
76
+ z as runFieldValidation
77
+ };