@lets-events/react 11.6.5 → 11.7.0

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.
Files changed (76) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +18 -20
  3. package/CHANGELOG.md +6 -0
  4. package/dist/index.css +171 -0
  5. package/dist/index.d.mts +9 -12
  6. package/dist/index.d.ts +9 -12
  7. package/dist/index.js +200 -188
  8. package/dist/index.mjs +205 -191
  9. package/package.json +1 -2
  10. package/src/components/Alert.tsx +303 -303
  11. package/src/components/Avatar.tsx +55 -55
  12. package/src/components/Badge.tsx +125 -125
  13. package/src/components/Box.tsx +3 -3
  14. package/src/components/Button/index.tsx +16 -16
  15. package/src/components/Button/styledComponents.ts +287 -287
  16. package/src/components/ButtonGroup.tsx +484 -484
  17. package/src/components/Calendar/index.tsx +136 -136
  18. package/src/components/Calendar/styledComponents.ts +209 -209
  19. package/src/components/Card.tsx +48 -48
  20. package/src/components/CheckboxGroup.tsx +176 -176
  21. package/src/components/Container.tsx +39 -39
  22. package/src/components/Drawer/index.tsx +48 -48
  23. package/src/components/Drawer/styledComponents.ts +46 -46
  24. package/src/components/Dropdown.tsx +302 -302
  25. package/src/components/Filter.tsx +164 -164
  26. package/src/components/Flex.tsx +118 -118
  27. package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
  28. package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
  29. package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -45
  30. package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
  31. package/src/components/FormFields/AddressFormFields/index.tsx +141 -139
  32. package/src/components/FormFields/BirthDateFormField.tsx +85 -87
  33. package/src/components/FormFields/CNPJFormField.tsx +87 -89
  34. package/src/components/FormFields/CPFFormField.tsx +77 -79
  35. package/src/components/FormFields/CheckboxGroupFormField.tsx +90 -90
  36. package/src/components/FormFields/Form.tsx +28 -29
  37. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +40 -42
  38. package/src/components/FormFields/MultiSelectFormField.tsx +55 -59
  39. package/src/components/FormFields/PhoneFormField.tsx +40 -130
  40. package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
  41. package/src/components/FormFields/SelectFormField.tsx +93 -93
  42. package/src/components/FormFields/TextAreaFormField.tsx +48 -48
  43. package/src/components/FormFields/TextFormField.tsx +107 -76
  44. package/src/components/FormFields/{ErrorFormMessage.tsx → subComponents/ErrorFormMessage.tsx} +36 -36
  45. package/src/components/FormFields/{FormLabel.tsx → subComponents/FormLabel.tsx} +29 -29
  46. package/src/components/FormFields/utils/validation.ts +20 -0
  47. package/src/components/Grid.tsx +137 -137
  48. package/src/components/Icon.tsx +47 -47
  49. package/src/components/MenuDropdown/index.tsx +30 -30
  50. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  51. package/src/components/Modal.tsx +90 -90
  52. package/src/components/MultiSelect.tsx +218 -218
  53. package/src/components/RadioGroup.tsx +210 -210
  54. package/src/components/Section.tsx +33 -33
  55. package/src/components/Step.tsx +164 -164
  56. package/src/components/Switch.tsx +108 -108
  57. package/src/components/Text.tsx +38 -38
  58. package/src/components/TextField.tsx +316 -312
  59. package/src/components/TextareaField.tsx +128 -128
  60. package/src/components/TimePicker.tsx +298 -298
  61. package/src/components/Toast/components/ToastItem.tsx +41 -41
  62. package/src/components/Toast/components/ToastProvider.tsx +63 -63
  63. package/src/components/Toast/hooks/useToast.ts +12 -12
  64. package/src/components/Toast/index.tsx +5 -5
  65. package/src/components/Toast/styles/index.ts +135 -135
  66. package/src/components/Toast/types/index.ts +46 -46
  67. package/src/components/Tooltip/index.tsx +66 -66
  68. package/src/components/Tooltip/styles.ts +77 -77
  69. package/src/hooks/useCountries.ts +41 -41
  70. package/src/hooks/useOnClickOutside.tsx +20 -20
  71. package/src/index.tsx +54 -54
  72. package/src/styles/index.ts +38 -38
  73. package/src/types/typographyValues.ts +178 -178
  74. package/src/utils/getNestedValue.ts +3 -3
  75. package/src/utils/states.ts +29 -29
  76. package/tsconfig.json +3 -3
package/dist/index.mjs CHANGED
@@ -2655,7 +2655,10 @@ var TextFieldStyled = styled(TextFieldRadix.Root, {
2655
2655
  }
2656
2656
  }
2657
2657
  }
2658
- ]
2658
+ ],
2659
+ defaultVariants: {
2660
+ typography: "labelSmall"
2661
+ }
2659
2662
  });
2660
2663
  var TextFieldSlotStyled = styled(TextFieldRadix.Slot, {
2661
2664
  display: "flex",
@@ -2690,7 +2693,17 @@ var InputAddon = styled(TextStyle, {
2690
2693
  display: "flex",
2691
2694
  flexWrap: "nowrap",
2692
2695
  alignItems: "center",
2693
- lineHeight: 1
2696
+ lineHeight: 1,
2697
+ variants: {
2698
+ color: {
2699
+ default: {
2700
+ borderColor: "$dark300"
2701
+ },
2702
+ error: {
2703
+ borderColor: "$error400"
2704
+ }
2705
+ }
2706
+ }
2694
2707
  });
2695
2708
  var maskFormat = format;
2696
2709
  var maskUnformat = unformat;
@@ -2719,7 +2732,7 @@ var TextField = React.forwardRef(
2719
2732
  ]);
2720
2733
  const maskRef = mask ? useMask(mask) : void 0;
2721
2734
  return /* @__PURE__ */ jsxs(Flex2, { gap: "0", css: { width: "100%" }, children: [
2722
- !!addon && /* @__PURE__ */ jsx7(InputAddon, { typography: "labelSmall", children: addon }),
2735
+ !!addon && /* @__PURE__ */ jsx7(InputAddon, { color, typography: "labelSmall", children: addon }),
2723
2736
  /* @__PURE__ */ jsxs(
2724
2737
  TextFieldStyled,
2725
2738
  __spreadProps(__spreadValues({
@@ -2782,27 +2795,17 @@ function TextFieldSlot(_a) {
2782
2795
  }, props), {
2783
2796
  color: void 0
2784
2797
  });
2785
- return onClick ? /* @__PURE__ */ jsx7(
2798
+ return /* @__PURE__ */ jsx7(
2786
2799
  TextFieldSlotStyled,
2787
2800
  __spreadProps(__spreadValues({}, sharedStyles), {
2788
2801
  style: {
2789
2802
  float: position === "flex-start" ? "left" : "right",
2790
2803
  order: position === "flex-start" ? 0 : 2,
2791
2804
  textAlign,
2792
- zIndex: 2,
2793
- cursor: "pointer"
2794
- },
2795
- onClick: () => onClick(),
2796
- children
2797
- })
2798
- ) : /* @__PURE__ */ jsx7(
2799
- TextFieldSlotStyled,
2800
- __spreadProps(__spreadValues({}, sharedStyles), {
2801
- style: {
2802
- float: position === "flex-start" ? "left" : "right",
2803
- order: position === "flex-start" ? 0 : 2,
2804
- textAlign
2805
+ zIndex: onClick ? 2 : void 0,
2806
+ cursor: onClick ? "pointer" : void 0
2805
2807
  },
2808
+ onClick,
2806
2809
  children
2807
2810
  })
2808
2811
  );
@@ -3814,8 +3817,8 @@ import { DayPicker } from "react-day-picker";
3814
3817
  function buildFormatLongFn(args) {
3815
3818
  return (options = {}) => {
3816
3819
  const width = options.width ? String(options.width) : args.defaultWidth;
3817
- const format3 = args.formats[width] || args.formats[args.defaultWidth];
3818
- return format3;
3820
+ const format4 = args.formats[width] || args.formats[args.defaultWidth];
3821
+ return format4;
3819
3822
  };
3820
3823
  }
3821
3824
 
@@ -4510,11 +4513,11 @@ var formatRelativeLocale2 = {
4510
4513
  other: "P"
4511
4514
  };
4512
4515
  var formatRelative2 = (token, date, _baseDate, _options) => {
4513
- const format3 = formatRelativeLocale2[token];
4514
- if (typeof format3 === "function") {
4515
- return format3(date);
4516
+ const format4 = formatRelativeLocale2[token];
4517
+ if (typeof format4 === "function") {
4518
+ return format4(date);
4516
4519
  }
4517
- return format3;
4520
+ return format4;
4518
4521
  };
4519
4522
 
4520
4523
  // ../../node_modules/date-fns/locale/pt-BR/_lib/localize.js
@@ -5782,14 +5785,14 @@ function isProtectedDayOfYearToken(token) {
5782
5785
  function isProtectedWeekYearToken(token) {
5783
5786
  return weekYearTokenRE.test(token);
5784
5787
  }
5785
- function warnOrThrowProtectedError(token, format3, input) {
5786
- const _message = message(token, format3, input);
5788
+ function warnOrThrowProtectedError(token, format4, input) {
5789
+ const _message = message(token, format4, input);
5787
5790
  console.warn(_message);
5788
5791
  if (throwTokens.includes(token)) throw new RangeError(_message);
5789
5792
  }
5790
- function message(token, format3, input) {
5793
+ function message(token, format4, input) {
5791
5794
  const subject = token[0] === "Y" ? "years" : "days of the month";
5792
- return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format3}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
5795
+ return `Use \`${token.toLowerCase()}\` instead of \`${token}\` (in \`${format4}\`) for formatting ${subject} to the input \`${input}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
5793
5796
  }
5794
5797
 
5795
5798
  // ../../node_modules/date-fns/format.js
@@ -9633,7 +9636,7 @@ function Section(_a) {
9633
9636
  return /* @__PURE__ */ jsx29(SectionStyled, __spreadProps(__spreadValues({}, props), { children }));
9634
9637
  }
9635
9638
 
9636
- // src/components/FormFields/ErrorFormMessage.tsx
9639
+ // src/components/FormFields/subComponents/ErrorFormMessage.tsx
9637
9640
  import { faXmarkCircle } from "@fortawesome/free-solid-svg-icons";
9638
9641
  import { FontAwesomeIcon as FontAwesomeIcon4 } from "@fortawesome/react-fontawesome";
9639
9642
  import { jsx as jsx30, jsxs as jsxs15 } from "react/jsx-runtime";
@@ -9648,7 +9651,7 @@ var ErrorFormMessage = ({ message: message2 }) => {
9648
9651
  ] });
9649
9652
  };
9650
9653
 
9651
- // src/components/FormFields/FormLabel.tsx
9654
+ // src/components/FormFields/subComponents/FormLabel.tsx
9652
9655
  import { jsx as jsx31, jsxs as jsxs16 } from "react/jsx-runtime";
9653
9656
  var FormLabel = ({
9654
9657
  name,
@@ -9717,38 +9720,65 @@ var TextAreaFormField = (_a) => {
9717
9720
  };
9718
9721
 
9719
9722
  // src/components/FormFields/TextFormField.tsx
9720
- import { useFormContext as useFormContext2 } from "react-hook-form";
9721
-
9722
- // src/utils/getNestedValue.ts
9723
- function getNestedValue(obj, path) {
9724
- return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
9725
- }
9726
-
9727
- // src/components/FormFields/TextFormField.tsx
9723
+ import {
9724
+ useController
9725
+ } from "react-hook-form";
9726
+ import { useCallback as useCallback3, useMemo as useMemo2 } from "react";
9727
+ import { format as format3, unformat as unformat2 } from "@react-input/mask";
9728
9728
  import { jsx as jsx33, jsxs as jsxs18 } from "react/jsx-runtime";
9729
- var TextFormField = ({
9730
- name,
9731
- label,
9732
- required,
9733
- placeholder,
9734
- mask,
9735
- validation,
9736
- validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
9737
- disabled = false,
9738
- value,
9739
- onChange
9740
- }) => {
9741
- const {
9742
- register,
9743
- formState: { errors }
9744
- } = useFormContext2();
9745
- const validationRules = __spreadValues({
9746
- required: required ? validationErrorMessage : false
9747
- }, validation);
9748
- const _a = register(name, validationRules), { ref } = _a, restFieldProps = __objRest(_a, ["ref"]);
9749
- const fieldError = getNestedValue(errors, name);
9729
+ var TextFormField = (_a) => {
9730
+ var _b = _a, {
9731
+ name,
9732
+ label,
9733
+ required,
9734
+ mask,
9735
+ validate,
9736
+ validationErrorMessage = "Este campo \xE9 obrigat\xF3rio.",
9737
+ onChange,
9738
+ valueFormatter
9739
+ } = _b, inputProps = __objRest(_b, [
9740
+ "name",
9741
+ "label",
9742
+ "required",
9743
+ "mask",
9744
+ "validate",
9745
+ "validationErrorMessage",
9746
+ "onChange",
9747
+ "valueFormatter"
9748
+ ]);
9749
+ const handleValidate = useCallback3(
9750
+ (value) => {
9751
+ var _a2;
9752
+ if (!required && value.trim() === "") return true;
9753
+ return (_a2 = validate == null ? void 0 : validate(value)) != null ? _a2 : true;
9754
+ },
9755
+ [validate, required]
9756
+ );
9757
+ const { field, fieldState } = useController({
9758
+ name,
9759
+ rules: {
9760
+ required: required ? validationErrorMessage : false,
9761
+ validate: handleValidate,
9762
+ onChange
9763
+ },
9764
+ defaultValue: ""
9765
+ });
9766
+ const fieldError = fieldState.error;
9750
9767
  const haveError = !!fieldError;
9751
9768
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
9769
+ const { value: formValue, onChange: formChange } = field;
9770
+ const formattedValue = useMemo2(() => {
9771
+ let value = formValue;
9772
+ if (valueFormatter) value = valueFormatter.format(value);
9773
+ if (mask) value = format3(value != null ? value : "", mask);
9774
+ return value;
9775
+ }, [formValue, valueFormatter, mask]);
9776
+ const handleChange = (e) => {
9777
+ let value = e.target.value;
9778
+ if (mask) value = unformat2(value, mask);
9779
+ if (valueFormatter) value = valueFormatter.unformat(value);
9780
+ formChange(value);
9781
+ };
9752
9782
  return /* @__PURE__ */ jsxs18(Flex2, { direction: "column", children: [
9753
9783
  label && /* @__PURE__ */ jsx33(
9754
9784
  FormLabel,
@@ -9761,16 +9791,13 @@ var TextFormField = ({
9761
9791
  ),
9762
9792
  /* @__PURE__ */ jsx33(
9763
9793
  TextField,
9764
- __spreadProps(__spreadValues({
9794
+ __spreadProps(__spreadValues(__spreadValues({
9765
9795
  mask,
9766
- placeholder,
9767
- disabled,
9768
9796
  color: haveError ? "error" : "default",
9769
9797
  "aria-labelledby": `${name}-label`
9770
- }, restFieldProps), {
9771
- ref,
9772
- onChange,
9773
- value
9798
+ }, inputProps), field), {
9799
+ onChange: handleChange,
9800
+ value: formattedValue
9774
9801
  })
9775
9802
  ),
9776
9803
  /* @__PURE__ */ jsx33(ErrorFormMessage, { message: errorMsg })
@@ -9786,19 +9813,17 @@ import { jsx as jsx34 } from "react/jsx-runtime";
9786
9813
  var Form = (_a) => {
9787
9814
  var _b = _a, {
9788
9815
  onSubmit,
9789
- children,
9790
- methods
9816
+ children
9791
9817
  } = _b, props = __objRest(_b, [
9792
9818
  "onSubmit",
9793
- "children",
9794
- "methods"
9819
+ "children"
9795
9820
  ]);
9796
- const formMethods = methods || useForm(props);
9821
+ const formMethods = useForm(props);
9797
9822
  return /* @__PURE__ */ jsx34(FormProvider, __spreadProps(__spreadValues({}, formMethods), { children: /* @__PURE__ */ jsx34("form", { onSubmit: formMethods.handleSubmit(onSubmit), children }) }));
9798
9823
  };
9799
9824
 
9800
9825
  // src/components/FormFields/MultiSelectFormField.tsx
9801
- import { useController, useFormContext as useFormContext3 } from "react-hook-form";
9826
+ import { useController as useController2 } from "react-hook-form";
9802
9827
  import { jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
9803
9828
  var MultiSelectFormField = (_a) => {
9804
9829
  var _b = _a, {
@@ -9811,10 +9836,7 @@ var MultiSelectFormField = (_a) => {
9811
9836
  "required"
9812
9837
  ]);
9813
9838
  var _a2;
9814
- const {
9815
- formState: { errors }
9816
- } = useFormContext3();
9817
- const { field } = useController({
9839
+ const { field, fieldState } = useController2({
9818
9840
  name,
9819
9841
  rules: {
9820
9842
  required
@@ -9822,8 +9844,8 @@ var MultiSelectFormField = (_a) => {
9822
9844
  defaultValue: []
9823
9845
  });
9824
9846
  const { value, onChange, ref, onBlur, disabled } = field;
9825
- const haveError = !!errors[name];
9826
- const errorMsg = (_a2 = errors[name]) == null ? void 0 : _a2.message;
9847
+ const haveError = !!fieldState.error;
9848
+ const errorMsg = (_a2 = fieldState.error) == null ? void 0 : _a2.message;
9827
9849
  const handleChange = (v) => {
9828
9850
  onChange(v);
9829
9851
  };
@@ -9850,50 +9872,51 @@ var MultiSelectFormField = (_a) => {
9850
9872
  ] });
9851
9873
  };
9852
9874
 
9875
+ // src/components/FormFields/utils/validation.ts
9876
+ var minMaxLength = (min, max, errorMsg) => (value) => {
9877
+ console.log(value);
9878
+ var length = value.length;
9879
+ return length > max || length < min ? errorMsg : true;
9880
+ };
9881
+
9853
9882
  // src/components/FormFields/PhoneFormField.tsx
9854
- import { useFormContext as useFormContext4 } from "react-hook-form";
9855
- import { jsx as jsx36, jsxs as jsxs20 } from "react/jsx-runtime";
9856
- var PhoneFormField = (_a) => {
9857
- var _b = _a, {
9858
- name,
9859
- label,
9860
- required,
9861
- defaultCountry = "br"
9862
- } = _b, props = __objRest(_b, [
9863
- "name",
9864
- "label",
9865
- "required",
9866
- "defaultCountry"
9867
- ]);
9868
- var _a2;
9869
- const {
9870
- register,
9871
- formState: { errors },
9872
- setValue,
9873
- watch
9874
- } = useFormContext4();
9875
- const haveError = !!errors[name];
9876
- const errorMsg = (_a2 = errors[name]) == null ? void 0 : _a2.message;
9877
- const handlePhoneChange = (phone) => {
9878
- setValue(name, phone);
9879
- };
9880
- return /* @__PURE__ */ jsxs20(Flex2, { direction: "column", children: [
9881
- /* @__PURE__ */ jsx36(
9882
- FormLabel,
9883
- {
9884
- name,
9885
- label,
9886
- required,
9887
- haveError
9883
+ import { jsx as jsx36 } from "react/jsx-runtime";
9884
+ var PhoneFormField = ({
9885
+ name,
9886
+ label,
9887
+ required
9888
+ }) => {
9889
+ return /* @__PURE__ */ jsx36(
9890
+ TextFormField,
9891
+ {
9892
+ name,
9893
+ label,
9894
+ required,
9895
+ addon: "+ 55",
9896
+ mask: {
9897
+ mask: "(__) _____-____}",
9898
+ replacement: { _: /\d/ }
9899
+ },
9900
+ placeholder: "(00) 00000-0000",
9901
+ type: "tel",
9902
+ validate: minMaxLength(12, 13, "Telefone inv\xE1lido"),
9903
+ valueFormatter: {
9904
+ format(v) {
9905
+ if (!v || v === "") return v;
9906
+ return v.replace(/\b55/, "");
9907
+ },
9908
+ unformat(v) {
9909
+ if (!v || v === "") return v;
9910
+ return "55" + v;
9911
+ }
9888
9912
  }
9889
- ),
9890
- /* @__PURE__ */ jsx36(ErrorFormMessage, { message: errorMsg })
9891
- ] });
9913
+ }
9914
+ );
9892
9915
  };
9893
9916
 
9894
9917
  // src/components/FormFields/CPFFormField.tsx
9895
- import { useFormContext as useFormContext5, useWatch } from "react-hook-form";
9896
- import { jsx as jsx37, jsxs as jsxs21 } from "react/jsx-runtime";
9918
+ import { useFormContext as useFormContext4, useWatch } from "react-hook-form";
9919
+ import { jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
9897
9920
  var isValidCPF = (cpf) => {
9898
9921
  cpf = cpf.replace(/[^\d]+/g, "");
9899
9922
  if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) return false;
@@ -9917,9 +9940,9 @@ var CPFFormField = ({
9917
9940
  validationErrorMessage,
9918
9941
  foreignerLabel
9919
9942
  }) => {
9920
- const { control, setValue } = useFormContext5();
9943
+ const { control, setValue } = useFormContext4();
9921
9944
  const foreigner = useWatch({ name: "foreigner", control });
9922
- return /* @__PURE__ */ jsxs21(Flex2, { direction: "column", children: [
9945
+ return /* @__PURE__ */ jsxs20(Flex2, { direction: "column", children: [
9923
9946
  /* @__PURE__ */ jsx37(
9924
9947
  TextFormField,
9925
9948
  {
@@ -9931,11 +9954,9 @@ var CPFFormField = ({
9931
9954
  mask: "___.___.___-__",
9932
9955
  replacement: { _: /[0-9]/ }
9933
9956
  },
9934
- validation: {
9935
- validate: (value) => {
9936
- if (!required || foreigner) return true;
9937
- return isValidCPF(value) || validationErrorMessage;
9938
- }
9957
+ validate: (value) => {
9958
+ if (!required || foreigner) return true;
9959
+ return isValidCPF(value) || validationErrorMessage;
9939
9960
  },
9940
9961
  disabled: foreigner
9941
9962
  }
@@ -10018,12 +10039,10 @@ var CNPJFormField = ({
10018
10039
  mask: "__.___.___/____-__",
10019
10040
  replacement: { _: /[0-9]/ }
10020
10041
  },
10021
- validation: {
10022
- validate: (value) => {
10023
- const isEmpty = value.replace(matchesNonDigit, "").length === 0;
10024
- if (!required && isEmpty) return true;
10025
- return isValidCNPJ(value) || validationErrorMessage;
10026
- }
10042
+ validate: (value) => {
10043
+ const isEmpty = value.replace(matchesNonDigit, "").length === 0;
10044
+ if (!required && isEmpty) return true;
10045
+ return isValidCNPJ(value) || validationErrorMessage;
10027
10046
  }
10028
10047
  }
10029
10048
  );
@@ -10076,12 +10095,10 @@ var BirthDateFormField = ({
10076
10095
  mask: "__/__/____",
10077
10096
  replacement: { _: /[0-9]/ }
10078
10097
  },
10079
- validation: {
10080
- validate: (value) => {
10081
- const isEmpty = value.replace(/[^\d]+/g, "").length === 0;
10082
- if (!required && isEmpty) return true;
10083
- return isValidBirthDate(value, language) || validationErrorMessage;
10084
- }
10098
+ validate: (value) => {
10099
+ const isEmpty = value.replace(/[^\d]+/g, "").length === 0;
10100
+ if (!required && isEmpty) return true;
10101
+ return isValidBirthDate(value, language) || validationErrorMessage;
10085
10102
  }
10086
10103
  }
10087
10104
  );
@@ -10111,24 +10128,28 @@ var IdentityDocumentNumberFormField = ({
10111
10128
  mask: "__.___.___-_",
10112
10129
  replacement: { _: /[0-9]/ }
10113
10130
  },
10114
- validation: {
10115
- validate: (value) => {
10116
- const isEmpty = value.replace(/[^\d]/g, "").length === 0;
10117
- if (!required && isEmpty) return true;
10118
- return isValidRG(value) || validationErrorMessage;
10119
- }
10131
+ validate: (value) => {
10132
+ const isEmpty = value.replace(/[^\d]/g, "").length === 0;
10133
+ if (!required && isEmpty) return true;
10134
+ return isValidRG(value) || validationErrorMessage;
10120
10135
  }
10121
10136
  }
10122
10137
  );
10123
10138
  };
10124
10139
 
10125
10140
  // src/components/FormFields/AddressFormFields/index.tsx
10126
- import { useEffect as useEffect5 } from "react";
10127
- import { useFormContext as useFormContext9, useWatch as useWatch2, useFormState } from "react-hook-form";
10141
+ import { useFormContext as useFormContext7, useWatch as useWatch2, useFormState } from "react-hook-form";
10142
+
10143
+ // src/components/FormFields/SelectFormField.tsx
10144
+ import { useFormContext as useFormContext5, Controller } from "react-hook-form";
10145
+
10146
+ // src/utils/getNestedValue.ts
10147
+ function getNestedValue(obj, path) {
10148
+ return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
10149
+ }
10128
10150
 
10129
10151
  // src/components/FormFields/SelectFormField.tsx
10130
- import { useFormContext as useFormContext6, Controller } from "react-hook-form";
10131
- import { jsx as jsx41, jsxs as jsxs22 } from "react/jsx-runtime";
10152
+ import { jsx as jsx41, jsxs as jsxs21 } from "react/jsx-runtime";
10132
10153
  var SelectFormField = ({
10133
10154
  name,
10134
10155
  label,
@@ -10142,14 +10163,14 @@ var SelectFormField = ({
10142
10163
  const {
10143
10164
  control,
10144
10165
  formState: { errors }
10145
- } = useFormContext6();
10166
+ } = useFormContext5();
10146
10167
  const fieldError = getNestedValue(errors, name);
10147
10168
  const haveError = !!fieldError;
10148
10169
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
10149
10170
  const validationRules = __spreadValues({
10150
10171
  required: required ? validationErrorMessage : false
10151
10172
  }, validation);
10152
- return /* @__PURE__ */ jsxs22(Flex2, { direction: "column", children: [
10173
+ return /* @__PURE__ */ jsxs21(Flex2, { direction: "column", children: [
10153
10174
  /* @__PURE__ */ jsx41(
10154
10175
  FormLabel,
10155
10176
  {
@@ -10245,19 +10266,15 @@ function CountryFormField({
10245
10266
  }
10246
10267
 
10247
10268
  // src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx
10248
- import { useController as useController3, useFormContext as useFormContext7 } from "react-hook-form";
10249
10269
  import { jsx as jsx43 } from "react/jsx-runtime";
10250
10270
  var PostalCodeFormField = ({
10251
10271
  name,
10252
10272
  label,
10253
10273
  required,
10254
10274
  placeholder,
10255
- validationErrorMessage
10275
+ validationErrorMessage,
10276
+ onChange
10256
10277
  }) => {
10257
- const { control } = useFormContext7();
10258
- const {
10259
- field: { onChange, value }
10260
- } = useController3({ name, control });
10261
10278
  return /* @__PURE__ */ jsx43(
10262
10279
  TextFormField,
10263
10280
  {
@@ -10269,14 +10286,11 @@ var PostalCodeFormField = ({
10269
10286
  mask: "_____-___",
10270
10287
  replacement: { _: /[0-9]/ }
10271
10288
  },
10272
- value,
10273
- onChange,
10274
- validation: {
10275
- validate: (value2) => {
10276
- const isEmpty = value2.replace(/[^\d]/g, "").length === 0;
10277
- if (!required && isEmpty) return true;
10278
- return /^\d{8}$/.test(value2.replace(/\D/g, "")) || validationErrorMessage;
10279
- }
10289
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
10290
+ validate: (value) => {
10291
+ const isEmpty = value.replace(/[^\d]/g, "").length === 0;
10292
+ if (!required && isEmpty) return true;
10293
+ return /^\d{8}$/.test(value.replace(/\D/g, "")) || validationErrorMessage;
10280
10294
  }
10281
10295
  }
10282
10296
  );
@@ -10334,7 +10348,7 @@ function StateFormField({
10334
10348
 
10335
10349
  // src/components/FormFields/AddressFormFields/CityFormField.tsx
10336
10350
  import { useEffect as useEffect4, useState as useState8 } from "react";
10337
- import { useFormContext as useFormContext8, Controller as Controller2 } from "react-hook-form";
10351
+ import { useFormContext as useFormContext6, Controller as Controller2 } from "react-hook-form";
10338
10352
  import { Fragment as Fragment3, jsx as jsx45 } from "react/jsx-runtime";
10339
10353
  function CityFormField({
10340
10354
  name,
@@ -10344,7 +10358,7 @@ function CityFormField({
10344
10358
  isBrazil,
10345
10359
  placeholder
10346
10360
  }) {
10347
- const { control, watch } = useFormContext8();
10361
+ const { control, watch } = useFormContext6();
10348
10362
  const selectedState = watch(stateName);
10349
10363
  const [cities, setCities] = useState8([]);
10350
10364
  const [loading, setLoading] = useState8(false);
@@ -10419,7 +10433,7 @@ function CityFormField({
10419
10433
  }
10420
10434
 
10421
10435
  // src/components/FormFields/AddressFormFields/index.tsx
10422
- import { jsx as jsx46, jsxs as jsxs23 } from "react/jsx-runtime";
10436
+ import { jsx as jsx46, jsxs as jsxs22 } from "react/jsx-runtime";
10423
10437
  function getNestedValue2(obj, path) {
10424
10438
  return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
10425
10439
  }
@@ -10448,29 +10462,28 @@ function AddressFormFields({
10448
10462
  required,
10449
10463
  layout = "column"
10450
10464
  }) {
10451
- const { control, setValue } = useFormContext9();
10465
+ const { control, setValue } = useFormContext7();
10452
10466
  const { errors } = useFormState({ control });
10453
10467
  const selectedCountry = useWatch2({ control, name: `${name}.country` });
10454
- const cep = useWatch2({ control, name: `${name}.zip_code` });
10455
10468
  const isBrazil = selectedCountry === "Brasil";
10456
10469
  const addressErrors = getNestedValue2(errors, name);
10457
10470
  const haveError = !!addressErrors;
10458
- useEffect5(() => {
10471
+ const handleCEPChange = (cep) => {
10472
+ if (!isBrazil) return;
10459
10473
  const cleanedCep = cep == null ? void 0 : cep.replace(/\D/g, "");
10460
- if (isBrazil && (cleanedCep == null ? void 0 : cleanedCep.length) === 8) {
10461
- fetch(`https://viacep.com.br/ws/${cleanedCep}/json`).then((res) => res.json()).then((data) => {
10462
- if (!data.erro) {
10463
- setValue(`${name}.street`, data.logradouro || "");
10464
- setValue(`${name}.neighborhood`, data.bairro || "");
10465
- setValue(`${name}.city`, data.localidade || "");
10466
- setValue(`${name}.state`, data.uf || "");
10467
- }
10468
- }).catch(() => {
10469
- console.error("Erro ao buscar CEP");
10470
- });
10471
- }
10472
- }, [cep, isBrazil]);
10473
- return /* @__PURE__ */ jsxs23(AddressContainerStyled, { layout, children: [
10474
+ if ((cleanedCep == null ? void 0 : cleanedCep.length) !== 8) return;
10475
+ fetch(`https://viacep.com.br/ws/${cleanedCep}/json`).then((res) => res.json()).then((data) => {
10476
+ if (!data.erro) {
10477
+ setValue(`${name}.street`, data.logradouro || "");
10478
+ setValue(`${name}.neighborhood`, data.bairro || "");
10479
+ setValue(`${name}.city`, data.localidade || "");
10480
+ setValue(`${name}.state`, data.uf || "");
10481
+ }
10482
+ }).catch(() => {
10483
+ console.error("Erro ao buscar CEP");
10484
+ });
10485
+ };
10486
+ return /* @__PURE__ */ jsxs22(AddressContainerStyled, { layout, children: [
10474
10487
  /* @__PURE__ */ jsx46(
10475
10488
  FormLabel,
10476
10489
  {
@@ -10496,7 +10509,8 @@ function AddressFormFields({
10496
10509
  label: "CEP",
10497
10510
  required,
10498
10511
  placeholder: "00000-000",
10499
- validationErrorMessage: "CEP inv\xE1lido"
10512
+ validationErrorMessage: "CEP inv\xE1lido",
10513
+ onChange: handleCEPChange
10500
10514
  }
10501
10515
  ) : /* @__PURE__ */ jsx46(
10502
10516
  TextFormField,
@@ -10547,8 +10561,8 @@ function AddressFormFields({
10547
10561
  }
10548
10562
 
10549
10563
  // src/components/FormFields/RadioGroupFormField.tsx
10550
- import { Controller as Controller3, useFormContext as useFormContext10 } from "react-hook-form";
10551
- import { jsx as jsx47, jsxs as jsxs24 } from "react/jsx-runtime";
10564
+ import { Controller as Controller3, useFormContext as useFormContext8 } from "react-hook-form";
10565
+ import { jsx as jsx47, jsxs as jsxs23 } from "react/jsx-runtime";
10552
10566
  var RadioGroupFormField = ({
10553
10567
  name,
10554
10568
  label,
@@ -10563,14 +10577,14 @@ var RadioGroupFormField = ({
10563
10577
  const {
10564
10578
  control,
10565
10579
  formState: { errors }
10566
- } = useFormContext10();
10580
+ } = useFormContext8();
10567
10581
  const fieldError = getNestedValue(errors, name);
10568
10582
  const haveError = !!fieldError;
10569
10583
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
10570
10584
  const validationRules = {
10571
10585
  required: required ? validationErrorMessage : false
10572
10586
  };
10573
- return /* @__PURE__ */ jsxs24(Flex2, { direction: "column", children: [
10587
+ return /* @__PURE__ */ jsxs23(Flex2, { direction: "column", children: [
10574
10588
  /* @__PURE__ */ jsx47(
10575
10589
  FormLabel,
10576
10590
  {
@@ -10595,7 +10609,7 @@ var RadioGroupFormField = ({
10595
10609
  color: haveError ? "error" : color,
10596
10610
  fontWeight,
10597
10611
  disabled,
10598
- children: options.map((option) => /* @__PURE__ */ jsxs24("label", { children: [
10612
+ children: options.map((option) => /* @__PURE__ */ jsxs23("label", { children: [
10599
10613
  /* @__PURE__ */ jsx47(RadioItem, { value: option.value }),
10600
10614
  option.label
10601
10615
  ] }, option.value))
@@ -10608,8 +10622,8 @@ var RadioGroupFormField = ({
10608
10622
  };
10609
10623
 
10610
10624
  // src/components/FormFields/CheckboxGroupFormField.tsx
10611
- import { Controller as Controller4, useFormContext as useFormContext11 } from "react-hook-form";
10612
- import { jsx as jsx48, jsxs as jsxs25 } from "react/jsx-runtime";
10625
+ import { Controller as Controller4, useFormContext as useFormContext9 } from "react-hook-form";
10626
+ import { jsx as jsx48, jsxs as jsxs24 } from "react/jsx-runtime";
10613
10627
  var CheckboxGroupFormField = ({
10614
10628
  name,
10615
10629
  label,
@@ -10624,7 +10638,7 @@ var CheckboxGroupFormField = ({
10624
10638
  const {
10625
10639
  control,
10626
10640
  formState: { errors }
10627
- } = useFormContext11();
10641
+ } = useFormContext9();
10628
10642
  const fieldError = getNestedValue(errors, name);
10629
10643
  const haveError = !!fieldError;
10630
10644
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
@@ -10632,7 +10646,7 @@ var CheckboxGroupFormField = ({
10632
10646
  required: required ? validationErrorMessage : false,
10633
10647
  validate: required ? (value) => (value == null ? void 0 : value.length) > 0 || validationErrorMessage : void 0
10634
10648
  };
10635
- return /* @__PURE__ */ jsxs25(Flex2, { direction: "column", children: [
10649
+ return /* @__PURE__ */ jsxs24(Flex2, { direction: "column", children: [
10636
10650
  /* @__PURE__ */ jsx48(
10637
10651
  FormLabel,
10638
10652
  {