@lets-events/react 11.7.0 → 11.7.2

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,5 +1,5 @@
1
1
 
2
- > @lets-events/react@11.7.0 build
2
+ > @lets-events/react@11.7.2 build
3
3
  > tsup src/index.tsx --format esm,cjs --dts --external react
4
4
 
5
5
  CLI Building entry: src/index.tsx
@@ -8,11 +8,11 @@
8
8
  CLI Target: es6
9
9
  ESM Build start
10
10
  CJS Build start
11
+ CJS dist\index.js 332.14 KB
12
+ CJS ⚡️ Build success in 234ms
13
+ ESM dist\index.mjs 320.00 KB
14
+ ESM ⚡️ Build success in 235ms
11
15
  DTS Build start
12
- ESM dist\index.mjs 319.18 KB
13
- ESM ⚡️ Build success in 516ms
14
- CJS dist\index.js 331.25 KB
15
- CJS ⚡️ Build success in 517ms
16
- DTS ⚡️ Build success in 4249ms
17
- DTS dist\index.d.mts 383.30 KB
18
- DTS dist\index.d.ts 383.30 KB
16
+ DTS ⚡️ Build success in 4217ms
17
+ DTS dist\index.d.mts 383.61 KB
18
+ DTS dist\index.d.ts 383.61 KB
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @lets-events/react
2
2
 
3
+ ## 11.7.2
4
+
5
+ ### Patch Changes
6
+
7
+ - form child function
8
+
9
+ ## 11.7.1
10
+
11
+ ### Patch Changes
12
+
13
+ - email input
14
+
3
15
  ## 11.7.0
4
16
 
5
17
  ### Minor Changes
package/dist/index.d.mts CHANGED
@@ -13,7 +13,7 @@ import { VariantProps } from '@stitches/react';
13
13
  import { MaskOptions, format, unformat } from '@react-input/mask';
14
14
  import { Dialog } from 'radix-ui';
15
15
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
16
- import { FieldError, Merge, FieldErrorsImpl, FieldValues, UseFormProps, SubmitHandler, useForm } from 'react-hook-form';
16
+ import { FieldError, Merge, FieldErrorsImpl, FieldValues, UseFormProps, SubmitHandler, UseFormReturn, useForm } from 'react-hook-form';
17
17
 
18
18
  interface IconProps extends Omit<FontAwesomeIconProps, "icon" | "size"> {
19
19
  name: IconName;
@@ -14535,7 +14535,7 @@ declare const TextFormField: ({ name, label, required, mask, validate, validatio
14535
14535
 
14536
14536
  type FormProps<T extends FieldValues = FieldValues> = UseFormProps<T> & {
14537
14537
  onSubmit: SubmitHandler<T>;
14538
- children: JSX.Element;
14538
+ children: JSX.Element | ((p: UseFormReturn<T, any, T>) => JSX.Element);
14539
14539
  methods?: ReturnType<typeof useForm<T>>;
14540
14540
  };
14541
14541
  declare const Form: <T extends FieldValues = FieldValues>({ onSubmit, children, ...props }: FormProps<T>) => react_jsx_runtime.JSX.Element;
@@ -14664,4 +14664,11 @@ type SelectFormFieldProps = {
14664
14664
  };
14665
14665
  declare const SelectFormField: ({ name, label, required, placeholder, options, validation, validationErrorMessage, defaultValue, }: SelectFormFieldProps) => react_jsx_runtime.JSX.Element;
14666
14666
 
14667
- export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, isValidCNPJ, maskFormat, maskUnformat, useToast };
14667
+ type EmailFormFieldProps = {
14668
+ name: string;
14669
+ label?: string;
14670
+ required?: boolean;
14671
+ };
14672
+ declare const EmailFormField: ({ name, label, required, }: EmailFormFieldProps) => react_jsx_runtime.JSX.Element;
14673
+
14674
+ export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, EmailFormField, type EmailFormFieldProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, isValidCNPJ, maskFormat, maskUnformat, useToast };
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ import { VariantProps } from '@stitches/react';
13
13
  import { MaskOptions, format, unformat } from '@react-input/mask';
14
14
  import { Dialog } from 'radix-ui';
15
15
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
16
- import { FieldError, Merge, FieldErrorsImpl, FieldValues, UseFormProps, SubmitHandler, useForm } from 'react-hook-form';
16
+ import { FieldError, Merge, FieldErrorsImpl, FieldValues, UseFormProps, SubmitHandler, UseFormReturn, useForm } from 'react-hook-form';
17
17
 
18
18
  interface IconProps extends Omit<FontAwesomeIconProps, "icon" | "size"> {
19
19
  name: IconName;
@@ -14535,7 +14535,7 @@ declare const TextFormField: ({ name, label, required, mask, validate, validatio
14535
14535
 
14536
14536
  type FormProps<T extends FieldValues = FieldValues> = UseFormProps<T> & {
14537
14537
  onSubmit: SubmitHandler<T>;
14538
- children: JSX.Element;
14538
+ children: JSX.Element | ((p: UseFormReturn<T, any, T>) => JSX.Element);
14539
14539
  methods?: ReturnType<typeof useForm<T>>;
14540
14540
  };
14541
14541
  declare const Form: <T extends FieldValues = FieldValues>({ onSubmit, children, ...props }: FormProps<T>) => react_jsx_runtime.JSX.Element;
@@ -14664,4 +14664,11 @@ type SelectFormFieldProps = {
14664
14664
  };
14665
14665
  declare const SelectFormField: ({ name, label, required, placeholder, options, validation, validationErrorMessage, defaultValue, }: SelectFormFieldProps) => react_jsx_runtime.JSX.Element;
14666
14666
 
14667
- export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, isValidCNPJ, maskFormat, maskUnformat, useToast };
14667
+ type EmailFormFieldProps = {
14668
+ name: string;
14669
+ label?: string;
14670
+ required?: boolean;
14671
+ };
14672
+ declare const EmailFormField: ({ name, label, required, }: EmailFormFieldProps) => react_jsx_runtime.JSX.Element;
14673
+
14674
+ export { AddressFormFields, Alert, AlertDialogCompleteStyled, AlertDialogDescriptionStyled, AlertDialogRowStyled, AlertDialogSimpleStyled, AlertDialogSubtitleStyled, AlertDialogTitleStyled, AlertDialoghrStyled, type AlertProps, Avatar, type AvatarProps, AvatarStyled, Badge, type BadgeProps, BadgeStyled, BirthDateFormField, Box, Button, ButtonGroup, type ButtonGroupProps, ButtonGroupStyled, ButtonItem, type ButtonItemProps, ButtonItemStyled, type ButtonProps, CNPJFormField, CPFFormField, Calendar, type CalendarProps, Card, type CardProps, CardStyled, CheckboxGroup, CheckboxGroupFormField, type CheckboxGroupFormFieldProps, type CheckboxGroupProps, CheckboxGroupStyled, CheckboxItem, type CheckboxItemProps, Container, type ContainerProps, ContainerStyled, CountryFormField, Drawer, type DrawerProps, DropdownMenu, DropdownMenuItem, type DropdownMenuItemProps, type DropdownMenuProps, EmailFormField, type EmailFormFieldProps, ErrorFormMessage, type ErrorFormMessageProps, Filter, FilterItem, type FilterItemProps, type FilterProps, Flex, type FlexProps, FlexStyled, Form, FormLabel, type FormLabelProps, type FormProps, Grid, type GridProps, GridStyled, Icon, IdentityDocumentNumberFormField, InputStyled, MenuDropdown, type MenuDropdownProps, Modal, type ModalProps, MultiSelect, MultiSelectFormField, type MultiSelectFormFieldProps, type MultiSelectProps, PhoneFormField, type PhoneFormFieldProps, RadioGroup, RadioGroupFormField, type RadioGroupFormFieldProps, type RadioGroupProps, RadioGroupStyled, RadioItem, type RadioItemProps, Section, type SectionProps, SectionStyled, SelectFormField, type SelectFormFieldProps, Step, StepContent, StepList, type StepProps, StepStyled, StepTrigger, StepWrapper, Switch, type SwitchProps, SwitchStyled, Text, TextAreaFormField, type TextAreaFormFieldProps, TextField, type TextFieldProps, TextFieldSlot, type TextFieldSlotProps, TextFieldSlotStyled, TextFieldStyled, TextFormField, type TextFormFieldProps, type TextProps, TextStyle, TextareaField, type TextareaFieldProps, TextareaFieldStyle, TimePicker, TimePickerButtonStyled, TimePickerDropdownStyled, TimePickerFooterStyled, type TimePickerProps, TimePickerStyled, TimerPickerContentStyled, type Toast, type ToastComponentProps, type ToastConfig, type ToastContextType, ToastItem, type ToastOptions, ToastProvider, type ToastProviderProps, type ToastType, type ToasterShowOptions, Tooltip, TooltipContent, type TooltipProps, TooltipProvider, TooltipRoot, TooltipTrigger, isValidCNPJ, maskFormat, maskUnformat, useToast };
package/dist/index.js CHANGED
@@ -1066,6 +1066,7 @@ __export(index_exports, {
1066
1066
  Drawer: () => Drawer,
1067
1067
  DropdownMenu: () => DropdownMenu2,
1068
1068
  DropdownMenuItem: () => DropdownMenuItem,
1069
+ EmailFormField: () => EmailFormField,
1069
1070
  ErrorFormMessage: () => ErrorFormMessage,
1070
1071
  Filter: () => Filter,
1071
1072
  FilterItem: () => FilterItem,
@@ -9911,8 +9912,15 @@ var Form = (_a) => {
9911
9912
  "onSubmit",
9912
9913
  "children"
9913
9914
  ]);
9914
- const formMethods = (0, import_react_hook_form3.useForm)(props);
9915
- return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_hook_form3.FormProvider, __spreadProps(__spreadValues({}, formMethods), { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("form", { onSubmit: formMethods.handleSubmit(onSubmit), children }) }));
9915
+ const formMethods = (0, import_react_hook_form3.useForm)(__spreadValues({
9916
+ mode: "onTouched"
9917
+ }, props));
9918
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_react_hook_form3.FormProvider, __spreadProps(__spreadValues({}, formMethods), { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("form", { onSubmit: formMethods.handleSubmit(onSubmit), children: (() => {
9919
+ if (typeof children === "function") {
9920
+ return children(formMethods);
9921
+ }
9922
+ return children;
9923
+ })() }) }));
9916
9924
  };
9917
9925
 
9918
9926
  // src/components/FormFields/MultiSelectFormField.tsx
@@ -9966,8 +9974,14 @@ var MultiSelectFormField = (_a) => {
9966
9974
  };
9967
9975
 
9968
9976
  // src/components/FormFields/utils/validation.ts
9977
+ var isValidEmail = (email) => {
9978
+ const emailRexep = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
9979
+ return emailRexep.test(email);
9980
+ };
9981
+ var validateEmail = (errorMsg) => (value) => {
9982
+ return !isValidEmail(value) ? errorMsg : true;
9983
+ };
9969
9984
  var minMaxLength = (min, max, errorMsg) => (value) => {
9970
- console.log(value);
9971
9985
  var length = value.length;
9972
9986
  return length > max || length < min ? errorMsg : true;
9973
9987
  };
@@ -9992,15 +10006,15 @@ var PhoneFormField = ({
9992
10006
  },
9993
10007
  placeholder: "(00) 00000-0000",
9994
10008
  type: "tel",
9995
- validate: minMaxLength(12, 13, "Telefone inv\xE1lido"),
10009
+ validate: minMaxLength(13, 14, "Telefone inv\xE1lido"),
9996
10010
  valueFormatter: {
9997
10011
  format(v) {
9998
10012
  if (!v || v === "") return v;
9999
- return v.replace(/\b55/, "");
10013
+ return v.replace(/^\+55/, "");
10000
10014
  },
10001
10015
  unformat(v) {
10002
10016
  if (!v || v === "") return v;
10003
- return "55" + v;
10017
+ return "+55" + v;
10004
10018
  }
10005
10019
  }
10006
10020
  }
@@ -10780,6 +10794,26 @@ var CheckboxGroupFormField = ({
10780
10794
  /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ErrorFormMessage, { message: errorMsg })
10781
10795
  ] });
10782
10796
  };
10797
+
10798
+ // src/components/FormFields/EmailFormField.tsx
10799
+ var import_jsx_runtime49 = require("react/jsx-runtime");
10800
+ var EmailFormField = ({
10801
+ name,
10802
+ label,
10803
+ required
10804
+ }) => {
10805
+ return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
10806
+ TextFormField,
10807
+ {
10808
+ name,
10809
+ label,
10810
+ required,
10811
+ placeholder: "@mail.com",
10812
+ type: "email",
10813
+ validate: validateEmail("E-mail inv\xE1lido.")
10814
+ }
10815
+ );
10816
+ };
10783
10817
  // Annotate the CommonJS export names for ESM import in node:
10784
10818
  0 && (module.exports = {
10785
10819
  AddressFormFields,
@@ -10817,6 +10851,7 @@ var CheckboxGroupFormField = ({
10817
10851
  Drawer,
10818
10852
  DropdownMenu,
10819
10853
  DropdownMenuItem,
10854
+ EmailFormField,
10820
10855
  ErrorFormMessage,
10821
10856
  Filter,
10822
10857
  FilterItem,
package/dist/index.mjs CHANGED
@@ -9818,8 +9818,15 @@ var Form = (_a) => {
9818
9818
  "onSubmit",
9819
9819
  "children"
9820
9820
  ]);
9821
- const formMethods = useForm(props);
9822
- return /* @__PURE__ */ jsx34(FormProvider, __spreadProps(__spreadValues({}, formMethods), { children: /* @__PURE__ */ jsx34("form", { onSubmit: formMethods.handleSubmit(onSubmit), children }) }));
9821
+ const formMethods = useForm(__spreadValues({
9822
+ mode: "onTouched"
9823
+ }, props));
9824
+ return /* @__PURE__ */ jsx34(FormProvider, __spreadProps(__spreadValues({}, formMethods), { children: /* @__PURE__ */ jsx34("form", { onSubmit: formMethods.handleSubmit(onSubmit), children: (() => {
9825
+ if (typeof children === "function") {
9826
+ return children(formMethods);
9827
+ }
9828
+ return children;
9829
+ })() }) }));
9823
9830
  };
9824
9831
 
9825
9832
  // src/components/FormFields/MultiSelectFormField.tsx
@@ -9873,8 +9880,14 @@ var MultiSelectFormField = (_a) => {
9873
9880
  };
9874
9881
 
9875
9882
  // src/components/FormFields/utils/validation.ts
9883
+ var isValidEmail = (email) => {
9884
+ const emailRexep = /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
9885
+ return emailRexep.test(email);
9886
+ };
9887
+ var validateEmail = (errorMsg) => (value) => {
9888
+ return !isValidEmail(value) ? errorMsg : true;
9889
+ };
9876
9890
  var minMaxLength = (min, max, errorMsg) => (value) => {
9877
- console.log(value);
9878
9891
  var length = value.length;
9879
9892
  return length > max || length < min ? errorMsg : true;
9880
9893
  };
@@ -9899,15 +9912,15 @@ var PhoneFormField = ({
9899
9912
  },
9900
9913
  placeholder: "(00) 00000-0000",
9901
9914
  type: "tel",
9902
- validate: minMaxLength(12, 13, "Telefone inv\xE1lido"),
9915
+ validate: minMaxLength(13, 14, "Telefone inv\xE1lido"),
9903
9916
  valueFormatter: {
9904
9917
  format(v) {
9905
9918
  if (!v || v === "") return v;
9906
- return v.replace(/\b55/, "");
9919
+ return v.replace(/^\+55/, "");
9907
9920
  },
9908
9921
  unformat(v) {
9909
9922
  if (!v || v === "") return v;
9910
- return "55" + v;
9923
+ return "+55" + v;
9911
9924
  }
9912
9925
  }
9913
9926
  }
@@ -10687,6 +10700,26 @@ var CheckboxGroupFormField = ({
10687
10700
  /* @__PURE__ */ jsx48(ErrorFormMessage, { message: errorMsg })
10688
10701
  ] });
10689
10702
  };
10703
+
10704
+ // src/components/FormFields/EmailFormField.tsx
10705
+ import { jsx as jsx49 } from "react/jsx-runtime";
10706
+ var EmailFormField = ({
10707
+ name,
10708
+ label,
10709
+ required
10710
+ }) => {
10711
+ return /* @__PURE__ */ jsx49(
10712
+ TextFormField,
10713
+ {
10714
+ name,
10715
+ label,
10716
+ required,
10717
+ placeholder: "@mail.com",
10718
+ type: "email",
10719
+ validate: validateEmail("E-mail inv\xE1lido.")
10720
+ }
10721
+ );
10722
+ };
10690
10723
  export {
10691
10724
  AddressFormFields,
10692
10725
  Alert,
@@ -10723,6 +10756,7 @@ export {
10723
10756
  Drawer,
10724
10757
  DropdownMenu2 as DropdownMenu,
10725
10758
  DropdownMenuItem,
10759
+ EmailFormField,
10726
10760
  ErrorFormMessage,
10727
10761
  Filter,
10728
10762
  FilterItem,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lets-events/react",
3
- "version": "11.7.0",
3
+ "version": "11.7.2",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -0,0 +1,25 @@
1
+ import { TextFormField } from "./TextFormField";
2
+ import { validateEmail } from "./utils/validation";
3
+
4
+ export type EmailFormFieldProps = {
5
+ name: string;
6
+ label?: string;
7
+ required?: boolean;
8
+ };
9
+
10
+ export const EmailFormField = ({
11
+ name,
12
+ label,
13
+ required,
14
+ }: EmailFormFieldProps) => {
15
+ return (
16
+ <TextFormField
17
+ name={name}
18
+ label={label}
19
+ required={required}
20
+ placeholder="@mail.com"
21
+ type="email"
22
+ validate={validateEmail("E-mail inválido.")}
23
+ />
24
+ );
25
+ };
@@ -1,15 +1,16 @@
1
- import { JSX } from "react";
1
+ import { JSX, useMemo } from "react";
2
2
  import {
3
3
  FormProvider,
4
4
  useForm,
5
5
  SubmitHandler,
6
6
  FieldValues,
7
7
  UseFormProps,
8
+ UseFormReturn,
8
9
  } from "react-hook-form";
9
10
 
10
11
  export type FormProps<T extends FieldValues = FieldValues> = UseFormProps<T> & {
11
12
  onSubmit: SubmitHandler<T>;
12
- children: JSX.Element;
13
+ children: JSX.Element | ((p: UseFormReturn<T, any, T>) => JSX.Element);
13
14
  methods?: ReturnType<typeof useForm<T>>;
14
15
  };
15
16
 
@@ -18,11 +19,21 @@ export const Form = <T extends FieldValues = FieldValues>({
18
19
  children,
19
20
  ...props
20
21
  }: FormProps<T>) => {
21
- const formMethods = useForm<T>(props);
22
-
22
+ const formMethods = useForm<T>({
23
+ mode: "onTouched",
24
+ ...props,
25
+ });
26
+
23
27
  return (
24
28
  <FormProvider {...formMethods}>
25
- <form onSubmit={formMethods.handleSubmit(onSubmit)}>{children}</form>
29
+ <form onSubmit={formMethods.handleSubmit(onSubmit)}>
30
+ {(() => {
31
+ if (typeof children === "function") {
32
+ return children(formMethods);
33
+ }
34
+ return children;
35
+ })()}
36
+ </form>
26
37
  </FormProvider>
27
38
  );
28
39
  };
@@ -24,15 +24,15 @@ export const PhoneFormField = ({
24
24
  }}
25
25
  placeholder="(00) 00000-0000"
26
26
  type="tel"
27
- validate={minMaxLength(12, 13, "Telefone inválido")}
27
+ validate={minMaxLength(13, 14, "Telefone inválido")}
28
28
  valueFormatter={{
29
29
  format(v) {
30
30
  if (!v || v === "") return v;
31
- return v.replace(/\b55/, "");
31
+ return v.replace(/^\+55/, "");
32
32
  },
33
33
  unformat(v) {
34
34
  if (!v || v === "") return v;
35
- return "55" + v;
35
+ return "+55" + v;
36
36
  },
37
37
  }}
38
38
  />
@@ -1,9 +1,13 @@
1
- const validateEmail = (email: string) => {
1
+ const isValidEmail = (email: string) => {
2
2
  const emailRexep =
3
3
  /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
4
4
  return emailRexep.test(email);
5
5
  };
6
6
 
7
+ export const validateEmail = (errorMsg: string) => (value: string) => {
8
+ return !isValidEmail(value) ? errorMsg : true;
9
+ };
10
+
7
11
  export const maxLength = (max: number, errorMsg: string) => (value: string) => {
8
12
  return value.length > max ? errorMsg : true;
9
13
  };
@@ -14,7 +18,6 @@ export const minLength = (min: number, errorMsg: string) => (value: string) => {
14
18
 
15
19
  export const minMaxLength =
16
20
  (min: number, max: number, errorMsg: string) => (value: string) => {
17
- console.log(value)
18
21
  var length = value.length;
19
22
  return length > max || length < min ? errorMsg : true;
20
23
  };
package/src/index.tsx CHANGED
@@ -52,3 +52,4 @@ export * from "./components/FormFields/RadioGroupFormField";
52
52
  export * from "./components/FormFields/CheckboxGroupFormField";
53
53
  export * from "./components/FormFields/AddressFormFields/CountryFormField";
54
54
  export * from "./components/FormFields/SelectFormField";
55
+ export * from './components/FormFields/EmailFormField';