@availity/mui-controlled-form 0.2.4 → 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 +14 -0
- package/dist/index.d.mts +9 -17
- package/dist/index.d.ts +9 -17
- package/dist/index.js +154 -136
- package/dist/index.mjs +175 -157
- package/package.json +1 -1
- package/src/lib/AsyncAutocomplete.tsx +13 -16
- package/src/lib/Autocomplete.tsx +13 -16
- package/src/lib/Checkbox.stories.tsx +10 -5
- package/src/lib/Checkbox.tsx +26 -14
- package/src/lib/CodesAutocomplete.tsx +13 -16
- package/src/lib/ControlledForm.tsx +1 -1
- package/src/lib/Datepicker.tsx +23 -4
- package/src/lib/Input.stories.tsx +7 -2
- package/src/lib/Input.tsx +20 -15
- package/src/lib/OrganizationAutocomplete.tsx +13 -16
- package/src/lib/ProviderAutocomplete.tsx +13 -16
- package/src/lib/RadioGroup.tsx +6 -9
- 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,13 +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
|
-
|
|
98
|
-
|
|
99
|
-
|
|
93
|
+
required: typeof required === "object" ? required.value : !!required,
|
|
94
|
+
error: !!error,
|
|
95
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
96
|
+
error.message,
|
|
100
97
|
/* @__PURE__ */ jsx("br", {}),
|
|
101
98
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
102
99
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -117,7 +114,7 @@ var ControlledAsyncAutocomplete = (_a) => {
|
|
|
117
114
|
|
|
118
115
|
// src/lib/Autocomplete.tsx
|
|
119
116
|
import { Autocomplete } from "@availity/mui-autocomplete";
|
|
120
|
-
import {
|
|
117
|
+
import { Controller as Controller2 } from "react-hook-form";
|
|
121
118
|
import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
122
119
|
var ControlledAutocomplete = (_a) => {
|
|
123
120
|
var _b = _a, {
|
|
@@ -153,13 +150,9 @@ var ControlledAutocomplete = (_a) => {
|
|
|
153
150
|
"validate",
|
|
154
151
|
"value"
|
|
155
152
|
]);
|
|
156
|
-
var _a2;
|
|
157
|
-
const { control, getFieldState } = useFormContext2();
|
|
158
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
159
153
|
return /* @__PURE__ */ jsx2(
|
|
160
154
|
Controller2,
|
|
161
155
|
{
|
|
162
|
-
control,
|
|
163
156
|
name,
|
|
164
157
|
defaultValue,
|
|
165
158
|
rules: {
|
|
@@ -177,13 +170,14 @@ var ControlledAutocomplete = (_a) => {
|
|
|
177
170
|
value
|
|
178
171
|
},
|
|
179
172
|
shouldUnregister,
|
|
180
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx2(
|
|
173
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx2(
|
|
181
174
|
Autocomplete,
|
|
182
175
|
__spreadProps(__spreadValues({}, rest), {
|
|
183
176
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
177
|
+
required: typeof required === "object" ? required.value : !!required,
|
|
178
|
+
error: !!error,
|
|
179
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
|
|
180
|
+
error.message,
|
|
187
181
|
/* @__PURE__ */ jsx2("br", {}),
|
|
188
182
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
189
183
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -204,46 +198,50 @@ var ControlledAutocomplete = (_a) => {
|
|
|
204
198
|
|
|
205
199
|
// src/lib/Checkbox.tsx
|
|
206
200
|
import { Checkbox } from "@availity/mui-checkbox";
|
|
207
|
-
import {
|
|
201
|
+
import { Controller as Controller3 } from "react-hook-form";
|
|
208
202
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
209
203
|
var ControlledCheckbox = (_a) => {
|
|
210
204
|
var _b = _a, {
|
|
211
205
|
name,
|
|
212
|
-
setValueAs,
|
|
213
206
|
disabled,
|
|
214
207
|
onChange,
|
|
215
208
|
onBlur,
|
|
216
209
|
value,
|
|
210
|
+
defaultValue = false,
|
|
217
211
|
shouldUnregister,
|
|
218
212
|
deps
|
|
219
213
|
} = _b, rest = __objRest(_b, [
|
|
220
214
|
"name",
|
|
221
|
-
"setValueAs",
|
|
222
215
|
"disabled",
|
|
223
216
|
"onChange",
|
|
224
217
|
"onBlur",
|
|
225
218
|
"value",
|
|
219
|
+
"defaultValue",
|
|
226
220
|
"shouldUnregister",
|
|
227
221
|
"deps"
|
|
228
222
|
]);
|
|
229
|
-
const { register } = useFormContext3();
|
|
230
223
|
return /* @__PURE__ */ jsx3(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
224
|
+
Controller3,
|
|
225
|
+
{
|
|
226
|
+
name,
|
|
227
|
+
defaultValue,
|
|
234
228
|
disabled,
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
229
|
+
rules: {
|
|
230
|
+
onChange,
|
|
231
|
+
onBlur,
|
|
232
|
+
value,
|
|
233
|
+
shouldUnregister,
|
|
234
|
+
deps
|
|
235
|
+
},
|
|
238
236
|
shouldUnregister,
|
|
239
|
-
|
|
240
|
-
}
|
|
237
|
+
render: ({ field }) => /* @__PURE__ */ jsx3(Checkbox, __spreadProps(__spreadValues(__spreadValues({}, rest), field), { checked: field.value, onChange: (e) => field.onChange(e.target.checked) }))
|
|
238
|
+
}
|
|
241
239
|
);
|
|
242
240
|
};
|
|
243
241
|
|
|
244
242
|
// src/lib/CodesAutocomplete.tsx
|
|
245
243
|
import { CodesAutocomplete } from "@availity/mui-autocomplete";
|
|
246
|
-
import {
|
|
244
|
+
import { Controller as Controller4 } from "react-hook-form";
|
|
247
245
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
248
246
|
var ControlledCodesAutocomplete = (_a) => {
|
|
249
247
|
var _b = _a, {
|
|
@@ -275,14 +273,10 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
275
273
|
"value",
|
|
276
274
|
"FieldProps"
|
|
277
275
|
]);
|
|
278
|
-
var _a2;
|
|
279
|
-
const { control, getFieldState } = useFormContext4();
|
|
280
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
281
276
|
return /* @__PURE__ */ jsx4(
|
|
282
|
-
|
|
277
|
+
Controller4,
|
|
283
278
|
{
|
|
284
279
|
name,
|
|
285
|
-
control,
|
|
286
280
|
defaultValue,
|
|
287
281
|
rules: {
|
|
288
282
|
deps,
|
|
@@ -297,13 +291,14 @@ var ControlledCodesAutocomplete = (_a) => {
|
|
|
297
291
|
value
|
|
298
292
|
},
|
|
299
293
|
shouldUnregister,
|
|
300
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx4(
|
|
294
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx4(
|
|
301
295
|
CodesAutocomplete,
|
|
302
296
|
__spreadProps(__spreadValues({}, rest), {
|
|
303
297
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
298
|
+
required: typeof required === "object" ? required.value : !!required,
|
|
299
|
+
error: !!error,
|
|
300
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
|
|
301
|
+
error.message,
|
|
307
302
|
/* @__PURE__ */ jsx4("br", {}),
|
|
308
303
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
309
304
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -332,13 +327,13 @@ var ControlledForm = (_a) => {
|
|
|
332
327
|
useFormOptions.resolver = validationResolver(schema);
|
|
333
328
|
}
|
|
334
329
|
const methods = useForm(useFormOptions);
|
|
335
|
-
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)) }));
|
|
336
331
|
};
|
|
337
332
|
|
|
338
333
|
// src/lib/Datepicker.tsx
|
|
339
334
|
import { Datepicker } from "@availity/mui-datepicker";
|
|
340
|
-
import {
|
|
341
|
-
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
335
|
+
import { Controller as Controller5 } from "react-hook-form";
|
|
336
|
+
import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
342
337
|
var ControlledDatepicker = (_a) => {
|
|
343
338
|
var _b = _a, {
|
|
344
339
|
name,
|
|
@@ -354,7 +349,8 @@ var ControlledDatepicker = (_a) => {
|
|
|
354
349
|
required,
|
|
355
350
|
shouldUnregister,
|
|
356
351
|
validate,
|
|
357
|
-
value
|
|
352
|
+
value,
|
|
353
|
+
FieldProps
|
|
358
354
|
} = _b, rest = __objRest(_b, [
|
|
359
355
|
"name",
|
|
360
356
|
"defaultValue",
|
|
@@ -369,14 +365,13 @@ var ControlledDatepicker = (_a) => {
|
|
|
369
365
|
"required",
|
|
370
366
|
"shouldUnregister",
|
|
371
367
|
"validate",
|
|
372
|
-
"value"
|
|
368
|
+
"value",
|
|
369
|
+
"FieldProps"
|
|
373
370
|
]);
|
|
374
|
-
const { control } = useFormContext5();
|
|
375
371
|
return /* @__PURE__ */ jsx6(
|
|
376
|
-
|
|
372
|
+
Controller5,
|
|
377
373
|
{
|
|
378
374
|
name,
|
|
379
|
-
control,
|
|
380
375
|
defaultValue,
|
|
381
376
|
rules: {
|
|
382
377
|
deps,
|
|
@@ -393,14 +388,29 @@ var ControlledDatepicker = (_a) => {
|
|
|
393
388
|
value
|
|
394
389
|
},
|
|
395
390
|
shouldUnregister,
|
|
396
|
-
render: ({ field: { onChange: onChange2, value: value2 } }) => /* @__PURE__ */ jsx6(
|
|
391
|
+
render: ({ field: { onChange: onChange2, value: value2 }, fieldState: { error } }) => /* @__PURE__ */ jsx6(
|
|
392
|
+
Datepicker,
|
|
393
|
+
__spreadProps(__spreadValues({}, rest), {
|
|
394
|
+
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
395
|
+
required: typeof required === "object" ? required.value : !!required,
|
|
396
|
+
error: !!error,
|
|
397
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
398
|
+
error == null ? void 0 : error.message,
|
|
399
|
+
/* @__PURE__ */ jsx6("br", {}),
|
|
400
|
+
FieldProps == null ? void 0 : FieldProps.helperText
|
|
401
|
+
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
402
|
+
}),
|
|
403
|
+
onChange: onChange2,
|
|
404
|
+
value: value2 || null
|
|
405
|
+
})
|
|
406
|
+
)
|
|
397
407
|
}
|
|
398
408
|
);
|
|
399
409
|
};
|
|
400
410
|
|
|
401
411
|
// src/lib/Input.tsx
|
|
402
412
|
import { Input } from "@availity/mui-form-utils";
|
|
403
|
-
import {
|
|
413
|
+
import { Controller as Controller6 } from "react-hook-form";
|
|
404
414
|
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
405
415
|
var ControlledInput = (_a) => {
|
|
406
416
|
var _b = _a, {
|
|
@@ -412,7 +422,7 @@ var ControlledInput = (_a) => {
|
|
|
412
422
|
min,
|
|
413
423
|
pattern,
|
|
414
424
|
validate,
|
|
415
|
-
|
|
425
|
+
defaultValue,
|
|
416
426
|
disabled,
|
|
417
427
|
onChange,
|
|
418
428
|
onBlur,
|
|
@@ -428,7 +438,7 @@ var ControlledInput = (_a) => {
|
|
|
428
438
|
"min",
|
|
429
439
|
"pattern",
|
|
430
440
|
"validate",
|
|
431
|
-
"
|
|
441
|
+
"defaultValue",
|
|
432
442
|
"disabled",
|
|
433
443
|
"onChange",
|
|
434
444
|
"onBlur",
|
|
@@ -436,35 +446,42 @@ var ControlledInput = (_a) => {
|
|
|
436
446
|
"shouldUnregister",
|
|
437
447
|
"deps"
|
|
438
448
|
]);
|
|
439
|
-
const { register, getFieldState } = useFormContext6();
|
|
440
449
|
return /* @__PURE__ */ jsx7(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
}), register(name, {
|
|
446
|
-
required,
|
|
447
|
-
maxLength,
|
|
448
|
-
minLength,
|
|
449
|
-
max,
|
|
450
|
-
min,
|
|
451
|
-
pattern,
|
|
452
|
-
validate,
|
|
453
|
-
setValueAs,
|
|
450
|
+
Controller6,
|
|
451
|
+
{
|
|
452
|
+
name,
|
|
453
|
+
defaultValue,
|
|
454
454
|
disabled,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
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
|
+
},
|
|
458
469
|
shouldUnregister,
|
|
459
|
-
|
|
460
|
-
|
|
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
|
+
}
|
|
461
478
|
);
|
|
462
479
|
};
|
|
463
480
|
|
|
464
481
|
// src/lib/OrganizationAutocomplete.tsx
|
|
465
482
|
import { OrganizationAutocomplete } from "@availity/mui-autocomplete";
|
|
466
|
-
import {
|
|
467
|
-
import { Fragment as
|
|
483
|
+
import { Controller as Controller7 } from "react-hook-form";
|
|
484
|
+
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
468
485
|
var ControlledOrganizationAutocomplete = (_a) => {
|
|
469
486
|
var _b = _a, {
|
|
470
487
|
name,
|
|
@@ -491,14 +508,10 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
491
508
|
"value",
|
|
492
509
|
"FieldProps"
|
|
493
510
|
]);
|
|
494
|
-
var _a2;
|
|
495
|
-
const { control, getFieldState } = useFormContext7();
|
|
496
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
497
511
|
return /* @__PURE__ */ jsx8(
|
|
498
|
-
|
|
512
|
+
Controller7,
|
|
499
513
|
{
|
|
500
514
|
name,
|
|
501
|
-
control,
|
|
502
515
|
defaultValue,
|
|
503
516
|
rules: {
|
|
504
517
|
deps,
|
|
@@ -511,13 +524,14 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
511
524
|
value
|
|
512
525
|
},
|
|
513
526
|
shouldUnregister,
|
|
514
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx8(
|
|
527
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx8(
|
|
515
528
|
OrganizationAutocomplete,
|
|
516
529
|
__spreadProps(__spreadValues({}, rest), {
|
|
517
530
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
531
|
+
required: typeof required === "object" ? required.value : !!required,
|
|
532
|
+
error: !!error,
|
|
533
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
|
|
534
|
+
error.message,
|
|
521
535
|
/* @__PURE__ */ jsx8("br", {}),
|
|
522
536
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
523
537
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -538,8 +552,8 @@ var ControlledOrganizationAutocomplete = (_a) => {
|
|
|
538
552
|
|
|
539
553
|
// src/lib/ProviderAutocomplete.tsx
|
|
540
554
|
import { ProviderAutocomplete } from "@availity/mui-autocomplete";
|
|
541
|
-
import {
|
|
542
|
-
import { Fragment as
|
|
555
|
+
import { Controller as Controller8 } from "react-hook-form";
|
|
556
|
+
import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
543
557
|
var ControlledProviderAutocomplete = (_a) => {
|
|
544
558
|
var _b = _a, {
|
|
545
559
|
name,
|
|
@@ -574,14 +588,10 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
574
588
|
"value",
|
|
575
589
|
"FieldProps"
|
|
576
590
|
]);
|
|
577
|
-
var _a2;
|
|
578
|
-
const { control, getFieldState } = useFormContext8();
|
|
579
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
580
591
|
return /* @__PURE__ */ jsx9(
|
|
581
|
-
|
|
592
|
+
Controller8,
|
|
582
593
|
{
|
|
583
594
|
name,
|
|
584
|
-
control,
|
|
585
595
|
defaultValue,
|
|
586
596
|
rules: {
|
|
587
597
|
deps,
|
|
@@ -598,13 +608,14 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
598
608
|
value
|
|
599
609
|
},
|
|
600
610
|
shouldUnregister,
|
|
601
|
-
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx9(
|
|
611
|
+
render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 }, fieldState: { error } }) => /* @__PURE__ */ jsx9(
|
|
602
612
|
ProviderAutocomplete,
|
|
603
613
|
__spreadProps(__spreadValues({}, rest), {
|
|
604
614
|
FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
615
|
+
required: typeof required === "object" ? required.value : !!required,
|
|
616
|
+
error: !!error,
|
|
617
|
+
helperText: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
|
|
618
|
+
error.message,
|
|
608
619
|
/* @__PURE__ */ jsx9("br", {}),
|
|
609
620
|
FieldProps == null ? void 0 : FieldProps.helperText
|
|
610
621
|
] }) : FieldProps == null ? void 0 : FieldProps.helperText
|
|
@@ -625,9 +636,9 @@ var ControlledProviderAutocomplete = (_a) => {
|
|
|
625
636
|
|
|
626
637
|
// src/lib/RadioGroup.tsx
|
|
627
638
|
import { RadioGroup } from "@availity/mui-form-utils";
|
|
628
|
-
import {
|
|
639
|
+
import { Controller as Controller9 } from "react-hook-form";
|
|
629
640
|
import { FormControl, FormLabel, FormHelperText } from "@availity/mui-form-utils";
|
|
630
|
-
import { Fragment as
|
|
641
|
+
import { Fragment as Fragment7, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
631
642
|
var ControlledRadioGroup = (_a) => {
|
|
632
643
|
var _b = _a, {
|
|
633
644
|
name,
|
|
@@ -652,22 +663,18 @@ var ControlledRadioGroup = (_a) => {
|
|
|
652
663
|
"shouldUnregister",
|
|
653
664
|
"value"
|
|
654
665
|
]);
|
|
655
|
-
var _a2;
|
|
656
|
-
const { control, getFieldState } = useFormContext9();
|
|
657
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
658
666
|
return /* @__PURE__ */ jsx10(
|
|
659
|
-
|
|
667
|
+
Controller9,
|
|
660
668
|
{
|
|
661
|
-
control,
|
|
662
669
|
name,
|
|
663
670
|
defaultValue,
|
|
664
671
|
rules: { deps, onBlur, onChange, required, shouldUnregister, value },
|
|
665
672
|
shouldUnregister,
|
|
666
|
-
render: ({ field }) => /* @__PURE__ */
|
|
667
|
-
/* @__PURE__ */ jsx10(FormLabel, { children: label }),
|
|
673
|
+
render: ({ field, fieldState: { error } }) => /* @__PURE__ */ jsxs7(FormControl, { error: !!error, children: [
|
|
674
|
+
/* @__PURE__ */ jsx10(FormLabel, { required: typeof required === "object" ? required.value : !!required, children: label }),
|
|
668
675
|
/* @__PURE__ */ jsx10(RadioGroup, __spreadValues(__spreadValues({}, field), rest)),
|
|
669
|
-
/* @__PURE__ */ jsx10(FormHelperText, { children:
|
|
670
|
-
|
|
676
|
+
/* @__PURE__ */ jsx10(FormHelperText, { children: (error == null ? void 0 : error.message) ? /* @__PURE__ */ jsxs7(Fragment7, { children: [
|
|
677
|
+
error.message,
|
|
671
678
|
/* @__PURE__ */ jsx10("br", {}),
|
|
672
679
|
helperText
|
|
673
680
|
] }) : helperText })
|
|
@@ -678,7 +685,7 @@ var ControlledRadioGroup = (_a) => {
|
|
|
678
685
|
|
|
679
686
|
// src/lib/Select.tsx
|
|
680
687
|
import { Select } from "@availity/mui-form-utils";
|
|
681
|
-
import {
|
|
688
|
+
import { Controller as Controller10 } from "react-hook-form";
|
|
682
689
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
683
690
|
var ControlledSelect = (_a) => {
|
|
684
691
|
var _b = _a, {
|
|
@@ -690,11 +697,11 @@ var ControlledSelect = (_a) => {
|
|
|
690
697
|
min,
|
|
691
698
|
pattern,
|
|
692
699
|
validate,
|
|
693
|
-
setValueAs,
|
|
694
700
|
disabled,
|
|
695
701
|
onChange,
|
|
696
702
|
onBlur,
|
|
697
703
|
value,
|
|
704
|
+
defaultValue,
|
|
698
705
|
shouldUnregister,
|
|
699
706
|
deps
|
|
700
707
|
} = _b, rest = __objRest(_b, [
|
|
@@ -706,43 +713,50 @@ var ControlledSelect = (_a) => {
|
|
|
706
713
|
"min",
|
|
707
714
|
"pattern",
|
|
708
715
|
"validate",
|
|
709
|
-
"setValueAs",
|
|
710
716
|
"disabled",
|
|
711
717
|
"onChange",
|
|
712
718
|
"onBlur",
|
|
713
719
|
"value",
|
|
720
|
+
"defaultValue",
|
|
714
721
|
"shouldUnregister",
|
|
715
722
|
"deps"
|
|
716
723
|
]);
|
|
717
|
-
const { register, getFieldState } = useFormContext10();
|
|
718
724
|
return /* @__PURE__ */ jsx11(
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
}), register(name, {
|
|
724
|
-
required,
|
|
725
|
-
maxLength,
|
|
726
|
-
minLength,
|
|
727
|
-
max,
|
|
728
|
-
min,
|
|
729
|
-
pattern,
|
|
730
|
-
validate,
|
|
731
|
-
setValueAs,
|
|
725
|
+
Controller10,
|
|
726
|
+
{
|
|
727
|
+
name,
|
|
728
|
+
defaultValue,
|
|
732
729
|
disabled,
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
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
|
+
},
|
|
736
744
|
shouldUnregister,
|
|
737
|
-
|
|
738
|
-
|
|
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
|
+
}
|
|
739
753
|
);
|
|
740
754
|
};
|
|
741
755
|
|
|
742
756
|
// src/lib/TextField.tsx
|
|
743
757
|
import { TextField } from "@availity/mui-textfield";
|
|
744
|
-
import {
|
|
745
|
-
import { Fragment as
|
|
758
|
+
import { Controller as Controller11 } from "react-hook-form";
|
|
759
|
+
import { Fragment as Fragment8, jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
746
760
|
var ControlledTextField = (_a) => {
|
|
747
761
|
var _b = _a, {
|
|
748
762
|
name,
|
|
@@ -754,8 +768,8 @@ var ControlledTextField = (_a) => {
|
|
|
754
768
|
min,
|
|
755
769
|
pattern,
|
|
756
770
|
validate,
|
|
757
|
-
setValueAs,
|
|
758
771
|
disabled,
|
|
772
|
+
defaultValue,
|
|
759
773
|
onChange,
|
|
760
774
|
onBlur,
|
|
761
775
|
value,
|
|
@@ -771,44 +785,48 @@ var ControlledTextField = (_a) => {
|
|
|
771
785
|
"min",
|
|
772
786
|
"pattern",
|
|
773
787
|
"validate",
|
|
774
|
-
"setValueAs",
|
|
775
788
|
"disabled",
|
|
789
|
+
"defaultValue",
|
|
776
790
|
"onChange",
|
|
777
791
|
"onBlur",
|
|
778
792
|
"value",
|
|
779
793
|
"shouldUnregister",
|
|
780
794
|
"deps"
|
|
781
795
|
]);
|
|
782
|
-
var _a2;
|
|
783
|
-
const { register, getFieldState } = useFormContext11();
|
|
784
|
-
const errorMessage = (_a2 = getFieldState(name).error) == null ? void 0 : _a2.message;
|
|
785
796
|
return /* @__PURE__ */ jsx12(
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
required,
|
|
791
|
-
maxLength,
|
|
792
|
-
minLength,
|
|
793
|
-
max,
|
|
794
|
-
min,
|
|
795
|
-
pattern,
|
|
796
|
-
validate,
|
|
797
|
-
setValueAs,
|
|
797
|
+
Controller11,
|
|
798
|
+
{
|
|
799
|
+
name,
|
|
800
|
+
defaultValue,
|
|
798
801
|
disabled,
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
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
|
+
},
|
|
802
816
|
shouldUnregister,
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
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
|
+
}
|
|
812
830
|
);
|
|
813
831
|
};
|
|
814
832
|
export {
|