@ttoss/forms 0.35.1 → 0.35.3

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.
@@ -1,926 +0,0 @@
1
- /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
- import * as React from 'react';
3
- import { FormErrorMessage, FormField, FormFieldPatternFormat, __name, isCnpjValid, isCpfValid } from "./chunk-QJQFXN4B.js";
4
-
5
- // src/Form.tsx
6
- import { Box } from "@ttoss/ui";
7
- import * as React2 from "react";
8
- import { FormProvider } from "react-hook-form";
9
- var Form = /* @__PURE__ */__name(({
10
- children,
11
- onSubmit,
12
- sx,
13
- ...formMethods
14
- }) => {
15
- return /* @__PURE__ */React2.createElement(FormProvider, formMethods, /* @__PURE__ */React2.createElement(Box, {
16
- as: "form",
17
- variant: "forms.form",
18
- onSubmit: formMethods.handleSubmit(data => {
19
- return onSubmit?.(data);
20
- }),
21
- sx
22
- }, children));
23
- }, "Form");
24
-
25
- // src/FormFieldCheckbox.tsx
26
- import { Checkbox } from "@ttoss/ui";
27
- var FormFieldCheckbox = /* @__PURE__ */__name(({
28
- defaultValue = false,
29
- disabled,
30
- ...props
31
- }) => {
32
- const {
33
- label,
34
- name,
35
- labelTooltip,
36
- warning,
37
- sx,
38
- css,
39
- rules,
40
- id,
41
- onBlur,
42
- onChange,
43
- ...checkboxProps
44
- } = props;
45
- return /* @__PURE__ */React.createElement(FormField, {
46
- id,
47
- label,
48
- name,
49
- labelTooltip,
50
- warning,
51
- sx,
52
- css,
53
- defaultValue,
54
- rules,
55
- disabled,
56
- render: /* @__PURE__ */__name(({
57
- field,
58
- fieldState
59
- }) => {
60
- const {
61
- value,
62
- ...fieldWithoutValue
63
- } = field;
64
- return /* @__PURE__ */React.createElement(Checkbox, {
65
- ...checkboxProps,
66
- ...fieldWithoutValue,
67
- onBlur: /* @__PURE__ */__name(e => {
68
- field.onBlur();
69
- onBlur?.(e);
70
- }, "onBlur"),
71
- onChange: /* @__PURE__ */__name(e => {
72
- field.onChange(e);
73
- onChange?.(e);
74
- }, "onChange"),
75
- checked: value,
76
- disabled: disabled ?? field.disabled,
77
- "aria-invalid": !!fieldState.error
78
- });
79
- }, "render")
80
- });
81
- }, "FormFieldCheckbox");
82
-
83
- // src/FormFieldCreditCardNumber.tsx
84
- var FormFieldCreditCardNumber = /* @__PURE__ */__name(({
85
- format = "#### #### #### ####",
86
- placeholder = "1234 1234 1234 1234",
87
- ...formFieldPatternFormatProps
88
- }) => {
89
- return /* @__PURE__ */React.createElement(FormFieldPatternFormat, {
90
- format,
91
- placeholder,
92
- ...formFieldPatternFormatProps
93
- });
94
- }, "FormFieldCreditCardNumber");
95
-
96
- // src/FormFieldCurrencyInput.tsx
97
- import { defineMessages, useI18n } from "@ttoss/react-i18n";
98
-
99
- // src/FormFieldNumericFormat.tsx
100
- import { Input } from "@ttoss/ui";
101
- import { NumericFormat } from "react-number-format";
102
- var FormFieldNumericFormat = /* @__PURE__ */__name(({
103
- disabled,
104
- ...props
105
- }) => {
106
- const {
107
- label,
108
- name,
109
- labelTooltip,
110
- warning,
111
- sx,
112
- css,
113
- rules,
114
- id,
115
- defaultValue,
116
- leadingIcon,
117
- trailingIcon,
118
- auxiliaryCheckbox,
119
- onBlur,
120
- onValueChange,
121
- ...numericFormatProps
122
- } = props;
123
- return /* @__PURE__ */React.createElement(FormField, {
124
- id,
125
- label,
126
- name,
127
- labelTooltip,
128
- warning,
129
- sx,
130
- css,
131
- defaultValue,
132
- rules,
133
- disabled,
134
- auxiliaryCheckbox,
135
- render: /* @__PURE__ */__name(({
136
- field
137
- }) => {
138
- return /* @__PURE__ */React.createElement(NumericFormat, {
139
- ...numericFormatProps,
140
- name: field.name,
141
- value: field.value,
142
- onBlur: /* @__PURE__ */__name(e => {
143
- field.onBlur();
144
- onBlur?.(e);
145
- }, "onBlur"),
146
- onValueChange: /* @__PURE__ */__name((values, sourceInfo) => {
147
- field.onChange(values.floatValue);
148
- onValueChange?.(values, sourceInfo);
149
- }, "onValueChange"),
150
- customInput: Input,
151
- leadingIcon,
152
- trailingIcon,
153
- disabled: disabled ?? field.disabled
154
- });
155
- }, "render")
156
- });
157
- }, "FormFieldNumericFormat");
158
-
159
- // src/FormFieldCurrencyInput.tsx
160
- var messages = defineMessages({
161
- decimalSeparator: {
162
- id: "JnCaDG",
163
- defaultMessage: [{
164
- "type": 0,
165
- "value": "."
166
- }]
167
- },
168
- thousandSeparator: {
169
- id: "0+4wTp",
170
- defaultMessage: [{
171
- "type": 0,
172
- "value": ","
173
- }]
174
- }
175
- });
176
- var FormFieldCurrencyInput = /* @__PURE__ */__name(({
177
- prefix,
178
- decimalSeparator,
179
- thousandSeparator,
180
- ...formFieldNumericFormatProps
181
- }) => {
182
- const {
183
- intl
184
- } = useI18n();
185
- const finalDecimalSeparator = decimalSeparator ?? intl.formatMessage(messages.decimalSeparator);
186
- const finalThousandSeparator = thousandSeparator ?? intl.formatMessage(messages.thousandSeparator);
187
- return /* @__PURE__ */React.createElement(FormFieldNumericFormat, {
188
- fixedDecimalScale: true,
189
- decimalScale: 2,
190
- prefix,
191
- decimalSeparator: finalDecimalSeparator,
192
- thousandSeparator: finalThousandSeparator,
193
- placeholder: `${prefix} 0${finalDecimalSeparator}00`,
194
- allowNegative: false,
195
- ...formFieldNumericFormatProps
196
- });
197
- }, "FormFieldCurrencyInput");
198
-
199
- // src/FormFieldInput.tsx
200
- import { Input as Input2 } from "@ttoss/ui";
201
- var FormFieldInput = /* @__PURE__ */__name(({
202
- defaultValue = "",
203
- disabled,
204
- ...props
205
- }) => {
206
- const {
207
- label,
208
- name,
209
- labelTooltip,
210
- warning,
211
- sx,
212
- css,
213
- rules,
214
- id,
215
- leadingIcon,
216
- trailingIcon,
217
- auxiliaryCheckbox,
218
- onBlur,
219
- onChange,
220
- ...inputProps
221
- } = props;
222
- return /* @__PURE__ */React.createElement(FormField, {
223
- id,
224
- label,
225
- name,
226
- labelTooltip,
227
- warning,
228
- sx,
229
- css,
230
- defaultValue,
231
- rules,
232
- disabled,
233
- auxiliaryCheckbox,
234
- render: /* @__PURE__ */__name(({
235
- field,
236
- fieldState
237
- }) => {
238
- return /* @__PURE__ */React.createElement(Input2, {
239
- ...inputProps,
240
- ...field,
241
- onBlur: /* @__PURE__ */__name(e => {
242
- field.onBlur();
243
- onBlur?.(e);
244
- }, "onBlur"),
245
- onChange: /* @__PURE__ */__name(e => {
246
- field.onChange(e);
247
- onChange?.(e);
248
- }, "onChange"),
249
- leadingIcon,
250
- trailingIcon,
251
- disabled: disabled ?? field.disabled,
252
- "aria-invalid": fieldState.error ? "true" : void 0
253
- });
254
- }, "render")
255
- });
256
- }, "FormFieldInput");
257
-
258
- // src/FormFieldPassword.tsx
259
- import { InputPassword } from "@ttoss/ui";
260
- var FormFieldPassword = /* @__PURE__ */__name(({
261
- defaultValue = "",
262
- disabled,
263
- ...props
264
- }) => {
265
- const {
266
- label,
267
- name,
268
- labelTooltip,
269
- warning,
270
- sx,
271
- css,
272
- rules,
273
- id,
274
- leadingIcon,
275
- auxiliaryCheckbox,
276
- onBlur,
277
- onChange,
278
- ...inputProps
279
- } = props;
280
- return /* @__PURE__ */React.createElement(FormField, {
281
- id,
282
- label,
283
- name,
284
- labelTooltip,
285
- warning,
286
- sx,
287
- css,
288
- defaultValue,
289
- rules,
290
- disabled,
291
- auxiliaryCheckbox,
292
- render: /* @__PURE__ */__name(({
293
- field,
294
- fieldState
295
- }) => {
296
- return /* @__PURE__ */React.createElement(InputPassword, {
297
- ...inputProps,
298
- ...field,
299
- onBlur: /* @__PURE__ */__name(e => {
300
- field.onBlur();
301
- onBlur?.(e);
302
- }, "onBlur"),
303
- onChange: /* @__PURE__ */__name(e => {
304
- field.onChange(e);
305
- onChange?.(e);
306
- }, "onChange"),
307
- leadingIcon,
308
- disabled: disabled ?? field.disabled,
309
- "aria-invalid": fieldState.error ? "true" : void 0
310
- });
311
- }, "render")
312
- });
313
- }, "FormFieldPassword");
314
-
315
- // src/FormFieldRadio.tsx
316
- import { Flex, Label, Radio } from "@ttoss/ui";
317
- var FormFieldRadio = /* @__PURE__ */__name(({
318
- disabled,
319
- options,
320
- ...props
321
- }) => {
322
- const {
323
- label,
324
- name,
325
- labelTooltip,
326
- warning,
327
- sx,
328
- css,
329
- rules,
330
- id,
331
- defaultValue,
332
- onBlur,
333
- onChange,
334
- ...radioProps
335
- } = props;
336
- return /* @__PURE__ */React.createElement(FormField, {
337
- id,
338
- label,
339
- name,
340
- labelTooltip,
341
- warning,
342
- sx,
343
- css,
344
- defaultValue,
345
- rules,
346
- disabled,
347
- render: /* @__PURE__ */__name(({
348
- field
349
- }) => {
350
- return /* @__PURE__ */React.createElement(Flex, {
351
- sx: {
352
- flexDirection: "column",
353
- gap: "1"
354
- }
355
- }, options.map(option => {
356
- const key = `form-field-radio-${name}-${option.value}`;
357
- return /* @__PURE__ */React.createElement(Label, {
358
- key,
359
- sx: {
360
- fontSize: "md"
361
- }
362
- }, /* @__PURE__ */React.createElement(Radio, {
363
- ref: field.ref,
364
- onChange: /* @__PURE__ */__name(e => {
365
- field.onChange(e);
366
- onChange?.(e);
367
- }, "onChange"),
368
- onBlur: /* @__PURE__ */__name(e => {
369
- field.onBlur();
370
- onBlur?.(e);
371
- }, "onBlur"),
372
- value: option.value,
373
- checked: field.value === option.value,
374
- name,
375
- disabled: disabled ?? field.disabled,
376
- ...radioProps
377
- }), option.label);
378
- }));
379
- }, "render")
380
- });
381
- }, "FormFieldRadio");
382
-
383
- // src/FormFieldRadioCard.tsx
384
- import { Box as Box2, Flex as Flex2, Label as Label2, Radio as Radio2, Text } from "@ttoss/ui";
385
- var FormFieldRadioCard = /* @__PURE__ */__name(({
386
- disabled,
387
- ...props
388
- }) => {
389
- const {
390
- label,
391
- name,
392
- labelTooltip,
393
- warning,
394
- sx,
395
- css,
396
- rules,
397
- id,
398
- defaultValue,
399
- options,
400
- direction = "column",
401
- width = "full",
402
- onBlur,
403
- onChange,
404
- ...radioProps
405
- } = props;
406
- return /* @__PURE__ */React.createElement(FormField, {
407
- id,
408
- label,
409
- name,
410
- labelTooltip,
411
- warning,
412
- sx,
413
- css,
414
- defaultValue,
415
- rules,
416
- disabled,
417
- render: /* @__PURE__ */__name(({
418
- field
419
- }) => {
420
- return /* @__PURE__ */React.createElement(Flex2, {
421
- sx: {
422
- flexDirection: direction,
423
- gap: "4"
424
- }
425
- }, options.map(option => {
426
- const key = `form-field-radio-${name}-${option.value}`;
427
- return /* @__PURE__ */React.createElement(Box2, {
428
- key,
429
- sx: {
430
- gap: "2",
431
- width,
432
- border: "md",
433
- borderColor: "display.border.muted.default",
434
- borderRadius: "md"
435
- }
436
- }, /* @__PURE__ */React.createElement(Label2, {
437
- sx: {
438
- fontSize: "md",
439
- width: "100%",
440
- padding: "4"
441
- }
442
- }, /* @__PURE__ */React.createElement(Radio2, {
443
- ...radioProps,
444
- ref: field.ref,
445
- onChange: /* @__PURE__ */__name(e => {
446
- field.onChange(e);
447
- onChange?.(e);
448
- }, "onChange"),
449
- onBlur: /* @__PURE__ */__name(e => {
450
- field.onBlur();
451
- onBlur?.(e);
452
- }, "onBlur"),
453
- value: option.value,
454
- checked: field.value === option.value,
455
- name,
456
- disabled: disabled ?? field.disabled
457
- }), /* @__PURE__ */React.createElement(Flex2, {
458
- sx: {
459
- flexDirection: "column",
460
- gap: "1"
461
- }
462
- }, option.label && /* @__PURE__ */React.createElement(Text, null, option.label), option.description && /* @__PURE__ */React.createElement(Text, {
463
- sx: {
464
- fontSize: "sm"
465
- }
466
- }, option.description))));
467
- }));
468
- }, "render")
469
- });
470
- }, "FormFieldRadioCard");
471
-
472
- // src/FormFieldRadioCardIcony.tsx
473
- import { Box as Box3, Flex as Flex3, Tag, Text as Text2 } from "@ttoss/ui";
474
- import * as React3 from "react";
475
- var FormFieldRadioCardIcony = /* @__PURE__ */__name(({
476
- disabled,
477
- ...props
478
- }) => {
479
- const {
480
- label,
481
- name,
482
- labelTooltip,
483
- warning,
484
- sx,
485
- css,
486
- rules,
487
- id,
488
- defaultValue,
489
- options,
490
- direction = "row",
491
- width = "full"
492
- } = props;
493
- return /* @__PURE__ */React3.createElement(FormField, {
494
- id,
495
- label,
496
- name,
497
- labelTooltip,
498
- warning,
499
- sx,
500
- css,
501
- defaultValue,
502
- rules,
503
- disabled,
504
- render: /* @__PURE__ */__name(({
505
- field
506
- }) => {
507
- const isDisabled = disabled ?? field.disabled;
508
- const handleOptionClick = /* @__PURE__ */__name(optionValue => {
509
- if (!isDisabled) {
510
- field.onChange(optionValue);
511
- field.onBlur();
512
- }
513
- }, "handleOptionClick");
514
- return /* @__PURE__ */React3.createElement(Flex3, {
515
- sx: {
516
- flexDirection: direction,
517
- gap: "4"
518
- }
519
- }, options.map(option => {
520
- const key = `form-field-radio-card-${name}-${option.value}`;
521
- const isSelected = field.value === option.value;
522
- const IconComponent = option.icon;
523
- const tag = option.tag;
524
- return /* @__PURE__ */React3.createElement(Box3, {
525
- key,
526
- onClick: /* @__PURE__ */__name(() => {
527
- return handleOptionClick(option.value);
528
- }, "onClick"),
529
- sx: {
530
- width,
531
- padding: "6",
532
- border: isSelected ? "lg" : "md",
533
- borderColor: isSelected ? "input.background.accent.default" : "input.border.muted.default",
534
- borderRadius: "md",
535
- backgroundColor: isSelected ? "feedback.background.positive.default" : "transparent",
536
- display: "flex",
537
- flexDirection: "column",
538
- alignItems: "center",
539
- justifyContent: "center",
540
- textAlign: "center",
541
- cursor: isDisabled ? "not-allowed" : "pointer",
542
- opacity: isDisabled ? 0.5 : 1,
543
- transition: "all 0.2s ease-in-out"
544
- }
545
- }, IconComponent && /* @__PURE__ */React3.createElement(Box3, {
546
- sx: {
547
- marginBottom: "2",
548
- color: "text.primary"
549
- }
550
- }, /* @__PURE__ */React3.createElement(IconComponent, {
551
- size: 24
552
- })), /* @__PURE__ */React3.createElement(Flex3, {
553
- sx: {
554
- flexDirection: "column",
555
- gap: "1"
556
- }
557
- }, option.label && /* @__PURE__ */React3.createElement(Text2, {
558
- sx: {
559
- fontSize: "lg",
560
- fontWeight: "semibold",
561
- color: "text.primary"
562
- }
563
- }, option.label), option.description && /* @__PURE__ */React3.createElement(Text2, {
564
- sx: {
565
- fontSize: "md",
566
- color: "text.secondary"
567
- }
568
- }, option.description)), tag?.label && /* @__PURE__ */React3.createElement(Tag, {
569
- variant: tag?.variant,
570
- sx: {
571
- px: "3",
572
- mt: "2",
573
- fontSize: "sm",
574
- ...tag?.sx
575
- }
576
- }, tag.label));
577
- }));
578
- }, "render")
579
- });
580
- }, "FormFieldRadioCardIcony");
581
-
582
- // src/FormFieldSelect.tsx
583
- import { Select } from "@ttoss/ui";
584
- var FormFieldSelect = /* @__PURE__ */__name(({
585
- disabled,
586
- ...props
587
- }) => {
588
- const {
589
- label,
590
- name,
591
- labelTooltip,
592
- warning,
593
- sx,
594
- css,
595
- rules,
596
- id,
597
- defaultValue,
598
- onBlur,
599
- onChange,
600
- ...selectProps
601
- } = props;
602
- return /* @__PURE__ */React.createElement(FormField, {
603
- id,
604
- label,
605
- name,
606
- labelTooltip,
607
- warning,
608
- sx,
609
- css,
610
- defaultValue,
611
- rules,
612
- disabled,
613
- render: /* @__PURE__ */__name(({
614
- field,
615
- fieldState
616
- }) => {
617
- return /* @__PURE__ */React.createElement(Select, {
618
- ...selectProps,
619
- ...field,
620
- onBlur: /* @__PURE__ */__name(e => {
621
- field.onBlur();
622
- onBlur?.(e);
623
- }, "onBlur"),
624
- onChange: /* @__PURE__ */__name(newValue => {
625
- field.onChange(newValue);
626
- onChange?.(newValue);
627
- }, "onChange"),
628
- isDisabled: disabled ?? field.disabled,
629
- "aria-invalid": fieldState.error ? "true" : void 0
630
- });
631
- }, "render")
632
- });
633
- }, "FormFieldSelect");
634
-
635
- // src/FormFieldSwitch.tsx
636
- import { Switch } from "@ttoss/ui";
637
- var FormFieldSwitch = /* @__PURE__ */__name(({
638
- disabled,
639
- ...props
640
- }) => {
641
- const {
642
- label,
643
- name,
644
- labelTooltip,
645
- warning,
646
- sx,
647
- css,
648
- rules,
649
- id,
650
- defaultValue,
651
- onBlur,
652
- onChange,
653
- ...switchProps
654
- } = props;
655
- return /* @__PURE__ */React.createElement(FormField, {
656
- id,
657
- label,
658
- name,
659
- labelTooltip,
660
- warning,
661
- sx,
662
- css,
663
- defaultValue,
664
- rules,
665
- disabled,
666
- render: /* @__PURE__ */__name(({
667
- field,
668
- fieldState
669
- }) => {
670
- return /* @__PURE__ */React.createElement(Switch, {
671
- ...switchProps,
672
- ...field,
673
- onBlur: /* @__PURE__ */__name(e => {
674
- field.onBlur();
675
- onBlur?.(e);
676
- }, "onBlur"),
677
- onChange: /* @__PURE__ */__name(e => {
678
- field.onChange(e);
679
- onChange?.(e);
680
- }, "onChange"),
681
- disabled: disabled ?? field.disabled,
682
- "aria-invalid": !!fieldState.error
683
- });
684
- }, "render")
685
- });
686
- }, "FormFieldSwitch");
687
-
688
- // src/FormFieldTextarea.tsx
689
- import { Textarea } from "@ttoss/ui";
690
- var FormFieldTextarea = /* @__PURE__ */__name(({
691
- defaultValue = "",
692
- disabled,
693
- ...props
694
- }) => {
695
- const {
696
- label,
697
- name,
698
- labelTooltip,
699
- warning,
700
- sx,
701
- css,
702
- rules,
703
- id,
704
- auxiliaryCheckbox,
705
- onBlur,
706
- onChange,
707
- ...textareaProps
708
- } = props;
709
- return /* @__PURE__ */React.createElement(FormField, {
710
- id,
711
- label,
712
- name,
713
- labelTooltip,
714
- warning,
715
- sx,
716
- css,
717
- defaultValue,
718
- rules,
719
- disabled,
720
- auxiliaryCheckbox,
721
- render: /* @__PURE__ */__name(({
722
- field,
723
- fieldState
724
- }) => {
725
- return /* @__PURE__ */React.createElement(Textarea, {
726
- ...textareaProps,
727
- ...field,
728
- onBlur: /* @__PURE__ */__name(e => {
729
- field.onBlur();
730
- onBlur?.(e);
731
- }, "onBlur"),
732
- onChange: /* @__PURE__ */__name(e => {
733
- field.onChange(e);
734
- onChange?.(e);
735
- }, "onChange"),
736
- disabled: disabled ?? field.disabled,
737
- "aria-invalid": fieldState.error ? "true" : void 0
738
- });
739
- }, "render")
740
- });
741
- }, "FormFieldTextarea");
742
-
743
- // src/FormGroup.tsx
744
- import { Box as Box4, Flex as Flex4, Text as Text3 } from "@ttoss/ui";
745
- import * as React4 from "react";
746
- var FormGroupLevelsManagerContext = /* @__PURE__ */React4.createContext({
747
- levelsLength: 1,
748
- registerChild: /* @__PURE__ */__name(() => {
749
- return null;
750
- }, "registerChild")
751
- });
752
- var FormGroupLevelsManager = /* @__PURE__ */__name(({
753
- children
754
- }) => {
755
- const [levelsLength, setLevelsLength] = React4.useState(0);
756
- const registerChild = React4.useCallback(level => {
757
- if (level + 1 > levelsLength) {
758
- setLevelsLength(level + 1);
759
- }
760
- }, [levelsLength]);
761
- return /* @__PURE__ */React4.createElement(FormGroupLevelsManagerContext.Provider, {
762
- value: {
763
- levelsLength,
764
- registerChild
765
- }
766
- }, children);
767
- }, "FormGroupLevelsManager");
768
- var FormGroupContext = /* @__PURE__ */React4.createContext({});
769
- var useFormGroup = /* @__PURE__ */__name(() => {
770
- const {
771
- parentLevel
772
- } = React4.useContext(FormGroupContext);
773
- const {
774
- levelsLength
775
- } = React4.useContext(FormGroupLevelsManagerContext);
776
- return {
777
- level: parentLevel,
778
- levelsLength
779
- };
780
- }, "useFormGroup");
781
- var FormGroupWrapper = /* @__PURE__ */__name(({
782
- title,
783
- direction,
784
- children,
785
- name,
786
- ...boxProps
787
- }) => {
788
- const {
789
- level
790
- } = useFormGroup();
791
- const {
792
- registerChild
793
- } = React4.useContext(FormGroupLevelsManagerContext);
794
- React4.useEffect(() => {
795
- if (typeof level === "number") {
796
- registerChild(level);
797
- }
798
- }, [level, registerChild]);
799
- const childrenContainerSx = {
800
- flexDirection: direction || "column",
801
- gap: "1",
802
- width: "100%"
803
- };
804
- return /* @__PURE__ */React4.createElement(Box4, {
805
- "aria-level": level,
806
- ...boxProps,
807
- sx: {
808
- marginTop: level === 0 ? "none" : "4",
809
- marginBottom: "4",
810
- ...boxProps.sx
811
- }
812
- }, title && /* @__PURE__ */React4.createElement(Box4, {
813
- sx: {
814
- marginBottom: "2"
815
- }
816
- }, /* @__PURE__ */React4.createElement(Text3, {
817
- sx: {
818
- fontSize: "2xl",
819
- fontWeight: "bold"
820
- }
821
- }, title)), /* @__PURE__ */React4.createElement(Flex4, {
822
- sx: childrenContainerSx
823
- }, children), name && /* @__PURE__ */React4.createElement(FormErrorMessage, {
824
- name
825
- }));
826
- }, "FormGroupWrapper");
827
- var FormGroup = /* @__PURE__ */__name(props => {
828
- const {
829
- level
830
- } = useFormGroup();
831
- const currentLevel = level === void 0 ? 0 : level + 1;
832
- return /* @__PURE__ */React4.createElement(FormGroupContext.Provider, {
833
- value: {
834
- parentLevel: currentLevel
835
- }
836
- }, currentLevel === 0 ? /* @__PURE__ */React4.createElement(FormGroupLevelsManager, null, /* @__PURE__ */React4.createElement(FormGroupWrapper, props)) : /* @__PURE__ */React4.createElement(FormGroupWrapper, props));
837
- }, "FormGroup");
838
-
839
- // src/yup/i18n.ts
840
- import { defineMessage } from "@ttoss/react-i18n";
841
- import { setLocale } from "yup";
842
- setLocale({
843
- mixed: {
844
- required: defineMessage({
845
- id: "MfWGyg",
846
- defaultMessage: [{
847
- "type": 0,
848
- "value": "Field is required"
849
- }]
850
- }),
851
- notType: /* @__PURE__ */__name(({
852
- type
853
- }) => {
854
- return {
855
- ...defineMessage({
856
- id: "ZhaPt0",
857
- defaultMessage: [{
858
- "type": 0,
859
- "value": "Invalid Value for Field of type "
860
- }, {
861
- "type": 1,
862
- "value": "type"
863
- }]
864
- }),
865
- values: {
866
- type
867
- }
868
- };
869
- }, "notType")
870
- },
871
- string: {
872
- min: /* @__PURE__ */__name(({
873
- min
874
- }) => {
875
- return {
876
- ...defineMessage({
877
- id: "D1C6fR",
878
- defaultMessage: [{
879
- "type": 0,
880
- "value": "Field must be at least "
881
- }, {
882
- "type": 1,
883
- "value": "min"
884
- }, {
885
- "type": 0,
886
- "value": " characters"
887
- }]
888
- }),
889
- values: {
890
- min
891
- }
892
- };
893
- }, "min")
894
- }
895
- });
896
-
897
- // src/yup/schema.ts
898
- import * as yup from "yup";
899
- yup.addMethod(yup.string, "cnpj", function () {
900
- return this.test("valid-cnpj", "Invalid CNPJ", value => {
901
- return isCnpjValid(value);
902
- });
903
- });
904
- yup.addMethod(yup.string, "cpf", function () {
905
- return this.test("valid-cpf", "Invalid CPF", value => {
906
- return isCpfValid(value);
907
- });
908
- });
909
- yup.addMethod(yup.string, "password", function ({
910
- required
911
- } = {}) {
912
- const schema = this.trim();
913
- if (required) {
914
- schema.required("Password is required");
915
- }
916
- return schema.min(8, "Password must be at least 8 characters long");
917
- });
918
-
919
- // src/yup/yup.ts
920
- import * as yup2 from "yup";
921
-
922
- // src/index.ts
923
- import { yupResolver } from "@hookform/resolvers/yup";
924
- import { Controller, FormProvider as FormProvider2, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch } from "react-hook-form";
925
- export * from "react-hook-form";
926
- export { Form, FormFieldCheckbox, FormFieldCreditCardNumber, FormFieldNumericFormat, FormFieldCurrencyInput, FormFieldInput, FormFieldPassword, FormFieldRadio, FormFieldRadioCard, FormFieldRadioCardIcony, FormFieldSelect, FormFieldSwitch, FormFieldTextarea, useFormGroup, FormGroup, yup2 as yup, yupResolver, Controller, FormProvider2 as FormProvider, useController, useFieldArray, useForm, useFormContext, useFormState, useWatch };