@availity/mui-controlled-form 0.1.2 → 0.1.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/dist/index.mjs CHANGED
@@ -30,9 +30,310 @@ var __objRest = (source, exclude) => {
30
30
  return target;
31
31
  };
32
32
 
33
+ // src/lib/AsyncAutocomplete.tsx
34
+ import { AsyncAutocomplete } from "@availity/mui-autocomplete";
35
+ import { useFormContext, Controller } from "react-hook-form";
36
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
37
+ var ControlledAsyncAutocomplete = (_a) => {
38
+ var _b = _a, {
39
+ name,
40
+ deps,
41
+ max,
42
+ maxLength,
43
+ min,
44
+ minLength,
45
+ onBlur,
46
+ onChange,
47
+ pattern,
48
+ required,
49
+ shouldUnregister,
50
+ validate,
51
+ value,
52
+ FieldProps
53
+ } = _b, rest = __objRest(_b, [
54
+ "name",
55
+ "deps",
56
+ "max",
57
+ "maxLength",
58
+ "min",
59
+ "minLength",
60
+ "onBlur",
61
+ "onChange",
62
+ "pattern",
63
+ "required",
64
+ "shouldUnregister",
65
+ "validate",
66
+ "value",
67
+ "FieldProps"
68
+ ]);
69
+ var _a2;
70
+ const {
71
+ control,
72
+ formState: { errors }
73
+ } = useFormContext();
74
+ const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
75
+ return /* @__PURE__ */ jsx(
76
+ Controller,
77
+ {
78
+ name,
79
+ control,
80
+ defaultValue: rest.defaultValue,
81
+ rules: {
82
+ deps,
83
+ max,
84
+ maxLength,
85
+ min,
86
+ minLength,
87
+ onBlur,
88
+ onChange,
89
+ pattern,
90
+ required,
91
+ shouldUnregister,
92
+ validate,
93
+ value
94
+ },
95
+ shouldUnregister,
96
+ render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx(
97
+ AsyncAutocomplete,
98
+ __spreadProps(__spreadValues({}, rest), {
99
+ FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
100
+ error: !!errorMessage,
101
+ helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs(Fragment, { children: [
102
+ errorMessage,
103
+ /* @__PURE__ */ jsx("br", {}),
104
+ FieldProps == null ? void 0 : FieldProps.helperText
105
+ ] }) : FieldProps == null ? void 0 : FieldProps.helperText
106
+ }),
107
+ onChange: (event, value3, reason) => {
108
+ if (reason === "clear") {
109
+ onChange2(null);
110
+ }
111
+ onChange2(value3);
112
+ },
113
+ onBlur: onBlur2,
114
+ value: value2 || null
115
+ })
116
+ )
117
+ }
118
+ );
119
+ };
120
+
121
+ // src/lib/Autocomplete.tsx
122
+ import { Autocomplete } from "@availity/mui-autocomplete";
123
+ import { useFormContext as useFormContext2, Controller as Controller2 } from "react-hook-form";
124
+ import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
125
+ var ControlledAutocomplete = (_a) => {
126
+ var _b = _a, {
127
+ name,
128
+ FieldProps,
129
+ defaultValue,
130
+ deps,
131
+ max,
132
+ maxLength,
133
+ min,
134
+ minLength,
135
+ onBlur,
136
+ onChange,
137
+ pattern,
138
+ required,
139
+ shouldUnregister,
140
+ validate,
141
+ value
142
+ } = _b, rest = __objRest(_b, [
143
+ "name",
144
+ "FieldProps",
145
+ "defaultValue",
146
+ "deps",
147
+ "max",
148
+ "maxLength",
149
+ "min",
150
+ "minLength",
151
+ "onBlur",
152
+ "onChange",
153
+ "pattern",
154
+ "required",
155
+ "shouldUnregister",
156
+ "validate",
157
+ "value"
158
+ ]);
159
+ var _a2;
160
+ const {
161
+ control,
162
+ formState: { errors }
163
+ } = useFormContext2();
164
+ const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
165
+ return /* @__PURE__ */ jsx2(
166
+ Controller2,
167
+ {
168
+ control,
169
+ name,
170
+ defaultValue,
171
+ rules: {
172
+ deps,
173
+ max,
174
+ maxLength,
175
+ min,
176
+ minLength,
177
+ onBlur,
178
+ onChange,
179
+ pattern,
180
+ required,
181
+ shouldUnregister,
182
+ validate,
183
+ value
184
+ },
185
+ shouldUnregister,
186
+ render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx2(
187
+ Autocomplete,
188
+ __spreadProps(__spreadValues({}, rest), {
189
+ FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
190
+ error: !!errorMessage,
191
+ helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs2(Fragment2, { children: [
192
+ errorMessage,
193
+ /* @__PURE__ */ jsx2("br", {}),
194
+ FieldProps == null ? void 0 : FieldProps.helperText
195
+ ] }) : FieldProps == null ? void 0 : FieldProps.helperText
196
+ }),
197
+ onChange: (event, value3, reason) => {
198
+ if (reason === "clear") {
199
+ onChange2(null);
200
+ }
201
+ onChange2(value3);
202
+ },
203
+ onBlur: onBlur2,
204
+ value: value2 || null
205
+ })
206
+ )
207
+ }
208
+ );
209
+ };
210
+
211
+ // src/lib/Checkbox.tsx
212
+ import { Checkbox } from "@availity/mui-checkbox";
213
+ import { useFormContext as useFormContext3 } from "react-hook-form";
214
+ import { jsx as jsx3 } from "react/jsx-runtime";
215
+ var ControlledCheckbox = (_a) => {
216
+ var _b = _a, {
217
+ name,
218
+ setValueAs,
219
+ disabled,
220
+ onChange,
221
+ onBlur,
222
+ value,
223
+ shouldUnregister,
224
+ deps
225
+ } = _b, rest = __objRest(_b, [
226
+ "name",
227
+ "setValueAs",
228
+ "disabled",
229
+ "onChange",
230
+ "onBlur",
231
+ "value",
232
+ "shouldUnregister",
233
+ "deps"
234
+ ]);
235
+ const { register } = useFormContext3();
236
+ return /* @__PURE__ */ jsx3(
237
+ Checkbox,
238
+ __spreadValues(__spreadValues({}, rest), register(name, {
239
+ setValueAs,
240
+ disabled,
241
+ onChange,
242
+ onBlur,
243
+ value,
244
+ shouldUnregister,
245
+ deps
246
+ }))
247
+ );
248
+ };
249
+
250
+ // src/lib/CodesAutocomplete.tsx
251
+ import { CodesAutocomplete } from "@availity/mui-autocomplete";
252
+ import { useFormContext as useFormContext4, Controller as Controller3 } from "react-hook-form";
253
+ import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
254
+ var ControlledCodesAutocomplete = (_a) => {
255
+ var _b = _a, {
256
+ name,
257
+ defaultValue,
258
+ deps,
259
+ max,
260
+ maxLength,
261
+ onBlur,
262
+ onChange,
263
+ pattern,
264
+ required,
265
+ shouldUnregister,
266
+ validate,
267
+ value,
268
+ FieldProps
269
+ } = _b, rest = __objRest(_b, [
270
+ "name",
271
+ "defaultValue",
272
+ "deps",
273
+ "max",
274
+ "maxLength",
275
+ "onBlur",
276
+ "onChange",
277
+ "pattern",
278
+ "required",
279
+ "shouldUnregister",
280
+ "validate",
281
+ "value",
282
+ "FieldProps"
283
+ ]);
284
+ var _a2;
285
+ const {
286
+ control,
287
+ formState: { errors }
288
+ } = useFormContext4();
289
+ const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
290
+ return /* @__PURE__ */ jsx4(
291
+ Controller3,
292
+ {
293
+ name,
294
+ control,
295
+ defaultValue,
296
+ rules: {
297
+ deps,
298
+ max,
299
+ maxLength,
300
+ onBlur,
301
+ onChange,
302
+ pattern,
303
+ required,
304
+ shouldUnregister,
305
+ validate,
306
+ value
307
+ },
308
+ shouldUnregister,
309
+ render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx4(
310
+ CodesAutocomplete,
311
+ __spreadProps(__spreadValues({}, rest), {
312
+ FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
313
+ error: !!errorMessage,
314
+ helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs3(Fragment3, { children: [
315
+ errorMessage,
316
+ /* @__PURE__ */ jsx4("br", {}),
317
+ FieldProps == null ? void 0 : FieldProps.helperText
318
+ ] }) : FieldProps == null ? void 0 : FieldProps.helperText
319
+ }),
320
+ onChange: (event, value3, reason) => {
321
+ if (reason === "clear") {
322
+ onChange2(null);
323
+ }
324
+ onChange2(value3);
325
+ },
326
+ onBlur: onBlur2,
327
+ value: value2 || null
328
+ })
329
+ )
330
+ }
331
+ );
332
+ };
333
+
33
334
  // src/lib/ControlledForm.tsx
34
335
  import { useForm, FormProvider } from "react-hook-form";
35
- import { jsx } from "react/jsx-runtime";
336
+ import { jsx as jsx5 } from "react/jsx-runtime";
36
337
  var ControlledForm = (_a) => {
37
338
  var _b = _a, { onSubmit, values, schema, validationResolver } = _b, rest = __objRest(_b, ["onSubmit", "values", "schema", "validationResolver"]);
38
339
  const useFormOptions = { values };
@@ -40,8 +341,512 @@ var ControlledForm = (_a) => {
40
341
  useFormOptions.resolver = validationResolver(schema);
41
342
  }
42
343
  const methods = useForm(useFormOptions);
43
- return /* @__PURE__ */ jsx(FormProvider, __spreadProps(__spreadValues({}, methods), { children: /* @__PURE__ */ jsx("form", __spreadValues({ onSubmit: methods.handleSubmit(onSubmit) }, rest)) }));
344
+ return /* @__PURE__ */ jsx5(FormProvider, __spreadProps(__spreadValues({}, methods), { children: /* @__PURE__ */ jsx5("form", __spreadValues({ onSubmit: methods.handleSubmit(onSubmit) }, rest)) }));
345
+ };
346
+
347
+ // src/lib/Datepicker.tsx
348
+ import { Datepicker } from "@availity/mui-datepicker";
349
+ import { useFormContext as useFormContext5, Controller as Controller4 } from "react-hook-form";
350
+ import { jsx as jsx6 } from "react/jsx-runtime";
351
+ var ControlledDatepicker = (_a) => {
352
+ var _b = _a, {
353
+ name,
354
+ defaultValue,
355
+ deps,
356
+ max,
357
+ maxLength,
358
+ min,
359
+ minLength,
360
+ onBlur,
361
+ onChange,
362
+ pattern,
363
+ required,
364
+ shouldUnregister,
365
+ validate,
366
+ value
367
+ } = _b, rest = __objRest(_b, [
368
+ "name",
369
+ "defaultValue",
370
+ "deps",
371
+ "max",
372
+ "maxLength",
373
+ "min",
374
+ "minLength",
375
+ "onBlur",
376
+ "onChange",
377
+ "pattern",
378
+ "required",
379
+ "shouldUnregister",
380
+ "validate",
381
+ "value"
382
+ ]);
383
+ const { control } = useFormContext5();
384
+ return /* @__PURE__ */ jsx6(
385
+ Controller4,
386
+ {
387
+ name,
388
+ control,
389
+ defaultValue,
390
+ rules: {
391
+ deps,
392
+ max,
393
+ maxLength,
394
+ min,
395
+ minLength,
396
+ onBlur,
397
+ onChange,
398
+ pattern,
399
+ required,
400
+ shouldUnregister,
401
+ validate,
402
+ value
403
+ },
404
+ shouldUnregister,
405
+ render: ({ field: { onChange: onChange2, value: value2 } }) => /* @__PURE__ */ jsx6(Datepicker, __spreadProps(__spreadValues({}, rest), { onChange: onChange2, value: value2 || null }))
406
+ }
407
+ );
408
+ };
409
+
410
+ // src/lib/Input.tsx
411
+ import { Input } from "@availity/mui-form-utils";
412
+ import { useFormContext as useFormContext6 } from "react-hook-form";
413
+ import { jsx as jsx7 } from "react/jsx-runtime";
414
+ var ControlledInput = (_a) => {
415
+ var _b = _a, {
416
+ name,
417
+ required,
418
+ maxLength,
419
+ minLength,
420
+ max,
421
+ min,
422
+ pattern,
423
+ validate,
424
+ setValueAs,
425
+ disabled,
426
+ onChange,
427
+ onBlur,
428
+ value,
429
+ shouldUnregister,
430
+ deps
431
+ } = _b, rest = __objRest(_b, [
432
+ "name",
433
+ "required",
434
+ "maxLength",
435
+ "minLength",
436
+ "max",
437
+ "min",
438
+ "pattern",
439
+ "validate",
440
+ "setValueAs",
441
+ "disabled",
442
+ "onChange",
443
+ "onBlur",
444
+ "value",
445
+ "shouldUnregister",
446
+ "deps"
447
+ ]);
448
+ const {
449
+ register,
450
+ formState: { errors }
451
+ } = useFormContext6();
452
+ return /* @__PURE__ */ jsx7(
453
+ Input,
454
+ __spreadValues(__spreadProps(__spreadValues({}, rest), {
455
+ error: !!errors[name],
456
+ required: !!required
457
+ }), register(name, {
458
+ required,
459
+ maxLength,
460
+ minLength,
461
+ max,
462
+ min,
463
+ pattern,
464
+ validate,
465
+ setValueAs,
466
+ disabled,
467
+ onChange,
468
+ onBlur,
469
+ value,
470
+ shouldUnregister,
471
+ deps
472
+ }))
473
+ );
474
+ };
475
+
476
+ // src/lib/OrganizationAutocomplete.tsx
477
+ import { OrganizationAutocomplete } from "@availity/mui-autocomplete";
478
+ import { useFormContext as useFormContext7, Controller as Controller5 } from "react-hook-form";
479
+ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
480
+ var ControlledOrganizationAutocomplete = (_a) => {
481
+ var _b = _a, {
482
+ name,
483
+ defaultValue,
484
+ deps,
485
+ onBlur,
486
+ onChange,
487
+ pattern,
488
+ required,
489
+ shouldUnregister,
490
+ validate,
491
+ value,
492
+ FieldProps
493
+ } = _b, rest = __objRest(_b, [
494
+ "name",
495
+ "defaultValue",
496
+ "deps",
497
+ "onBlur",
498
+ "onChange",
499
+ "pattern",
500
+ "required",
501
+ "shouldUnregister",
502
+ "validate",
503
+ "value",
504
+ "FieldProps"
505
+ ]);
506
+ var _a2;
507
+ const {
508
+ control,
509
+ formState: { errors }
510
+ } = useFormContext7();
511
+ const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
512
+ return /* @__PURE__ */ jsx8(
513
+ Controller5,
514
+ {
515
+ name,
516
+ control,
517
+ defaultValue,
518
+ rules: {
519
+ deps,
520
+ onBlur,
521
+ onChange,
522
+ pattern,
523
+ required,
524
+ shouldUnregister,
525
+ validate,
526
+ value
527
+ },
528
+ shouldUnregister,
529
+ render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx8(
530
+ OrganizationAutocomplete,
531
+ __spreadProps(__spreadValues({}, rest), {
532
+ FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
533
+ error: !!errorMessage,
534
+ helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs4(Fragment4, { children: [
535
+ errorMessage,
536
+ /* @__PURE__ */ jsx8("br", {}),
537
+ FieldProps == null ? void 0 : FieldProps.helperText
538
+ ] }) : FieldProps == null ? void 0 : FieldProps.helperText
539
+ }),
540
+ onChange: (event, value3, reason) => {
541
+ if (reason === "clear") {
542
+ onChange2(null);
543
+ }
544
+ onChange2(value3);
545
+ },
546
+ onBlur: onBlur2,
547
+ value: value2 || null
548
+ })
549
+ )
550
+ }
551
+ );
552
+ };
553
+
554
+ // src/lib/ProviderAutocomplete.tsx
555
+ import { ProviderAutocomplete } from "@availity/mui-autocomplete";
556
+ import { useFormContext as useFormContext8, Controller as Controller6 } from "react-hook-form";
557
+ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
558
+ var ControlledProviderAutocomplete = (_a) => {
559
+ var _b = _a, {
560
+ name,
561
+ defaultValue,
562
+ deps,
563
+ max,
564
+ maxLength,
565
+ min,
566
+ minLength,
567
+ onBlur,
568
+ onChange,
569
+ pattern,
570
+ required,
571
+ shouldUnregister,
572
+ validate,
573
+ value,
574
+ FieldProps
575
+ } = _b, rest = __objRest(_b, [
576
+ "name",
577
+ "defaultValue",
578
+ "deps",
579
+ "max",
580
+ "maxLength",
581
+ "min",
582
+ "minLength",
583
+ "onBlur",
584
+ "onChange",
585
+ "pattern",
586
+ "required",
587
+ "shouldUnregister",
588
+ "validate",
589
+ "value",
590
+ "FieldProps"
591
+ ]);
592
+ var _a2;
593
+ const {
594
+ control,
595
+ formState: { errors }
596
+ } = useFormContext8();
597
+ const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
598
+ return /* @__PURE__ */ jsx9(
599
+ Controller6,
600
+ {
601
+ name,
602
+ control,
603
+ defaultValue,
604
+ rules: {
605
+ deps,
606
+ max,
607
+ maxLength,
608
+ min,
609
+ minLength,
610
+ onBlur,
611
+ onChange,
612
+ pattern,
613
+ required,
614
+ shouldUnregister,
615
+ validate,
616
+ value
617
+ },
618
+ shouldUnregister,
619
+ render: ({ field: { onChange: onChange2, value: value2, onBlur: onBlur2 } }) => /* @__PURE__ */ jsx9(
620
+ ProviderAutocomplete,
621
+ __spreadProps(__spreadValues({}, rest), {
622
+ FieldProps: __spreadProps(__spreadValues({}, FieldProps), {
623
+ error: !!errorMessage,
624
+ helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs5(Fragment5, { children: [
625
+ errorMessage,
626
+ /* @__PURE__ */ jsx9("br", {}),
627
+ FieldProps == null ? void 0 : FieldProps.helperText
628
+ ] }) : FieldProps == null ? void 0 : FieldProps.helperText
629
+ }),
630
+ onChange: (event, value3, reason) => {
631
+ if (reason === "clear") {
632
+ onChange2(null);
633
+ }
634
+ onChange2(value3);
635
+ },
636
+ onBlur: onBlur2,
637
+ value: value2 || null
638
+ })
639
+ )
640
+ }
641
+ );
642
+ };
643
+
644
+ // src/lib/RadioGroup.tsx
645
+ import { RadioGroup } from "@availity/mui-form-utils";
646
+ import { useFormContext as useFormContext9, Controller as Controller7 } from "react-hook-form";
647
+ import { FormControl, FormLabel, FormHelperText } from "@availity/mui-form-utils";
648
+ import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
649
+ var ControlledRadioGroup = (_a) => {
650
+ var _b = _a, {
651
+ name,
652
+ helperText,
653
+ label,
654
+ defaultValue,
655
+ deps,
656
+ onBlur,
657
+ onChange,
658
+ required,
659
+ shouldUnregister,
660
+ value
661
+ } = _b, rest = __objRest(_b, [
662
+ "name",
663
+ "helperText",
664
+ "label",
665
+ "defaultValue",
666
+ "deps",
667
+ "onBlur",
668
+ "onChange",
669
+ "required",
670
+ "shouldUnregister",
671
+ "value"
672
+ ]);
673
+ var _a2;
674
+ const {
675
+ control,
676
+ formState: { errors }
677
+ } = useFormContext9();
678
+ const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
679
+ return /* @__PURE__ */ jsx10(
680
+ Controller7,
681
+ {
682
+ control,
683
+ name,
684
+ defaultValue,
685
+ rules: { deps, onBlur, onChange, required, shouldUnregister, value },
686
+ shouldUnregister,
687
+ render: ({ field }) => /* @__PURE__ */ jsxs6(FormControl, { error: !!errorMessage, children: [
688
+ /* @__PURE__ */ jsx10(FormLabel, { children: label }),
689
+ /* @__PURE__ */ jsx10(RadioGroup, __spreadValues(__spreadValues({}, field), rest)),
690
+ /* @__PURE__ */ jsx10(FormHelperText, { children: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs6(Fragment6, { children: [
691
+ errorMessage,
692
+ /* @__PURE__ */ jsx10("br", {}),
693
+ helperText
694
+ ] }) : helperText })
695
+ ] })
696
+ }
697
+ );
698
+ };
699
+
700
+ // src/lib/Select.tsx
701
+ import { Select } from "@availity/mui-form-utils";
702
+ import { useFormContext as useFormContext10 } from "react-hook-form";
703
+ import { jsx as jsx11 } from "react/jsx-runtime";
704
+ var ControlledSelect = (_a) => {
705
+ var _b = _a, {
706
+ name,
707
+ required,
708
+ maxLength,
709
+ minLength,
710
+ max,
711
+ min,
712
+ pattern,
713
+ validate,
714
+ setValueAs,
715
+ disabled,
716
+ onChange,
717
+ onBlur,
718
+ value,
719
+ shouldUnregister,
720
+ deps
721
+ } = _b, rest = __objRest(_b, [
722
+ "name",
723
+ "required",
724
+ "maxLength",
725
+ "minLength",
726
+ "max",
727
+ "min",
728
+ "pattern",
729
+ "validate",
730
+ "setValueAs",
731
+ "disabled",
732
+ "onChange",
733
+ "onBlur",
734
+ "value",
735
+ "shouldUnregister",
736
+ "deps"
737
+ ]);
738
+ const {
739
+ register,
740
+ formState: { errors }
741
+ } = useFormContext10();
742
+ return /* @__PURE__ */ jsx11(
743
+ Select,
744
+ __spreadValues(__spreadProps(__spreadValues({}, rest), {
745
+ error: !!errors[name],
746
+ required: !!required
747
+ }), register(name, {
748
+ required,
749
+ maxLength,
750
+ minLength,
751
+ max,
752
+ min,
753
+ pattern,
754
+ validate,
755
+ setValueAs,
756
+ disabled,
757
+ onChange,
758
+ onBlur,
759
+ value,
760
+ shouldUnregister,
761
+ deps
762
+ }))
763
+ );
764
+ };
765
+
766
+ // src/lib/TextField.tsx
767
+ import { TextField } from "@availity/mui-textfield";
768
+ import { useFormContext as useFormContext11 } from "react-hook-form";
769
+ import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
770
+ var ControlledTextField = (_a) => {
771
+ var _b = _a, {
772
+ name,
773
+ helperText,
774
+ required,
775
+ maxLength,
776
+ minLength,
777
+ max,
778
+ min,
779
+ pattern,
780
+ validate,
781
+ setValueAs,
782
+ disabled,
783
+ onChange,
784
+ onBlur,
785
+ value,
786
+ shouldUnregister,
787
+ deps
788
+ } = _b, rest = __objRest(_b, [
789
+ "name",
790
+ "helperText",
791
+ "required",
792
+ "maxLength",
793
+ "minLength",
794
+ "max",
795
+ "min",
796
+ "pattern",
797
+ "validate",
798
+ "setValueAs",
799
+ "disabled",
800
+ "onChange",
801
+ "onBlur",
802
+ "value",
803
+ "shouldUnregister",
804
+ "deps"
805
+ ]);
806
+ var _a2;
807
+ const {
808
+ register,
809
+ formState: { errors }
810
+ } = useFormContext11();
811
+ const errorMessage = (_a2 = errors[name]) == null ? void 0 : _a2.message;
812
+ return /* @__PURE__ */ jsx12(
813
+ TextField,
814
+ __spreadProps(__spreadValues(__spreadValues({}, rest), register(name, {
815
+ required,
816
+ maxLength,
817
+ minLength,
818
+ max,
819
+ min,
820
+ pattern,
821
+ validate,
822
+ setValueAs,
823
+ disabled,
824
+ onChange,
825
+ onBlur,
826
+ value,
827
+ shouldUnregister,
828
+ deps
829
+ })), {
830
+ error: !!errors[name],
831
+ helperText: errorMessage && typeof errorMessage === "string" ? /* @__PURE__ */ jsxs7(Fragment7, { children: [
832
+ errorMessage,
833
+ /* @__PURE__ */ jsx12("br", {}),
834
+ helperText
835
+ ] }) : helperText
836
+ })
837
+ );
44
838
  };
45
839
  export {
46
- ControlledForm
840
+ ControlledAsyncAutocomplete,
841
+ ControlledAutocomplete,
842
+ ControlledCheckbox,
843
+ ControlledCodesAutocomplete,
844
+ ControlledDatepicker,
845
+ ControlledForm,
846
+ ControlledInput,
847
+ ControlledOrganizationAutocomplete,
848
+ ControlledProviderAutocomplete,
849
+ ControlledRadioGroup,
850
+ ControlledSelect,
851
+ ControlledTextField
47
852
  };