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,60 +1,53 @@
|
|
|
1
|
-
import { useCallback as
|
|
1
|
+
import { useCallback as r, useRef as h, useEffect as y } from "react";
|
|
2
2
|
import { getFieldDefaultValue as g } from "../utils/fieldDefaults.utils.js";
|
|
3
|
-
import { computeIsFieldVisible as
|
|
4
|
-
function
|
|
3
|
+
import { computeIsFieldVisible as I, computeIsFieldDisabled as c } from "../../form-engine/field-dependency-graph.js";
|
|
4
|
+
function E({
|
|
5
5
|
form: e,
|
|
6
|
-
formConfig:
|
|
7
|
-
isCascadingDisabled: n
|
|
6
|
+
formConfig: d
|
|
8
7
|
}) {
|
|
9
|
-
const
|
|
10
|
-
(
|
|
8
|
+
const f = r(
|
|
9
|
+
(i) => I(i, e.getValues()),
|
|
11
10
|
[e]
|
|
12
|
-
), D =
|
|
13
|
-
(
|
|
14
|
-
isCascadingDisabled: n
|
|
15
|
-
}),
|
|
16
|
-
[e, n]
|
|
17
|
-
), F = c(
|
|
18
|
-
(t) => a(t, e.getValues(), {
|
|
19
|
-
isCascadingDisabled: () => !1
|
|
20
|
-
}),
|
|
11
|
+
), D = r(
|
|
12
|
+
(i) => c(i, e.getValues()),
|
|
21
13
|
[e]
|
|
22
|
-
),
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
), p = r(
|
|
15
|
+
(i) => c(i, e.getValues()),
|
|
16
|
+
[e]
|
|
17
|
+
), u = h(/* @__PURE__ */ new Set());
|
|
18
|
+
return y(() => {
|
|
19
|
+
const i = d.fields.filter(
|
|
20
|
+
(s) => s.disableDependency && s.disableDependency.length > 0
|
|
26
21
|
);
|
|
27
|
-
if (
|
|
22
|
+
if (i.length === 0)
|
|
28
23
|
return;
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
for (const l of
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}) && d.add(l.id);
|
|
35
|
-
return d;
|
|
24
|
+
const a = (s) => {
|
|
25
|
+
const n = /* @__PURE__ */ new Set();
|
|
26
|
+
for (const l of i)
|
|
27
|
+
c(l, s ?? e.getValues()) && n.add(l.id);
|
|
28
|
+
return n;
|
|
36
29
|
};
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
30
|
+
u.current = a(void 0);
|
|
31
|
+
const F = e.watch((s, n) => {
|
|
32
|
+
if (!n.name)
|
|
40
33
|
return;
|
|
41
|
-
const l =
|
|
42
|
-
for (const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
for (const
|
|
46
|
-
const b =
|
|
47
|
-
(
|
|
34
|
+
const l = a(s), o = [];
|
|
35
|
+
for (const t of l)
|
|
36
|
+
u.current.has(t) || o.push(t);
|
|
37
|
+
u.current = l;
|
|
38
|
+
for (const t of o) {
|
|
39
|
+
const b = d.fields.find(
|
|
40
|
+
(V) => V.id === t
|
|
48
41
|
);
|
|
49
|
-
b && (e.setValue(
|
|
42
|
+
b && (e.setValue(t, g(b), {
|
|
50
43
|
shouldValidate: !1,
|
|
51
44
|
shouldDirty: !0
|
|
52
|
-
}), e.clearErrors(
|
|
45
|
+
}), e.clearErrors(t));
|
|
53
46
|
}
|
|
54
47
|
});
|
|
55
|
-
return () =>
|
|
56
|
-
}, [e,
|
|
48
|
+
return () => F.unsubscribe();
|
|
49
|
+
}, [e, d.fields]), { isFieldVisible: f, isFieldDisabled: D, isFieldDisabledForSubmitValidation: p };
|
|
57
50
|
}
|
|
58
51
|
export {
|
|
59
|
-
|
|
52
|
+
E as useFieldVisibility
|
|
60
53
|
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { FieldGroup } from '../../form-engine';
|
|
2
|
+
import { IField } from '../types/fields.types';
|
|
3
|
+
import { IFormConfig, UseReactHookFormReturn } from '../types/reactHookForm.types';
|
|
4
|
+
export interface UseFormStepsReturn {
|
|
5
|
+
groups: FieldGroup[];
|
|
6
|
+
currentStep: number;
|
|
7
|
+
totalSteps: number;
|
|
8
|
+
isFirstStep: boolean;
|
|
9
|
+
isLastStep: boolean;
|
|
10
|
+
/** Whether current step has no validation errors and all required fields are filled. */
|
|
11
|
+
canProceed: boolean;
|
|
12
|
+
/** Fields belonging to the current step. */
|
|
13
|
+
currentStepFields: IField[];
|
|
14
|
+
/** Advance to the next step. Validates current step first if `validateBeforeNext` is true. Returns false if blocked. */
|
|
15
|
+
goNext: () => boolean;
|
|
16
|
+
/** Go back one step (never gated by validation). */
|
|
17
|
+
goPrev: () => void;
|
|
18
|
+
/** Jump to a specific step index. Forward jumps validate intermediate steps. */
|
|
19
|
+
goToStep: (index: number) => void;
|
|
20
|
+
/** Check if a specific step is complete. */
|
|
21
|
+
isStepComplete: (stepIndex: number) => boolean;
|
|
22
|
+
/** Check if a step has been visited. */
|
|
23
|
+
isStepVisited: (stepIndex: number) => boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Manages multi-step / grouped form navigation.
|
|
27
|
+
* Returns `null` when `formConfig.formType` is `'default'` or absent.
|
|
28
|
+
*/
|
|
29
|
+
export declare function useFormSteps(formConfig: IFormConfig, formHelpers: UseReactHookFormReturn): UseFormStepsReturn | null;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useMemo as m, useState as F, useRef as N, useCallback as u } from "react";
|
|
2
|
+
import { buildFieldGroups as k, isStepComplete as P } from "../../form-engine/field-groups.js";
|
|
3
|
+
function L(i, g) {
|
|
4
|
+
const { formType: d } = i, s = m(() => !d || d === "default" ? [] : k(i.fields, i.steps), [d, i.fields, i.steps]), [r, o] = F(0), [w, c] = F(
|
|
5
|
+
() => /* @__PURE__ */ new Set([0])
|
|
6
|
+
), I = m(() => {
|
|
7
|
+
if (s.length === 0) return /* @__PURE__ */ new Map();
|
|
8
|
+
const t = new Map(i.fields.map((n) => [n.id, n])), e = /* @__PURE__ */ new Map();
|
|
9
|
+
for (const n of s)
|
|
10
|
+
e.set(
|
|
11
|
+
n.groupId,
|
|
12
|
+
n.fieldIds.map((l) => t.get(l)).filter(Boolean)
|
|
13
|
+
);
|
|
14
|
+
return e;
|
|
15
|
+
}, [s, i.fields]), a = N(g);
|
|
16
|
+
a.current = g;
|
|
17
|
+
const p = u(
|
|
18
|
+
(t) => {
|
|
19
|
+
const e = s[t];
|
|
20
|
+
if (!e) return !1;
|
|
21
|
+
const n = a.current.form;
|
|
22
|
+
return P(
|
|
23
|
+
e.fieldIds,
|
|
24
|
+
i.fields,
|
|
25
|
+
n.getValues(),
|
|
26
|
+
n.formState.errors
|
|
27
|
+
);
|
|
28
|
+
},
|
|
29
|
+
[s, i.fields]
|
|
30
|
+
), f = u(
|
|
31
|
+
async (t) => {
|
|
32
|
+
const e = s[t];
|
|
33
|
+
if (!e) return !1;
|
|
34
|
+
const n = e.fieldIds.filter((l) => {
|
|
35
|
+
const S = i.fields.find((G) => G.id === l);
|
|
36
|
+
return S ? a.current.isFieldVisible(S) : !1;
|
|
37
|
+
});
|
|
38
|
+
return n.length === 0 ? !0 : a.current.form.trigger(n);
|
|
39
|
+
},
|
|
40
|
+
[s, i.fields]
|
|
41
|
+
), M = u(() => {
|
|
42
|
+
const t = s[r];
|
|
43
|
+
if (!t || r >= s.length - 1) return !1;
|
|
44
|
+
if (t.validateBeforeNext)
|
|
45
|
+
return f(r).then((n) => {
|
|
46
|
+
if (n) {
|
|
47
|
+
const l = r + 1;
|
|
48
|
+
o(l), c((S) => new Set(S).add(l));
|
|
49
|
+
}
|
|
50
|
+
}), p(r);
|
|
51
|
+
const e = r + 1;
|
|
52
|
+
return o(e), c((n) => new Set(n).add(e)), !0;
|
|
53
|
+
}, [r, s, f, p]), V = u(() => {
|
|
54
|
+
r > 0 && o(r - 1);
|
|
55
|
+
}, [r]), b = u(
|
|
56
|
+
(t) => {
|
|
57
|
+
if (!(t < 0 || t >= s.length || t === r)) {
|
|
58
|
+
if (t < r) {
|
|
59
|
+
o(t), c((e) => new Set(e).add(t));
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
(async () => {
|
|
63
|
+
for (let e = r; e < t; e++)
|
|
64
|
+
if (s[e].validateBeforeNext && !await f(e)) {
|
|
65
|
+
o(e), c((l) => new Set(l).add(e));
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
o(t), c((e) => new Set(e).add(t));
|
|
69
|
+
})();
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
[r, s, f]
|
|
73
|
+
), y = u(
|
|
74
|
+
(t) => w.has(t),
|
|
75
|
+
[w]
|
|
76
|
+
);
|
|
77
|
+
if (!d || d === "default") return null;
|
|
78
|
+
const v = s.length, h = s[r], B = h ? I.get(h.groupId) ?? [] : [];
|
|
79
|
+
return {
|
|
80
|
+
groups: s,
|
|
81
|
+
currentStep: r,
|
|
82
|
+
totalSteps: v,
|
|
83
|
+
isFirstStep: r === 0,
|
|
84
|
+
isLastStep: r === v - 1,
|
|
85
|
+
canProceed: p(r),
|
|
86
|
+
currentStepFields: B,
|
|
87
|
+
goNext: M,
|
|
88
|
+
goPrev: V,
|
|
89
|
+
goToStep: b,
|
|
90
|
+
isStepComplete: p,
|
|
91
|
+
isStepVisited: y
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
export {
|
|
95
|
+
L as useFormSteps
|
|
96
|
+
};
|
|
@@ -6,9 +6,9 @@ import { useFieldVisibility as Z } from "./useFieldVisibility.js";
|
|
|
6
6
|
import { useFormFieldChangeSubscription as _ } from "./useFormFieldChangeSubscription.js";
|
|
7
7
|
import { getFieldDefaultValue as m } from "../utils/fieldDefaults.utils.js";
|
|
8
8
|
import { focusFirstFormValidationError as $ } from "../utils/formValidationFeedback.utils.js";
|
|
9
|
-
import { getFieldTestId as
|
|
10
|
-
import { buildEvaluateFieldValidationOptions as
|
|
11
|
-
const de = (i, u,
|
|
9
|
+
import { getFieldTestId as g } from "../utils/fieldTestIds.js";
|
|
10
|
+
import { buildEvaluateFieldValidationOptions as k } from "../utils/evaluateFieldValidation.js";
|
|
11
|
+
const de = (i, u, d, f, S, v) => {
|
|
12
12
|
const y = l(() => {
|
|
13
13
|
const e = {};
|
|
14
14
|
return i.fields.forEach((t) => {
|
|
@@ -24,14 +24,14 @@ const de = (i, u, a, f, S, v) => {
|
|
|
24
24
|
return Object.keys(u ?? {}).filter(
|
|
25
25
|
(t) => !e.has(t)
|
|
26
26
|
);
|
|
27
|
-
}, [i.fields, u]),
|
|
27
|
+
}, [i.fields, u]), a = P(() => {
|
|
28
28
|
const e = y(), t = T();
|
|
29
29
|
return { ...e, ...t };
|
|
30
30
|
}, [y, T]), r = X({
|
|
31
|
-
defaultValues:
|
|
31
|
+
defaultValues: a,
|
|
32
32
|
mode: "onTouched",
|
|
33
33
|
reValidateMode: "onChange"
|
|
34
|
-
}), I = c(
|
|
34
|
+
}), I = c(a), R = c(null), w = c(() => {
|
|
35
35
|
}), K = l((e) => I.current[e], []), H = c(
|
|
36
36
|
new Set(i.fields.map((e) => e.id))
|
|
37
37
|
);
|
|
@@ -60,19 +60,18 @@ const de = (i, u, a, f, S, v) => {
|
|
|
60
60
|
$({
|
|
61
61
|
fieldErrors: r.formState.errors,
|
|
62
62
|
fieldsInOrder: i.fields,
|
|
63
|
-
getFieldTestId:
|
|
63
|
+
getFieldTestId: g
|
|
64
64
|
});
|
|
65
65
|
}, [r.formState.errors, i.fields]);
|
|
66
66
|
b(() => {
|
|
67
67
|
F && p();
|
|
68
68
|
}, [F, p]);
|
|
69
|
-
const {
|
|
69
|
+
const { getEarlierFieldsIds: W, setValueWithCascading: q } = Y(r, i, {
|
|
70
70
|
getFieldDefaultValue: m,
|
|
71
71
|
resolveFieldValidationEvaluationOptions: (e) => w.current(e)
|
|
72
72
|
}), { isFieldVisible: E, isFieldDisabled: B, isFieldDisabledForSubmitValidation: G } = Z({
|
|
73
73
|
form: r,
|
|
74
|
-
formConfig: i
|
|
75
|
-
isCascadingDisabled: W
|
|
74
|
+
formConfig: i
|
|
76
75
|
});
|
|
77
76
|
_({
|
|
78
77
|
form: r,
|
|
@@ -108,28 +107,28 @@ const de = (i, u, a, f, S, v) => {
|
|
|
108
107
|
(t) => {
|
|
109
108
|
j(!1);
|
|
110
109
|
const s = n(t);
|
|
111
|
-
e?.(s),
|
|
110
|
+
e?.(s), d?.(s);
|
|
112
111
|
},
|
|
113
112
|
() => {
|
|
114
113
|
j(!0);
|
|
115
114
|
}
|
|
116
115
|
),
|
|
117
|
-
[r, n,
|
|
116
|
+
[r, n, d]
|
|
118
117
|
), L = l(
|
|
119
118
|
(e) => {
|
|
120
|
-
const t = e ||
|
|
119
|
+
const t = e || a;
|
|
121
120
|
r.reset(t), S?.(t);
|
|
122
121
|
},
|
|
123
|
-
[r,
|
|
122
|
+
[r, a, S]
|
|
124
123
|
), Q = l(() => {
|
|
125
124
|
const e = r.getValues();
|
|
126
125
|
f?.(e);
|
|
127
126
|
}, [r, f]), U = l(
|
|
128
127
|
(e) => {
|
|
129
128
|
const t = r.getValues(), s = n(t);
|
|
130
|
-
e?.(s),
|
|
129
|
+
e?.(s), d?.(s);
|
|
131
130
|
},
|
|
132
|
-
[r, n,
|
|
131
|
+
[r, n, d]
|
|
133
132
|
), h = {
|
|
134
133
|
formId: i.formId,
|
|
135
134
|
formConfig: i,
|
|
@@ -144,7 +143,7 @@ const de = (i, u, a, f, S, v) => {
|
|
|
144
143
|
isFieldDisabled: B,
|
|
145
144
|
isFieldDisabledForSubmitValidation: G,
|
|
146
145
|
submitValidatedForm: U,
|
|
147
|
-
getEarlierFieldsIds:
|
|
146
|
+
getEarlierFieldsIds: W,
|
|
148
147
|
scrollToFirstError: p,
|
|
149
148
|
setToEmptyFields: V,
|
|
150
149
|
markFieldAsEmpty: N,
|
|
@@ -153,7 +152,7 @@ const de = (i, u, a, f, S, v) => {
|
|
|
153
152
|
formContext: v
|
|
154
153
|
};
|
|
155
154
|
return b(() => {
|
|
156
|
-
R.current = h, w.current = (e) =>
|
|
155
|
+
R.current = h, w.current = (e) => k(h, e);
|
|
157
156
|
}), h;
|
|
158
157
|
};
|
|
159
158
|
export {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Option } from '../../components/forms/select';
|
|
2
2
|
import { UseSelectOptionsProps } from '../types/reactHookForm.types';
|
|
3
|
-
export declare const useSelectOptions: ({ apiConfig, formHelpers,
|
|
3
|
+
export declare const useSelectOptions: ({ apiConfig, formHelpers, initialOptions, id, isEnabled, getSelectOptionsName, fieldSupportedValues, cascadingDependency, }: UseSelectOptionsProps) => {
|
|
4
4
|
options: Option[];
|
|
5
5
|
isLoading: boolean;
|
|
6
6
|
error: Error | null;
|
|
@@ -1,116 +1,113 @@
|
|
|
1
|
-
import { useMemo as
|
|
2
|
-
import { useWatch as
|
|
3
|
-
import { serializeFormStateForQueryKey as
|
|
4
|
-
const
|
|
5
|
-
apiConfig:
|
|
6
|
-
formHelpers:
|
|
7
|
-
formConfig: k,
|
|
1
|
+
import { useMemo as m, useState as E, useRef as a, useEffect as z, useCallback as L } from "react";
|
|
2
|
+
import { useWatch as W } from "react-hook-form";
|
|
3
|
+
import { serializeFormStateForQueryKey as _ } from "../utils/serializeFormStateForQueryKey.js";
|
|
4
|
+
const B = ({
|
|
5
|
+
apiConfig: r,
|
|
6
|
+
formHelpers: c,
|
|
8
7
|
initialOptions: d = [],
|
|
9
|
-
id:
|
|
10
|
-
isEnabled:
|
|
8
|
+
id: s,
|
|
9
|
+
isEnabled: N,
|
|
11
10
|
getSelectOptionsName: i,
|
|
12
|
-
fieldSupportedValues:
|
|
11
|
+
fieldSupportedValues: l,
|
|
12
|
+
cascadingDependency: y
|
|
13
13
|
}) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const u = m(() => {
|
|
15
|
+
const e = r?.fieldsToPassInApi ?? [];
|
|
16
|
+
if (!(r?.passCascadingDependencyFields !== !1))
|
|
17
|
+
return e;
|
|
18
|
+
const o = [...y?.map((t) => t.fieldId) ?? []];
|
|
19
|
+
return e.forEach((t) => {
|
|
20
|
+
o.includes(t) || o.push(t);
|
|
21
|
+
}), o;
|
|
22
|
+
}, [
|
|
23
|
+
r?.fieldsToPassInApi,
|
|
24
|
+
r?.passCascadingDependencyFields,
|
|
25
|
+
y
|
|
26
|
+
]), f = W({
|
|
27
|
+
control: c?.form.control,
|
|
28
|
+
name: u,
|
|
29
|
+
disabled: !c?.form.control || !u.length
|
|
30
|
+
}), p = m(() => {
|
|
31
|
+
if (!u.length)
|
|
20
32
|
return {};
|
|
21
|
-
const e = {};
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
const a = c[m];
|
|
26
|
-
a != null && a !== "" && (e[s] = a);
|
|
27
|
-
}), e;
|
|
28
|
-
}
|
|
29
|
-
const n = E(), O = t?.includeOnlyMandatoryFieldsInPayload || !1;
|
|
30
|
-
return p(r, O).forEach((c) => {
|
|
31
|
-
const s = n[c];
|
|
32
|
-
s != null && s !== "" && (e[c] = s);
|
|
33
|
+
const e = {}, n = Array.isArray(f) ? f : [f];
|
|
34
|
+
return u.forEach((F, o) => {
|
|
35
|
+
const t = n[o];
|
|
36
|
+
t != null && t !== "" && (e[F] = t);
|
|
33
37
|
}), e;
|
|
34
|
-
}, [
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
[f]
|
|
44
|
-
), J = V(
|
|
45
|
-
() => u ? JSON.stringify(u) : "",
|
|
46
|
-
[u]
|
|
47
|
-
), [S, w] = v(d), [K, x] = v(!1), [Q, I] = v(null), R = l(o), g = l(t), b = l(f), C = l(u), z = l(d), A = l(i);
|
|
48
|
-
N(() => {
|
|
49
|
-
R.current = o, g.current = t, b.current = f, C.current = u, z.current = d, A.current = i;
|
|
38
|
+
}, [u, f]), T = m(
|
|
39
|
+
() => _(p),
|
|
40
|
+
[p]
|
|
41
|
+
), k = m(
|
|
42
|
+
() => l ? JSON.stringify(l) : "",
|
|
43
|
+
[l]
|
|
44
|
+
), [I, O] = E(d), [G, S] = E(!1), [J, g] = E(null), v = a(c), V = a(r), w = a(p), x = a(l), C = a(d), R = a(i);
|
|
45
|
+
z(() => {
|
|
46
|
+
v.current = c, V.current = r, w.current = p, x.current = l, C.current = d, R.current = i;
|
|
50
47
|
});
|
|
51
|
-
const
|
|
52
|
-
const e =
|
|
48
|
+
const h = L(async () => {
|
|
49
|
+
const e = v.current, n = V.current, F = w.current, o = x.current, t = C.current, P = R.current;
|
|
53
50
|
if (e) {
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
56
|
-
return await
|
|
51
|
+
const b = P ? e.formContext?.getSelectOptions?.[P] : void 0;
|
|
52
|
+
if (b)
|
|
53
|
+
return await b({
|
|
57
54
|
formHelpers: e,
|
|
58
|
-
fieldId:
|
|
59
|
-
newValue: e.form.getValues(
|
|
60
|
-
oldValue: e.getPreviousFieldValue(
|
|
55
|
+
fieldId: s,
|
|
56
|
+
newValue: e.form.getValues(s),
|
|
57
|
+
oldValue: e.getPreviousFieldValue(s)
|
|
61
58
|
});
|
|
62
59
|
}
|
|
63
60
|
if (!n?.apiEndpoint)
|
|
64
|
-
return
|
|
65
|
-
const
|
|
66
|
-
return
|
|
67
|
-
fieldId:
|
|
61
|
+
return t;
|
|
62
|
+
const D = e?.formContext?.transport?.fetchSelectOptions;
|
|
63
|
+
return D ? D({
|
|
64
|
+
fieldId: s,
|
|
68
65
|
apiConfig: n,
|
|
69
|
-
earlierFieldsValues:
|
|
70
|
-
fieldSupportedValues:
|
|
66
|
+
earlierFieldsValues: F,
|
|
67
|
+
fieldSupportedValues: o
|
|
71
68
|
}) : (process.env.NODE_ENV !== "production" && console.warn(
|
|
72
|
-
`[form-react] Select field "${
|
|
73
|
-
),
|
|
74
|
-
}, [
|
|
75
|
-
|
|
76
|
-
if (!
|
|
69
|
+
`[form-react] Select field "${s}" has apiConfig but no formContext.transport.fetchSelectOptions was provided.`
|
|
70
|
+
), t);
|
|
71
|
+
}, [s]), K = !!(i && c?.formContext?.getSelectOptions?.[i]), A = N && (K || !!r?.apiEndpoint && !!c?.formContext?.transport?.fetchSelectOptions), M = r?.apiEndpoint;
|
|
72
|
+
z(() => {
|
|
73
|
+
if (!A)
|
|
77
74
|
return;
|
|
78
75
|
let e = !1;
|
|
79
76
|
return (async () => {
|
|
80
|
-
|
|
77
|
+
S(!0), g(null);
|
|
81
78
|
try {
|
|
82
|
-
const n = await
|
|
83
|
-
e ||
|
|
79
|
+
const n = await h();
|
|
80
|
+
e || O(n);
|
|
84
81
|
} catch (n) {
|
|
85
|
-
e ||
|
|
82
|
+
e || g(
|
|
86
83
|
n instanceof Error ? n : new Error("Failed to fetch options")
|
|
87
84
|
);
|
|
88
85
|
} finally {
|
|
89
|
-
e ||
|
|
86
|
+
e || S(!1);
|
|
90
87
|
}
|
|
91
88
|
})(), () => {
|
|
92
89
|
e = !0;
|
|
93
90
|
};
|
|
94
91
|
}, [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
92
|
+
A,
|
|
93
|
+
h,
|
|
94
|
+
T,
|
|
95
|
+
k,
|
|
99
96
|
i,
|
|
100
|
-
|
|
101
|
-
|
|
97
|
+
M,
|
|
98
|
+
s
|
|
102
99
|
]);
|
|
103
|
-
const
|
|
104
|
-
const e = await
|
|
105
|
-
return
|
|
106
|
-
}, [
|
|
100
|
+
const Q = L(async () => {
|
|
101
|
+
const e = await h();
|
|
102
|
+
return O(e), e;
|
|
103
|
+
}, [h]);
|
|
107
104
|
return {
|
|
108
|
-
options:
|
|
109
|
-
isLoading:
|
|
110
|
-
error:
|
|
111
|
-
refetch:
|
|
105
|
+
options: I.length > 0 ? I : d,
|
|
106
|
+
isLoading: G,
|
|
107
|
+
error: J,
|
|
108
|
+
refetch: Q
|
|
112
109
|
};
|
|
113
110
|
};
|
|
114
111
|
export {
|
|
115
|
-
|
|
112
|
+
B as useSelectOptions
|
|
116
113
|
};
|
|
@@ -18,6 +18,8 @@ export { useFieldVisibility } from './hooks/useFieldVisibility';
|
|
|
18
18
|
export type { UseFieldVisibilityReturn } from './hooks/useFieldVisibility';
|
|
19
19
|
export { useCascadingForm } from './hooks/useCascadingForm';
|
|
20
20
|
export type { UseCascadingFormReturn } from './hooks/useCascadingForm';
|
|
21
|
+
export { useFormSteps } from './hooks/useFormSteps';
|
|
22
|
+
export type { UseFormStepsReturn } from './hooks/useFormSteps';
|
|
21
23
|
export { useSelectOptions } from './hooks/useSelectOptions';
|
|
22
24
|
export { useFillFormByPaste } from './hooks/useFillFormByPaste';
|
|
23
25
|
export { useFillFormByFileUpload } from './hooks/useFillFormByFileUpload';
|
|
@@ -34,12 +36,12 @@ export { FormFileUploadWrapper } from './components/FormFileUploadWrapper';
|
|
|
34
36
|
export { registerFieldType, getFieldComponent, hasRegisteredFieldType, listRegisteredFieldTypes, } from './registry/fieldRegistry';
|
|
35
37
|
export { registerDefaultFieldTypes } from './registry/defaultFieldRegistrations';
|
|
36
38
|
export { resolveFieldComponent, renderRegisteredField } from './registry/resolveFieldComponent';
|
|
37
|
-
export type { IFormConfig, FormFieldProps, FieldVisibilityBase, ReactHooksFormProps, UseSelectOptionsProps, FormContext, FormValidationMeta, FormTransport, CustomFieldTypesMap, FetchSelectOptionsParams, PastedValuesValidationResult, ValidatePastedValuesParams, ValidateUploadedFileParams, UploadedFileValidationResult, ValidateTextFieldWithBackendParams, TextFieldBackendValidationResult, SupportedValuesMap, } from './types/reactHookForm.types';
|
|
39
|
+
export type { IFormConfig, FormFieldProps, FormType, FormStepConfig, FormStepStateMeta, ReactHooksFormStepActions, FieldVisibilityBase, ReactHooksFormProps, UseSelectOptionsProps, FormContext, FormValidationMeta, FormTransport, CustomFieldTypesMap, FetchSelectOptionsParams, PastedValuesValidationResult, ValidatePastedValuesParams, ValidateUploadedFileParams, UploadedFileValidationResult, ValidateTextFieldWithBackendParams, TextFieldBackendValidationResult, SupportedValuesMap, } from './types/reactHookForm.types';
|
|
38
40
|
export type { IField } from './types/fields.types';
|
|
39
41
|
export type * from './types/fields.types';
|
|
40
42
|
export type * from './types/fieldsOutput.types';
|
|
41
|
-
export { isEmptyValue, buildCascadeParentFormState, collectFieldDependencyIds, collectFormWatchFieldIds, collectFilterSidebarWatchFieldIds, collectSectionWatchFieldIds, collectVisibleFieldIds,
|
|
42
|
-
export type { FieldDependency, FormValuesSnapshot, } from '../form-engine';
|
|
43
|
+
export { isEmptyValue, buildCascadeParentFormState, buildFieldGroups, collectFieldDependencyIds, collectFormWatchFieldIds, collectFilterSidebarWatchFieldIds, collectSectionWatchFieldIds, collectVisibleFieldIds, computeIsFieldDisabled, computeIsFieldVisible, getDependentFieldIds, getFirstIncompleteStep, hasVisibleFieldErrors, isStepComplete, } from '../form-engine';
|
|
44
|
+
export type { FieldDependency, FieldGroup, FormValuesSnapshot, } from '../form-engine';
|
|
43
45
|
export { getFieldDefaultValue } from './utils/fieldDefaults.utils';
|
|
44
46
|
export { batchSetFormFieldValues } from './utils/batchFormFieldUpdates';
|
|
45
47
|
export { serializeFormStateForQueryKey } from './utils/serializeFormStateForQueryKey';
|