@availity/mui-controlled-form 0.2.3 → 0.2.4
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/CHANGELOG.md +8 -0
- package/dist/index.js +19 -46
- package/dist/index.mjs +19 -46
- package/package.json +1 -1
- package/src/lib/AsyncAutocomplete.tsx +2 -5
- package/src/lib/Autocomplete.tsx +2 -5
- package/src/lib/CodesAutocomplete.tsx +2 -5
- package/src/lib/Input.tsx +2 -5
- package/src/lib/OrganizationAutocomplete.tsx +2 -5
- package/src/lib/ProviderAutocomplete.tsx +2 -5
- package/src/lib/RadioGroup.tsx +2 -5
- package/src/lib/Select.tsx +2 -5
- package/src/lib/TextField.tsx +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
|
|
4
4
|
|
|
5
|
+
## [0.2.4](https://github.com/Availity/element/compare/@availity/mui-controlled-form@0.2.3...@availity/mui-controlled-form@0.2.4) (2025-02-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **mui-controlled-form:** support nested form properties ([5746baf](https://github.com/Availity/element/commit/5746bafdee011b6fcc7d6f712946fcb597ea48da))
|
|
11
|
+
* **mui-controlled-form:** support nested form properties for ControlledAsyncAutocomplete ([9c97199](https://github.com/Availity/element/commit/9c97199bbee014ebcaef6fbbf3ab81b962e87c7b))
|
|
12
|
+
|
|
5
13
|
## [0.2.3](https://github.com/Availity/element/compare/@availity/mui-controlled-form@0.2.2...@availity/mui-controlled-form@0.2.3) (2025-02-05)
|
|
6
14
|
|
|
7
15
|
### Dependency Updates
|
package/dist/index.js
CHANGED
|
@@ -101,11 +101,8 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
101
101
|
"FieldProps"
|
|
102
102
|
]);
|
|
103
103
|
var _a2;
|
|
104
|
-
const {
|
|
105
|
-
|
|
106
|
-
formState: { errors }
|
|
107
|
-
} = (0, import_react_hook_form.useFormContext)();
|
|
108
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
104
|
+
const { control, getFieldState } = (0, import_react_hook_form.useFormContext)();
|
|
105
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
109
106
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
110
107
|
import_react_hook_form.Controller,
|
|
111
108
|
{
|
|
@@ -191,11 +188,8 @@ var ControlledAutocomplete = (_a) => {
|
|
|
191
188
|
"value"
|
|
192
189
|
]);
|
|
193
190
|
var _a2;
|
|
194
|
-
const {
|
|
195
|
-
|
|
196
|
-
formState: { errors }
|
|
197
|
-
} = (0, import_react_hook_form2.useFormContext)();
|
|
198
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
191
|
+
const { control, getFieldState } = (0, import_react_hook_form2.useFormContext)();
|
|
192
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
199
193
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
200
194
|
import_react_hook_form2.Controller,
|
|
201
195
|
{
|
|
@@ -316,11 +310,8 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
316
310
|
"FieldProps"
|
|
317
311
|
]);
|
|
318
312
|
var _a2;
|
|
319
|
-
const {
|
|
320
|
-
|
|
321
|
-
formState: { errors }
|
|
322
|
-
} = (0, import_react_hook_form4.useFormContext)();
|
|
323
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
313
|
+
const { control, getFieldState } = (0, import_react_hook_form4.useFormContext)();
|
|
314
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
324
315
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
325
316
|
import_react_hook_form4.Controller,
|
|
326
317
|
{
|
|
@@ -479,14 +470,11 @@ var ControlledInput = (_a) => {
|
|
|
479
470
|
"shouldUnregister",
|
|
480
471
|
"deps"
|
|
481
472
|
]);
|
|
482
|
-
const {
|
|
483
|
-
register,
|
|
484
|
-
formState: { errors }
|
|
485
|
-
} = (0, import_react_hook_form7.useFormContext)();
|
|
473
|
+
const { register, getFieldState } = (0, import_react_hook_form7.useFormContext)();
|
|
486
474
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
487
475
|
import_mui_form_utils.Input,
|
|
488
476
|
__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
489
|
-
error: !!
|
|
477
|
+
error: !!getFieldState(name).error,
|
|
490
478
|
required: !!required
|
|
491
479
|
}), register(name, {
|
|
492
480
|
required,
|
|
@@ -538,11 +526,8 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
538
526
|
"FieldProps"
|
|
539
527
|
]);
|
|
540
528
|
var _a2;
|
|
541
|
-
const {
|
|
542
|
-
|
|
543
|
-
formState: { errors }
|
|
544
|
-
} = (0, import_react_hook_form8.useFormContext)();
|
|
545
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
529
|
+
const { control, getFieldState } = (0, import_react_hook_form8.useFormContext)();
|
|
530
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
546
531
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
547
532
|
import_react_hook_form8.Controller,
|
|
548
533
|
{
|
|
@@ -624,11 +609,8 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
624
609
|
"FieldProps"
|
|
625
610
|
]);
|
|
626
611
|
var _a2;
|
|
627
|
-
const {
|
|
628
|
-
|
|
629
|
-
formState: { errors }
|
|
630
|
-
} = (0, import_react_hook_form9.useFormContext)();
|
|
631
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
612
|
+
const { control, getFieldState } = (0, import_react_hook_form9.useFormContext)();
|
|
613
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
632
614
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
633
615
|
import_react_hook_form9.Controller,
|
|
634
616
|
{
|
|
@@ -705,11 +687,8 @@ var ControlledRadioGroup = (_a) => {
|
|
|
705
687
|
"value"
|
|
706
688
|
]);
|
|
707
689
|
var _a2;
|
|
708
|
-
const {
|
|
709
|
-
|
|
710
|
-
formState: { errors }
|
|
711
|
-
} = (0, import_react_hook_form10.useFormContext)();
|
|
712
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
690
|
+
const { control, getFieldState } = (0, import_react_hook_form10.useFormContext)();
|
|
691
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
713
692
|
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
714
693
|
import_react_hook_form10.Controller,
|
|
715
694
|
{
|
|
@@ -769,14 +748,11 @@ var ControlledSelect = (_a) => {
|
|
|
769
748
|
"shouldUnregister",
|
|
770
749
|
"deps"
|
|
771
750
|
]);
|
|
772
|
-
const {
|
|
773
|
-
register,
|
|
774
|
-
formState: { errors }
|
|
775
|
-
} = (0, import_react_hook_form11.useFormContext)();
|
|
751
|
+
const { register, getFieldState } = (0, import_react_hook_form11.useFormContext)();
|
|
776
752
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
777
753
|
import_mui_form_utils4.Select,
|
|
778
754
|
__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
779
|
-
error: !!
|
|
755
|
+
error: !!getFieldState(name).error,
|
|
780
756
|
required: !!required
|
|
781
757
|
}), register(name, {
|
|
782
758
|
required,
|
|
@@ -838,11 +814,8 @@ var ControlledTextField = (_a) => {
|
|
|
838
814
|
"deps"
|
|
839
815
|
]);
|
|
840
816
|
var _a2;
|
|
841
|
-
const {
|
|
842
|
-
|
|
843
|
-
formState: { errors }
|
|
844
|
-
} = (0, import_react_hook_form12.useFormContext)();
|
|
845
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
817
|
+
const { register, getFieldState } = (0, import_react_hook_form12.useFormContext)();
|
|
818
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
846
819
|
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
847
820
|
import_mui_textfield.TextField,
|
|
848
821
|
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
@@ -863,7 +836,7 @@ var ControlledTextField = (_a) => {
|
|
|
863
836
|
shouldUnregister,
|
|
864
837
|
deps
|
|
865
838
|
})), {
|
|
866
|
-
error: !!
|
|
839
|
+
error: !!getFieldState(name).error,
|
|
867
840
|
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
868
841
|
errorMessage,
|
|
869
842
|
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("br", {}),
|
package/dist/index.mjs
CHANGED
|
@@ -67,11 +67,8 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
67
67
|
"FieldProps"
|
|
68
68
|
]);
|
|
69
69
|
var _a2;
|
|
70
|
-
const {
|
|
71
|
-
|
|
72
|
-
formState: { errors }
|
|
73
|
-
} = useFormContext();
|
|
74
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
70
|
+
const { control, getFieldState } = useFormContext();
|
|
71
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
75
72
|
return /* @__PURE__ */ jsx(
|
|
76
73
|
Controller,
|
|
77
74
|
{
|
|
@@ -157,11 +154,8 @@ var ControlledAutocomplete = (_a) => {
|
|
|
157
154
|
"value"
|
|
158
155
|
]);
|
|
159
156
|
var _a2;
|
|
160
|
-
const {
|
|
161
|
-
|
|
162
|
-
formState: { errors }
|
|
163
|
-
} = useFormContext2();
|
|
164
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
157
|
+
const { control, getFieldState } = useFormContext2();
|
|
158
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
165
159
|
return /* @__PURE__ */ jsx2(
|
|
166
160
|
Controller2,
|
|
167
161
|
{
|
|
@@ -282,11 +276,8 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
282
276
|
"FieldProps"
|
|
283
277
|
]);
|
|
284
278
|
var _a2;
|
|
285
|
-
const {
|
|
286
|
-
|
|
287
|
-
formState: { errors }
|
|
288
|
-
} = useFormContext4();
|
|
289
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
279
|
+
const { control, getFieldState } = useFormContext4();
|
|
280
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
290
281
|
return /* @__PURE__ */ jsx4(
|
|
291
282
|
Controller3,
|
|
292
283
|
{
|
|
@@ -445,14 +436,11 @@ var ControlledInput = (_a) => {
|
|
|
445
436
|
"shouldUnregister",
|
|
446
437
|
"deps"
|
|
447
438
|
]);
|
|
448
|
-
const {
|
|
449
|
-
register,
|
|
450
|
-
formState: { errors }
|
|
451
|
-
} = useFormContext6();
|
|
439
|
+
const { register, getFieldState } = useFormContext6();
|
|
452
440
|
return /* @__PURE__ */ jsx7(
|
|
453
441
|
Input,
|
|
454
442
|
__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
455
|
-
error: !!
|
|
443
|
+
error: !!getFieldState(name).error,
|
|
456
444
|
required: !!required
|
|
457
445
|
}), register(name, {
|
|
458
446
|
required,
|
|
@@ -504,11 +492,8 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
504
492
|
"FieldProps"
|
|
505
493
|
]);
|
|
506
494
|
var _a2;
|
|
507
|
-
const {
|
|
508
|
-
|
|
509
|
-
formState: { errors }
|
|
510
|
-
} = useFormContext7();
|
|
511
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
495
|
+
const { control, getFieldState } = useFormContext7();
|
|
496
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
512
497
|
return /* @__PURE__ */ jsx8(
|
|
513
498
|
Controller5,
|
|
514
499
|
{
|
|
@@ -590,11 +575,8 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
590
575
|
"FieldProps"
|
|
591
576
|
]);
|
|
592
577
|
var _a2;
|
|
593
|
-
const {
|
|
594
|
-
|
|
595
|
-
formState: { errors }
|
|
596
|
-
} = useFormContext8();
|
|
597
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
578
|
+
const { control, getFieldState } = useFormContext8();
|
|
579
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
598
580
|
return /* @__PURE__ */ jsx9(
|
|
599
581
|
Controller6,
|
|
600
582
|
{
|
|
@@ -671,11 +653,8 @@ var ControlledRadioGroup = (_a) => {
|
|
|
671
653
|
"value"
|
|
672
654
|
]);
|
|
673
655
|
var _a2;
|
|
674
|
-
const {
|
|
675
|
-
|
|
676
|
-
formState: { errors }
|
|
677
|
-
} = useFormContext9();
|
|
678
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
656
|
+
const { control, getFieldState } = useFormContext9();
|
|
657
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
679
658
|
return /* @__PURE__ */ jsx10(
|
|
680
659
|
Controller7,
|
|
681
660
|
{
|
|
@@ -735,14 +714,11 @@ var ControlledSelect = (_a) => {
|
|
|
735
714
|
"shouldUnregister",
|
|
736
715
|
"deps"
|
|
737
716
|
]);
|
|
738
|
-
const {
|
|
739
|
-
register,
|
|
740
|
-
formState: { errors }
|
|
741
|
-
} = useFormContext10();
|
|
717
|
+
const { register, getFieldState } = useFormContext10();
|
|
742
718
|
return /* @__PURE__ */ jsx11(
|
|
743
719
|
Select,
|
|
744
720
|
__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
745
|
-
error: !!
|
|
721
|
+
error: !!getFieldState(name).error,
|
|
746
722
|
required: !!required
|
|
747
723
|
}), register(name, {
|
|
748
724
|
required,
|
|
@@ -804,11 +780,8 @@ var ControlledTextField = (_a) => {
|
|
|
804
780
|
"deps"
|
|
805
781
|
]);
|
|
806
782
|
var _a2;
|
|
807
|
-
const {
|
|
808
|
-
|
|
809
|
-
formState: { errors }
|
|
810
|
-
} = useFormContext11();
|
|
811
|
-
const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
|
|
783
|
+
const { register, getFieldState } = useFormContext11();
|
|
784
|
+
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
812
785
|
return /* @__PURE__ */ jsx12(
|
|
813
786
|
TextField,
|
|
814
787
|
__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, rest), {
|
|
@@ -829,7 +802,7 @@ var ControlledTextField = (_a) => {
|
|
|
829
802
|
shouldUnregister,
|
|
830
803
|
deps
|
|
831
804
|
})), {
|
|
832
|
-
error: !!
|
|
805
|
+
error: !!getFieldState(name).error,
|
|
833
806
|
helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
834
807
|
errorMessage,
|
|
835
808
|
/* @__PURE__ */ jsx12("br", {}),
|
package/package.json
CHANGED
|
@@ -35,11 +35,8 @@ export const ControlledAsyncAutocomplete = <
|
|
|
35
35
|
FieldProps,
|
|
36
36
|
...rest
|
|
37
37
|
}: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => {
|
|
38
|
-
const {
|
|
39
|
-
|
|
40
|
-
formState: { errors },
|
|
41
|
-
} = useFormContext();
|
|
42
|
-
const errorMessage = errors[name]?.message;
|
|
38
|
+
const { control, getFieldState } = useFormContext();
|
|
39
|
+
const errorMessage = getFieldState(name).error?.message;
|
|
43
40
|
return (
|
|
44
41
|
<Controller
|
|
45
42
|
name={name}
|
package/src/lib/Autocomplete.tsx
CHANGED
|
@@ -39,11 +39,8 @@ export const ControlledAutocomplete = <
|
|
|
39
39
|
value,
|
|
40
40
|
...rest
|
|
41
41
|
}: ControlledAutocompleteProps<T, Multiple, DisableClearable, FreeSolo, ChipComponent>) => {
|
|
42
|
-
const {
|
|
43
|
-
|
|
44
|
-
formState: { errors },
|
|
45
|
-
} = useFormContext();
|
|
46
|
-
const errorMessage = errors[name]?.message;
|
|
42
|
+
const { control, getFieldState } = useFormContext();
|
|
43
|
+
const errorMessage = getFieldState(name).error?.message;
|
|
47
44
|
return (
|
|
48
45
|
<Controller
|
|
49
46
|
control={control}
|
|
@@ -21,11 +21,8 @@ export const ControlledCodesAutocomplete = ({
|
|
|
21
21
|
FieldProps,
|
|
22
22
|
...rest
|
|
23
23
|
}: ControlledCodesAutocompleteProps) => {
|
|
24
|
-
const {
|
|
25
|
-
|
|
26
|
-
formState: { errors },
|
|
27
|
-
} = useFormContext();
|
|
28
|
-
const errorMessage = errors[name]?.message;
|
|
24
|
+
const { control, getFieldState } = useFormContext();
|
|
25
|
+
const errorMessage = getFieldState(name).error?.message;
|
|
29
26
|
return (
|
|
30
27
|
<Controller
|
|
31
28
|
name={name}
|
package/src/lib/Input.tsx
CHANGED
|
@@ -24,14 +24,11 @@ export const ControlledInput = ({
|
|
|
24
24
|
deps,
|
|
25
25
|
...rest
|
|
26
26
|
}: ControlledInputProps) => {
|
|
27
|
-
const {
|
|
28
|
-
register,
|
|
29
|
-
formState: { errors },
|
|
30
|
-
} = useFormContext();
|
|
27
|
+
const { register, getFieldState } = useFormContext();
|
|
31
28
|
return (
|
|
32
29
|
<Input
|
|
33
30
|
{...rest}
|
|
34
|
-
error={!!
|
|
31
|
+
error={!!getFieldState(name).error}
|
|
35
32
|
required={!!required}
|
|
36
33
|
{...register(name, {
|
|
37
34
|
required,
|
|
@@ -22,11 +22,8 @@ export const ControlledOrganizationAutocomplete = ({
|
|
|
22
22
|
FieldProps,
|
|
23
23
|
...rest
|
|
24
24
|
}: ControlledOrgAutocompleteProps) => {
|
|
25
|
-
const {
|
|
26
|
-
|
|
27
|
-
formState: { errors },
|
|
28
|
-
} = useFormContext();
|
|
29
|
-
const errorMessage = errors[name]?.message;
|
|
25
|
+
const { control, getFieldState } = useFormContext();
|
|
26
|
+
const errorMessage = getFieldState(name).error?.message;
|
|
30
27
|
return (
|
|
31
28
|
<Controller
|
|
32
29
|
name={name}
|
|
@@ -23,11 +23,8 @@ export const ControlledProviderAutocomplete = ({
|
|
|
23
23
|
FieldProps,
|
|
24
24
|
...rest
|
|
25
25
|
}: ControlledProviderAutocompleteProps) => {
|
|
26
|
-
const {
|
|
27
|
-
|
|
28
|
-
formState: { errors },
|
|
29
|
-
} = useFormContext();
|
|
30
|
-
const errorMessage = errors[name]?.message;
|
|
26
|
+
const { control, getFieldState } = useFormContext();
|
|
27
|
+
const errorMessage = getFieldState(name).error?.message;
|
|
31
28
|
return (
|
|
32
29
|
<Controller
|
|
33
30
|
name={name}
|
package/src/lib/RadioGroup.tsx
CHANGED
|
@@ -34,11 +34,8 @@ export const ControlledRadioGroup = ({
|
|
|
34
34
|
value,
|
|
35
35
|
...rest
|
|
36
36
|
}: ControlledRadioGroupProps) => {
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
formState: { errors },
|
|
40
|
-
} = useFormContext();
|
|
41
|
-
const errorMessage = errors[name]?.message;
|
|
37
|
+
const { control, getFieldState } = useFormContext();
|
|
38
|
+
const errorMessage = getFieldState(name).error?.message;
|
|
42
39
|
return (
|
|
43
40
|
<Controller
|
|
44
41
|
control={control}
|
package/src/lib/Select.tsx
CHANGED
|
@@ -24,15 +24,12 @@ export const ControlledSelect = ({
|
|
|
24
24
|
deps,
|
|
25
25
|
...rest
|
|
26
26
|
}: ControlledSelectProps) => {
|
|
27
|
-
const {
|
|
28
|
-
register,
|
|
29
|
-
formState: { errors },
|
|
30
|
-
} = useFormContext();
|
|
27
|
+
const { register, getFieldState } = useFormContext();
|
|
31
28
|
|
|
32
29
|
return (
|
|
33
30
|
<Select
|
|
34
31
|
{...rest}
|
|
35
|
-
error={!!
|
|
32
|
+
error={!!getFieldState(name).error}
|
|
36
33
|
required={!!required}
|
|
37
34
|
{...register(name, {
|
|
38
35
|
required,
|
package/src/lib/TextField.tsx
CHANGED
|
@@ -24,12 +24,9 @@ export const ControlledTextField = ({
|
|
|
24
24
|
deps,
|
|
25
25
|
...rest
|
|
26
26
|
}: ControlledTextFieldProps) => {
|
|
27
|
-
const {
|
|
28
|
-
register,
|
|
29
|
-
formState: { errors },
|
|
30
|
-
} = useFormContext();
|
|
27
|
+
const { register, getFieldState } = useFormContext();
|
|
31
28
|
|
|
32
|
-
const errorMessage =
|
|
29
|
+
const errorMessage = getFieldState(name).error?.message;
|
|
33
30
|
|
|
34
31
|
return (
|
|
35
32
|
<TextField
|
|
@@ -51,7 +48,7 @@ export const ControlledTextField = ({
|
|
|
51
48
|
shouldUnregister,
|
|
52
49
|
deps,
|
|
53
50
|
})}
|
|
54
|
-
error={!!
|
|
51
|
+
error={!!getFieldState(name).error}
|
|
55
52
|
helperText={
|
|
56
53
|
errorMessage && typeof errorMessage === 'string' ? (
|
|
57
54
|
<>
|