impact-nova 2.5.4 → 2.5.6
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/components/data/ag-grid-react/index.js +64 -64
- package/dist/components/data/data-table/data-table-column-state.d.ts +7 -0
- package/dist/components/data/data-table/data-table-column-state.js +48 -23
- package/dist/form-engine/field-dependency-graph.d.ts +1 -4
- package/dist/form-engine/field-dependency-graph.js +53 -57
- package/dist/form-engine/field-groups.d.ts +15 -0
- package/dist/form-engine/field-groups.js +60 -0
- package/dist/form-engine/index.d.ts +3 -2
- package/dist/form-engine/index.js +17 -14
- package/dist/form-engine/types.d.ts +17 -0
- package/dist/form-react/Fields/RichTextField.d.ts +3 -0
- package/dist/form-react/Fields/RichTextField.js +214 -0
- package/dist/form-react/Fields/SelectField.js +27 -28
- package/dist/form-react/Fields/SliderRangeField.d.ts +3 -0
- package/dist/form-react/Fields/SliderRangeField.js +69 -0
- package/dist/form-react/ReactHooksForm.js +149 -87
- package/dist/form-react/fields.d.ts +2 -0
- package/dist/form-react/fields.js +22 -18
- package/dist/form-react/hooks/useCascadingForm.d.ts +1 -2
- package/dist/form-react/hooks/useCascadingForm.js +59 -67
- package/dist/form-react/hooks/useFieldVisibility.d.ts +1 -2
- package/dist/form-react/hooks/useFieldVisibility.js +36 -43
- package/dist/form-react/hooks/useFormSteps.d.ts +29 -0
- package/dist/form-react/hooks/useFormSteps.js +96 -0
- package/dist/form-react/hooks/useReactHookForm.js +17 -18
- package/dist/form-react/hooks/useSelectOptions.d.ts +1 -1
- package/dist/form-react/hooks/useSelectOptions.js +80 -83
- package/dist/form-react/index.d.ts +5 -3
- package/dist/form-react/index.js +93 -88
- package/dist/form-react/registry/defaultFieldRegistrations.d.ts +1 -1
- package/dist/form-react/registry/defaultFieldRegistrations.js +11 -9
- package/dist/form-react/types/fields.types.d.ts +31 -12
- package/dist/form-react/types/fieldsOutput.types.d.ts +5 -1
- package/dist/form-react/types/reactHookForm.types.d.ts +31 -2
- package/dist/form-react/utils/fieldDefaults.utils.js +28 -13
- package/dist/impact-nova.css +1 -1
- package/dist/llms/rules/installation.js +1 -1
- package/dist/llms/rules/requirements.js +1 -1
- package/package.json +17 -2
package/dist/form-react/index.js
CHANGED
|
@@ -1,97 +1,102 @@
|
|
|
1
1
|
import { ReactHooksForm as r, ReactHooksForm as t } from "./ReactHooksForm.js";
|
|
2
|
-
import { useReactHookForm as
|
|
2
|
+
import { useReactHookForm as i } from "./hooks/useReactHookForm.js";
|
|
3
3
|
import { useFieldVisibility as d } from "./hooks/useFieldVisibility.js";
|
|
4
4
|
import { useCascadingForm as m } from "./hooks/useCascadingForm.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
24
|
-
import {
|
|
25
|
-
import {
|
|
26
|
-
import {
|
|
27
|
-
import {
|
|
28
|
-
import {
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
31
|
-
import {
|
|
32
|
-
import {
|
|
33
|
-
import {
|
|
34
|
-
import {
|
|
5
|
+
import { useFormSteps as p } from "./hooks/useFormSteps.js";
|
|
6
|
+
import { useSelectOptions as u } from "./hooks/useSelectOptions.js";
|
|
7
|
+
import { useFillFormByPaste as x } from "./hooks/useFillFormByPaste.js";
|
|
8
|
+
import { useFillFormByFileUpload as b } from "./hooks/useFillFormByFileUpload.js";
|
|
9
|
+
import { FieldRenderer as y } from "./components/FieldRenderer.js";
|
|
10
|
+
import { FormFieldRow as g } from "./components/FormFieldRow.js";
|
|
11
|
+
import { ObjectFieldRenderer as I } from "./components/ObjectFieldRenderer.js";
|
|
12
|
+
import { ArrayFieldRenderer as D } from "./components/ArrayFieldRenderer.js";
|
|
13
|
+
import { SetToEmptyWrapper as v } from "./components/SetToEmptyWrapper.js";
|
|
14
|
+
import { FormFileUploadWrapper as E } from "./components/FormFileUploadWrapper.js";
|
|
15
|
+
import { getFieldComponent as W, hasRegisteredFieldType as k, listRegisteredFieldTypes as O, registerFieldType as B } from "./registry/fieldRegistry.js";
|
|
16
|
+
import { registerDefaultFieldTypes as K } from "./registry/defaultFieldRegistrations.js";
|
|
17
|
+
import { renderRegisteredField as q, resolveFieldComponent as w } from "./registry/resolveFieldComponent.js";
|
|
18
|
+
import { isEmptyValue as U } from "../form-engine/is-empty-value.js";
|
|
19
|
+
import { buildCascadeParentFormState as A, collectFieldDependencyIds as G, collectFilterSidebarWatchFieldIds as L, collectFormWatchFieldIds as N, collectSectionWatchFieldIds as Q, collectVisibleFieldIds as Y, computeIsFieldDisabled as J, computeIsFieldVisible as X, getDependentFieldIds as Z, hasVisibleFieldErrors as _ } from "../form-engine/field-dependency-graph.js";
|
|
20
|
+
import { buildFieldGroups as ee, getFirstIncompleteStep as oe, isStepComplete as re } from "../form-engine/field-groups.js";
|
|
21
|
+
import { getFieldDefaultValue as le } from "./utils/fieldDefaults.utils.js";
|
|
22
|
+
import { batchSetFormFieldValues as ae } from "./utils/batchFormFieldUpdates.js";
|
|
23
|
+
import { serializeFormStateForQueryKey as se } from "./utils/serializeFormStateForQueryKey.js";
|
|
24
|
+
import { buildFormValidationToastMessage as Fe, focusFirstFormValidationError as pe, showFormValidationFailureFeedback as fe } from "./utils/formValidationFeedback.utils.js";
|
|
25
|
+
import { buildFieldValidationRules as ne, isFieldValueValid as xe } from "./utils/buildFieldValidationRules.js";
|
|
26
|
+
import { buildEvaluateFieldValidationOptions as be, evaluateFieldValidation as Ve, fieldNeedsValidationRules as ye } from "./utils/evaluateFieldValidation.js";
|
|
27
|
+
import { evaluateVisibleRequiredFormFields as ge, validateVisibleRequiredFormFields as Se } from "./utils/validateVisibleRequiredFormFields.js";
|
|
28
|
+
import { resolveFormSubmittable as he } from "./utils/resolveFormSubmittable.js";
|
|
29
|
+
import { buildParentCascadeKey as Ce, buildSelectRemountKey as ve } from "./utils/buildSelectRemountKey.js";
|
|
30
|
+
import { runFieldValidation as Ee } from "./utils/validationUtils.js";
|
|
31
|
+
import { buildFieldPath as We, findFieldByPath as ke, flattenFieldIds as Oe } from "./utils/fieldPath.utils.js";
|
|
32
|
+
import { stableSerialize as He } from "./utils/stableSerialize.js";
|
|
33
|
+
import { toCascadedFilterValues as Me } from "./utils/select-option-filter-values.js";
|
|
34
|
+
import { formatYmd as we, toLocalDate as ze } from "./utils/calendar-boundary.js";
|
|
35
|
+
import { handleDateFnsFormat as je, startOfDayDate as Ae } from "./utils/date.utils.js";
|
|
36
|
+
import { buildRangeIncompleteMessage as Le, isRangeIncompleteValidationMessage as Ne } from "./utils/fieldRangeValidation.utils.js";
|
|
35
37
|
export {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
D as ArrayFieldRenderer,
|
|
39
|
+
y as FieldRenderer,
|
|
40
|
+
g as FormFieldRow,
|
|
41
|
+
E as FormFileUploadWrapper,
|
|
42
|
+
I as ObjectFieldRenderer,
|
|
41
43
|
r as ReactHooksForm,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
L as
|
|
55
|
-
N as
|
|
56
|
-
Q as
|
|
57
|
-
Y as
|
|
58
|
-
|
|
59
|
-
|
|
44
|
+
v as SetToEmptyWrapper,
|
|
45
|
+
ae as batchSetFormFieldValues,
|
|
46
|
+
A as buildCascadeParentFormState,
|
|
47
|
+
be as buildEvaluateFieldValidationOptions,
|
|
48
|
+
ee as buildFieldGroups,
|
|
49
|
+
We as buildFieldPath,
|
|
50
|
+
ne as buildFieldValidationRules,
|
|
51
|
+
Fe as buildFormValidationToastMessage,
|
|
52
|
+
Ce as buildParentCascadeKey,
|
|
53
|
+
Le as buildRangeIncompleteMessage,
|
|
54
|
+
ve as buildSelectRemountKey,
|
|
55
|
+
G as collectFieldDependencyIds,
|
|
56
|
+
L as collectFilterSidebarWatchFieldIds,
|
|
57
|
+
N as collectFormWatchFieldIds,
|
|
58
|
+
Q as collectSectionWatchFieldIds,
|
|
59
|
+
Y as collectVisibleFieldIds,
|
|
60
|
+
J as computeIsFieldDisabled,
|
|
61
|
+
X as computeIsFieldVisible,
|
|
60
62
|
t as default,
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
K as
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
63
|
+
Ve as evaluateFieldValidation,
|
|
64
|
+
ge as evaluateVisibleRequiredFormFields,
|
|
65
|
+
ye as fieldNeedsValidationRules,
|
|
66
|
+
ke as findFieldByPath,
|
|
67
|
+
Oe as flattenFieldIds,
|
|
68
|
+
pe as focusFirstFormValidationError,
|
|
69
|
+
we as formatYmd,
|
|
70
|
+
Z as getDependentFieldIds,
|
|
71
|
+
W as getFieldComponent,
|
|
72
|
+
le as getFieldDefaultValue,
|
|
73
|
+
oe as getFirstIncompleteStep,
|
|
74
|
+
je as handleDateFnsFormat,
|
|
75
|
+
k as hasRegisteredFieldType,
|
|
76
|
+
_ as hasVisibleFieldErrors,
|
|
77
|
+
U as isEmptyValue,
|
|
78
|
+
xe as isFieldValueValid,
|
|
79
|
+
Ne as isRangeIncompleteValidationMessage,
|
|
80
|
+
re as isStepComplete,
|
|
81
|
+
O as listRegisteredFieldTypes,
|
|
82
|
+
K as registerDefaultFieldTypes,
|
|
83
|
+
B as registerFieldType,
|
|
84
|
+
q as renderRegisteredField,
|
|
85
|
+
w as resolveFieldComponent,
|
|
86
|
+
he as resolveFormSubmittable,
|
|
87
|
+
Ee as runFieldValidation,
|
|
88
|
+
se as serializeFormStateForQueryKey,
|
|
89
|
+
fe as showFormValidationFailureFeedback,
|
|
90
|
+
He as stableSerialize,
|
|
91
|
+
Ae as startOfDayDate,
|
|
92
|
+
Me as toCascadedFilterValues,
|
|
93
|
+
ze as toLocalDate,
|
|
90
94
|
m as useCascadingForm,
|
|
91
95
|
d as useFieldVisibility,
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
96
|
+
b as useFillFormByFileUpload,
|
|
97
|
+
x as useFillFormByPaste,
|
|
98
|
+
p as useFormSteps,
|
|
99
|
+
i as useReactHookForm,
|
|
100
|
+
u as useSelectOptions,
|
|
101
|
+
Se as validateVisibleRequiredFormFields
|
|
97
102
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Register all
|
|
1
|
+
/** Register all 23 built-in field types. Safe to call multiple times — runs once. */
|
|
2
2
|
export declare function registerDefaultFieldTypes(): void;
|
|
@@ -13,18 +13,20 @@ import { MultiMonthPickerField as _ } from "../Fields/MultiMonthPickerField.js";
|
|
|
13
13
|
import { FileUploadField as n } from "../Fields/FileUploadField.js";
|
|
14
14
|
import { FillFormByPasteField as c } from "../Fields/FillFormByPasteField.js";
|
|
15
15
|
import { FillFormByFileUploadField as u } from "../Fields/FillFormByFileUploadField.js";
|
|
16
|
-
import { ChipsField as
|
|
17
|
-
import { TextFieldWithBackendValidation as
|
|
18
|
-
import { SwitchField as
|
|
19
|
-
import { CheckboxField as
|
|
20
|
-
import { LabelField as
|
|
21
|
-
import { DividerField as
|
|
16
|
+
import { ChipsField as h } from "../Fields/ChipsField.js";
|
|
17
|
+
import { TextFieldWithBackendValidation as b } from "../Fields/TextFieldWithBackendValidation.js";
|
|
18
|
+
import { SwitchField as s } from "../Fields/SwitchField.js";
|
|
19
|
+
import { CheckboxField as x } from "../Fields/CheckboxField.js";
|
|
20
|
+
import { LabelField as g } from "../Fields/LabelField.js";
|
|
21
|
+
import { DividerField as k } from "../Fields/DividerField.js";
|
|
22
22
|
import { DividerWithLabelField as w } from "../Fields/DividerWithLabelField.js";
|
|
23
23
|
import { NumericComboboxField as y } from "../Fields/NumericComboboxField.js";
|
|
24
|
+
import { SliderRangeField as R } from "../Fields/SliderRangeField.js";
|
|
25
|
+
import { RichTextField as T } from "../Fields/RichTextField.js";
|
|
24
26
|
let i = !1;
|
|
25
|
-
function
|
|
26
|
-
i || (i = !0, e("divider",
|
|
27
|
+
function Y() {
|
|
28
|
+
i || (i = !0, e("divider", k), e("divider_with_label", w), e("label", g), e("select", r), e("button_group", o), e("radio", t), e("text", m), e("numeric_combobox", y), e("text_area", l), e("date", p), e("date_range", d), e("week_range", a), e("multi_week_picker", F), e("month_range", f), e("multi_month_picker", _), e("file_upload", n), e("fill_form_by_paste", c), e("fill_form_by_file_upload", u), e("chips", h), e("text_with_backend_validation", b), e("switch", s), e("checkbox", x), e("slider_range", R), e("rich_text", T));
|
|
27
29
|
}
|
|
28
30
|
export {
|
|
29
|
-
|
|
31
|
+
Y as registerDefaultFieldTypes
|
|
30
32
|
};
|
|
@@ -119,19 +119,19 @@ export type SelectField = BaseField & {
|
|
|
119
119
|
apiConfig?: {
|
|
120
120
|
apiEndpoint: string;
|
|
121
121
|
method: "GET" | "POST";
|
|
122
|
-
/** When true, cascaded POSTs send `filters: []` (no parent field values). Use for independent selects (e.g. optional attributes). */
|
|
123
|
-
doNotIncludeSectionFormStateInApiRequest?: boolean;
|
|
124
|
-
includeOnlyMandatoryFieldsInPayload?: boolean;
|
|
125
|
-
/** When true, enables cascade behaviour even when `formConfig.isCascading` is false. */
|
|
126
|
-
isCascading?: boolean;
|
|
127
122
|
/**
|
|
128
|
-
* Explicit list of field IDs whose values should be
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
* Example: `["division_name", "l0_name"]` — only send Division and Department as filters.
|
|
123
|
+
* Explicit list of field IDs whose current values should be included in the API request payload.
|
|
124
|
+
* Combined with `cascadingDependency` field IDs when `passCascadingDependencyFields` is true (default).
|
|
125
|
+
* When `passCascadingDependencyFields` is false, only this list is sent.
|
|
126
|
+
* Example: `["division_name", "l0_name"]`.
|
|
133
127
|
*/
|
|
134
|
-
|
|
128
|
+
fieldsToPassInApi?: string[];
|
|
129
|
+
/**
|
|
130
|
+
* Controls which field values are sent with select-option API requests.
|
|
131
|
+
* - `true` (default): send `cascadingDependency` field IDs plus any `fieldsToPassInApi`
|
|
132
|
+
* - `false`: send only `fieldsToPassInApi` (ignore cascadingDependency for the payload)
|
|
133
|
+
*/
|
|
134
|
+
passCascadingDependencyFields?: boolean;
|
|
135
135
|
};
|
|
136
136
|
};
|
|
137
137
|
export type DateInputField = BaseField & {
|
|
@@ -378,6 +378,17 @@ export type ObjectFieldConfig = BaseField & {
|
|
|
378
378
|
collapsible?: boolean;
|
|
379
379
|
defaultCollapsed?: boolean;
|
|
380
380
|
};
|
|
381
|
+
export type SliderRangeField = BaseField & {
|
|
382
|
+
fieldType: "slider_range";
|
|
383
|
+
min?: number;
|
|
384
|
+
max?: number;
|
|
385
|
+
step?: number;
|
|
386
|
+
defaultValue?: number[];
|
|
387
|
+
/** When true, renders two thumbs (range mode). Default: single thumb. */
|
|
388
|
+
range?: boolean;
|
|
389
|
+
/** Show current value(s) next to the slider. Default: true. */
|
|
390
|
+
showValue?: boolean;
|
|
391
|
+
};
|
|
381
392
|
export type ArrayFieldConfig = BaseField & {
|
|
382
393
|
fieldType: "array";
|
|
383
394
|
/** Template fields cloned for each array item */
|
|
@@ -397,6 +408,14 @@ export type ArrayFieldConfig = BaseField & {
|
|
|
397
408
|
/** Default values for a new item (keys match itemFields[].id) */
|
|
398
409
|
defaultItemValue?: Record<string, unknown>;
|
|
399
410
|
};
|
|
400
|
-
export type
|
|
411
|
+
export type RichTextField = BaseField & {
|
|
412
|
+
fieldType: "rich_text";
|
|
413
|
+
/** Toolbar items to show. Default: ['undo','redo','bold','italic','underline','strikethrough','heading','quote','link','bulletedList','numberedList'] */
|
|
414
|
+
toolbar?: string[];
|
|
415
|
+
defaultValue?: string;
|
|
416
|
+
/** Minimum editor height in px. Default: 150 */
|
|
417
|
+
minHeight?: number;
|
|
418
|
+
};
|
|
419
|
+
export type IField = FileUploadField | ButtonsGroupField | SelectField | DateInputField | DateRangeField | WeekRangeField | MonthRangeField | MultiMonthPickerField | TextAreaField | RadioField | TextField | NumericComboboxField | CopyPasteField | FillFormByFileUploadField | TextFieldWithBackendValidation | ChipsField | DividerField | DividerWithLabelField | LabelField | SwitchField | CheckboxField | MultiWeekRangeField | SliderRangeField | RichTextField | ObjectFieldConfig | ArrayFieldConfig;
|
|
401
420
|
/** Discriminant string union for every built-in field type */
|
|
402
421
|
export type FieldType = IField["fieldType"];
|
|
@@ -25,13 +25,15 @@ export type NumericComboboxFieldOutput = number | "" | null | undefined;
|
|
|
25
25
|
export type ChipsFieldOutput = string | string[] | null | undefined;
|
|
26
26
|
export type SwitchFieldOutput = boolean | null | undefined;
|
|
27
27
|
export type CheckboxFieldOutput = boolean | null | undefined;
|
|
28
|
+
export type SliderRangeFieldOutput = number[] | null | undefined;
|
|
29
|
+
export type RichTextFieldOutput = string | null | undefined;
|
|
28
30
|
/** Presentational fields do not store a value */
|
|
29
31
|
export type PresentationalFieldOutput = null | undefined;
|
|
30
32
|
/**
|
|
31
33
|
* Union of all field output values (recursive for object / array nesting).
|
|
32
34
|
* Defined independently of FieldTypeToOutputMap to avoid circular map lookups.
|
|
33
35
|
*/
|
|
34
|
-
export type FieldOutputValue = FileUploadFieldOutput | ButtonsGroupFieldOutput | SelectFieldOutput | DateInputFieldOutput | DateRangeFieldOutput | WeekRangeFieldOutput | MultiWeekPickerFieldOutput | MonthRangeFieldOutput | MultiMonthPickerFieldOutput | TextAreaFieldOutput | RadioFieldOutput | TextFieldOutput | NumericComboboxFieldOutput | CopyPasteFieldOutput | FillFormByFileUploadFieldOutput | TextFieldWithBackendValidationOutput | ChipsFieldOutput | SwitchFieldOutput | CheckboxFieldOutput | PresentationalFieldOutput | {
|
|
36
|
+
export type FieldOutputValue = FileUploadFieldOutput | ButtonsGroupFieldOutput | SelectFieldOutput | DateInputFieldOutput | DateRangeFieldOutput | WeekRangeFieldOutput | MultiWeekPickerFieldOutput | MonthRangeFieldOutput | MultiMonthPickerFieldOutput | TextAreaFieldOutput | RadioFieldOutput | TextFieldOutput | NumericComboboxFieldOutput | CopyPasteFieldOutput | FillFormByFileUploadFieldOutput | TextFieldWithBackendValidationOutput | ChipsFieldOutput | SwitchFieldOutput | CheckboxFieldOutput | SliderRangeFieldOutput | RichTextFieldOutput | PresentationalFieldOutput | {
|
|
35
37
|
[key: string]: FieldOutputValue;
|
|
36
38
|
} | Array<{
|
|
37
39
|
[key: string]: FieldOutputValue;
|
|
@@ -59,6 +61,8 @@ export type FieldTypeToOutputMap = {
|
|
|
59
61
|
chips: ChipsFieldOutput;
|
|
60
62
|
switch: SwitchFieldOutput;
|
|
61
63
|
checkbox: CheckboxFieldOutput;
|
|
64
|
+
slider_range: SliderRangeFieldOutput;
|
|
65
|
+
rich_text: RichTextFieldOutput;
|
|
62
66
|
object: {
|
|
63
67
|
[key: string]: FieldOutputValue;
|
|
64
68
|
} | null | undefined;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
import { FieldErrors, FormState, RegisterOptions, UseFormReturn } from 'react-hook-form';
|
|
3
3
|
import { Option } from '../../components/forms/select';
|
|
4
|
-
import { FieldVisibilityBase } from '../../form-engine';
|
|
4
|
+
import { FieldVisibilityBase, FormStepConfig } from '../../form-engine';
|
|
5
5
|
import { FieldType, IField, SelectField } from './fields.types';
|
|
6
6
|
export type { FieldVisibilityBase } from '../../form-engine';
|
|
7
|
+
export type { FormStepConfig } from '../../form-engine';
|
|
8
|
+
export type FormType = 'default' | 'stepped' | 'grouped';
|
|
7
9
|
export type IFormConfig = {
|
|
8
10
|
formId: string;
|
|
9
11
|
fields: Array<IField>;
|
|
@@ -13,6 +15,10 @@ export type IFormConfig = {
|
|
|
13
15
|
isCascading?: boolean;
|
|
14
16
|
includeOnlyVisibleFieldsInSubmit?: boolean;
|
|
15
17
|
enableFieldOrdering?: boolean;
|
|
18
|
+
/** Layout mode. `'stepped'` shows one step at a time; `'grouped'` shows all groups with section headers. */
|
|
19
|
+
formType?: FormType;
|
|
20
|
+
/** Step metadata — order, titles, validation gating. When omitted, derived from field `fieldGroup` order. */
|
|
21
|
+
steps?: FormStepConfig[];
|
|
16
22
|
};
|
|
17
23
|
export interface FormFieldProps {
|
|
18
24
|
field: IField;
|
|
@@ -105,8 +111,17 @@ export interface FormTransport {
|
|
|
105
111
|
}
|
|
106
112
|
/** Built-in fieldType keys plus arbitrary custom string keys */
|
|
107
113
|
export type CustomFieldTypesMap = Partial<Record<FieldType, ComponentType<FormFieldProps>>> & Record<string, ComponentType<FormFieldProps>>;
|
|
114
|
+
export interface FormStepStateMeta {
|
|
115
|
+
currentStep: number;
|
|
116
|
+
totalSteps: number;
|
|
117
|
+
isFirstStep: boolean;
|
|
118
|
+
isLastStep: boolean;
|
|
119
|
+
canProceed: boolean;
|
|
120
|
+
completedSteps: number[];
|
|
121
|
+
}
|
|
108
122
|
export interface FormValidationMeta {
|
|
109
123
|
isSubmittable: boolean;
|
|
124
|
+
stepState?: FormStepStateMeta;
|
|
110
125
|
}
|
|
111
126
|
export interface FormContextValidateFormParams {
|
|
112
127
|
formValues: ReactHookFormState;
|
|
@@ -176,16 +191,28 @@ export interface ReactHooksFormProps {
|
|
|
176
191
|
/** Consumer-injected context — validators, custom field types, lifecycle hooks */
|
|
177
192
|
formContext?: FormContext;
|
|
178
193
|
}
|
|
194
|
+
export interface ReactHooksFormStepActions {
|
|
195
|
+
currentStep: number;
|
|
196
|
+
totalSteps: number;
|
|
197
|
+
isFirstStep: boolean;
|
|
198
|
+
isLastStep: boolean;
|
|
199
|
+
canProceed: boolean;
|
|
200
|
+
goNext: () => boolean;
|
|
201
|
+
goPrev: () => void;
|
|
202
|
+
goToStep: (index: number) => void;
|
|
203
|
+
isStepComplete: (stepIndex: number) => boolean;
|
|
204
|
+
isStepVisited: (stepIndex: number) => boolean;
|
|
205
|
+
}
|
|
179
206
|
export interface ReactHooksFormRef {
|
|
180
207
|
submitForm: () => Promise<boolean>;
|
|
181
208
|
hasErrors: boolean;
|
|
182
209
|
errors: FieldErrors<ReactHookFormState>;
|
|
183
210
|
isValid: boolean;
|
|
211
|
+
stepActions?: ReactHooksFormStepActions;
|
|
184
212
|
}
|
|
185
213
|
export interface UseSelectOptionsProps {
|
|
186
214
|
apiConfig?: SelectField["apiConfig"];
|
|
187
215
|
formHelpers?: UseReactHookFormReturn;
|
|
188
|
-
formConfig?: IFormConfig;
|
|
189
216
|
initialOptions?: Option[];
|
|
190
217
|
id: string;
|
|
191
218
|
isEnabled: boolean;
|
|
@@ -193,4 +220,6 @@ export interface UseSelectOptionsProps {
|
|
|
193
220
|
getSelectOptionsName?: string;
|
|
194
221
|
/** Field-specific values to inject into API payload (e.g., viewSettings, globalFilters) */
|
|
195
222
|
fieldSupportedValues?: Record<string, unknown>;
|
|
223
|
+
/** Field's cascading dependency config — used to auto-derive which parent field values to pass in API requests. */
|
|
224
|
+
cascadingDependency?: IField["cascadingDependency"];
|
|
196
225
|
}
|
|
@@ -1,21 +1,36 @@
|
|
|
1
1
|
function u(e) {
|
|
2
2
|
if (e.fieldType === "object") {
|
|
3
|
-
const
|
|
4
|
-
return e.fields.forEach((
|
|
5
|
-
a
|
|
6
|
-
}),
|
|
3
|
+
const t = {};
|
|
4
|
+
return e.fields.forEach((a) => {
|
|
5
|
+
t[a.id] = u(a);
|
|
6
|
+
}), t;
|
|
7
7
|
}
|
|
8
8
|
if (e.fieldType === "array") {
|
|
9
|
-
const
|
|
10
|
-
return
|
|
9
|
+
const t = e.defaultItemValue ?? {}, a = e.minItems ?? 0;
|
|
10
|
+
return a > 0 ? Array.from({ length: a }, () => ({ ...t })) : [];
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
if (e.fieldType === "button_group" && e.defaultSelectedValue || e.fieldType === "radio" && e.defaultSelectedValue)
|
|
13
|
+
return e.defaultSelectedValue || null;
|
|
14
|
+
if (e.fieldType === "date_range" && e.defaultRange)
|
|
15
|
+
return {
|
|
16
|
+
start: e.defaultRange.start || null,
|
|
17
|
+
end: e.defaultRange.end || null
|
|
18
|
+
};
|
|
19
|
+
if (e.fieldType === "month_range" && e.defaultRange)
|
|
20
|
+
return {
|
|
21
|
+
start: e.defaultRange.start || null,
|
|
22
|
+
end: e.defaultRange.end || null
|
|
23
|
+
};
|
|
24
|
+
if (e.fieldType === "switch" || e.fieldType === "checkbox")
|
|
25
|
+
return e.defaultSelectedValue ?? !1;
|
|
26
|
+
if (e.fieldType === "text" || e.fieldType === "text_area" || e.fieldType === "numeric_combobox" || e.fieldType === "rich_text")
|
|
27
|
+
return e.defaultValue ?? "";
|
|
28
|
+
if (e.fieldType === "slider_range") {
|
|
29
|
+
if (e.defaultValue) return e.defaultValue;
|
|
30
|
+
const t = e.min ?? 0;
|
|
31
|
+
return e.range ? [t, e.max ?? 100] : [t];
|
|
32
|
+
}
|
|
33
|
+
return e.fieldType === "date" ? "" : e.fieldType === "select" ? [] : e.fieldType === "week_range" && e.defaultRange ? {
|
|
19
34
|
start: e.defaultRange.start || null,
|
|
20
35
|
end: e.defaultRange.end || null
|
|
21
36
|
} : null;
|