impact-nova 2.5.5 → 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.
Files changed (34) hide show
  1. package/dist/form-engine/field-dependency-graph.d.ts +1 -4
  2. package/dist/form-engine/field-dependency-graph.js +53 -57
  3. package/dist/form-engine/field-groups.d.ts +15 -0
  4. package/dist/form-engine/field-groups.js +60 -0
  5. package/dist/form-engine/index.d.ts +3 -2
  6. package/dist/form-engine/index.js +17 -14
  7. package/dist/form-engine/types.d.ts +17 -0
  8. package/dist/form-react/Fields/RichTextField.d.ts +3 -0
  9. package/dist/form-react/Fields/RichTextField.js +214 -0
  10. package/dist/form-react/Fields/SelectField.js +27 -28
  11. package/dist/form-react/Fields/SliderRangeField.d.ts +3 -0
  12. package/dist/form-react/Fields/SliderRangeField.js +69 -0
  13. package/dist/form-react/ReactHooksForm.js +149 -87
  14. package/dist/form-react/fields.d.ts +2 -0
  15. package/dist/form-react/fields.js +22 -18
  16. package/dist/form-react/hooks/useCascadingForm.d.ts +1 -2
  17. package/dist/form-react/hooks/useCascadingForm.js +59 -67
  18. package/dist/form-react/hooks/useFieldVisibility.d.ts +1 -2
  19. package/dist/form-react/hooks/useFieldVisibility.js +36 -43
  20. package/dist/form-react/hooks/useFormSteps.d.ts +29 -0
  21. package/dist/form-react/hooks/useFormSteps.js +96 -0
  22. package/dist/form-react/hooks/useReactHookForm.js +17 -18
  23. package/dist/form-react/hooks/useSelectOptions.d.ts +1 -1
  24. package/dist/form-react/hooks/useSelectOptions.js +80 -83
  25. package/dist/form-react/index.d.ts +5 -3
  26. package/dist/form-react/index.js +93 -88
  27. package/dist/form-react/registry/defaultFieldRegistrations.d.ts +1 -1
  28. package/dist/form-react/registry/defaultFieldRegistrations.js +11 -9
  29. package/dist/form-react/types/fields.types.d.ts +31 -12
  30. package/dist/form-react/types/fieldsOutput.types.d.ts +5 -1
  31. package/dist/form-react/types/reactHookForm.types.d.ts +31 -2
  32. package/dist/form-react/utils/fieldDefaults.utils.js +28 -13
  33. package/dist/impact-nova.css +1 -1
  34. package/package.json +17 -2
@@ -0,0 +1,69 @@
1
+ import { jsx as t, jsxs as l } from "react/jsx-runtime";
2
+ import { Controller as g } from "react-hook-form";
3
+ import { Slider as v } from "../../components/forms/slider/slider.js";
4
+ const y = {
5
+ opacity: 0.4,
6
+ pointerEvents: "none"
7
+ }, N = "bg-muted", A = ({
8
+ field: e,
9
+ validationRules: x,
10
+ isDisabled: o,
11
+ formHelpers: h
12
+ }) => {
13
+ const r = e.fieldType === "slider_range" ? e : null;
14
+ if (!r) return null;
15
+ const s = r.min ?? 0, c = r.max ?? 100, p = r.step ?? 1, m = r.showValue ?? !0;
16
+ return /* @__PURE__ */ t(
17
+ g,
18
+ {
19
+ name: e.id,
20
+ control: h.form.control,
21
+ rules: x,
22
+ render: ({ field: i, fieldState: u }) => {
23
+ const d = i.value, n = Array.isArray(d) ? d : [s], a = !!u.error;
24
+ return /* @__PURE__ */ l("div", { style: o ? y : void 0, children: [
25
+ e.label ? /* @__PURE__ */ l("label", { className: "mb-2 block text-xs font-medium text-content-muted", children: [
26
+ e.label,
27
+ e.isRequired && /* @__PURE__ */ t("span", { className: "ml-1 text-destructive", children: "*" })
28
+ ] }) : null,
29
+ /* @__PURE__ */ l("div", { className: "flex items-center gap-3", children: [
30
+ /* @__PURE__ */ t("span", { className: "min-w-[2rem] text-right text-xs tabular-nums text-content-muted", children: m ? n[0] : s }),
31
+ /* @__PURE__ */ t(
32
+ w,
33
+ {
34
+ "aria-label": e.label ?? e.id,
35
+ value: n,
36
+ min: s,
37
+ max: c,
38
+ step: p,
39
+ disabled: o,
40
+ onValueChange: (b) => {
41
+ i.onChange(b);
42
+ }
43
+ }
44
+ ),
45
+ /* @__PURE__ */ t("span", { className: "min-w-[2rem] text-xs tabular-nums text-content-muted", children: m && n.length > 1 ? n[n.length - 1] : c })
46
+ ] }),
47
+ (a || e.helpText) && /* @__PURE__ */ t(
48
+ "p",
49
+ {
50
+ className: `mt-1 text-xs ${a ? "text-destructive" : "text-content-muted"}`,
51
+ children: a ? u.error?.message : e.helpText
52
+ }
53
+ )
54
+ ] });
55
+ }
56
+ }
57
+ );
58
+ }, w = (e) => /* @__PURE__ */ l("div", { className: "relative w-full isolate", children: [
59
+ /* @__PURE__ */ t(
60
+ "div",
61
+ {
62
+ className: `absolute left-0 right-0 top-1/2 h-1.5 -translate-y-1/2 rounded-full ${N}`
63
+ }
64
+ ),
65
+ /* @__PURE__ */ t(v, { ...e })
66
+ ] });
67
+ export {
68
+ A as SliderRangeField
69
+ };
@@ -1,132 +1,194 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import { forwardRef as O, useRef as m, useEffect as n, useCallback as j, useImperativeHandle as x } from "react";
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 { GRID_COLS_MAP as M, GAP_X_MAP as $, GAP_Y_MAP as N } from "./utils/fieldRendererUtils.js";
5
- import { FormFieldRow as P } from "./components/FormFieldRow.js";
6
- import { showFormValidationFailureFeedback as q } from "./utils/formValidationFeedback.utils.js";
7
- import { resolveFormSubmittable as B, mergeFormValidationFieldErrors as L } from "./utils/resolveFormSubmittable.js";
8
- import { validateVisibleRequiredFormFields as X } from "./utils/validateVisibleRequiredFormFields.js";
9
- const C = O(
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: R,
12
- formConfig: i,
13
- formInitialState: E,
14
- onSubmit: h,
15
- onCancel: v,
16
- onReset: S,
17
- sendFormStateToParent: t,
18
- supportedValues: g,
19
- formContext: o
20
- }, k) => {
21
- const r = G(
22
- i,
23
- E,
24
- h,
25
- v,
26
- S,
27
- o
28
- ), { errors: w, isValid: H, isDirty: y, isValidating: D } = r.form.formState, u = m(r), f = m(t), b = m(o), F = m(i.fields);
29
- n(() => {
30
- u.current = r, f.current = t, b.current = o, F.current = i.fields;
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 l = j(() => {
33
- const e = f.current;
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 s = u.current;
52
+ const i = b.current;
37
53
  e(
38
- s.form.formState,
39
- s.form.getValues(),
54
+ i.form.formState,
55
+ i.form.getValues(),
40
56
  {
41
- isSubmittable: B({
42
- formConfigFields: F.current,
43
- formHelpers: s,
44
- formContext: b.current
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
- n(() => {
50
- if (!t)
65
+ }, [R]);
66
+ S(() => {
67
+ if (!d)
51
68
  return;
52
- l();
53
- const e = r.form.watch(() => {
54
- l();
69
+ m();
70
+ const e = t.form.watch(() => {
71
+ m();
55
72
  });
56
73
  return () => e.unsubscribe();
57
- }, [t, l, r.form]), n(() => {
58
- t && l();
74
+ }, [d, m, t.form]), S(() => {
75
+ d && m();
59
76
  }, [
60
- t,
61
- l,
62
- w,
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
- const e = i.fields.filter(
71
- (a) => r.isFieldVisible(a)
72
- ), s = X(
73
- r.form,
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: r.isFieldDisabled,
77
- isFieldDisabledForValidation: r.isFieldDisabledForSubmitValidation,
78
- formHelpers: r
103
+ isFieldDisabled: t.isFieldDisabled,
104
+ isFieldDisabledForValidation: t.isFieldDisabledForSubmitValidation,
105
+ formHelpers: t
79
106
  }
80
- ), d = o?.validateForm?.({
81
- formValues: r.form.getValues(),
107
+ ), o = c?.validateForm?.({
108
+ formValues: t.form.getValues(),
82
109
  visibleFields: e
83
- }), A = L(
84
- s.fieldErrors,
85
- d?.fieldErrors
110
+ }), L = K(
111
+ i.fieldErrors,
112
+ o?.fieldErrors
86
113
  );
87
- return s.isValid && (d?.isValid ?? !0) ? (r.submitValidatedForm(void 0), !0) : (d?.fieldErrors && Object.entries(d.fieldErrors).forEach(
88
- ([a, I]) => {
89
- r.form.setError(a, {
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: I.message
118
+ message: O.message
92
119
  });
93
120
  }
94
- ), q({
95
- fieldErrors: A,
121
+ ), z({
122
+ fieldErrors: L,
96
123
  fieldsInOrder: e,
97
124
  showToast: (a) => {
98
- r.formContext?.transport?.showFormErrorToast?.(
125
+ t.formContext?.transport?.showFormErrorToast?.(
99
126
  a
100
127
  );
101
128
  }
102
129
  }), !1);
103
130
  },
104
- hasErrors: Object.keys(r.form.formState?.errors || {}).length > 0,
105
- errors: r.form.formState?.errors,
106
- isValid: r.form.formState?.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
- [i.fields, r, o]
147
+ [s.fields, s.formType, t, c, r]
109
148
  );
110
- const p = i.gapBetweenFields ?? 6, _ = `grid ${M[i.columns || 1]} ${$[p] ?? "gap-x-6"} ${N[p] ?? "gap-y-6"}`, V = (e) => /* @__PURE__ */ c(
111
- P,
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: r,
115
- formConfig: i,
116
- supportedValues: g
153
+ formHelpers: t,
154
+ formConfig: s,
155
+ supportedValues: w
117
156
  },
118
157
  e.id
119
- );
120
- return /* @__PURE__ */ c(
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: R || "react-hooks-form",
124
- onSubmit: r.handleSubmit(void 0),
125
- children: /* @__PURE__ */ c("div", { className: _, children: i?.enableFieldOrdering ? i?.fields?.sort((e, s) => (e?.order ?? 0) - (s?.order ?? 0)).map(V) : i?.fields?.map(V) })
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
- C as ReactHooksForm
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 F } from "./Fields/ButtonsGroupField.js";
4
- import { RadioField as p } from "./Fields/RadioField.js";
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 B } from "./Fields/SelectField.js";
10
- import { CheckboxField as R } from "./Fields/CheckboxField.js";
11
- import { SwitchField as g } from "./Fields/SwitchField.js";
12
- import { ChipsField as C } from "./Fields/ChipsField.js";
13
- import { DateInputField as T } from "./Fields/DateInputField.js";
14
- import { FillFormByPasteField as y } from "./Fields/FillFormByPasteField.js";
15
- import { FillFormByFileUploadField as S } from "./Fields/FillFormByFileUploadField.js";
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
- F as ButtonsGroupField,
22
- R as CheckboxField,
23
- C as ChipsField,
24
- T as DateInputField,
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
- S as FillFormByFileUploadField,
28
- y as FillFormByPasteField,
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
- p as RadioField,
34
- B as SelectField,
35
- g as SwitchField,
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, FieldVisibilityBase } from '../types/reactHookForm.types';
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 g } from "react";
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, computeIsCascadingDisabled as x } from "../../form-engine/field-dependency-graph.js";
4
- import { batchSetFormFieldValues as D } from "../utils/batchFormFieldUpdates.js";
5
- import { isFieldValueValid as S } from "../utils/buildFieldValidationRules.js";
6
- import { findFieldByPath as T } from "../utils/fieldPath.utils.js";
7
- const B = (a, s, h) => {
8
- const { getFieldDefaultValue: c, resolveFieldValidationEvaluationOptions: F } = h, p = r(
9
- () => s.fields.filter((e) => e.isRequired),
10
- [s.fields]
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 (!s.isCascading)
13
+ if (!i.isCascading)
14
14
  return !0;
15
- const n = a.getValues(), d = p(), i = d.findIndex(
15
+ const a = n.getValues(), l = o(), s = l.findIndex(
16
16
  (t) => t.id === e.id
17
17
  );
18
- if (i === -1)
19
- return d.every(
20
- (t) => !V(n[t.id])
18
+ if (s === -1)
19
+ return l.every(
20
+ (t) => !V(a[t.id])
21
21
  );
22
- for (let t = 0; t < i; t += 1) {
23
- const l = d[t];
24
- if (V(n[l.id]))
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
- [a, s.isCascading, p]
29
+ [n, i.isCascading, o]
30
30
  ), I = r(
31
- (e, n = !1) => {
32
- let i = s.fields.filter(
33
- (l) => l.fieldType !== "label" && l.fieldType !== "divider"
31
+ (e, a = !1) => {
32
+ let s = i.fields.filter(
33
+ (d) => d.fieldType !== "label" && d.fieldType !== "divider"
34
34
  );
35
- n && (i = i.filter((l) => l.isRequired));
36
- const t = i.findIndex(
37
- (l) => l.id === e
35
+ a && (s = s.filter((d) => d.isRequired));
36
+ const t = s.findIndex(
37
+ (d) => d.id === e
38
38
  );
39
- return t === -1 ? [] : i.slice(0, t).map((l) => l.id);
39
+ return t === -1 ? [] : s.slice(0, t).map((d) => d.id);
40
40
  },
41
- [s.fields]
42
- ), o = r(
41
+ [i.fields]
42
+ ), p = r(
43
43
  (e) => {
44
- const n = v(
45
- s.fields,
44
+ const a = v(
45
+ i.fields,
46
46
  e
47
- ), d = new Set(n);
48
- return s.fields.filter(
49
- (i) => d.has(i.id)
47
+ ), l = new Set(a);
48
+ return i.fields.filter(
49
+ (s) => l.has(s.id)
50
50
  );
51
51
  },
52
- [s.fields]
52
+ [i.fields]
53
53
  ), u = r(
54
54
  (e) => {
55
- if (!s.isCascading)
55
+ if (!i.isCascading)
56
56
  return;
57
- const n = o(e), d = a.getValues(), i = n.map((t) => {
58
- const l = c(t);
59
- return d[t.id] === l ? null : {
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: l
61
+ value: d
62
62
  };
63
63
  }).filter(
64
64
  (t) => t !== null
65
65
  );
66
- D(a, i, {
66
+ x(n, s, {
67
67
  shouldDirty: !0,
68
68
  shouldValidate: !1
69
69
  });
70
70
  },
71
- [a, s.isCascading, o, c]
71
+ [n, i.isCascading, p, c]
72
72
  );
73
- g(() => {
74
- if (!s.isCascading)
73
+ E(() => {
74
+ if (!i.isCascading)
75
75
  return;
76
- const e = a.watch((n, { name: d, type: i }) => {
77
- d && i === "change" && u(d);
76
+ const e = n.watch((a, { name: l, type: s }) => {
77
+ l && s === "change" && u(l);
78
78
  });
79
79
  return () => e.unsubscribe();
80
- }, [a, s.isCascading, u]);
80
+ }, [n, i.isCascading, u]);
81
81
  const b = r(
82
- (e, n) => {
83
- a.setValue(e, n, {
82
+ (e, a) => {
83
+ n.setValue(e, a, {
84
84
  shouldValidate: !0,
85
85
  shouldDirty: !0
86
86
  });
87
- const d = T(s.fields, e);
88
- if (d) {
89
- const i = F?.(e);
90
- S(
91
- d,
92
- n,
93
- i
94
- ) && a.clearErrors(e);
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
- a,
100
- s.fields,
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
- B as useCascadingForm
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, isCascadingDisabled, }: UseFieldVisibilityParams): UseFieldVisibilityReturn;
12
+ export declare function useFieldVisibility({ form, formConfig, }: UseFieldVisibilityParams): UseFieldVisibilityReturn;
14
13
  export {};