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.
- package/dist/filter-shell/index.d.ts +12 -0
- package/dist/filter-shell/index.js +9 -0
- package/dist/filter-shell/utils/buildFilterFieldValidationRules.d.ts +1 -0
- package/dist/filter-shell/utils/validateVisibleRequiredFilterFields.d.ts +1 -0
- package/dist/filter-shell/utils/validationNavigation.utils.d.ts +26 -0
- package/dist/filter-shell/utils/validationNavigation.utils.js +38 -0
- package/dist/form-engine/field-dependency-graph.d.ts +17 -0
- package/dist/form-engine/field-dependency-graph.js +90 -0
- package/dist/form-engine/index.d.ts +9 -0
- package/dist/form-engine/index.js +16 -0
- package/dist/form-engine/is-empty-value.d.ts +1 -0
- package/dist/form-engine/is-empty-value.js +8 -0
- package/dist/form-engine/types.d.ts +17 -0
- package/dist/form-react/Fields/ButtonsGroupField.d.ts +3 -0
- package/dist/form-react/Fields/ButtonsGroupField.js +52 -0
- package/dist/form-react/Fields/CheckboxField.d.ts +3 -0
- package/dist/form-react/Fields/CheckboxField.js +46 -0
- package/dist/form-react/Fields/ChipsField.d.ts +3 -0
- package/dist/form-react/Fields/ChipsField.js +146 -0
- package/dist/form-react/Fields/DateInputField.d.ts +8 -0
- package/dist/form-react/Fields/DateInputField.js +134 -0
- package/dist/form-react/Fields/DateRangeField.d.ts +8 -0
- package/dist/form-react/Fields/DateRangeField.js +57 -0
- package/dist/form-react/Fields/DividerField.d.ts +3 -0
- package/dist/form-react/Fields/DividerField.js +9 -0
- package/dist/form-react/Fields/DividerWithLabelField.d.ts +3 -0
- package/dist/form-react/Fields/DividerWithLabelField.js +31 -0
- package/dist/form-react/Fields/FileUploadField.d.ts +3 -0
- package/dist/form-react/Fields/FileUploadField.js +42 -0
- package/dist/form-react/Fields/FillFormByFileUploadField.d.ts +3 -0
- package/dist/form-react/Fields/FillFormByFileUploadField.js +65 -0
- package/dist/form-react/Fields/FillFormByPasteField.d.ts +3 -0
- package/dist/form-react/Fields/FillFormByPasteField.js +106 -0
- package/dist/form-react/Fields/LabelField.d.ts +3 -0
- package/dist/form-react/Fields/LabelField.js +14 -0
- package/dist/form-react/Fields/MonthRangeField.d.ts +8 -0
- package/dist/form-react/Fields/MonthRangeField.js +72 -0
- package/dist/form-react/Fields/MultiMonthPickerField.d.ts +8 -0
- package/dist/form-react/Fields/MultiMonthPickerField.js +46 -0
- package/dist/form-react/Fields/MultiWeekPickerField.d.ts +8 -0
- package/dist/form-react/Fields/MultiWeekPickerField.js +47 -0
- package/dist/form-react/Fields/NumericComboboxField.d.ts +18 -0
- package/dist/form-react/Fields/NumericComboboxField.js +51 -0
- package/dist/form-react/Fields/RadioField.d.ts +3 -0
- package/dist/form-react/Fields/RadioField.js +68 -0
- package/dist/form-react/Fields/SelectField.d.ts +3 -0
- package/dist/form-react/Fields/SelectField.js +76 -0
- package/dist/form-react/Fields/SwitchField.d.ts +3 -0
- package/dist/form-react/Fields/SwitchField.js +47 -0
- package/dist/form-react/Fields/TextAreaField.d.ts +3 -0
- package/dist/form-react/Fields/TextAreaField.js +41 -0
- package/dist/form-react/Fields/TextField.d.ts +3 -0
- package/dist/form-react/Fields/TextField.js +75 -0
- package/dist/form-react/Fields/TextFieldWithBackendValidation.d.ts +3 -0
- package/dist/form-react/Fields/TextFieldWithBackendValidation.js +117 -0
- package/dist/form-react/Fields/WeekRangePicker.d.ts +8 -0
- package/dist/form-react/Fields/WeekRangePicker.js +71 -0
- package/dist/form-react/ReactHooksForm.d.ts +3 -0
- package/dist/form-react/ReactHooksForm.js +132 -0
- package/dist/form-react/components/ArrayFieldRenderer.d.ts +13 -0
- package/dist/form-react/components/ArrayFieldRenderer.js +90 -0
- package/dist/form-react/components/FieldRenderer.d.ts +16 -0
- package/dist/form-react/components/FieldRenderer.js +68 -0
- package/dist/form-react/components/FormFieldRow.d.ts +13 -0
- package/dist/form-react/components/FormFieldRow.js +47 -0
- package/dist/form-react/components/FormFileUploadWrapper.d.ts +22 -0
- package/dist/form-react/components/FormFileUploadWrapper.js +88 -0
- package/dist/form-react/components/ObjectFieldRenderer.d.ts +13 -0
- package/dist/form-react/components/ObjectFieldRenderer.js +46 -0
- package/dist/form-react/components/SetToEmptyWrapper.d.ts +16 -0
- package/dist/form-react/components/SetToEmptyWrapper.js +49 -0
- package/dist/form-react/fields.d.ts +23 -0
- package/dist/form-react/fields.js +40 -0
- package/dist/form-react/hooks/useCascadingForm.d.ts +17 -0
- package/dist/form-react/hooks/useCascadingForm.js +122 -0
- package/dist/form-react/hooks/useFieldVisibility.d.ts +14 -0
- package/dist/form-react/hooks/useFieldVisibility.js +60 -0
- package/dist/form-react/hooks/useFillFormByFileUpload.d.ts +33 -0
- package/dist/form-react/hooks/useFillFormByFileUpload.js +199 -0
- package/dist/form-react/hooks/useFillFormByPaste.d.ts +33 -0
- package/dist/form-react/hooks/useFillFormByPaste.js +104 -0
- package/dist/form-react/hooks/useFormFieldChangeSubscription.d.ts +13 -0
- package/dist/form-react/hooks/useFormFieldChangeSubscription.js +42 -0
- package/dist/form-react/hooks/useReactHookForm.d.ts +3 -0
- package/dist/form-react/hooks/useReactHookForm.js +161 -0
- package/dist/form-react/hooks/useSelectOptions.d.ts +8 -0
- package/dist/form-react/hooks/useSelectOptions.js +116 -0
- package/dist/form-react/index.d.ts +62 -0
- package/dist/form-react/index.js +97 -0
- package/dist/form-react/registry/defaultFieldRegistrations.d.ts +2 -0
- package/dist/form-react/registry/defaultFieldRegistrations.js +30 -0
- package/dist/form-react/registry/fieldRegistry.d.ts +14 -0
- package/dist/form-react/registry/fieldRegistry.js +19 -0
- package/dist/form-react/registry/resolveFieldComponent.d.ts +10 -0
- package/dist/form-react/registry/resolveFieldComponent.js +137 -0
- package/dist/form-react/types/fields.types.d.ts +402 -0
- package/dist/form-react/types/fieldsOutput.types.d.ts +73 -0
- package/dist/form-react/types/reactHookForm.types.d.ts +196 -0
- package/dist/form-react/utils/batchFormFieldUpdates.d.ts +14 -0
- package/dist/form-react/utils/batchFormFieldUpdates.js +13 -0
- package/dist/form-react/utils/buildFieldValidationRules.d.ts +6 -0
- package/dist/form-react/utils/buildFieldValidationRules.js +13 -0
- package/dist/form-react/utils/buildSelectRemountKey.d.ts +14 -0
- package/dist/form-react/utils/buildSelectRemountKey.js +14 -0
- package/dist/form-react/utils/calendar-boundary.d.ts +3 -0
- package/dist/form-react/utils/calendar-boundary.js +33 -0
- package/dist/form-react/utils/date.utils.d.ts +31 -0
- package/dist/form-react/utils/date.utils.js +86 -0
- package/dist/form-react/utils/evaluateFieldValidation.d.ts +19 -0
- package/dist/form-react/utils/evaluateFieldValidation.js +53 -0
- package/dist/form-react/utils/fieldDefaults.utils.d.ts +6 -0
- package/dist/form-react/utils/fieldDefaults.utils.js +25 -0
- package/dist/form-react/utils/fieldPath.utils.d.ts +23 -0
- package/dist/form-react/utils/fieldPath.utils.js +26 -0
- package/dist/form-react/utils/fieldRangeValidation.utils.d.ts +3 -0
- package/dist/form-react/utils/fieldRangeValidation.utils.js +24 -0
- package/dist/form-react/utils/fieldRendererUtils.d.ts +10 -0
- package/dist/form-react/utils/fieldRendererUtils.js +47 -0
- package/dist/form-react/utils/fieldTestIds.d.ts +3 -0
- package/dist/form-react/utils/fieldTestIds.js +13 -0
- package/dist/form-react/utils/formDate.utils.d.ts +13 -0
- package/dist/form-react/utils/formDate.utils.js +9 -0
- package/dist/form-react/utils/formValidationFeedback.utils.d.ts +32 -0
- package/dist/form-react/utils/formValidationFeedback.utils.js +153 -0
- package/dist/form-react/utils/icons.d.ts +5 -0
- package/dist/form-react/utils/icons.js +10 -0
- package/dist/form-react/utils/optionFlag.d.ts +11 -0
- package/dist/form-react/utils/optionFlag.js +17 -0
- package/dist/form-react/utils/pastedValues.d.ts +1 -0
- package/dist/form-react/utils/resolveFormSubmittable.d.ts +18 -0
- package/dist/form-react/utils/resolveFormSubmittable.js +32 -0
- package/dist/form-react/utils/select-option-filter-values.d.ts +5 -0
- package/dist/form-react/utils/select-option-filter-values.js +30 -0
- package/dist/form-react/utils/serializeFormStateForQueryKey.d.ts +1 -0
- package/dist/form-react/utils/serializeFormStateForQueryKey.js +21 -0
- package/dist/form-react/utils/stableSerialize.d.ts +5 -0
- package/dist/form-react/utils/stableSerialize.js +11 -0
- package/dist/form-react/utils/validateVisibleRequiredFormFields.d.ts +21 -0
- package/dist/form-react/utils/validateVisibleRequiredFormFields.js +64 -0
- package/dist/form-react/utils/validationUtils.d.ts +3 -0
- package/dist/form-react/utils/validationUtils.js +77 -0
- package/dist/impact-nova.css +1 -1
- package/dist/lib/primitives/use-field-chrome.js +16 -16
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/real-world-patterns.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +21 -2
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function d(a, e, t) {
|
|
2
|
+
if (e.length === 0)
|
|
3
|
+
return;
|
|
4
|
+
const o = t?.shouldDirty ?? !0, u = t?.shouldValidate ?? !1;
|
|
5
|
+
for (const l of e)
|
|
6
|
+
a.setValue(l.fieldName, l.value, {
|
|
7
|
+
shouldDirty: o,
|
|
8
|
+
shouldValidate: u
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
d as batchSetFormFieldValues
|
|
13
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EvaluateFieldValidationOptions, FieldValidationShape } from './evaluateFieldValidation';
|
|
2
|
+
export type { FieldValidationShape } from './evaluateFieldValidation';
|
|
3
|
+
export type { EvaluateFieldValidationOptions } from './evaluateFieldValidation';
|
|
4
|
+
export { buildRangeIncompleteMessage, isRangeIncompleteValidationMessage, } from './fieldRangeValidation.utils';
|
|
5
|
+
export declare function isFieldValueValid(field: FieldValidationShape, value: unknown, options?: EvaluateFieldValidationOptions): boolean;
|
|
6
|
+
export declare function buildFieldValidationRules(field: FieldValidationShape, options?: EvaluateFieldValidationOptions): Record<string, unknown>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { fieldNeedsValidationRules as a, evaluateFieldValidation as t } from "./evaluateFieldValidation.js";
|
|
2
|
+
function n(i, e, l) {
|
|
3
|
+
return t(i, e, l) === null;
|
|
4
|
+
}
|
|
5
|
+
function d(i, e) {
|
|
6
|
+
return a(i) ? {
|
|
7
|
+
validate: (l) => t(i, l, e) ?? !0
|
|
8
|
+
} : {};
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
d as buildFieldValidationRules,
|
|
12
|
+
n as isFieldValueValid
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface BuildSelectRemountKeyOptions {
|
|
2
|
+
fieldId: string;
|
|
3
|
+
isMultiSelect: boolean;
|
|
4
|
+
hasSelectValue: boolean;
|
|
5
|
+
parentCascadeKey: string;
|
|
6
|
+
isDisabled: boolean;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* impact-nova Select keeps internal open/focus UI when form values are cleared
|
|
10
|
+
* externally (cascade). Remounting on value, parent, or disabled changes resets it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function buildSelectRemountKey(options: BuildSelectRemountKeyOptions): string;
|
|
13
|
+
export declare function buildParentCascadeKey(parentFieldIds: string[], watchedParentValues: unknown): string;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function t(e) {
|
|
2
|
+
const a = e.isDisabled ? "disabled" : "enabled";
|
|
3
|
+
if (e.isMultiSelect)
|
|
4
|
+
return `${e.fieldId}-${e.parentCascadeKey}-${a}`;
|
|
5
|
+
const l = e.hasSelectValue ? "has-value" : "empty";
|
|
6
|
+
return `${e.fieldId}-${l}-${e.parentCascadeKey}-${a}`;
|
|
7
|
+
}
|
|
8
|
+
function d(e, a) {
|
|
9
|
+
return e.length === 0 ? "root" : JSON.stringify(a ?? null);
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
d as buildParentCascadeKey,
|
|
13
|
+
t as buildSelectRemountKey
|
|
14
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { startOfDayDate as c } from "./date.utils.js";
|
|
2
|
+
function p(t) {
|
|
3
|
+
return `${t.getFullYear()}-${String(t.getMonth() + 1).padStart(2, "0")}-${String(t.getDate()).padStart(2, "0")}`;
|
|
4
|
+
}
|
|
5
|
+
function d(t) {
|
|
6
|
+
const r = t.trim().split("-");
|
|
7
|
+
if (r.length !== 3) return;
|
|
8
|
+
const e = Number(r[0]), i = Number(r[1]), n = Number(r[2]);
|
|
9
|
+
if (!Number.isFinite(e) || !Number.isFinite(i) || !Number.isFinite(n))
|
|
10
|
+
return;
|
|
11
|
+
const s = new Date(e, i - 1, n);
|
|
12
|
+
if (!Number.isNaN(s.getTime()))
|
|
13
|
+
return c(s);
|
|
14
|
+
}
|
|
15
|
+
function N(t) {
|
|
16
|
+
if (!t) return;
|
|
17
|
+
if (t instanceof Date) return t;
|
|
18
|
+
if (typeof t != "string") return;
|
|
19
|
+
const r = t.trim();
|
|
20
|
+
if (r === "") return;
|
|
21
|
+
if (r.includes("/")) {
|
|
22
|
+
const [m, a] = r.split("/"), o = parseInt(m, 10), u = parseInt(a, 10);
|
|
23
|
+
return !Number.isFinite(o) || !Number.isFinite(u) ? void 0 : new Date(u, o - 1, 1);
|
|
24
|
+
}
|
|
25
|
+
const e = r.split("-"), i = parseInt(e[0], 10), n = parseInt(e[1], 10), s = e[2] ? parseInt(e[2], 10) : 1;
|
|
26
|
+
if (!(!Number.isFinite(i) || !Number.isFinite(n) || !Number.isFinite(s)))
|
|
27
|
+
return new Date(i, n - 1, s);
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
p as formatYmd,
|
|
31
|
+
d as parseYmdString,
|
|
32
|
+
N as toLocalDate
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DateRangeField, WeekRangeField } from '../types/fields.types';
|
|
2
|
+
export declare const DEFAULT_PICKER_DATE_FORMAT = "yyyy-MM-dd";
|
|
3
|
+
/**
|
|
4
|
+
* Makes a remote-config date format safe for the date-fns based pickers.
|
|
5
|
+
*
|
|
6
|
+
* 1. Normalizes moment-style tokens to date-fns tokens (DD → dd, YYYY → yyyy).
|
|
7
|
+
* `M` is left untouched — lowercase `m` means minutes in date-fns. Already
|
|
8
|
+
* valid date-fns strings pass through unchanged.
|
|
9
|
+
* 2. date-fns throws a RangeError on invalid/unsupported tokens instead of
|
|
10
|
+
* failing gracefully, so probe the format once and fall back to
|
|
11
|
+
* DEFAULT_PICKER_DATE_FORMAT when it throws — a bad config value can then
|
|
12
|
+
* never crash the picker at render time.
|
|
13
|
+
*/
|
|
14
|
+
export declare function handleDateFnsFormat(configFormat?: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Formats a Date for user-facing copy (e.g. `{minDate}` in validation messages)
|
|
17
|
+
* using the field's configured `dateFormat`, falling back to `YYYY-MM-DD`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function formatDateByConfigFormat(d: Date, df?: string): string;
|
|
20
|
+
export declare function startOfDayDate(d: Date): Date;
|
|
21
|
+
export declare function addDaysDate(d: Date, n: number): Date;
|
|
22
|
+
export declare const handleMinMaxProp: (dateRangeField: DateRangeField) => {
|
|
23
|
+
minDate: Date | undefined;
|
|
24
|
+
maxDate: Date | undefined;
|
|
25
|
+
};
|
|
26
|
+
export declare const resolveWeekRangeMinMax: (weekRangeField: Pick<WeekRangeField, "minDate" | "maxDate" | "minStartOffsetDays" | "disablePastWeeks" | "minWeeksOffset" | "maxWeeksOffset" | "startMonth" | "endMonth">) => {
|
|
27
|
+
minDate: Date | undefined;
|
|
28
|
+
maxDate: Date | undefined;
|
|
29
|
+
startMonth: Date | undefined;
|
|
30
|
+
endMonth: Date | undefined;
|
|
31
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { format as M } from "date-fns";
|
|
2
|
+
import { toLocalDate as o } from "./calendar-boundary.js";
|
|
3
|
+
const e = "yyyy-MM-dd", c = /* @__PURE__ */ new Map();
|
|
4
|
+
function y(t) {
|
|
5
|
+
const s = t?.trim();
|
|
6
|
+
if (!s) return e;
|
|
7
|
+
const n = s.replace(/D/g, "d").replace(/Y/g, "y");
|
|
8
|
+
let a = c.get(n);
|
|
9
|
+
if (a === void 0) {
|
|
10
|
+
try {
|
|
11
|
+
M(/* @__PURE__ */ new Date(), n), a = !0;
|
|
12
|
+
} catch {
|
|
13
|
+
a = !1;
|
|
14
|
+
}
|
|
15
|
+
c.set(n, a);
|
|
16
|
+
}
|
|
17
|
+
return a ? n : e;
|
|
18
|
+
}
|
|
19
|
+
function r(t) {
|
|
20
|
+
const s = new Date(t);
|
|
21
|
+
return s.setHours(0, 0, 0, 0), s;
|
|
22
|
+
}
|
|
23
|
+
function D(t, s) {
|
|
24
|
+
const n = new Date(t);
|
|
25
|
+
return n.setDate(n.getDate() + s), n;
|
|
26
|
+
}
|
|
27
|
+
const O = (t) => {
|
|
28
|
+
let s, n;
|
|
29
|
+
if (t.minStartOffsetDays != null && t.minStartOffsetDays >= 0)
|
|
30
|
+
s = r(
|
|
31
|
+
D(/* @__PURE__ */ new Date(), t.minStartOffsetDays)
|
|
32
|
+
);
|
|
33
|
+
else if (t.minDate) {
|
|
34
|
+
const a = o(t.minDate);
|
|
35
|
+
a && (s = r(a));
|
|
36
|
+
}
|
|
37
|
+
if (t.maxDate) {
|
|
38
|
+
const a = o(t.maxDate);
|
|
39
|
+
a && (n = r(a));
|
|
40
|
+
}
|
|
41
|
+
return { minDate: s, maxDate: n };
|
|
42
|
+
}, p = (t) => {
|
|
43
|
+
let s, n;
|
|
44
|
+
const a = /* @__PURE__ */ new Date();
|
|
45
|
+
if (t.minWeeksOffset != null)
|
|
46
|
+
s = r(
|
|
47
|
+
D(a, -t.minWeeksOffset * 7)
|
|
48
|
+
);
|
|
49
|
+
else if (t.minStartOffsetDays != null && t.minStartOffsetDays >= 0)
|
|
50
|
+
s = r(
|
|
51
|
+
D(a, t.minStartOffsetDays)
|
|
52
|
+
);
|
|
53
|
+
else if (t.disablePastWeeks)
|
|
54
|
+
s = r(a);
|
|
55
|
+
else if (t.minDate) {
|
|
56
|
+
const f = o(t.minDate);
|
|
57
|
+
f && (s = r(f));
|
|
58
|
+
}
|
|
59
|
+
if (t.maxWeeksOffset != null)
|
|
60
|
+
n = r(
|
|
61
|
+
D(a, t.maxWeeksOffset * 7)
|
|
62
|
+
);
|
|
63
|
+
else if (t.maxDate) {
|
|
64
|
+
const f = o(t.maxDate);
|
|
65
|
+
f && (n = r(f));
|
|
66
|
+
}
|
|
67
|
+
let m;
|
|
68
|
+
if (t.startMonth) {
|
|
69
|
+
const f = o(t.startMonth);
|
|
70
|
+
f && (m = r(f));
|
|
71
|
+
}
|
|
72
|
+
let i;
|
|
73
|
+
if (t.endMonth) {
|
|
74
|
+
const f = o(t.endMonth);
|
|
75
|
+
f && (i = r(f));
|
|
76
|
+
}
|
|
77
|
+
return { minDate: s, maxDate: n, startMonth: m, endMonth: i };
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
e as DEFAULT_PICKER_DATE_FORMAT,
|
|
81
|
+
D as addDaysDate,
|
|
82
|
+
y as handleDateFnsFormat,
|
|
83
|
+
O as handleMinMaxProp,
|
|
84
|
+
p as resolveWeekRangeMinMax,
|
|
85
|
+
r as startOfDayDate
|
|
86
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ValidationRule } from '../types/fields.types';
|
|
2
|
+
import { FormContextFieldChangeParams, FormContextValidator } from '../types/reactHookForm.types';
|
|
3
|
+
import { UseReactHookFormReturn } from '../hooks/useReactHookForm';
|
|
4
|
+
export interface FieldValidationShape {
|
|
5
|
+
id: string;
|
|
6
|
+
label?: string;
|
|
7
|
+
fieldType: string;
|
|
8
|
+
isRequired?: boolean;
|
|
9
|
+
validation?: ValidationRule[];
|
|
10
|
+
}
|
|
11
|
+
export interface EvaluateFieldValidationOptions {
|
|
12
|
+
fieldId?: string;
|
|
13
|
+
formHelpers?: FormContextFieldChangeParams['formHelpers'];
|
|
14
|
+
contextValidators?: Record<string, FormContextValidator>;
|
|
15
|
+
getPreviousFieldValue?: (fieldId: string) => unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare function buildEvaluateFieldValidationOptions(formHelpers: Pick<UseReactHookFormReturn, 'getPreviousFieldValue' | 'formContext'>, fieldId: string): EvaluateFieldValidationOptions;
|
|
18
|
+
export declare function evaluateFieldValidation(field: FieldValidationShape, value: unknown, options?: EvaluateFieldValidationOptions): string | null;
|
|
19
|
+
export declare function fieldNeedsValidationRules(field: FieldValidationShape): boolean;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isEmptyValue as n } from "../../form-engine/is-empty-value.js";
|
|
2
|
+
import { runFieldValidation as d } from "./validationUtils.js";
|
|
3
|
+
import { isRangeValueComplete as c, buildRangeIncompleteMessage as m } from "./fieldRangeValidation.utils.js";
|
|
4
|
+
function p(e, i) {
|
|
5
|
+
return {
|
|
6
|
+
fieldId: i,
|
|
7
|
+
formHelpers: e,
|
|
8
|
+
getPreviousFieldValue: (r) => e.getPreviousFieldValue(r),
|
|
9
|
+
contextValidators: e.formContext?.validators
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
const o = /* @__PURE__ */ new Set([
|
|
13
|
+
"date_range",
|
|
14
|
+
"week_range",
|
|
15
|
+
"month_range"
|
|
16
|
+
]), f = /* @__PURE__ */ new Set([
|
|
17
|
+
"select",
|
|
18
|
+
"chips",
|
|
19
|
+
"multi_month_picker",
|
|
20
|
+
"multi_week_picker"
|
|
21
|
+
]);
|
|
22
|
+
function l(e) {
|
|
23
|
+
return `${e.label || "This field"} is required`;
|
|
24
|
+
}
|
|
25
|
+
function h(e, i) {
|
|
26
|
+
return !e.isRequired && n(i);
|
|
27
|
+
}
|
|
28
|
+
function t(e, i, r) {
|
|
29
|
+
if (!e.validation?.length || o.has(e.fieldType) || h(e, i))
|
|
30
|
+
return null;
|
|
31
|
+
const u = r?.fieldId ?? e.id, s = {
|
|
32
|
+
fieldId: u,
|
|
33
|
+
newValue: i,
|
|
34
|
+
oldValue: r?.getPreviousFieldValue?.(u),
|
|
35
|
+
formHelpers: r?.formHelpers
|
|
36
|
+
}, a = d(
|
|
37
|
+
e.validation,
|
|
38
|
+
s,
|
|
39
|
+
r?.contextValidators ?? r?.formHelpers?.formContext?.validators
|
|
40
|
+
);
|
|
41
|
+
return a === !0 ? null : a;
|
|
42
|
+
}
|
|
43
|
+
function T(e, i, r) {
|
|
44
|
+
return e.fieldType === "switch" ? e.isRequired && i !== !0 ? `${e.label || "This field"} must be enabled` : null : e.fieldType === "checkbox" ? e.isRequired && i !== !0 ? `${e.label || "This field"} must be checked` : null : e.isRequired && o.has(e.fieldType) ? c(i) ? t(e, i, r) : m(e.fieldType) : e.isRequired && f.has(e.fieldType) ? n(i) ? l(e) : t(e, i, r) : e.isRequired && n(i) ? l(e) : t(e, i, r);
|
|
45
|
+
}
|
|
46
|
+
function _(e) {
|
|
47
|
+
return !!e.isRequired || !!e.validation?.length;
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
p as buildEvaluateFieldValidationOptions,
|
|
51
|
+
T as evaluateFieldValidation,
|
|
52
|
+
_ as fieldNeedsValidationRules
|
|
53
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
function u(e) {
|
|
2
|
+
if (e.fieldType === "object") {
|
|
3
|
+
const a = {};
|
|
4
|
+
return e.fields.forEach((t) => {
|
|
5
|
+
a[t.id] = u(t);
|
|
6
|
+
}), a;
|
|
7
|
+
}
|
|
8
|
+
if (e.fieldType === "array") {
|
|
9
|
+
const a = e.defaultItemValue ?? {}, t = e.minItems ?? 0;
|
|
10
|
+
return t > 0 ? Array.from({ length: t }, () => ({ ...a })) : [];
|
|
11
|
+
}
|
|
12
|
+
return e.fieldType === "button_group" && e.defaultSelectedValue || e.fieldType === "radio" && e.defaultSelectedValue ? e.defaultSelectedValue || null : e.fieldType === "date_range" && e.defaultRange ? {
|
|
13
|
+
start: e.defaultRange.start || null,
|
|
14
|
+
end: e.defaultRange.end || null
|
|
15
|
+
} : e.fieldType === "month_range" && e.defaultRange ? {
|
|
16
|
+
start: e.defaultRange.start || null,
|
|
17
|
+
end: e.defaultRange.end || null
|
|
18
|
+
} : e.fieldType === "switch" || e.fieldType === "checkbox" ? e.defaultSelectedValue ?? !1 : e.fieldType === "text" || e.fieldType === "text_area" || e.fieldType === "numeric_combobox" ? e.defaultValue ?? "" : e.fieldType === "date" ? "" : e.fieldType === "select" ? [] : e.fieldType === "week_range" && e.defaultRange ? {
|
|
19
|
+
start: e.defaultRange.start || null,
|
|
20
|
+
end: e.defaultRange.end || null
|
|
21
|
+
} : null;
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
u as getFieldDefaultValue
|
|
25
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IField } from '../types/fields.types';
|
|
2
|
+
/**
|
|
3
|
+
* Builds a dot-separated RHF field path by joining a field's own `id`
|
|
4
|
+
* with the accumulated parent prefix.
|
|
5
|
+
*
|
|
6
|
+
* Examples:
|
|
7
|
+
* - `buildFieldPath("city")` → `"city"`
|
|
8
|
+
* - `buildFieldPath("city", "address")` → `"address.city"`
|
|
9
|
+
* - `buildFieldPath("city", "contacts.0.address")` → `"contacts.0.address.city"`
|
|
10
|
+
*/
|
|
11
|
+
export declare function buildFieldPath(fieldId: string, prefix?: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Recursively flattens nested `IField[]` into a list of full dot-paths.
|
|
14
|
+
*
|
|
15
|
+
* - ObjectField children are expanded with their parent path as prefix.
|
|
16
|
+
* - ArrayField is treated as an atomic value (submitted as a whole array).
|
|
17
|
+
* - Leaf fields produce a single path entry.
|
|
18
|
+
*/
|
|
19
|
+
export declare function flattenFieldIds(fields: IField[], prefix?: string): string[];
|
|
20
|
+
/**
|
|
21
|
+
* Finds a field config by its full RHF path (supports nested object fields).
|
|
22
|
+
*/
|
|
23
|
+
export declare function findFieldByPath(fields: IField[], fieldPath: string, prefix?: string): IField | undefined;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
function o(n, e) {
|
|
2
|
+
return e ? `${e}.${n}` : n;
|
|
3
|
+
}
|
|
4
|
+
function u(n, e) {
|
|
5
|
+
return n.flatMap((r) => {
|
|
6
|
+
const t = o(r.id, e);
|
|
7
|
+
return r.fieldType === "object" ? u(r.fields, t) : r.fieldType === "array" ? [t] : [t];
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
function d(n, e, r) {
|
|
11
|
+
for (const t of n) {
|
|
12
|
+
const i = o(t.id, r);
|
|
13
|
+
if (i === e)
|
|
14
|
+
return t;
|
|
15
|
+
if (t.fieldType === "object") {
|
|
16
|
+
const f = d(t.fields, e, i);
|
|
17
|
+
if (f)
|
|
18
|
+
return f;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
o as buildFieldPath,
|
|
24
|
+
d as findFieldByPath,
|
|
25
|
+
u as flattenFieldIds
|
|
26
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function a(e) {
|
|
2
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
3
|
+
return !1;
|
|
4
|
+
const t = e, n = t.start != null && String(t.start).trim() !== "", r = t.end != null && String(t.end).trim() !== "";
|
|
5
|
+
return n && r;
|
|
6
|
+
}
|
|
7
|
+
function d(e) {
|
|
8
|
+
switch (e) {
|
|
9
|
+
case "month_range":
|
|
10
|
+
return "Start and end months required";
|
|
11
|
+
case "week_range":
|
|
12
|
+
return "Start and end weeks required";
|
|
13
|
+
default:
|
|
14
|
+
return "Start and end dates required";
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function i(e) {
|
|
18
|
+
return e.includes("requires both from and to") || e === "Start and end months required" || e === "Start and end weeks required" || e === "Start and end dates required";
|
|
19
|
+
}
|
|
20
|
+
export {
|
|
21
|
+
d as buildRangeIncompleteMessage,
|
|
22
|
+
i as isRangeIncompleteValidationMessage,
|
|
23
|
+
a as isRangeValueComplete
|
|
24
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Lookup tables for `IFormConfig` numeric layout → full Tailwind utilities (JIT-safe). */
|
|
2
|
+
export declare const GAP_MAP: Record<number, string>;
|
|
3
|
+
/** Horizontal gap — honours the configured value exactly. */
|
|
4
|
+
export declare const GAP_X_MAP: Record<number, string>;
|
|
5
|
+
/** Vertical gap — floors at 4 (16px) so error / helper text never overlaps the next row. */
|
|
6
|
+
export declare const GAP_Y_MAP: Record<number, string>;
|
|
7
|
+
export declare const COL_SPAN_MAP: Record<number, string>;
|
|
8
|
+
export declare const GRID_COLS_MAP: Record<number, string>;
|
|
9
|
+
/** Full grid class string for `ReactHooksForm` (Tailwind JIT requires fixed map keys). */
|
|
10
|
+
export declare function buildFormGridClassName(columns?: number, gapBetweenFields?: number): string;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
const g = {
|
|
2
|
+
0: "gap-x-0",
|
|
3
|
+
1: "gap-x-1",
|
|
4
|
+
2: "gap-x-2",
|
|
5
|
+
3: "gap-x-3",
|
|
6
|
+
4: "gap-x-4",
|
|
7
|
+
5: "gap-x-5",
|
|
8
|
+
6: "gap-x-6",
|
|
9
|
+
7: "gap-x-7",
|
|
10
|
+
8: "gap-x-8",
|
|
11
|
+
9: "gap-x-9",
|
|
12
|
+
10: "gap-x-10",
|
|
13
|
+
11: "gap-x-11",
|
|
14
|
+
12: "gap-x-12"
|
|
15
|
+
}, p = {
|
|
16
|
+
0: "gap-y-4",
|
|
17
|
+
1: "gap-y-4",
|
|
18
|
+
2: "gap-y-4",
|
|
19
|
+
3: "gap-y-4",
|
|
20
|
+
4: "gap-y-4",
|
|
21
|
+
5: "gap-y-5",
|
|
22
|
+
6: "gap-y-6",
|
|
23
|
+
7: "gap-y-7",
|
|
24
|
+
8: "gap-y-8",
|
|
25
|
+
9: "gap-y-9",
|
|
26
|
+
10: "gap-y-10",
|
|
27
|
+
11: "gap-y-11",
|
|
28
|
+
12: "gap-y-12"
|
|
29
|
+
}, a = {
|
|
30
|
+
1: "grid-cols-1",
|
|
31
|
+
2: "grid-cols-2",
|
|
32
|
+
3: "grid-cols-3",
|
|
33
|
+
4: "grid-cols-4",
|
|
34
|
+
5: "grid-cols-5",
|
|
35
|
+
6: "grid-cols-6",
|
|
36
|
+
7: "grid-cols-7",
|
|
37
|
+
8: "grid-cols-8",
|
|
38
|
+
9: "grid-cols-9",
|
|
39
|
+
10: "grid-cols-10",
|
|
40
|
+
11: "grid-cols-11",
|
|
41
|
+
12: "grid-cols-12"
|
|
42
|
+
};
|
|
43
|
+
export {
|
|
44
|
+
g as GAP_X_MAP,
|
|
45
|
+
p as GAP_Y_MAP,
|
|
46
|
+
a as GRID_COLS_MAP
|
|
47
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { DateInputField } from '../types/fields.types';
|
|
2
|
+
export { formatYmd, parseYmdString, toLocalDate, } from './calendar-boundary';
|
|
3
|
+
export declare const DATE_FIELD_VALIDATION_FALLBACK = "Validation failed";
|
|
4
|
+
/**
|
|
5
|
+
* Remote UI definitions often ship `beforeMinimum` copy without `minOffsetDaysFromToday`.
|
|
6
|
+
* When that template is present and the field is not paired after another date and has no
|
|
7
|
+
* static `minDate`, default offset `0` so the calendar and validation match ("not before today").
|
|
8
|
+
*/
|
|
9
|
+
export declare function getEffectiveMinOffsetDaysFromToday(field: DateInputField): number | undefined;
|
|
10
|
+
export declare function applyDateRangeMessageTemplate(template: string | undefined, vars: {
|
|
11
|
+
minDate: string;
|
|
12
|
+
offset: number;
|
|
13
|
+
}): string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function e(t) {
|
|
2
|
+
if (t.minOffsetDaysFromToday != null) return t.minOffsetDaysFromToday;
|
|
3
|
+
if (t.pastDateNotAllowed) return 0;
|
|
4
|
+
if (!(t.dateAfterFieldId || t.minDate || !t.dateValidationMessages?.beforeMinimum?.trim()))
|
|
5
|
+
return 0;
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
e as getEffectiveMinOffsetDaysFromToday
|
|
9
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { IField } from '../types/fields.types';
|
|
2
|
+
export interface FormValidationToastMessage {
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
}
|
|
6
|
+
export interface BuildFormValidationToastMessageOptions {
|
|
7
|
+
/** Phrase appended to single-field guidance, e.g. "apply filters" or "continue". */
|
|
8
|
+
actionSuffix?: string;
|
|
9
|
+
/** Noun used in aggregate titles, e.g. "filter" or "field". */
|
|
10
|
+
entityNoun?: string;
|
|
11
|
+
}
|
|
12
|
+
type FormFieldShape = Pick<IField, 'id' | 'label' | 'fieldType'>;
|
|
13
|
+
export declare function buildFormValidationToastMessage(fieldErrors: Record<string, {
|
|
14
|
+
message?: string;
|
|
15
|
+
} | undefined>, allFields: FormFieldShape[], options?: BuildFormValidationToastMessageOptions): FormValidationToastMessage;
|
|
16
|
+
export declare function focusFirstFormValidationError(options: {
|
|
17
|
+
fieldErrors: Record<string, {
|
|
18
|
+
message?: string;
|
|
19
|
+
} | undefined>;
|
|
20
|
+
fieldsInOrder: FormFieldShape[];
|
|
21
|
+
getFieldTestId?: (fieldId: string) => string;
|
|
22
|
+
}): string | null;
|
|
23
|
+
export declare function showFormValidationFailureFeedback(options: {
|
|
24
|
+
fieldErrors: Record<string, {
|
|
25
|
+
message?: string;
|
|
26
|
+
} | undefined>;
|
|
27
|
+
fieldsInOrder: FormFieldShape[];
|
|
28
|
+
showToast: (message: FormValidationToastMessage) => void;
|
|
29
|
+
toastMessageOptions?: BuildFormValidationToastMessageOptions;
|
|
30
|
+
getFieldTestId?: (fieldId: string) => string;
|
|
31
|
+
}): void;
|
|
32
|
+
export {};
|