@lets-events/react 11.5.4 → 11.6.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 (74) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +20 -18
  3. package/CHANGELOG.md +12 -0
  4. package/dist/index.d.mts +103 -11
  5. package/dist/index.d.ts +103 -11
  6. package/dist/index.js +990 -133
  7. package/dist/index.mjs +951 -102
  8. package/package.json +2 -1
  9. package/src/components/Alert.tsx +303 -303
  10. package/src/components/Avatar.tsx +55 -55
  11. package/src/components/Badge.tsx +125 -125
  12. package/src/components/Box.tsx +3 -3
  13. package/src/components/Button/index.tsx +16 -16
  14. package/src/components/Button/styledComponents.ts +287 -287
  15. package/src/components/ButtonGroup.tsx +484 -484
  16. package/src/components/Calendar/index.tsx +136 -136
  17. package/src/components/Calendar/styledComponents.ts +209 -209
  18. package/src/components/Card.tsx +48 -48
  19. package/src/components/CheckboxGroup.tsx +176 -196
  20. package/src/components/Container.tsx +39 -39
  21. package/src/components/Drawer/index.tsx +48 -48
  22. package/src/components/Drawer/styledComponents.ts +46 -46
  23. package/src/components/Dropdown.tsx +192 -167
  24. package/src/components/Filter.tsx +164 -164
  25. package/src/components/Flex.tsx +118 -118
  26. package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -0
  27. package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -0
  28. package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +45 -0
  29. package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -0
  30. package/src/components/FormFields/AddressFormFields/index.tsx +139 -0
  31. package/src/components/FormFields/BirthDateFormField.tsx +87 -0
  32. package/src/components/FormFields/CNPJFormField.tsx +89 -0
  33. package/src/components/FormFields/CPFFormField.tsx +79 -0
  34. package/src/components/FormFields/CheckboxGroupFormField.tsx +90 -0
  35. package/src/components/FormFields/ErrorFormMessage.tsx +36 -36
  36. package/src/components/FormFields/Form.tsx +29 -25
  37. package/src/components/FormFields/FormLabel.tsx +29 -29
  38. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +42 -0
  39. package/src/components/FormFields/MultiSelectFormField.tsx +59 -59
  40. package/src/components/FormFields/PhoneFormField.tsx +130 -130
  41. package/src/components/FormFields/RadioGroupFormField.tsx +84 -0
  42. package/src/components/FormFields/SelectFormField.tsx +93 -0
  43. package/src/components/FormFields/TextAreaFormField.tsx +48 -48
  44. package/src/components/FormFields/TextFormField.tsx +76 -46
  45. package/src/components/Grid.tsx +137 -137
  46. package/src/components/Icon.tsx +47 -47
  47. package/src/components/MenuDropdown/index.tsx +30 -30
  48. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  49. package/src/components/Modal.tsx +90 -90
  50. package/src/components/MultiSelect.tsx +218 -218
  51. package/src/components/RadioGroup.tsx +210 -210
  52. package/src/components/Section.tsx +33 -33
  53. package/src/components/Step.tsx +164 -164
  54. package/src/components/Switch.tsx +108 -108
  55. package/src/components/Text.tsx +38 -38
  56. package/src/components/TextField.tsx +312 -315
  57. package/src/components/TextareaField.tsx +128 -128
  58. package/src/components/TimePicker.tsx +298 -298
  59. package/src/components/Toast/components/ToastItem.tsx +41 -41
  60. package/src/components/Toast/components/ToastProvider.tsx +63 -63
  61. package/src/components/Toast/hooks/useToast.ts +12 -12
  62. package/src/components/Toast/index.tsx +5 -5
  63. package/src/components/Toast/styles/index.ts +135 -135
  64. package/src/components/Toast/types/index.ts +46 -46
  65. package/src/components/Tooltip/index.tsx +66 -66
  66. package/src/components/Tooltip/styles.ts +77 -77
  67. package/src/hooks/useCountries.ts +41 -0
  68. package/src/hooks/useOnClickOutside.tsx +20 -20
  69. package/src/index.tsx +52 -45
  70. package/src/styles/index.ts +38 -38
  71. package/src/types/typographyValues.ts +178 -178
  72. package/src/utils/getNestedValue.ts +3 -0
  73. package/src/utils/states.ts +29 -0
  74. package/tsconfig.json +3 -3
@@ -1,25 +1,29 @@
1
- import { JSX } from "react";
2
- import {
3
- FormProvider,
4
- useForm,
5
- SubmitHandler,
6
- FieldValues,
7
- UseFormProps,
8
- } from "react-hook-form";
9
-
10
- export type FormProps = UseFormProps & {
11
- onSubmit: SubmitHandler<FieldValues>;
12
- children: JSX.Element;
13
- };
14
-
15
- export const Form = ({ onSubmit, children, ...props }: FormProps) => {
16
- const methods = useForm(props);
17
-
18
- const { handleSubmit } = methods;
19
-
20
- return (
21
- <FormProvider {...methods}>
22
- <form onSubmit={handleSubmit(onSubmit)}>{children}</form>
23
- </FormProvider>
24
- );
25
- };
1
+ import { JSX } from "react";
2
+ import {
3
+ FormProvider,
4
+ useForm,
5
+ SubmitHandler,
6
+ FieldValues,
7
+ UseFormProps,
8
+ } from "react-hook-form";
9
+
10
+ export type FormProps<T extends FieldValues = FieldValues> = UseFormProps<T> & {
11
+ onSubmit: SubmitHandler<T>;
12
+ children: JSX.Element;
13
+ methods?: ReturnType<typeof useForm<T>>;
14
+ };
15
+
16
+ export const Form = <T extends FieldValues = FieldValues>({
17
+ onSubmit,
18
+ children,
19
+ methods,
20
+ ...props
21
+ }: FormProps<T>) => {
22
+ const formMethods = methods || useForm<T>(props);
23
+
24
+ return (
25
+ <FormProvider {...formMethods}>
26
+ <form onSubmit={formMethods.handleSubmit(onSubmit)}>{children}</form>
27
+ </FormProvider>
28
+ );
29
+ };
@@ -1,29 +1,29 @@
1
- import { Text } from "../Text";
2
-
3
- export type FormLabelProps = {
4
- name: string;
5
- label?: string;
6
- haveError?: boolean;
7
- required?: boolean;
8
- };
9
-
10
- export const FormLabel = ({
11
- name,
12
- label,
13
- haveError,
14
- required,
15
- }: FormLabelProps) => {
16
- if (!label) return null;
17
-
18
- return (
19
- <Text
20
- typography={"labelMedium"}
21
- fontWeight={"medium"}
22
- color={haveError ? "error600" : "dark700"}
23
- id={`${name}-label`}
24
- >
25
- {label}
26
- {!required && <Text color="dark500"> (opcional)</Text>}
27
- </Text>
28
- );
29
- };
1
+ import { Text } from "../Text";
2
+
3
+ export type FormLabelProps = {
4
+ name: string;
5
+ label?: string;
6
+ haveError?: boolean;
7
+ required?: boolean;
8
+ };
9
+
10
+ export const FormLabel = ({
11
+ name,
12
+ label,
13
+ haveError,
14
+ required,
15
+ }: FormLabelProps) => {
16
+ if (!label) return null;
17
+
18
+ return (
19
+ <Text
20
+ typography={"labelMedium"}
21
+ fontWeight={"medium"}
22
+ color={haveError ? "error600" : "dark700"}
23
+ id={`${name}-label`}
24
+ >
25
+ {label}
26
+ {!required && <Text color="dark500"> (opcional)</Text>}
27
+ </Text>
28
+ );
29
+ };
@@ -0,0 +1,42 @@
1
+ import { TextFormField } from "./TextFormField";
2
+
3
+ type IdentityDocumentNumberFormFieldProps = {
4
+ name: string;
5
+ label: string;
6
+ required?: boolean;
7
+ placeholder?: string;
8
+ validationErrorMessage: string;
9
+ };
10
+
11
+ const isValidRG = (rg: string): boolean => {
12
+ const cleaned = rg.replace(/[^\d]/g, "");
13
+ return /^\d{9}$/.test(cleaned);
14
+ };
15
+
16
+ export const IdentityDocumentNumberFormField = ({
17
+ name,
18
+ label,
19
+ required,
20
+ placeholder,
21
+ validationErrorMessage,
22
+ }: IdentityDocumentNumberFormFieldProps) => {
23
+ return (
24
+ <TextFormField
25
+ name={name}
26
+ label={label}
27
+ required={required}
28
+ placeholder={placeholder || "__.___.___-_"}
29
+ mask={{
30
+ mask: "__.___.___-_",
31
+ replacement: { _: /[0-9]/ },
32
+ }}
33
+ validation={{
34
+ validate: (value: string) => {
35
+ const isEmpty = value.replace(/[^\d]/g, "").length === 0;
36
+ if (!required && isEmpty) return true;
37
+ return isValidRG(value) || validationErrorMessage;
38
+ },
39
+ }}
40
+ />
41
+ );
42
+ };
@@ -1,59 +1,59 @@
1
- import { useController, useFormContext } from "react-hook-form";
2
- import { Flex } from "../Flex";
3
- import { FormLabel } from "./FormLabel";
4
- import { ErrorFormMessage } from "./ErrorFormMessage";
5
- import { MultiSelect, MultiSelectProps } from "../MultiSelect";
6
-
7
- export type MultiSelectFormFieldProps = MultiSelectProps & {
8
- name: string;
9
- label?: string;
10
- required?: boolean;
11
- };
12
-
13
- export const MultiSelectFormField = ({
14
- name,
15
- label,
16
- required,
17
- ...rest
18
- }: MultiSelectFormFieldProps) => {
19
- const {
20
- formState: { errors },
21
- } = useFormContext();
22
-
23
- const { field } = useController({
24
- name,
25
- rules: {
26
- required
27
- },
28
- defaultValue: [],
29
- });
30
-
31
- const { value, onChange, ref, onBlur, disabled } = field;
32
-
33
- const haveError = !!errors[name];
34
-
35
- const errorMsg = errors[name]?.message;
36
-
37
- const handleChange = (v: any) => {
38
- onChange(v);
39
- };
40
-
41
- return (
42
- <Flex direction={"column"}>
43
- <FormLabel
44
- name={name}
45
- label={label}
46
- required={required}
47
- haveError={haveError}
48
- />
49
- <MultiSelect
50
- value={value}
51
- onValueChange={handleChange}
52
- ref={ref}
53
- color={haveError ? "error" : "default"}
54
- {...rest}
55
- />
56
- <ErrorFormMessage message={errorMsg} />
57
- </Flex>
58
- );
59
- };
1
+ import { useController, useFormContext } from "react-hook-form";
2
+ import { Flex } from "../Flex";
3
+ import { FormLabel } from "./FormLabel";
4
+ import { ErrorFormMessage } from "./ErrorFormMessage";
5
+ import { MultiSelect, MultiSelectProps } from "../MultiSelect";
6
+
7
+ export type MultiSelectFormFieldProps = MultiSelectProps & {
8
+ name: string;
9
+ label?: string;
10
+ required?: boolean;
11
+ };
12
+
13
+ export const MultiSelectFormField = ({
14
+ name,
15
+ label,
16
+ required,
17
+ ...rest
18
+ }: MultiSelectFormFieldProps) => {
19
+ const {
20
+ formState: { errors },
21
+ } = useFormContext();
22
+
23
+ const { field } = useController({
24
+ name,
25
+ rules: {
26
+ required
27
+ },
28
+ defaultValue: [],
29
+ });
30
+
31
+ const { value, onChange, ref, onBlur, disabled } = field;
32
+
33
+ const haveError = !!errors[name];
34
+
35
+ const errorMsg = errors[name]?.message;
36
+
37
+ const handleChange = (v: any) => {
38
+ onChange(v);
39
+ };
40
+
41
+ return (
42
+ <Flex direction={"column"}>
43
+ <FormLabel
44
+ name={name}
45
+ label={label}
46
+ required={required}
47
+ haveError={haveError}
48
+ />
49
+ <MultiSelect
50
+ value={value}
51
+ onValueChange={handleChange}
52
+ ref={ref}
53
+ color={haveError ? "error" : "default"}
54
+ {...rest}
55
+ />
56
+ <ErrorFormMessage message={errorMsg} />
57
+ </Flex>
58
+ );
59
+ };
@@ -1,130 +1,130 @@
1
- import { useFormContext } from "react-hook-form";
2
- import { Flex } from "../Flex";
3
- import { FormLabel } from "./FormLabel";
4
- import { ErrorFormMessage } from "./ErrorFormMessage";
5
- // import { PhoneInput, PhoneInputProps } from 'react-international-phone'
6
- import { styled } from "../../styles";
7
- import { typographyValues } from "../../types/typographyValues";
8
- // import 'react-international-phone/style.css'
9
-
10
- export type PhoneFormFieldProps = {
11
- name: string;
12
- label?: string;
13
- required?: boolean;
14
- defaultCountry?: string;
15
- };
16
- // const PhoneFormInput = styled(PhoneInput, {
17
- // $$borderColor: '$colors$neutral300',
18
- // boxSizing: 'border-box',
19
- // borderRadius: '$sm',
20
- // display: 'flex',
21
- // flex: 1,
22
- // fontFamily: '$default',
23
- // color: '$dark500',
24
-
25
- // img: {
26
- // width: '$18',
27
- // height: '$18',
28
- // marginLeft: '$8',
29
- // },
30
- // ul: {
31
- // border: 'none',
32
- // },
33
- // input: {
34
- // height: '$40 !important',
35
- // flex: 1,
36
- // borderColor: '$$borderColor !important',
37
- // borderTopRightRadius: '$sm !important',
38
- // borderBottomRightRadius: '$sm !important',
39
- // fontSize: 'inherit !important',
40
- // '&:focus': {
41
- // $$borderColor: '$colors$brand300',
42
- // },
43
- // },
44
- // button: {
45
- // height: '$40 !important',
46
- // borderRight: 'none',
47
- // borderTopLeftRadius: '$sm !important',
48
- // borderBottomLeftRadius: '$sm !important',
49
- // borderColor: '$$borderColor !important',
50
- // marginRight: '0 !important',
51
- // '&:active': {
52
- // $$borderColor: '$colors$brand300',
53
- // },
54
- // div: {
55
- // padding: 'auto $12',
56
- // gap: ' $8px',
57
- // },
58
- // },
59
-
60
- // '&:has(input:disabled)': {
61
- // backgroundColor: '$dark100',
62
- // color: '$dark400',
63
- // $$borderColor: '$colors$dark200',
64
- // cursor: 'not-allowed',
65
- // img: {
66
- // opacity: 0.6,
67
- // },
68
- // button: {
69
- // $$borderColor: '$colors$dark200',
70
- // },
71
- // },
72
- // variants: {
73
- // typography: typographyValues,
74
- // color: {
75
- // default: {
76
- // $$borderColor: '$colors$neutral300',
77
- // },
78
- // error: {
79
- // $$borderColor: '$colors$error600',
80
- // },
81
- // },
82
- // },
83
- // defaultVariants: {
84
- // typography: 'labelSmall',
85
- // color: 'default',
86
- // },
87
- // })
88
-
89
- export const PhoneFormField = ({
90
- name,
91
- label,
92
- required,
93
- defaultCountry = "br",
94
- ...props
95
- }: PhoneFormFieldProps) => {
96
- const {
97
- register,
98
- formState: { errors },
99
- setValue,
100
- watch,
101
- } = useFormContext();
102
-
103
- const haveError = !!errors[name];
104
- const errorMsg = errors[name]?.message;
105
-
106
- const handlePhoneChange = (phone: string) => {
107
- setValue(name, phone);
108
- };
109
-
110
- return (
111
- <Flex direction={"column"}>
112
- <FormLabel
113
- name={name}
114
- label={label}
115
- required={required}
116
- haveError={haveError}
117
- />
118
- {/* <PhoneFormInput
119
- {...register(name, { required })}
120
- defaultCountry={defaultCountry}
121
- value={watch(name)}
122
- color={haveError ? 'error' : 'default'}
123
- onChange={handlePhoneChange}
124
- {...props}
125
- aria-labelledby={`${name}-label`}
126
- /> */}
127
- <ErrorFormMessage message={errorMsg} />
128
- </Flex>
129
- );
130
- };
1
+ import { useFormContext } from "react-hook-form";
2
+ import { Flex } from "../Flex";
3
+ import { FormLabel } from "./FormLabel";
4
+ import { ErrorFormMessage } from "./ErrorFormMessage";
5
+ // import { PhoneInput, PhoneInputProps } from 'react-international-phone'
6
+ import { styled } from "../../styles";
7
+ import { typographyValues } from "../../types/typographyValues";
8
+ // import 'react-international-phone/style.css'
9
+
10
+ export type PhoneFormFieldProps = {
11
+ name: string;
12
+ label?: string;
13
+ required?: boolean;
14
+ defaultCountry?: string;
15
+ };
16
+ // const PhoneFormInput = styled(PhoneInput, {
17
+ // $$borderColor: '$colors$neutral300',
18
+ // boxSizing: 'border-box',
19
+ // borderRadius: '$sm',
20
+ // display: 'flex',
21
+ // flex: 1,
22
+ // fontFamily: '$default',
23
+ // color: '$dark500',
24
+
25
+ // img: {
26
+ // width: '$18',
27
+ // height: '$18',
28
+ // marginLeft: '$8',
29
+ // },
30
+ // ul: {
31
+ // border: 'none',
32
+ // },
33
+ // input: {
34
+ // height: '$40 !important',
35
+ // flex: 1,
36
+ // borderColor: '$$borderColor !important',
37
+ // borderTopRightRadius: '$sm !important',
38
+ // borderBottomRightRadius: '$sm !important',
39
+ // fontSize: 'inherit !important',
40
+ // '&:focus': {
41
+ // $$borderColor: '$colors$brand300',
42
+ // },
43
+ // },
44
+ // button: {
45
+ // height: '$40 !important',
46
+ // borderRight: 'none',
47
+ // borderTopLeftRadius: '$sm !important',
48
+ // borderBottomLeftRadius: '$sm !important',
49
+ // borderColor: '$$borderColor !important',
50
+ // marginRight: '0 !important',
51
+ // '&:active': {
52
+ // $$borderColor: '$colors$brand300',
53
+ // },
54
+ // div: {
55
+ // padding: 'auto $12',
56
+ // gap: ' $8px',
57
+ // },
58
+ // },
59
+
60
+ // '&:has(input:disabled)': {
61
+ // backgroundColor: '$dark100',
62
+ // color: '$dark400',
63
+ // $$borderColor: '$colors$dark200',
64
+ // cursor: 'not-allowed',
65
+ // img: {
66
+ // opacity: 0.6,
67
+ // },
68
+ // button: {
69
+ // $$borderColor: '$colors$dark200',
70
+ // },
71
+ // },
72
+ // variants: {
73
+ // typography: typographyValues,
74
+ // color: {
75
+ // default: {
76
+ // $$borderColor: '$colors$neutral300',
77
+ // },
78
+ // error: {
79
+ // $$borderColor: '$colors$error600',
80
+ // },
81
+ // },
82
+ // },
83
+ // defaultVariants: {
84
+ // typography: 'labelSmall',
85
+ // color: 'default',
86
+ // },
87
+ // })
88
+
89
+ export const PhoneFormField = ({
90
+ name,
91
+ label,
92
+ required,
93
+ defaultCountry = "br",
94
+ ...props
95
+ }: PhoneFormFieldProps) => {
96
+ const {
97
+ register,
98
+ formState: { errors },
99
+ setValue,
100
+ watch,
101
+ } = useFormContext();
102
+
103
+ const haveError = !!errors[name];
104
+ const errorMsg = errors[name]?.message;
105
+
106
+ const handlePhoneChange = (phone: string) => {
107
+ setValue(name, phone);
108
+ };
109
+
110
+ return (
111
+ <Flex direction={"column"}>
112
+ <FormLabel
113
+ name={name}
114
+ label={label}
115
+ required={required}
116
+ haveError={haveError}
117
+ />
118
+ {/* <PhoneFormInput
119
+ {...register(name, { required })}
120
+ defaultCountry={defaultCountry}
121
+ value={watch(name)}
122
+ color={haveError ? 'error' : 'default'}
123
+ onChange={handlePhoneChange}
124
+ {...props}
125
+ aria-labelledby={`${name}-label`}
126
+ /> */}
127
+ <ErrorFormMessage message={errorMsg} />
128
+ </Flex>
129
+ );
130
+ };
@@ -0,0 +1,84 @@
1
+ import { Controller, useFormContext } from "react-hook-form";
2
+ import { Flex } from "../Flex";
3
+ import { FormLabel } from "./FormLabel";
4
+ import { ErrorFormMessage } from "./ErrorFormMessage";
5
+ import { RadioGroup, RadioItem } from "../RadioGroup";
6
+ import { getNestedValue } from "../../utils/getNestedValue";
7
+
8
+ type Option = {
9
+ label: string;
10
+ value: string;
11
+ };
12
+
13
+ export type RadioGroupFormFieldProps = {
14
+ name: string;
15
+ label: string;
16
+ options: Option[];
17
+ required?: boolean;
18
+ defaultValue?: string;
19
+ validationErrorMessage?: string;
20
+ color?: "blue" | "success" | "error";
21
+ fontWeight?: "regular" | "medium" | "semibold" | "bold";
22
+ disabled?: boolean;
23
+ };
24
+
25
+ export const RadioGroupFormField = ({
26
+ name,
27
+ label,
28
+ options,
29
+ required,
30
+ defaultValue,
31
+ validationErrorMessage = "Este campo é obrigatório.",
32
+ color = "blue",
33
+ fontWeight = "regular",
34
+ disabled = false,
35
+ }: RadioGroupFormFieldProps) => {
36
+ const {
37
+ control,
38
+ formState: { errors },
39
+ } = useFormContext();
40
+
41
+ const fieldError = getNestedValue(errors, name);
42
+ const haveError = !!fieldError;
43
+ const errorMsg = fieldError?.message;
44
+
45
+ const validationRules = {
46
+ required: required ? validationErrorMessage : false,
47
+ };
48
+
49
+ return (
50
+ <Flex direction="column">
51
+ <FormLabel
52
+ name={name}
53
+ label={label}
54
+ required={required}
55
+ haveError={haveError}
56
+ />
57
+
58
+ <Controller
59
+ name={name}
60
+ control={control}
61
+ defaultValue={defaultValue || ""}
62
+ rules={validationRules}
63
+ render={({ field: { value, onChange } }) => (
64
+ <RadioGroup
65
+ value={value}
66
+ onValueChange={onChange}
67
+ color={haveError ? "error" : color}
68
+ fontWeight={fontWeight}
69
+ disabled={disabled}
70
+ >
71
+ {options.map((option) => (
72
+ <label key={option.value}>
73
+ <RadioItem value={option.value} />
74
+ {option.label}
75
+ </label>
76
+ ))}
77
+ </RadioGroup>
78
+ )}
79
+ />
80
+
81
+ <ErrorFormMessage message={errorMsg} />
82
+ </Flex>
83
+ );
84
+ };