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
|
@@ -1,132 +1,194 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
1
|
+
import { jsx as l, jsxs as T } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as j, useRef as n, useEffect as S, useCallback as y, useImperativeHandle as M } from "react";
|
|
3
3
|
import { useReactHookForm as G } from "./hooks/useReactHookForm.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
4
|
+
import { useFormSteps as $ } from "./hooks/useFormSteps.js";
|
|
5
|
+
import { GRID_COLS_MAP as q, GAP_X_MAP as B, GAP_Y_MAP as X } from "./utils/fieldRendererUtils.js";
|
|
6
|
+
import { FormFieldRow as Y } from "./components/FormFieldRow.js";
|
|
7
|
+
import { showFormValidationFailureFeedback as z } from "./utils/formValidationFeedback.utils.js";
|
|
8
|
+
import { resolveFormSubmittable as J, mergeFormValidationFieldErrors as K } from "./utils/resolveFormSubmittable.js";
|
|
9
|
+
import { validateVisibleRequiredFormFields as Q } from "./utils/validateVisibleRequiredFormFields.js";
|
|
10
|
+
import { getFirstIncompleteStep as U } from "../form-engine/field-groups.js";
|
|
11
|
+
const de = j(
|
|
10
12
|
({
|
|
11
|
-
formId:
|
|
12
|
-
formConfig:
|
|
13
|
-
formInitialState:
|
|
14
|
-
onSubmit:
|
|
15
|
-
onCancel:
|
|
16
|
-
onReset:
|
|
17
|
-
sendFormStateToParent:
|
|
18
|
-
supportedValues:
|
|
19
|
-
formContext:
|
|
20
|
-
},
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
), { errors:
|
|
29
|
-
|
|
30
|
-
|
|
13
|
+
formId: p,
|
|
14
|
+
formConfig: s,
|
|
15
|
+
formInitialState: k,
|
|
16
|
+
onSubmit: x,
|
|
17
|
+
onCancel: N,
|
|
18
|
+
onReset: P,
|
|
19
|
+
sendFormStateToParent: d,
|
|
20
|
+
supportedValues: w,
|
|
21
|
+
formContext: c
|
|
22
|
+
}, H) => {
|
|
23
|
+
const t = G(
|
|
24
|
+
s,
|
|
25
|
+
k,
|
|
26
|
+
x,
|
|
27
|
+
N,
|
|
28
|
+
P,
|
|
29
|
+
c
|
|
30
|
+
), r = $(s, t), { errors: I, isValid: A, isDirty: D, isValidating: _ } = t.form.formState, b = n(t), F = n(d), h = n(c), V = n(s.fields), v = n(r);
|
|
31
|
+
S(() => {
|
|
32
|
+
b.current = t, F.current = d, h.current = c, V.current = s.fields, v.current = r;
|
|
31
33
|
});
|
|
32
|
-
const
|
|
33
|
-
const e =
|
|
34
|
+
const R = y(() => {
|
|
35
|
+
const e = v.current;
|
|
36
|
+
if (!e) return;
|
|
37
|
+
const i = [];
|
|
38
|
+
for (let o = 0; o < e.totalSteps; o++)
|
|
39
|
+
e.isStepComplete(o) && i.push(o);
|
|
40
|
+
return {
|
|
41
|
+
currentStep: e.currentStep,
|
|
42
|
+
totalSteps: e.totalSteps,
|
|
43
|
+
isFirstStep: e.isFirstStep,
|
|
44
|
+
isLastStep: e.isLastStep,
|
|
45
|
+
canProceed: e.canProceed,
|
|
46
|
+
completedSteps: i
|
|
47
|
+
};
|
|
48
|
+
}, []), m = y(() => {
|
|
49
|
+
const e = F.current;
|
|
34
50
|
if (!e)
|
|
35
51
|
return;
|
|
36
|
-
const
|
|
52
|
+
const i = b.current;
|
|
37
53
|
e(
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
i.form.formState,
|
|
55
|
+
i.form.getValues(),
|
|
40
56
|
{
|
|
41
|
-
isSubmittable:
|
|
42
|
-
formConfigFields:
|
|
43
|
-
formHelpers:
|
|
44
|
-
formContext:
|
|
45
|
-
})
|
|
57
|
+
isSubmittable: J({
|
|
58
|
+
formConfigFields: V.current,
|
|
59
|
+
formHelpers: i,
|
|
60
|
+
formContext: h.current
|
|
61
|
+
}),
|
|
62
|
+
stepState: R()
|
|
46
63
|
}
|
|
47
64
|
);
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
if (!
|
|
65
|
+
}, [R]);
|
|
66
|
+
S(() => {
|
|
67
|
+
if (!d)
|
|
51
68
|
return;
|
|
52
|
-
|
|
53
|
-
const e =
|
|
54
|
-
|
|
69
|
+
m();
|
|
70
|
+
const e = t.form.watch(() => {
|
|
71
|
+
m();
|
|
55
72
|
});
|
|
56
73
|
return () => e.unsubscribe();
|
|
57
|
-
}, [
|
|
58
|
-
|
|
74
|
+
}, [d, m, t.form]), S(() => {
|
|
75
|
+
d && m();
|
|
59
76
|
}, [
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
77
|
+
d,
|
|
78
|
+
m,
|
|
79
|
+
I,
|
|
80
|
+
A,
|
|
81
|
+
D,
|
|
82
|
+
_,
|
|
83
|
+
r?.currentStep
|
|
84
|
+
]), M(
|
|
63
85
|
H,
|
|
64
|
-
y,
|
|
65
|
-
D
|
|
66
|
-
]), x(
|
|
67
|
-
k,
|
|
68
86
|
() => ({
|
|
69
87
|
submitForm: async () => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
88
|
+
if (r && s.formType === "stepped") {
|
|
89
|
+
const a = U(
|
|
90
|
+
r.groups,
|
|
91
|
+
s.fields,
|
|
92
|
+
t.form.getValues(),
|
|
93
|
+
t.form.formState.errors
|
|
94
|
+
);
|
|
95
|
+
a !== -1 && r.goToStep(a);
|
|
96
|
+
}
|
|
97
|
+
const e = s.fields.filter(
|
|
98
|
+
(a) => t.isFieldVisible(a)
|
|
99
|
+
), i = Q(
|
|
100
|
+
t.form,
|
|
74
101
|
e,
|
|
75
102
|
{
|
|
76
|
-
isFieldDisabled:
|
|
77
|
-
isFieldDisabledForValidation:
|
|
78
|
-
formHelpers:
|
|
103
|
+
isFieldDisabled: t.isFieldDisabled,
|
|
104
|
+
isFieldDisabledForValidation: t.isFieldDisabledForSubmitValidation,
|
|
105
|
+
formHelpers: t
|
|
79
106
|
}
|
|
80
|
-
),
|
|
81
|
-
formValues:
|
|
107
|
+
), o = c?.validateForm?.({
|
|
108
|
+
formValues: t.form.getValues(),
|
|
82
109
|
visibleFields: e
|
|
83
|
-
}),
|
|
84
|
-
|
|
85
|
-
|
|
110
|
+
}), L = K(
|
|
111
|
+
i.fieldErrors,
|
|
112
|
+
o?.fieldErrors
|
|
86
113
|
);
|
|
87
|
-
return
|
|
88
|
-
([a,
|
|
89
|
-
|
|
114
|
+
return i.isValid && (o?.isValid ?? !0) ? (t.submitValidatedForm(void 0), !0) : (o?.fieldErrors && Object.entries(o.fieldErrors).forEach(
|
|
115
|
+
([a, O]) => {
|
|
116
|
+
t.form.setError(a, {
|
|
90
117
|
type: "validate",
|
|
91
|
-
message:
|
|
118
|
+
message: O.message
|
|
92
119
|
});
|
|
93
120
|
}
|
|
94
|
-
),
|
|
95
|
-
fieldErrors:
|
|
121
|
+
), z({
|
|
122
|
+
fieldErrors: L,
|
|
96
123
|
fieldsInOrder: e,
|
|
97
124
|
showToast: (a) => {
|
|
98
|
-
|
|
125
|
+
t.formContext?.transport?.showFormErrorToast?.(
|
|
99
126
|
a
|
|
100
127
|
);
|
|
101
128
|
}
|
|
102
129
|
}), !1);
|
|
103
130
|
},
|
|
104
|
-
hasErrors: Object.keys(
|
|
105
|
-
errors:
|
|
106
|
-
isValid:
|
|
131
|
+
hasErrors: Object.keys(t.form.formState?.errors || {}).length > 0,
|
|
132
|
+
errors: t.form.formState?.errors,
|
|
133
|
+
isValid: t.form.formState?.isValid,
|
|
134
|
+
stepActions: r ? {
|
|
135
|
+
currentStep: r.currentStep,
|
|
136
|
+
totalSteps: r.totalSteps,
|
|
137
|
+
isFirstStep: r.isFirstStep,
|
|
138
|
+
isLastStep: r.isLastStep,
|
|
139
|
+
canProceed: r.canProceed,
|
|
140
|
+
goNext: r.goNext,
|
|
141
|
+
goPrev: r.goPrev,
|
|
142
|
+
goToStep: r.goToStep,
|
|
143
|
+
isStepComplete: r.isStepComplete,
|
|
144
|
+
isStepVisited: r.isStepVisited
|
|
145
|
+
} : void 0
|
|
107
146
|
}),
|
|
108
|
-
[
|
|
147
|
+
[s.fields, s.formType, t, c, r]
|
|
109
148
|
);
|
|
110
|
-
const
|
|
111
|
-
|
|
149
|
+
const g = s.gapBetweenFields ?? 6, u = `grid ${q[s.columns || 1]} ${B[g] ?? "gap-x-6"} ${X[g] ?? "gap-y-6"}`, E = (e) => /* @__PURE__ */ l(
|
|
150
|
+
Y,
|
|
112
151
|
{
|
|
113
152
|
field: e,
|
|
114
|
-
formHelpers:
|
|
115
|
-
formConfig:
|
|
116
|
-
supportedValues:
|
|
153
|
+
formHelpers: t,
|
|
154
|
+
formConfig: s,
|
|
155
|
+
supportedValues: w
|
|
117
156
|
},
|
|
118
157
|
e.id
|
|
119
|
-
);
|
|
120
|
-
return /* @__PURE__ */
|
|
158
|
+
), f = (e) => s?.enableFieldOrdering ? [...e].sort((i, o) => (i?.order ?? 0) - (o?.order ?? 0)).map(E) : e.map(E);
|
|
159
|
+
return s.formType === "stepped" && r ? /* @__PURE__ */ l(
|
|
160
|
+
"form",
|
|
161
|
+
{
|
|
162
|
+
id: p || "react-hooks-form",
|
|
163
|
+
onSubmit: t.handleSubmit(void 0),
|
|
164
|
+
children: /* @__PURE__ */ l("div", { className: u, children: f(r.currentStepFields) })
|
|
165
|
+
}
|
|
166
|
+
) : s.formType === "grouped" && r ? /* @__PURE__ */ l(
|
|
167
|
+
"form",
|
|
168
|
+
{
|
|
169
|
+
id: p || "react-hooks-form",
|
|
170
|
+
onSubmit: t.handleSubmit(void 0),
|
|
171
|
+
children: r.groups.map((e) => {
|
|
172
|
+
const i = s.fields.filter(
|
|
173
|
+
(o) => e.fieldIds.includes(o.id)
|
|
174
|
+
);
|
|
175
|
+
return /* @__PURE__ */ T("fieldset", { className: "mb-6", children: [
|
|
176
|
+
e.title && /* @__PURE__ */ l("legend", { className: "text-lg font-semibold mb-3", children: e.title }),
|
|
177
|
+
e.description && /* @__PURE__ */ l("p", { className: "text-sm text-muted-foreground mb-4", children: e.description }),
|
|
178
|
+
/* @__PURE__ */ l("div", { className: u, children: f(i) })
|
|
179
|
+
] }, e.groupId);
|
|
180
|
+
})
|
|
181
|
+
}
|
|
182
|
+
) : /* @__PURE__ */ l(
|
|
121
183
|
"form",
|
|
122
184
|
{
|
|
123
|
-
id:
|
|
124
|
-
onSubmit:
|
|
125
|
-
children: /* @__PURE__ */
|
|
185
|
+
id: p || "react-hooks-form",
|
|
186
|
+
onSubmit: t.handleSubmit(void 0),
|
|
187
|
+
children: /* @__PURE__ */ l("div", { className: u, children: f(s.fields) })
|
|
126
188
|
}
|
|
127
189
|
);
|
|
128
190
|
}
|
|
129
191
|
);
|
|
130
192
|
export {
|
|
131
|
-
|
|
193
|
+
de as ReactHooksForm
|
|
132
194
|
};
|
|
@@ -21,3 +21,5 @@ export { NumericComboboxField } from './Fields/NumericComboboxField';
|
|
|
21
21
|
export { MultiMonthPickerField } from './Fields/MultiMonthPickerField';
|
|
22
22
|
export { MultiWeekPickerField } from './Fields/MultiWeekPickerField';
|
|
23
23
|
export { TextFieldWithBackendValidation } from './Fields/TextFieldWithBackendValidation';
|
|
24
|
+
export { SliderRangeField } from './Fields/SliderRangeField';
|
|
25
|
+
export { RichTextField } from './Fields/RichTextField';
|
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
import { TextField as r } from "./Fields/TextField.js";
|
|
2
2
|
import { TextAreaField as i } from "./Fields/TextAreaField.js";
|
|
3
|
-
import { ButtonsGroupField as
|
|
4
|
-
import { RadioField as
|
|
3
|
+
import { ButtonsGroupField as d } from "./Fields/ButtonsGroupField.js";
|
|
4
|
+
import { RadioField as F } from "./Fields/RadioField.js";
|
|
5
5
|
import { DateRangeField as m } from "./Fields/DateRangeField.js";
|
|
6
6
|
import { WeekRangeField as a } from "./Fields/WeekRangePicker.js";
|
|
7
7
|
import { MonthRangeField as c } from "./Fields/MonthRangeField.js";
|
|
8
8
|
import { FileUploadField as k } from "./Fields/FileUploadField.js";
|
|
9
|
-
import { SelectField as
|
|
10
|
-
import { CheckboxField as
|
|
11
|
-
import { SwitchField as
|
|
12
|
-
import { ChipsField as
|
|
13
|
-
import { DateInputField as
|
|
14
|
-
import { FillFormByPasteField as
|
|
15
|
-
import { FillFormByFileUploadField as
|
|
9
|
+
import { SelectField as R } from "./Fields/SelectField.js";
|
|
10
|
+
import { CheckboxField as B } from "./Fields/CheckboxField.js";
|
|
11
|
+
import { SwitchField as T } from "./Fields/SwitchField.js";
|
|
12
|
+
import { ChipsField as s } from "./Fields/ChipsField.js";
|
|
13
|
+
import { DateInputField as P } from "./Fields/DateInputField.js";
|
|
14
|
+
import { FillFormByPasteField as W } from "./Fields/FillFormByPasteField.js";
|
|
15
|
+
import { FillFormByFileUploadField as D } from "./Fields/FillFormByFileUploadField.js";
|
|
16
16
|
import { NumericComboboxField as w } from "./Fields/NumericComboboxField.js";
|
|
17
17
|
import { MultiMonthPickerField as G } from "./Fields/MultiMonthPickerField.js";
|
|
18
18
|
import { MultiWeekPickerField as N } from "./Fields/MultiWeekPickerField.js";
|
|
19
19
|
import { TextFieldWithBackendValidation as j } from "./Fields/TextFieldWithBackendValidation.js";
|
|
20
|
+
import { SliderRangeField as v } from "./Fields/SliderRangeField.js";
|
|
21
|
+
import { RichTextField as E } from "./Fields/RichTextField.js";
|
|
20
22
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
d as ButtonsGroupField,
|
|
24
|
+
B as CheckboxField,
|
|
25
|
+
s as ChipsField,
|
|
26
|
+
P as DateInputField,
|
|
25
27
|
m as DateRangeField,
|
|
26
28
|
k as FileUploadField,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
D as FillFormByFileUploadField,
|
|
30
|
+
W as FillFormByPasteField,
|
|
29
31
|
c as MonthRangeField,
|
|
30
32
|
G as MultiMonthPickerField,
|
|
31
33
|
N as MultiWeekPickerField,
|
|
32
34
|
w as NumericComboboxField,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
F as RadioField,
|
|
36
|
+
E as RichTextField,
|
|
37
|
+
R as SelectField,
|
|
38
|
+
v as SliderRangeField,
|
|
39
|
+
T as SwitchField,
|
|
36
40
|
i as TextAreaField,
|
|
37
41
|
r as TextField,
|
|
38
42
|
j as TextFieldWithBackendValidation,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UseFormReturn } from 'react-hook-form';
|
|
2
2
|
import { IField } from '../types/fields.types';
|
|
3
|
-
import { IFormConfig
|
|
3
|
+
import { IFormConfig } from '../types/reactHookForm.types';
|
|
4
4
|
import { ReactHookFormState } from './useReactHookForm';
|
|
5
5
|
import { EvaluateFieldValidationOptions } from '../utils/evaluateFieldValidation';
|
|
6
6
|
export interface UseCascadingFormConfig {
|
|
@@ -12,6 +12,5 @@ export interface UseCascadingFormReturn {
|
|
|
12
12
|
clearSubsequentFields: (fieldName: string) => void;
|
|
13
13
|
getEarlierFieldsIds: (currentFieldId: string, onlyMandatory?: boolean) => string[];
|
|
14
14
|
setValueWithCascading: (fieldName: string, value: unknown) => void;
|
|
15
|
-
isCascadingDisabled: (field: FieldVisibilityBase) => boolean;
|
|
16
15
|
}
|
|
17
16
|
export declare const useCascadingForm: (form: UseFormReturn<ReactHookFormState>, formConfig: IFormConfig, cascadingFormConfig: UseCascadingFormConfig) => UseCascadingFormReturn;
|
|
@@ -1,122 +1,114 @@
|
|
|
1
|
-
import { useCallback as r, useEffect as
|
|
1
|
+
import { useCallback as r, useEffect as E } from "react";
|
|
2
2
|
import { isEmptyValue as V } from "../../form-engine/is-empty-value.js";
|
|
3
|
-
import { getDependentFieldIds as v
|
|
4
|
-
import { batchSetFormFieldValues as
|
|
5
|
-
import { isFieldValueValid as
|
|
6
|
-
import { findFieldByPath as
|
|
7
|
-
const
|
|
8
|
-
const { getFieldDefaultValue: c, resolveFieldValidationEvaluationOptions: F } = h,
|
|
9
|
-
() =>
|
|
10
|
-
[
|
|
3
|
+
import { getDependentFieldIds as v } from "../../form-engine/field-dependency-graph.js";
|
|
4
|
+
import { batchSetFormFieldValues as x } from "../utils/batchFormFieldUpdates.js";
|
|
5
|
+
import { isFieldValueValid as f } from "../utils/buildFieldValidationRules.js";
|
|
6
|
+
import { findFieldByPath as D } from "../utils/fieldPath.utils.js";
|
|
7
|
+
const M = (n, i, h) => {
|
|
8
|
+
const { getFieldDefaultValue: c, resolveFieldValidationEvaluationOptions: F } = h, o = r(
|
|
9
|
+
() => i.fields.filter((e) => e.isRequired),
|
|
10
|
+
[i.fields]
|
|
11
11
|
), y = r(
|
|
12
12
|
(e) => {
|
|
13
|
-
if (!
|
|
13
|
+
if (!i.isCascading)
|
|
14
14
|
return !0;
|
|
15
|
-
const
|
|
15
|
+
const a = n.getValues(), l = o(), s = l.findIndex(
|
|
16
16
|
(t) => t.id === e.id
|
|
17
17
|
);
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
(t) => !V(
|
|
18
|
+
if (s === -1)
|
|
19
|
+
return l.every(
|
|
20
|
+
(t) => !V(a[t.id])
|
|
21
21
|
);
|
|
22
|
-
for (let t = 0; t <
|
|
23
|
-
const
|
|
24
|
-
if (V(
|
|
22
|
+
for (let t = 0; t < s; t += 1) {
|
|
23
|
+
const d = l[t];
|
|
24
|
+
if (V(a[d.id]))
|
|
25
25
|
return !1;
|
|
26
26
|
}
|
|
27
27
|
return !0;
|
|
28
28
|
},
|
|
29
|
-
[
|
|
29
|
+
[n, i.isCascading, o]
|
|
30
30
|
), I = r(
|
|
31
|
-
(e,
|
|
32
|
-
let
|
|
33
|
-
(
|
|
31
|
+
(e, a = !1) => {
|
|
32
|
+
let s = i.fields.filter(
|
|
33
|
+
(d) => d.fieldType !== "label" && d.fieldType !== "divider"
|
|
34
34
|
);
|
|
35
|
-
|
|
36
|
-
const t =
|
|
37
|
-
(
|
|
35
|
+
a && (s = s.filter((d) => d.isRequired));
|
|
36
|
+
const t = s.findIndex(
|
|
37
|
+
(d) => d.id === e
|
|
38
38
|
);
|
|
39
|
-
return t === -1 ? [] :
|
|
39
|
+
return t === -1 ? [] : s.slice(0, t).map((d) => d.id);
|
|
40
40
|
},
|
|
41
|
-
[
|
|
42
|
-
),
|
|
41
|
+
[i.fields]
|
|
42
|
+
), p = r(
|
|
43
43
|
(e) => {
|
|
44
|
-
const
|
|
45
|
-
|
|
44
|
+
const a = v(
|
|
45
|
+
i.fields,
|
|
46
46
|
e
|
|
47
|
-
),
|
|
48
|
-
return
|
|
49
|
-
(
|
|
47
|
+
), l = new Set(a);
|
|
48
|
+
return i.fields.filter(
|
|
49
|
+
(s) => l.has(s.id)
|
|
50
50
|
);
|
|
51
51
|
},
|
|
52
|
-
[
|
|
52
|
+
[i.fields]
|
|
53
53
|
), u = r(
|
|
54
54
|
(e) => {
|
|
55
|
-
if (!
|
|
55
|
+
if (!i.isCascading)
|
|
56
56
|
return;
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
return
|
|
57
|
+
const a = p(e), l = n.getValues(), s = a.map((t) => {
|
|
58
|
+
const d = c(t);
|
|
59
|
+
return l[t.id] === d ? null : {
|
|
60
60
|
fieldName: t.id,
|
|
61
|
-
value:
|
|
61
|
+
value: d
|
|
62
62
|
};
|
|
63
63
|
}).filter(
|
|
64
64
|
(t) => t !== null
|
|
65
65
|
);
|
|
66
|
-
|
|
66
|
+
x(n, s, {
|
|
67
67
|
shouldDirty: !0,
|
|
68
68
|
shouldValidate: !1
|
|
69
69
|
});
|
|
70
70
|
},
|
|
71
|
-
[
|
|
71
|
+
[n, i.isCascading, p, c]
|
|
72
72
|
);
|
|
73
|
-
|
|
74
|
-
if (!
|
|
73
|
+
E(() => {
|
|
74
|
+
if (!i.isCascading)
|
|
75
75
|
return;
|
|
76
|
-
const e =
|
|
77
|
-
|
|
76
|
+
const e = n.watch((a, { name: l, type: s }) => {
|
|
77
|
+
l && s === "change" && u(l);
|
|
78
78
|
});
|
|
79
79
|
return () => e.unsubscribe();
|
|
80
|
-
}, [
|
|
80
|
+
}, [n, i.isCascading, u]);
|
|
81
81
|
const b = r(
|
|
82
|
-
(e,
|
|
83
|
-
|
|
82
|
+
(e, a) => {
|
|
83
|
+
n.setValue(e, a, {
|
|
84
84
|
shouldValidate: !0,
|
|
85
85
|
shouldDirty: !0
|
|
86
86
|
});
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
) &&
|
|
87
|
+
const l = D(i.fields, e);
|
|
88
|
+
if (l) {
|
|
89
|
+
const s = F?.(e);
|
|
90
|
+
f(
|
|
91
|
+
l,
|
|
92
|
+
a,
|
|
93
|
+
s
|
|
94
|
+
) && n.clearErrors(e);
|
|
95
95
|
}
|
|
96
96
|
u(e);
|
|
97
97
|
},
|
|
98
98
|
[
|
|
99
|
-
|
|
100
|
-
|
|
99
|
+
n,
|
|
100
|
+
i.fields,
|
|
101
101
|
u,
|
|
102
102
|
F
|
|
103
103
|
]
|
|
104
|
-
), E = r(
|
|
105
|
-
(e) => x(
|
|
106
|
-
e,
|
|
107
|
-
a.getValues(),
|
|
108
|
-
!!s.isCascading
|
|
109
|
-
),
|
|
110
|
-
[a, s.isCascading]
|
|
111
104
|
);
|
|
112
105
|
return {
|
|
113
106
|
areEarlierMandatoryFieldsFilled: y,
|
|
114
107
|
clearSubsequentFields: u,
|
|
115
108
|
getEarlierFieldsIds: I,
|
|
116
|
-
setValueWithCascading: b
|
|
117
|
-
isCascadingDisabled: E
|
|
109
|
+
setValueWithCascading: b
|
|
118
110
|
};
|
|
119
111
|
};
|
|
120
112
|
export {
|
|
121
|
-
|
|
113
|
+
M as useCascadingForm
|
|
122
114
|
};
|
|
@@ -3,12 +3,11 @@ import { IFormConfig, FieldVisibilityBase, ReactHookFormState } from '../types/r
|
|
|
3
3
|
interface UseFieldVisibilityParams {
|
|
4
4
|
form: UseFormReturn<ReactHookFormState>;
|
|
5
5
|
formConfig: IFormConfig;
|
|
6
|
-
isCascadingDisabled: (field: FieldVisibilityBase) => boolean;
|
|
7
6
|
}
|
|
8
7
|
export interface UseFieldVisibilityReturn {
|
|
9
8
|
isFieldVisible: (field: FieldVisibilityBase) => boolean;
|
|
10
9
|
isFieldDisabled: (field: FieldVisibilityBase) => boolean;
|
|
11
10
|
isFieldDisabledForSubmitValidation: (field: FieldVisibilityBase) => boolean;
|
|
12
11
|
}
|
|
13
|
-
export declare function useFieldVisibility({ form, formConfig,
|
|
12
|
+
export declare function useFieldVisibility({ form, formConfig, }: UseFieldVisibilityParams): UseFieldVisibilityReturn;
|
|
14
13
|
export {};
|