@lets-events/react 11.6.5 → 11.7.1

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 (77) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +18 -20
  3. package/CHANGELOG.md +12 -0
  4. package/dist/index.css +171 -0
  5. package/dist/index.d.mts +17 -13
  6. package/dist/index.d.ts +17 -13
  7. package/dist/index.js +230 -188
  8. package/dist/index.mjs +234 -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/EmailFormField.tsx +25 -0
  37. package/src/components/FormFields/Form.tsx +31 -29
  38. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +40 -42
  39. package/src/components/FormFields/MultiSelectFormField.tsx +55 -59
  40. package/src/components/FormFields/PhoneFormField.tsx +40 -130
  41. package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
  42. package/src/components/FormFields/SelectFormField.tsx +93 -93
  43. package/src/components/FormFields/TextAreaFormField.tsx +48 -48
  44. package/src/components/FormFields/TextFormField.tsx +107 -76
  45. package/src/components/FormFields/{ErrorFormMessage.tsx → subComponents/ErrorFormMessage.tsx} +36 -36
  46. package/src/components/FormFields/{FormLabel.tsx → subComponents/FormLabel.tsx} +29 -29
  47. package/src/components/FormFields/utils/validation.ts +23 -0
  48. package/src/components/Grid.tsx +137 -137
  49. package/src/components/Icon.tsx +47 -47
  50. package/src/components/MenuDropdown/index.tsx +30 -30
  51. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  52. package/src/components/Modal.tsx +90 -90
  53. package/src/components/MultiSelect.tsx +218 -218
  54. package/src/components/RadioGroup.tsx +210 -210
  55. package/src/components/Section.tsx +33 -33
  56. package/src/components/Step.tsx +164 -164
  57. package/src/components/Switch.tsx +108 -108
  58. package/src/components/Text.tsx +38 -38
  59. package/src/components/TextField.tsx +316 -312
  60. package/src/components/TextareaField.tsx +128 -128
  61. package/src/components/TimePicker.tsx +298 -298
  62. package/src/components/Toast/components/ToastItem.tsx +41 -41
  63. package/src/components/Toast/components/ToastProvider.tsx +63 -63
  64. package/src/components/Toast/hooks/useToast.ts +12 -12
  65. package/src/components/Toast/index.tsx +5 -5
  66. package/src/components/Toast/styles/index.ts +135 -135
  67. package/src/components/Toast/types/index.ts +46 -46
  68. package/src/components/Tooltip/index.tsx +66 -66
  69. package/src/components/Tooltip/styles.ts +77 -77
  70. package/src/hooks/useCountries.ts +41 -41
  71. package/src/hooks/useOnClickOutside.tsx +20 -20
  72. package/src/index.tsx +55 -54
  73. package/src/styles/index.ts +38 -38
  74. package/src/types/typographyValues.ts +178 -178
  75. package/src/utils/getNestedValue.ts +3 -3
  76. package/src/utils/states.ts +29 -29
  77. 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,19 @@ 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(__spreadValues({
9822
+ mode: "onTouched"
9823
+ }, props));
9797
9824
  return /* @__PURE__ */ jsx34(FormProvider, __spreadProps(__spreadValues({}, formMethods), { children: /* @__PURE__ */ jsx34("form", { onSubmit: formMethods.handleSubmit(onSubmit), children }) }));
9798
9825
  };
9799
9826
 
9800
9827
  // src/components/FormFields/MultiSelectFormField.tsx
9801
- import { useController, useFormContext as useFormContext3 } from "react-hook-form";
9828
+ import { useController as useController2 } from "react-hook-form";
9802
9829
  import { jsx as jsx35, jsxs as jsxs19 } from "react/jsx-runtime";
9803
9830
  var MultiSelectFormField = (_a) => {
9804
9831
  var _b = _a, {
@@ -9811,10 +9838,7 @@ var MultiSelectFormField = (_a) => {
9811
9838
  "required"
9812
9839
  ]);
9813
9840
  var _a2;
9814
- const {
9815
- formState: { errors }
9816
- } = useFormContext3();
9817
- const { field } = useController({
9841
+ const { field, fieldState } = useController2({
9818
9842
  name,
9819
9843
  rules: {
9820
9844
  required
@@ -9822,8 +9846,8 @@ var MultiSelectFormField = (_a) => {
9822
9846
  defaultValue: []
9823
9847
  });
9824
9848
  const { value, onChange, ref, onBlur, disabled } = field;
9825
- const haveError = !!errors[name];
9826
- const errorMsg = (_a2 = errors[name]) == null ? void 0 : _a2.message;
9849
+ const haveError = !!fieldState.error;
9850
+ const errorMsg = (_a2 = fieldState.error) == null ? void 0 : _a2.message;
9827
9851
  const handleChange = (v) => {
9828
9852
  onChange(v);
9829
9853
  };
@@ -9850,50 +9874,57 @@ var MultiSelectFormField = (_a) => {
9850
9874
  ] });
9851
9875
  };
9852
9876
 
9877
+ // src/components/FormFields/utils/validation.ts
9878
+ var isValidEmail = (email) => {
9879
+ const emailRexep = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
9880
+ return emailRexep.test(email);
9881
+ };
9882
+ var validateEmail = (errorMsg) => (value) => {
9883
+ return !isValidEmail(value) ? errorMsg : true;
9884
+ };
9885
+ var minMaxLength = (min, max, errorMsg) => (value) => {
9886
+ var length = value.length;
9887
+ return length > max || length < min ? errorMsg : true;
9888
+ };
9889
+
9853
9890
  // 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
9891
+ import { jsx as jsx36 } from "react/jsx-runtime";
9892
+ var PhoneFormField = ({
9893
+ name,
9894
+ label,
9895
+ required
9896
+ }) => {
9897
+ return /* @__PURE__ */ jsx36(
9898
+ TextFormField,
9899
+ {
9900
+ name,
9901
+ label,
9902
+ required,
9903
+ addon: "+ 55",
9904
+ mask: {
9905
+ mask: "(__) _____-____}",
9906
+ replacement: { _: /\d/ }
9907
+ },
9908
+ placeholder: "(00) 00000-0000",
9909
+ type: "tel",
9910
+ validate: minMaxLength(13, 14, "Telefone inv\xE1lido"),
9911
+ valueFormatter: {
9912
+ format(v) {
9913
+ if (!v || v === "") return v;
9914
+ return v.replace(/^\+55/, "");
9915
+ },
9916
+ unformat(v) {
9917
+ if (!v || v === "") return v;
9918
+ return "+55" + v;
9919
+ }
9888
9920
  }
9889
- ),
9890
- /* @__PURE__ */ jsx36(ErrorFormMessage, { message: errorMsg })
9891
- ] });
9921
+ }
9922
+ );
9892
9923
  };
9893
9924
 
9894
9925
  // 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";
9926
+ import { useFormContext as useFormContext4, useWatch } from "react-hook-form";
9927
+ import { jsx as jsx37, jsxs as jsxs20 } from "react/jsx-runtime";
9897
9928
  var isValidCPF = (cpf) => {
9898
9929
  cpf = cpf.replace(/[^\d]+/g, "");
9899
9930
  if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) return false;
@@ -9917,9 +9948,9 @@ var CPFFormField = ({
9917
9948
  validationErrorMessage,
9918
9949
  foreignerLabel
9919
9950
  }) => {
9920
- const { control, setValue } = useFormContext5();
9951
+ const { control, setValue } = useFormContext4();
9921
9952
  const foreigner = useWatch({ name: "foreigner", control });
9922
- return /* @__PURE__ */ jsxs21(Flex2, { direction: "column", children: [
9953
+ return /* @__PURE__ */ jsxs20(Flex2, { direction: "column", children: [
9923
9954
  /* @__PURE__ */ jsx37(
9924
9955
  TextFormField,
9925
9956
  {
@@ -9931,11 +9962,9 @@ var CPFFormField = ({
9931
9962
  mask: "___.___.___-__",
9932
9963
  replacement: { _: /[0-9]/ }
9933
9964
  },
9934
- validation: {
9935
- validate: (value) => {
9936
- if (!required || foreigner) return true;
9937
- return isValidCPF(value) || validationErrorMessage;
9938
- }
9965
+ validate: (value) => {
9966
+ if (!required || foreigner) return true;
9967
+ return isValidCPF(value) || validationErrorMessage;
9939
9968
  },
9940
9969
  disabled: foreigner
9941
9970
  }
@@ -10018,12 +10047,10 @@ var CNPJFormField = ({
10018
10047
  mask: "__.___.___/____-__",
10019
10048
  replacement: { _: /[0-9]/ }
10020
10049
  },
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
- }
10050
+ validate: (value) => {
10051
+ const isEmpty = value.replace(matchesNonDigit, "").length === 0;
10052
+ if (!required && isEmpty) return true;
10053
+ return isValidCNPJ(value) || validationErrorMessage;
10027
10054
  }
10028
10055
  }
10029
10056
  );
@@ -10076,12 +10103,10 @@ var BirthDateFormField = ({
10076
10103
  mask: "__/__/____",
10077
10104
  replacement: { _: /[0-9]/ }
10078
10105
  },
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
- }
10106
+ validate: (value) => {
10107
+ const isEmpty = value.replace(/[^\d]+/g, "").length === 0;
10108
+ if (!required && isEmpty) return true;
10109
+ return isValidBirthDate(value, language) || validationErrorMessage;
10085
10110
  }
10086
10111
  }
10087
10112
  );
@@ -10111,24 +10136,28 @@ var IdentityDocumentNumberFormField = ({
10111
10136
  mask: "__.___.___-_",
10112
10137
  replacement: { _: /[0-9]/ }
10113
10138
  },
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
- }
10139
+ validate: (value) => {
10140
+ const isEmpty = value.replace(/[^\d]/g, "").length === 0;
10141
+ if (!required && isEmpty) return true;
10142
+ return isValidRG(value) || validationErrorMessage;
10120
10143
  }
10121
10144
  }
10122
10145
  );
10123
10146
  };
10124
10147
 
10125
10148
  // 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";
10149
+ import { useFormContext as useFormContext7, useWatch as useWatch2, useFormState } from "react-hook-form";
10150
+
10151
+ // src/components/FormFields/SelectFormField.tsx
10152
+ import { useFormContext as useFormContext5, Controller } from "react-hook-form";
10153
+
10154
+ // src/utils/getNestedValue.ts
10155
+ function getNestedValue(obj, path) {
10156
+ return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
10157
+ }
10128
10158
 
10129
10159
  // 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";
10160
+ import { jsx as jsx41, jsxs as jsxs21 } from "react/jsx-runtime";
10132
10161
  var SelectFormField = ({
10133
10162
  name,
10134
10163
  label,
@@ -10142,14 +10171,14 @@ var SelectFormField = ({
10142
10171
  const {
10143
10172
  control,
10144
10173
  formState: { errors }
10145
- } = useFormContext6();
10174
+ } = useFormContext5();
10146
10175
  const fieldError = getNestedValue(errors, name);
10147
10176
  const haveError = !!fieldError;
10148
10177
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
10149
10178
  const validationRules = __spreadValues({
10150
10179
  required: required ? validationErrorMessage : false
10151
10180
  }, validation);
10152
- return /* @__PURE__ */ jsxs22(Flex2, { direction: "column", children: [
10181
+ return /* @__PURE__ */ jsxs21(Flex2, { direction: "column", children: [
10153
10182
  /* @__PURE__ */ jsx41(
10154
10183
  FormLabel,
10155
10184
  {
@@ -10245,19 +10274,15 @@ function CountryFormField({
10245
10274
  }
10246
10275
 
10247
10276
  // src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx
10248
- import { useController as useController3, useFormContext as useFormContext7 } from "react-hook-form";
10249
10277
  import { jsx as jsx43 } from "react/jsx-runtime";
10250
10278
  var PostalCodeFormField = ({
10251
10279
  name,
10252
10280
  label,
10253
10281
  required,
10254
10282
  placeholder,
10255
- validationErrorMessage
10283
+ validationErrorMessage,
10284
+ onChange
10256
10285
  }) => {
10257
- const { control } = useFormContext7();
10258
- const {
10259
- field: { onChange, value }
10260
- } = useController3({ name, control });
10261
10286
  return /* @__PURE__ */ jsx43(
10262
10287
  TextFormField,
10263
10288
  {
@@ -10269,14 +10294,11 @@ var PostalCodeFormField = ({
10269
10294
  mask: "_____-___",
10270
10295
  replacement: { _: /[0-9]/ }
10271
10296
  },
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
- }
10297
+ onChange: (e) => onChange == null ? void 0 : onChange(e.target.value),
10298
+ validate: (value) => {
10299
+ const isEmpty = value.replace(/[^\d]/g, "").length === 0;
10300
+ if (!required && isEmpty) return true;
10301
+ return /^\d{8}$/.test(value.replace(/\D/g, "")) || validationErrorMessage;
10280
10302
  }
10281
10303
  }
10282
10304
  );
@@ -10334,7 +10356,7 @@ function StateFormField({
10334
10356
 
10335
10357
  // src/components/FormFields/AddressFormFields/CityFormField.tsx
10336
10358
  import { useEffect as useEffect4, useState as useState8 } from "react";
10337
- import { useFormContext as useFormContext8, Controller as Controller2 } from "react-hook-form";
10359
+ import { useFormContext as useFormContext6, Controller as Controller2 } from "react-hook-form";
10338
10360
  import { Fragment as Fragment3, jsx as jsx45 } from "react/jsx-runtime";
10339
10361
  function CityFormField({
10340
10362
  name,
@@ -10344,7 +10366,7 @@ function CityFormField({
10344
10366
  isBrazil,
10345
10367
  placeholder
10346
10368
  }) {
10347
- const { control, watch } = useFormContext8();
10369
+ const { control, watch } = useFormContext6();
10348
10370
  const selectedState = watch(stateName);
10349
10371
  const [cities, setCities] = useState8([]);
10350
10372
  const [loading, setLoading] = useState8(false);
@@ -10419,7 +10441,7 @@ function CityFormField({
10419
10441
  }
10420
10442
 
10421
10443
  // src/components/FormFields/AddressFormFields/index.tsx
10422
- import { jsx as jsx46, jsxs as jsxs23 } from "react/jsx-runtime";
10444
+ import { jsx as jsx46, jsxs as jsxs22 } from "react/jsx-runtime";
10423
10445
  function getNestedValue2(obj, path) {
10424
10446
  return path.split(".").reduce((acc, key) => acc == null ? void 0 : acc[key], obj);
10425
10447
  }
@@ -10448,29 +10470,28 @@ function AddressFormFields({
10448
10470
  required,
10449
10471
  layout = "column"
10450
10472
  }) {
10451
- const { control, setValue } = useFormContext9();
10473
+ const { control, setValue } = useFormContext7();
10452
10474
  const { errors } = useFormState({ control });
10453
10475
  const selectedCountry = useWatch2({ control, name: `${name}.country` });
10454
- const cep = useWatch2({ control, name: `${name}.zip_code` });
10455
10476
  const isBrazil = selectedCountry === "Brasil";
10456
10477
  const addressErrors = getNestedValue2(errors, name);
10457
10478
  const haveError = !!addressErrors;
10458
- useEffect5(() => {
10479
+ const handleCEPChange = (cep) => {
10480
+ if (!isBrazil) return;
10459
10481
  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: [
10482
+ if ((cleanedCep == null ? void 0 : cleanedCep.length) !== 8) return;
10483
+ fetch(`https://viacep.com.br/ws/${cleanedCep}/json`).then((res) => res.json()).then((data) => {
10484
+ if (!data.erro) {
10485
+ setValue(`${name}.street`, data.logradouro || "");
10486
+ setValue(`${name}.neighborhood`, data.bairro || "");
10487
+ setValue(`${name}.city`, data.localidade || "");
10488
+ setValue(`${name}.state`, data.uf || "");
10489
+ }
10490
+ }).catch(() => {
10491
+ console.error("Erro ao buscar CEP");
10492
+ });
10493
+ };
10494
+ return /* @__PURE__ */ jsxs22(AddressContainerStyled, { layout, children: [
10474
10495
  /* @__PURE__ */ jsx46(
10475
10496
  FormLabel,
10476
10497
  {
@@ -10496,7 +10517,8 @@ function AddressFormFields({
10496
10517
  label: "CEP",
10497
10518
  required,
10498
10519
  placeholder: "00000-000",
10499
- validationErrorMessage: "CEP inv\xE1lido"
10520
+ validationErrorMessage: "CEP inv\xE1lido",
10521
+ onChange: handleCEPChange
10500
10522
  }
10501
10523
  ) : /* @__PURE__ */ jsx46(
10502
10524
  TextFormField,
@@ -10547,8 +10569,8 @@ function AddressFormFields({
10547
10569
  }
10548
10570
 
10549
10571
  // 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";
10572
+ import { Controller as Controller3, useFormContext as useFormContext8 } from "react-hook-form";
10573
+ import { jsx as jsx47, jsxs as jsxs23 } from "react/jsx-runtime";
10552
10574
  var RadioGroupFormField = ({
10553
10575
  name,
10554
10576
  label,
@@ -10563,14 +10585,14 @@ var RadioGroupFormField = ({
10563
10585
  const {
10564
10586
  control,
10565
10587
  formState: { errors }
10566
- } = useFormContext10();
10588
+ } = useFormContext8();
10567
10589
  const fieldError = getNestedValue(errors, name);
10568
10590
  const haveError = !!fieldError;
10569
10591
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
10570
10592
  const validationRules = {
10571
10593
  required: required ? validationErrorMessage : false
10572
10594
  };
10573
- return /* @__PURE__ */ jsxs24(Flex2, { direction: "column", children: [
10595
+ return /* @__PURE__ */ jsxs23(Flex2, { direction: "column", children: [
10574
10596
  /* @__PURE__ */ jsx47(
10575
10597
  FormLabel,
10576
10598
  {
@@ -10595,7 +10617,7 @@ var RadioGroupFormField = ({
10595
10617
  color: haveError ? "error" : color,
10596
10618
  fontWeight,
10597
10619
  disabled,
10598
- children: options.map((option) => /* @__PURE__ */ jsxs24("label", { children: [
10620
+ children: options.map((option) => /* @__PURE__ */ jsxs23("label", { children: [
10599
10621
  /* @__PURE__ */ jsx47(RadioItem, { value: option.value }),
10600
10622
  option.label
10601
10623
  ] }, option.value))
@@ -10608,8 +10630,8 @@ var RadioGroupFormField = ({
10608
10630
  };
10609
10631
 
10610
10632
  // 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";
10633
+ import { Controller as Controller4, useFormContext as useFormContext9 } from "react-hook-form";
10634
+ import { jsx as jsx48, jsxs as jsxs24 } from "react/jsx-runtime";
10613
10635
  var CheckboxGroupFormField = ({
10614
10636
  name,
10615
10637
  label,
@@ -10624,7 +10646,7 @@ var CheckboxGroupFormField = ({
10624
10646
  const {
10625
10647
  control,
10626
10648
  formState: { errors }
10627
- } = useFormContext11();
10649
+ } = useFormContext9();
10628
10650
  const fieldError = getNestedValue(errors, name);
10629
10651
  const haveError = !!fieldError;
10630
10652
  const errorMsg = fieldError == null ? void 0 : fieldError.message;
@@ -10632,7 +10654,7 @@ var CheckboxGroupFormField = ({
10632
10654
  required: required ? validationErrorMessage : false,
10633
10655
  validate: required ? (value) => (value == null ? void 0 : value.length) > 0 || validationErrorMessage : void 0
10634
10656
  };
10635
- return /* @__PURE__ */ jsxs25(Flex2, { direction: "column", children: [
10657
+ return /* @__PURE__ */ jsxs24(Flex2, { direction: "column", children: [
10636
10658
  /* @__PURE__ */ jsx48(
10637
10659
  FormLabel,
10638
10660
  {
@@ -10673,6 +10695,26 @@ var CheckboxGroupFormField = ({
10673
10695
  /* @__PURE__ */ jsx48(ErrorFormMessage, { message: errorMsg })
10674
10696
  ] });
10675
10697
  };
10698
+
10699
+ // src/components/FormFields/EmailFormField.tsx
10700
+ import { jsx as jsx49 } from "react/jsx-runtime";
10701
+ var EmailFormField = ({
10702
+ name,
10703
+ label,
10704
+ required
10705
+ }) => {
10706
+ return /* @__PURE__ */ jsx49(
10707
+ TextFormField,
10708
+ {
10709
+ name,
10710
+ label,
10711
+ required,
10712
+ placeholder: "@mail.com",
10713
+ type: "email",
10714
+ validate: validateEmail("E-mail inv\xE1lido.")
10715
+ }
10716
+ );
10717
+ };
10676
10718
  export {
10677
10719
  AddressFormFields,
10678
10720
  Alert,
@@ -10709,6 +10751,7 @@ export {
10709
10751
  Drawer,
10710
10752
  DropdownMenu2 as DropdownMenu,
10711
10753
  DropdownMenuItem,
10754
+ EmailFormField,
10712
10755
  ErrorFormMessage,
10713
10756
  Filter,
10714
10757
  FilterItem,