@availity/mui-controlled-form 0.2.5 → 0.2.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/CHANGELOG.md +7 -0
- package/dist/index.d.mts +8 -16
- package/dist/index.d.ts +8 -16
- package/dist/index.js +128 -132
- package/dist/index.mjs +144 -148
- package/package.json +1 -1
- package/src/lib/AsyncAutocomplete.tsx +12 -16
- package/src/lib/Autocomplete.tsx +12 -16
- package/src/lib/Checkbox.stories.tsx +10 -5
- package/src/lib/Checkbox.tsx +26 -14
- package/src/lib/CodesAutocomplete.tsx +12 -16
- package/src/lib/ControlledForm.tsx +1 -1
- package/src/lib/Datepicker.tsx +1 -3
- package/src/lib/Input.stories.tsx +7 -2
- package/src/lib/Input.tsx +20 -15
- package/src/lib/OrganizationAutocomplete.tsx +12 -16
- package/src/lib/ProviderAutocomplete.tsx +12 -16
- package/src/lib/RadioGroup.tsx +5 -8
- package/src/lib/Select.stories.tsx +62 -2
- package/src/lib/Select.tsx +20 -16
- package/src/lib/TextField.stories.tsx +7 -2
- package/src/lib/TextField.tsx +31 -28
package/dist/index.mjs
CHANGED
|
@@ -32,7 +32,7 @@ var __objRest = (source, exclude) => {
|
|
|
32
32
|
|
|
33
33
|
// src/lib/AsyncAutocomplete.tsx
|
|
34
34
|
import { AsyncAutocomplete } from "@availity/mui-autocomplete";
|
|
35
|
-
import {
|
|
35
|
+
import { Controller } from "react-hook-form";
|
|
36
36
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
37
37
|
var ControlledAsyncAutocomplete = (_a) => {
|
|
38
38
|
var _b = _a, {
|
|
@@ -66,14 +66,10 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
66
66
|
"value",
|
|
67
67
|
"FieldProps"
|
|
68
68
|
]);
|
|
69
|
-
var _a2;
|
|
70
|
-
const { control, getFieldState } = useFormContext();
|
|
71
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
72
69
|
return /* @__PURE__ */ jsx(
|
|
73
70
|
Controller,
|
|
74
71
|
{
|
|
75
72
|
name,
|
|
76
|
-
control,
|
|
77
73
|
defaultValue: rest.defaultValue,
|
|
78
74
|
rules: {
|
|
79
75
|
deps,
|
|
@@ -90,14 +86,14 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
90
86
|
value
|
|
91
87
|
},
|
|
92
88
|
shouldUnregister,
|
|
93
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx(
|
|
89
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx(
|
|
94
90
|
AsyncAutocomplete,
|
|
95
91
|
__spreadProps(__spreadValues({}, rest), {
|
|
96
92
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
97
93
|
required: typeof required === "object" ? required.value : !!required,
|
|
98
|
-
error: !!
|
|
99
|
-
helperText:
|
|
100
|
-
|
|
94
|
+
error: !!error,
|
|
95
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
error.message,
|
|
101
97
|
/* @__PURE__ */ jsx("br", {}),
|
|
102
98
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
103
99
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -118,7 +114,7 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
118
114
|
|
|
119
115
|
// src/lib/Autocomplete.tsx
|
|
120
116
|
import { Autocomplete } from "@availity/mui-autocomplete";
|
|
121
|
-
import {
|
|
117
|
+
import { Controller as Controller2 } from "react-hook-form";
|
|
122
118
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
123
119
|
var ControlledAutocomplete = (_a) => {
|
|
124
120
|
var _b = _a, {
|
|
@@ -154,13 +150,9 @@ var ControlledAutocomplete = (_a) => {
|
|
|
154
150
|
"validate",
|
|
155
151
|
"value"
|
|
156
152
|
]);
|
|
157
|
-
var _a2;
|
|
158
|
-
const { control, getFieldState } = useFormContext2();
|
|
159
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
160
153
|
return /* @__PURE__ */ jsx2(
|
|
161
154
|
Controller2,
|
|
162
155
|
{
|
|
163
|
-
control,
|
|
164
156
|
name,
|
|
165
157
|
defaultValue,
|
|
166
158
|
rules: {
|
|
@@ -178,14 +170,14 @@ var ControlledAutocomplete = (_a) => {
|
|
|
178
170
|
value
|
|
179
171
|
},
|
|
180
172
|
shouldUnregister,
|
|
181
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx2(
|
|
173
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx2(
|
|
182
174
|
Autocomplete,
|
|
183
175
|
__spreadProps(__spreadValues({}, rest), {
|
|
184
176
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
185
177
|
required: typeof required === "object" ? required.value : !!required,
|
|
186
|
-
error: !!
|
|
187
|
-
helperText:
|
|
188
|
-
|
|
178
|
+
error: !!error,
|
|
179
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
180
|
+
error.message,
|
|
189
181
|
/* @__PURE__ */ jsx2("br", {}),
|
|
190
182
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
191
183
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -206,46 +198,50 @@ var ControlledAutocomplete = (_a) => {
|
|
|
206
198
|
|
|
207
199
|
// src/lib/Checkbox.tsx
|
|
208
200
|
import { Checkbox } from "@availity/mui-checkbox";
|
|
209
|
-
import {
|
|
201
|
+
import { Controller as Controller3 } from "react-hook-form";
|
|
210
202
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
211
203
|
var ControlledCheckbox = (_a) => {
|
|
212
204
|
var _b = _a, {
|
|
213
205
|
name,
|
|
214
|
-
setValueAs,
|
|
215
206
|
disabled,
|
|
216
207
|
onChange,
|
|
217
208
|
onBlur,
|
|
218
209
|
value,
|
|
210
|
+
defaultValue = false,
|
|
219
211
|
shouldUnregister,
|
|
220
212
|
deps
|
|
221
213
|
} = _b, rest = __objRest(_b, [
|
|
222
214
|
"name",
|
|
223
|
-
"setValueAs",
|
|
224
215
|
"disabled",
|
|
225
216
|
"onChange",
|
|
226
217
|
"onBlur",
|
|
227
218
|
"value",
|
|
219
|
+
"defaultValue",
|
|
228
220
|
"shouldUnregister",
|
|
229
221
|
"deps"
|
|
230
222
|
]);
|
|
231
|
-
const { register } = useFormContext3();
|
|
232
223
|
return /* @__PURE__ */ jsx3(
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
224
|
+
Controller3,
|
|
225
|
+
{
|
|
226
|
+
name,
|
|
227
|
+
defaultValue,
|
|
236
228
|
disabled,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
229
|
+
rules: {
|
|
230
|
+
onChange,
|
|
231
|
+
onBlur,
|
|
232
|
+
value,
|
|
233
|
+
shouldUnregister,
|
|
234
|
+
deps
|
|
235
|
+
},
|
|
240
236
|
shouldUnregister,
|
|
241
|
-
|
|
242
|
-
}
|
|
237
|
+
render: ({ field }) => /* @__PURE__ */ jsx3(Checkbox, __spreadProps(__spreadValues(__spreadValues({}, rest), field), { checked: field.value, onChange: (e) => field.onChange(e.target.checked) }))
|
|
238
|
+
}
|
|
243
239
|
);
|
|
244
240
|
};
|
|
245
241
|
|
|
246
242
|
// src/lib/CodesAutocomplete.tsx
|
|
247
243
|
import { CodesAutocomplete } from "@availity/mui-autocomplete";
|
|
248
|
-
import {
|
|
244
|
+
import { Controller as Controller4 } from "react-hook-form";
|
|
249
245
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
250
246
|
var ControlledCodesAutocomplete = (_a) => {
|
|
251
247
|
var _b = _a, {
|
|
@@ -277,14 +273,10 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
277
273
|
"value",
|
|
278
274
|
"FieldProps"
|
|
279
275
|
]);
|
|
280
|
-
var _a2;
|
|
281
|
-
const { control, getFieldState } = useFormContext4();
|
|
282
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
283
276
|
return /* @__PURE__ */ jsx4(
|
|
284
|
-
|
|
277
|
+
Controller4,
|
|
285
278
|
{
|
|
286
279
|
name,
|
|
287
|
-
control,
|
|
288
280
|
defaultValue,
|
|
289
281
|
rules: {
|
|
290
282
|
deps,
|
|
@@ -299,14 +291,14 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
299
291
|
value
|
|
300
292
|
},
|
|
301
293
|
shouldUnregister,
|
|
302
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx4(
|
|
294
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx4(
|
|
303
295
|
CodesAutocomplete,
|
|
304
296
|
__spreadProps(__spreadValues({}, rest), {
|
|
305
297
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
306
298
|
required: typeof required === "object" ? required.value : !!required,
|
|
307
|
-
error: !!
|
|
308
|
-
helperText:
|
|
309
|
-
|
|
299
|
+
error: !!error,
|
|
300
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
301
|
+
error.message,
|
|
310
302
|
/* @__PURE__ */ jsx4("br", {}),
|
|
311
303
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
312
304
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -335,12 +327,12 @@ var ControlledForm = (_a) => {
|
|
|
335
327
|
useFormOptions.resolver = validationResolver(schema);
|
|
336
328
|
}
|
|
337
329
|
const methods = useForm(useFormOptions);
|
|
338
|
-
return /* @__PURE__ */ jsx5(FormProvider, __spreadProps(__spreadValues({}, methods), { children: /* @__PURE__ */ jsx5("form", __spreadValues({ onSubmit: methods.handleSubmit(onSubmit) }, rest)) }));
|
|
330
|
+
return /* @__PURE__ */ jsx5(FormProvider, __spreadProps(__spreadValues({}, methods), { children: /* @__PURE__ */ jsx5("form", __spreadValues({ onSubmit: methods.handleSubmit(onSubmit), noValidate: true }, rest)) }));
|
|
339
331
|
};
|
|
340
332
|
|
|
341
333
|
// src/lib/Datepicker.tsx
|
|
342
334
|
import { Datepicker } from "@availity/mui-datepicker";
|
|
343
|
-
import {
|
|
335
|
+
import { Controller as Controller5 } from "react-hook-form";
|
|
344
336
|
import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
345
337
|
var ControlledDatepicker = (_a) => {
|
|
346
338
|
var _b = _a, {
|
|
@@ -376,12 +368,10 @@ var ControlledDatepicker = (_a) => {
|
|
|
376
368
|
"value",
|
|
377
369
|
"FieldProps"
|
|
378
370
|
]);
|
|
379
|
-
const { control } = useFormContext5();
|
|
380
371
|
return /* @__PURE__ */ jsx6(
|
|
381
|
-
|
|
372
|
+
Controller5,
|
|
382
373
|
{
|
|
383
374
|
name,
|
|
384
|
-
control,
|
|
385
375
|
defaultValue,
|
|
386
376
|
rules: {
|
|
387
377
|
deps,
|
|
@@ -420,7 +410,7 @@ var ControlledDatepicker = (_a) => {
|
|
|
420
410
|
|
|
421
411
|
// src/lib/Input.tsx
|
|
422
412
|
import { Input } from "@availity/mui-form-utils";
|
|
423
|
-
import {
|
|
413
|
+
import { Controller as Controller6 } from "react-hook-form";
|
|
424
414
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
425
415
|
var ControlledInput = (_a) => {
|
|
426
416
|
var _b = _a, {
|
|
@@ -432,7 +422,7 @@ var ControlledInput = (_a) => {
|
|
|
432
422
|
min,
|
|
433
423
|
pattern,
|
|
434
424
|
validate,
|
|
435
|
-
|
|
425
|
+
defaultValue,
|
|
436
426
|
disabled,
|
|
437
427
|
onChange,
|
|
438
428
|
onBlur,
|
|
@@ -448,7 +438,7 @@ var ControlledInput = (_a) => {
|
|
|
448
438
|
"min",
|
|
449
439
|
"pattern",
|
|
450
440
|
"validate",
|
|
451
|
-
"
|
|
441
|
+
"defaultValue",
|
|
452
442
|
"disabled",
|
|
453
443
|
"onChange",
|
|
454
444
|
"onBlur",
|
|
@@ -456,34 +446,41 @@ var ControlledInput = (_a) => {
|
|
|
456
446
|
"shouldUnregister",
|
|
457
447
|
"deps"
|
|
458
448
|
]);
|
|
459
|
-
const { register, getFieldState } = useFormContext6();
|
|
460
449
|
return /* @__PURE__ */ jsx7(
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}), register(name, {
|
|
466
|
-
required,
|
|
467
|
-
maxLength,
|
|
468
|
-
minLength,
|
|
469
|
-
max,
|
|
470
|
-
min,
|
|
471
|
-
pattern,
|
|
472
|
-
validate,
|
|
473
|
-
setValueAs,
|
|
450
|
+
Controller6,
|
|
451
|
+
{
|
|
452
|
+
name,
|
|
453
|
+
defaultValue,
|
|
474
454
|
disabled,
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
455
|
+
rules: {
|
|
456
|
+
required,
|
|
457
|
+
maxLength,
|
|
458
|
+
minLength,
|
|
459
|
+
max,
|
|
460
|
+
min,
|
|
461
|
+
pattern,
|
|
462
|
+
validate,
|
|
463
|
+
onChange,
|
|
464
|
+
onBlur,
|
|
465
|
+
value,
|
|
466
|
+
shouldUnregister,
|
|
467
|
+
deps
|
|
468
|
+
},
|
|
478
469
|
shouldUnregister,
|
|
479
|
-
|
|
480
|
-
|
|
470
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx7(
|
|
471
|
+
Input,
|
|
472
|
+
__spreadProps(__spreadValues(__spreadValues({}, rest), field), {
|
|
473
|
+
error: !!error,
|
|
474
|
+
required: typeof required === "object" ? required.value : !!required
|
|
475
|
+
})
|
|
476
|
+
)
|
|
477
|
+
}
|
|
481
478
|
);
|
|
482
479
|
};
|
|
483
480
|
|
|
484
481
|
// src/lib/OrganizationAutocomplete.tsx
|
|
485
482
|
import { OrganizationAutocomplete } from "@availity/mui-autocomplete";
|
|
486
|
-
import {
|
|
483
|
+
import { Controller as Controller7 } from "react-hook-form";
|
|
487
484
|
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
488
485
|
var ControlledOrganizationAutocomplete = (_a) => {
|
|
489
486
|
var _b = _a, {
|
|
@@ -511,14 +508,10 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
511
508
|
"value",
|
|
512
509
|
"FieldProps"
|
|
513
510
|
]);
|
|
514
|
-
var _a2;
|
|
515
|
-
const { control, getFieldState } = useFormContext7();
|
|
516
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
517
511
|
return /* @__PURE__ */ jsx8(
|
|
518
|
-
|
|
512
|
+
Controller7,
|
|
519
513
|
{
|
|
520
514
|
name,
|
|
521
|
-
control,
|
|
522
515
|
defaultValue,
|
|
523
516
|
rules: {
|
|
524
517
|
deps,
|
|
@@ -531,14 +524,14 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
531
524
|
value
|
|
532
525
|
},
|
|
533
526
|
shouldUnregister,
|
|
534
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx8(
|
|
527
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx8(
|
|
535
528
|
OrganizationAutocomplete,
|
|
536
529
|
__spreadProps(__spreadValues({}, rest), {
|
|
537
530
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
538
531
|
required: typeof required === "object" ? required.value : !!required,
|
|
539
|
-
error: !!
|
|
540
|
-
helperText:
|
|
541
|
-
|
|
532
|
+
error: !!error,
|
|
533
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
534
|
+
error.message,
|
|
542
535
|
/* @__PURE__ */ jsx8("br", {}),
|
|
543
536
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
544
537
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -559,7 +552,7 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
559
552
|
|
|
560
553
|
// src/lib/ProviderAutocomplete.tsx
|
|
561
554
|
import { ProviderAutocomplete } from "@availity/mui-autocomplete";
|
|
562
|
-
import {
|
|
555
|
+
import { Controller as Controller8 } from "react-hook-form";
|
|
563
556
|
import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
564
557
|
var ControlledProviderAutocomplete = (_a) => {
|
|
565
558
|
var _b = _a, {
|
|
@@ -595,14 +588,10 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
595
588
|
"value",
|
|
596
589
|
"FieldProps"
|
|
597
590
|
]);
|
|
598
|
-
var _a2;
|
|
599
|
-
const { control, getFieldState } = useFormContext8();
|
|
600
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
601
591
|
return /* @__PURE__ */ jsx9(
|
|
602
|
-
|
|
592
|
+
Controller8,
|
|
603
593
|
{
|
|
604
594
|
name,
|
|
605
|
-
control,
|
|
606
595
|
defaultValue,
|
|
607
596
|
rules: {
|
|
608
597
|
deps,
|
|
@@ -619,14 +608,14 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
619
608
|
value
|
|
620
609
|
},
|
|
621
610
|
shouldUnregister,
|
|
622
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx9(
|
|
611
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx9(
|
|
623
612
|
ProviderAutocomplete,
|
|
624
613
|
__spreadProps(__spreadValues({}, rest), {
|
|
625
614
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
626
615
|
required: typeof required === "object" ? required.value : !!required,
|
|
627
|
-
error: !!
|
|
628
|
-
helperText:
|
|
629
|
-
|
|
616
|
+
error: !!error,
|
|
617
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
618
|
+
error.message,
|
|
630
619
|
/* @__PURE__ */ jsx9("br", {}),
|
|
631
620
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
632
621
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -647,7 +636,7 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
647
636
|
|
|
648
637
|
// src/lib/RadioGroup.tsx
|
|
649
638
|
import { RadioGroup } from "@availity/mui-form-utils";
|
|
650
|
-
import {
|
|
639
|
+
import { Controller as Controller9 } from "react-hook-form";
|
|
651
640
|
import { FormControl, FormLabel, FormHelperText } from "@availity/mui-form-utils";
|
|
652
641
|
import { Fragment as Fragment7, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
653
642
|
var ControlledRadioGroup = (_a) => {
|
|
@@ -674,22 +663,18 @@ var ControlledRadioGroup = (_a) => {
|
|
|
674
663
|
"shouldUnregister",
|
|
675
664
|
"value"
|
|
676
665
|
]);
|
|
677
|
-
var _a2;
|
|
678
|
-
const { control, getFieldState } = useFormContext9();
|
|
679
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
680
666
|
return /* @__PURE__ */ jsx10(
|
|
681
|
-
|
|
667
|
+
Controller9,
|
|
682
668
|
{
|
|
683
|
-
control,
|
|
684
669
|
name,
|
|
685
670
|
defaultValue,
|
|
686
671
|
rules: { deps, onBlur, onChange, required, shouldUnregister, value },
|
|
687
672
|
shouldUnregister,
|
|
688
|
-
render: ({ field }) => /* @__PURE__ */ jsxs7(FormControl, { error: !!
|
|
673
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsxs7(FormControl, { error: !!error, children: [
|
|
689
674
|
/* @__PURE__ */ jsx10(FormLabel, { required: typeof required === "object" ? required.value : !!required, children: label }),
|
|
690
675
|
/* @__PURE__ */ jsx10(RadioGroup, __spreadValues(__spreadValues({}, field), rest)),
|
|
691
|
-
/* @__PURE__ */ jsx10(FormHelperText, { children:
|
|
692
|
-
|
|
676
|
+
/* @__PURE__ */ jsx10(FormHelperText, { children: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
677
|
+
error.message,
|
|
693
678
|
/* @__PURE__ */ jsx10("br", {}),
|
|
694
679
|
helperText
|
|
695
680
|
] }) : helperText })
|
|
@@ -700,7 +685,7 @@ var ControlledRadioGroup = (_a) => {
|
|
|
700
685
|
|
|
701
686
|
// src/lib/Select.tsx
|
|
702
687
|
import { Select } from "@availity/mui-form-utils";
|
|
703
|
-
import {
|
|
688
|
+
import { Controller as Controller10 } from "react-hook-form";
|
|
704
689
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
705
690
|
var ControlledSelect = (_a) => {
|
|
706
691
|
var _b = _a, {
|
|
@@ -712,11 +697,11 @@ var ControlledSelect = (_a) => {
|
|
|
712
697
|
min,
|
|
713
698
|
pattern,
|
|
714
699
|
validate,
|
|
715
|
-
setValueAs,
|
|
716
700
|
disabled,
|
|
717
701
|
onChange,
|
|
718
702
|
onBlur,
|
|
719
703
|
value,
|
|
704
|
+
defaultValue,
|
|
720
705
|
shouldUnregister,
|
|
721
706
|
deps
|
|
722
707
|
} = _b, rest = __objRest(_b, [
|
|
@@ -728,42 +713,49 @@ var ControlledSelect = (_a) => {
|
|
|
728
713
|
"min",
|
|
729
714
|
"pattern",
|
|
730
715
|
"validate",
|
|
731
|
-
"setValueAs",
|
|
732
716
|
"disabled",
|
|
733
717
|
"onChange",
|
|
734
718
|
"onBlur",
|
|
735
719
|
"value",
|
|
720
|
+
"defaultValue",
|
|
736
721
|
"shouldUnregister",
|
|
737
722
|
"deps"
|
|
738
723
|
]);
|
|
739
|
-
const { register, getFieldState } = useFormContext10();
|
|
740
724
|
return /* @__PURE__ */ jsx11(
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}), register(name, {
|
|
746
|
-
required,
|
|
747
|
-
maxLength,
|
|
748
|
-
minLength,
|
|
749
|
-
max,
|
|
750
|
-
min,
|
|
751
|
-
pattern,
|
|
752
|
-
validate,
|
|
753
|
-
setValueAs,
|
|
725
|
+
Controller10,
|
|
726
|
+
{
|
|
727
|
+
name,
|
|
728
|
+
defaultValue,
|
|
754
729
|
disabled,
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
730
|
+
rules: {
|
|
731
|
+
required,
|
|
732
|
+
maxLength,
|
|
733
|
+
minLength,
|
|
734
|
+
max,
|
|
735
|
+
min,
|
|
736
|
+
pattern,
|
|
737
|
+
validate,
|
|
738
|
+
onChange,
|
|
739
|
+
onBlur,
|
|
740
|
+
value,
|
|
741
|
+
shouldUnregister,
|
|
742
|
+
deps
|
|
743
|
+
},
|
|
758
744
|
shouldUnregister,
|
|
759
|
-
|
|
760
|
-
|
|
745
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx11(
|
|
746
|
+
Select,
|
|
747
|
+
__spreadProps(__spreadValues(__spreadValues({}, rest), field), {
|
|
748
|
+
error: !!error,
|
|
749
|
+
required: typeof required === "object" ? required.value : !!required
|
|
750
|
+
})
|
|
751
|
+
)
|
|
752
|
+
}
|
|
761
753
|
);
|
|
762
754
|
};
|
|
763
755
|
|
|
764
756
|
// src/lib/TextField.tsx
|
|
765
757
|
import { TextField } from "@availity/mui-textfield";
|
|
766
|
-
import {
|
|
758
|
+
import { Controller as Controller11 } from "react-hook-form";
|
|
767
759
|
import { Fragment as Fragment8, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
768
760
|
var ControlledTextField = (_a) => {
|
|
769
761
|
var _b = _a, {
|
|
@@ -776,8 +768,8 @@ var ControlledTextField = (_a) => {
|
|
|
776
768
|
min,
|
|
777
769
|
pattern,
|
|
778
770
|
validate,
|
|
779
|
-
setValueAs,
|
|
780
771
|
disabled,
|
|
772
|
+
defaultValue,
|
|
781
773
|
onChange,
|
|
782
774
|
onBlur,
|
|
783
775
|
value,
|
|
@@ -793,44 +785,48 @@ var ControlledTextField = (_a) => {
|
|
|
793
785
|
"min",
|
|
794
786
|
"pattern",
|
|
795
787
|
"validate",
|
|
796
|
-
"setValueAs",
|
|
797
788
|
"disabled",
|
|
789
|
+
"defaultValue",
|
|
798
790
|
"onChange",
|
|
799
791
|
"onBlur",
|
|
800
792
|
"value",
|
|
801
793
|
"shouldUnregister",
|
|
802
794
|
"deps"
|
|
803
795
|
]);
|
|
804
|
-
var _a2;
|
|
805
|
-
const { register, getFieldState } = useFormContext11();
|
|
806
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
807
796
|
return /* @__PURE__ */ jsx12(
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
required,
|
|
813
|
-
maxLength,
|
|
814
|
-
minLength,
|
|
815
|
-
max,
|
|
816
|
-
min,
|
|
817
|
-
pattern,
|
|
818
|
-
validate,
|
|
819
|
-
setValueAs,
|
|
797
|
+
Controller11,
|
|
798
|
+
{
|
|
799
|
+
name,
|
|
800
|
+
defaultValue,
|
|
820
801
|
disabled,
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
802
|
+
rules: {
|
|
803
|
+
required,
|
|
804
|
+
maxLength,
|
|
805
|
+
minLength,
|
|
806
|
+
max,
|
|
807
|
+
min,
|
|
808
|
+
pattern,
|
|
809
|
+
validate,
|
|
810
|
+
onChange,
|
|
811
|
+
onBlur,
|
|
812
|
+
value,
|
|
813
|
+
shouldUnregister,
|
|
814
|
+
deps
|
|
815
|
+
},
|
|
824
816
|
shouldUnregister,
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
817
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsx12(
|
|
818
|
+
TextField,
|
|
819
|
+
__spreadProps(__spreadValues(__spreadValues({}, rest), field), {
|
|
820
|
+
required: typeof required === "object" ? required.value : !!required,
|
|
821
|
+
error: !!error,
|
|
822
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs8(Fragment8, { children: [
|
|
823
|
+
error.message,
|
|
824
|
+
/* @__PURE__ */ jsx12("br", {}),
|
|
825
|
+
helperText
|
|
826
|
+
] }) : helperText
|
|
827
|
+
})
|
|
828
|
+
)
|
|
829
|
+
}
|
|
834
830
|
);
|
|
835
831
|
};
|
|
836
832
|
export {
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AsyncAutocomplete, AsyncAutocompleteProps } from '@availity/mui-autocomplete';
|
|
2
|
-
import {
|
|
2
|
+
import { RegisterOptions, FieldValues, Controller, ControllerProps } from 'react-hook-form';
|
|
3
3
|
import { ChipTypeMap } from '@mui/material/Chip';
|
|
4
4
|
|
|
5
5
|
export type ControlledAsyncAutocompleteProps<
|
|
@@ -35,12 +35,9 @@ export const ControlledAsyncAutocomplete = <
|
|
|
35
35
|
FieldProps,
|
|
36
36
|
...rest
|
|
37
37
|
}: ControlledAsyncAutocompleteProps<Option, Multiple, DisableClearable, FreeSolo, ChipComponent>) => {
|
|
38
|
-
const { control, getFieldState } = useFormContext();
|
|
39
|
-
const errorMessage = getFieldState(name).error?.message;
|
|
40
38
|
return (
|
|
41
39
|
<Controller
|
|
42
40
|
name={name}
|
|
43
|
-
control={control}
|
|
44
41
|
defaultValue={rest.defaultValue}
|
|
45
42
|
rules={{
|
|
46
43
|
deps,
|
|
@@ -57,23 +54,22 @@ export const ControlledAsyncAutocomplete = <
|
|
|
57
54
|
value,
|
|
58
55
|
}}
|
|
59
56
|
shouldUnregister={shouldUnregister}
|
|
60
|
-
render={({ field: { onChange, value, onBlur } }) => (
|
|
57
|
+
render={({ field: { onChange, value, onBlur }, fieldState: { error } }) => (
|
|
61
58
|
<AsyncAutocomplete
|
|
62
59
|
{...rest}
|
|
63
60
|
FieldProps={{
|
|
64
61
|
...FieldProps,
|
|
65
62
|
required: typeof required === 'object' ? required.value : !!required,
|
|
66
|
-
error: !!
|
|
67
|
-
helperText:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
),
|
|
63
|
+
error: !!error,
|
|
64
|
+
helperText: error?.message ? (
|
|
65
|
+
<>
|
|
66
|
+
{error.message}
|
|
67
|
+
<br />
|
|
68
|
+
{FieldProps?.helperText}
|
|
69
|
+
</>
|
|
70
|
+
) : (
|
|
71
|
+
FieldProps?.helperText
|
|
72
|
+
),
|
|
77
73
|
}}
|
|
78
74
|
onChange={(event, value, reason) => {
|
|
79
75
|
if (reason === 'clear') {
|