@lets-events/react 12.4.1 → 12.5.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 (91) hide show
  1. package/.eslintrc.json +2 -2
  2. package/CHANGELOG.md +6 -0
  3. package/package.json +1 -1
  4. package/src/components/Alert.tsx +303 -303
  5. package/src/components/Avatar.tsx +55 -55
  6. package/src/components/Badge.tsx +125 -125
  7. package/src/components/Box.tsx +3 -3
  8. package/src/components/Button/index.tsx +45 -45
  9. package/src/components/Button/styledComponents.ts +313 -313
  10. package/src/components/ButtonGroup.tsx +484 -484
  11. package/src/components/Calendar/index.tsx +148 -148
  12. package/src/components/Calendar/styledComponents.ts +259 -259
  13. package/src/components/Card.tsx +67 -67
  14. package/src/components/CheckboxGroup.tsx +176 -176
  15. package/src/components/Container.tsx +39 -39
  16. package/src/components/Divider.tsx +7 -7
  17. package/src/components/DoubleCalendar/index.tsx +170 -166
  18. package/src/components/Drawer/index.tsx +100 -98
  19. package/src/components/Drawer/styledComponents.ts +103 -103
  20. package/src/components/Dropdown.tsx +302 -302
  21. package/src/components/Filter.tsx +164 -164
  22. package/src/components/Flex.tsx +118 -118
  23. package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
  24. package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
  25. package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
  26. package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
  27. package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
  28. package/src/components/FormFields/BirthDateFormField.tsx +84 -84
  29. package/src/components/FormFields/CNPJFormField.tsx +87 -87
  30. package/src/components/FormFields/CPFFormField.tsx +78 -78
  31. package/src/components/FormFields/CalendarFormField.tsx +95 -95
  32. package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
  33. package/src/components/FormFields/DoubleCalendarFormField.tsx +93 -90
  34. package/src/components/FormFields/EmailFormField.tsx +27 -27
  35. package/src/components/FormFields/Form.tsx +39 -39
  36. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +32 -32
  37. package/src/components/FormFields/MultiSelectFormField.tsx +64 -64
  38. package/src/components/FormFields/PhoneFormField.tsx +40 -40
  39. package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
  40. package/src/components/FormFields/RichEditorFormField.tsx +103 -103
  41. package/src/components/FormFields/SelectFormField.tsx +93 -93
  42. package/src/components/FormFields/SwitchFormField.tsx +46 -46
  43. package/src/components/FormFields/TextAreaFormField.tsx +59 -59
  44. package/src/components/FormFields/TextFormField.tsx +112 -112
  45. package/src/components/FormFields/TimePickerFormField.tsx +88 -88
  46. package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
  47. package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
  48. package/src/components/FormFields/utils/validation.ts +23 -23
  49. package/src/components/Grid.tsx +137 -137
  50. package/src/components/Icon.tsx +47 -47
  51. package/src/components/MenuDropdown/index.tsx +38 -38
  52. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  53. package/src/components/Modal.tsx +110 -110
  54. package/src/components/MultiSelect/index.tsx +243 -243
  55. package/src/components/MultiSelect/styledComponents.ts +160 -160
  56. package/src/components/RadioGroup.tsx +210 -210
  57. package/src/components/RichEditor/QuillComponent.tsx +457 -457
  58. package/src/components/RichEditor/RichEditor.tsx +49 -49
  59. package/src/components/RichEditor/index.ts +2 -2
  60. package/src/components/RichEditor/styledComponents.ts +1151 -1151
  61. package/src/components/Section.tsx +33 -33
  62. package/src/components/Step.tsx +164 -164
  63. package/src/components/Switch.tsx +108 -108
  64. package/src/components/Text.tsx +38 -38
  65. package/src/components/TextField.tsx +372 -372
  66. package/src/components/TextareaField.tsx +138 -138
  67. package/src/components/TimePicker.tsx +328 -328
  68. package/src/components/Toast/components/ToastItem.tsx +41 -41
  69. package/src/components/Toast/components/ToastProvider.tsx +63 -63
  70. package/src/components/Toast/hooks/useToast.ts +12 -12
  71. package/src/components/Toast/index.tsx +5 -5
  72. package/src/components/Toast/styles/index.ts +135 -135
  73. package/src/components/Toast/types/index.ts +46 -46
  74. package/src/components/Tooltip/index.tsx +66 -66
  75. package/src/components/Tooltip/styles.ts +77 -77
  76. package/src/hooks/useCountries.ts +41 -41
  77. package/src/hooks/useImageUpload.ts +139 -139
  78. package/src/hooks/useOnClickOutside.tsx +42 -42
  79. package/src/index.tsx +71 -71
  80. package/src/styles/index.ts +41 -41
  81. package/src/types/typographyValues.ts +178 -178
  82. package/src/utils/getNestedValue.ts +3 -3
  83. package/src/utils/states.ts +29 -29
  84. package/src/utils/uploadService.ts +180 -180
  85. package/tsconfig.json +3 -3
  86. package/tsup.config.ts +38 -38
  87. package/.turbo/turbo-build.log +0 -19
  88. package/dist/index.d.mts +0 -15398
  89. package/dist/index.d.ts +0 -15398
  90. package/dist/index.js +0 -13390
  91. package/dist/index.mjs +0 -13284
@@ -1,23 +1,23 @@
1
- const isValidEmail = (email: string) => {
2
- const emailRexep =
3
- /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
4
- return emailRexep.test(email);
5
- };
6
-
7
- export const validateEmail = (errorMsg: string) => (value: string) => {
8
- return !isValidEmail(value) ? errorMsg : true;
9
- };
10
-
11
- export const maxLength = (max: number, errorMsg: string) => (value: string) => {
12
- return value.length > max ? errorMsg : true;
13
- };
14
-
15
- export const minLength = (min: number, errorMsg: string) => (value: string) => {
16
- return value.length < min ? errorMsg : true;
17
- };
18
-
19
- export const minMaxLength =
20
- (min: number, max: number, errorMsg: string) => (value: string) => {
21
- var length = value.length;
22
- return length > max || length < min ? errorMsg : true;
23
- };
1
+ const isValidEmail = (email: string) => {
2
+ const emailRexep =
3
+ /^(([^<>()[\].,;:\s@"]+(\.[^<>()[\].,;:\s@"]+)*)|(".+"))@(([^<>()[\].,;:\s@"]+\.)+[^<>()[\].,;:\s@"]{2,})$/i;
4
+ return emailRexep.test(email);
5
+ };
6
+
7
+ export const validateEmail = (errorMsg: string) => (value: string) => {
8
+ return !isValidEmail(value) ? errorMsg : true;
9
+ };
10
+
11
+ export const maxLength = (max: number, errorMsg: string) => (value: string) => {
12
+ return value.length > max ? errorMsg : true;
13
+ };
14
+
15
+ export const minLength = (min: number, errorMsg: string) => (value: string) => {
16
+ return value.length < min ? errorMsg : true;
17
+ };
18
+
19
+ export const minMaxLength =
20
+ (min: number, max: number, errorMsg: string) => (value: string) => {
21
+ var length = value.length;
22
+ return length > max || length < min ? errorMsg : true;
23
+ };
@@ -1,138 +1,138 @@
1
- import { ComponentProps, ElementType } from 'react';
2
- import { styled } from '../styles'
3
- import { Grid as GridRadix } from "@radix-ui/themes";
4
- export const GridStyled = styled(GridRadix, {
5
- display: 'grid',
6
- variants: {
7
- display: {
8
- 'grid': { display: 'grid' },
9
- 'inline-grid': { display: 'inline-grid' },
10
- },
11
- align: {
12
- start: { alignItems: 'start' },
13
- center: { alignItems: 'center' },
14
- end: { alignItems: 'end' },
15
- stretch: { alignItems: 'stretch' },
16
- },
17
- justify: {
18
- start: { justifyContent: 'start' },
19
- center: { justifyContent: 'center' },
20
- end: { justifyContent: 'end' },
21
- between: { justifyContent: 'space-between' },
22
- },
23
- flow: {
24
- row: { gridAutoFlow: 'row' },
25
- column: { gridAutoFlow: 'column' },
26
- 'row-dense': { gridAutoFlow: 'row dense' },
27
- 'column-dense': { gridAutoFlow: 'column dense' },
28
- },
29
- columns: {
30
- 1: { gridTemplateColumns: 'repeat(1, 1fr)' },
31
- 2: { gridTemplateColumns: 'repeat(2, 1fr)' },
32
- 3: { gridTemplateColumns: 'repeat(3, 1fr)' },
33
- 4: { gridTemplateColumns: 'repeat(4, 1fr)' },
34
- 6: { gridTemplateColumns: 'repeat(6, 1fr)' },
35
- 12: { gridTemplateColumns: 'repeat(12, 1fr)' },
36
- },
37
- rows: {
38
- 1: { gridTemplateRows: 'repeat(1, 1fr)' },
39
- 2: { gridTemplateRows: 'repeat(2, 1fr)' },
40
- 3: { gridTemplateRows: 'repeat(3, 1fr)' },
41
- 4: { gridTemplateRows: 'repeat(4, 1fr)' },
42
- 5: { gridTemplateRows: 'repeat(5, 1fr)' },
43
- 6: { gridTemplateRows: 'repeat(6, 1fr)' },
44
- 7: { gridTemplateRows: 'repeat(7, 1fr)' },
45
- 8: { gridTemplateRows: 'repeat(8, 1fr)' },
46
- 9: { gridTemplateRows: 'repeat(9, 1fr)' },
47
- 10: { gridTemplateRows: 'repeat(10, 1fr)' },
48
- 11: { gridTemplateRows: 'repeat(11, 1fr)' },
49
- 12: { gridTemplateRows: 'repeat(12, 1fr)' },
50
- auto: { gridTemplateRows: 'auto' },
51
- },
52
- gap: {
53
- 2: { gap: '$2' },
54
- 4: { gap: '$4' },
55
- 6: { gap: '$6' },
56
- 8: { gap: '$8' },
57
- 10: { gap: '$10' },
58
- 12: { gap: '$12' },
59
- 14: { gap: '$14' },
60
- 16: { gap: '$16' },
61
- 20: { gap: '$20' },
62
- 22: { gap: '$22' },
63
- 24: { gap: '$24' },
64
- 32: { gap: '$32' },
65
- 36: { gap: '$36' },
66
- 40: { gap: '$40' },
67
- 48: { gap: '$48' },
68
- 56: { gap: '$56' },
69
- 64: { gap: '$64' },
70
- 72: { gap: '$72' },
71
- 80: { gap: '$80' },
72
- full: { gap: '$full' },
73
- },
74
- gapX: {
75
- 2: { gap: '$2' },
76
- 4: { gap: '$4' },
77
- 6: { gap: '$6' },
78
- 8: { gap: '$8' },
79
- 10: { gap: '$10' },
80
- 12: { gap: '$12' },
81
- 14: { gap: '$14' },
82
- 16: { gap: '$16' },
83
- 20: { gap: '$20' },
84
- 22: { gap: '$22' },
85
- 24: { gap: '$24' },
86
- 32: { gap: '$32' },
87
- 36: { gap: '$36' },
88
- 40: { gap: '$40' },
89
- 48: { gap: '$48' },
90
- 56: { gap: '$56' },
91
- 64: { gap: '$64' },
92
- 72: { gap: '$72' },
93
- 80: { gap: '$80' },
94
- full: { gap: '$full' },
95
- },
96
- gapY: {
97
- 2: { gap: '$2' },
98
- 4: { gap: '$4' },
99
- 6: { gap: '$6' },
100
- 8: { gap: '$8' },
101
- 10: { gap: '$10' },
102
- 12: { gap: '$12' },
103
- 14: { gap: '$14' },
104
- 16: { gap: '$16' },
105
- 20: { gap: '$20' },
106
- 22: { gap: '$22' },
107
- 24: { gap: '$24' },
108
- 32: { gap: '$32' },
109
- 36: { gap: '$36' },
110
- 40: { gap: '$40' },
111
- 48: { gap: '$48' },
112
- 56: { gap: '$56' },
113
- 64: { gap: '$64' },
114
- 72: { gap: '$72' },
115
- 80: { gap: '$80' },
116
- full: { gap: '$full' },
117
- },
118
- },
119
- defaultVariants: {
120
- gap: 10,
121
- }
122
-
123
- })
124
-
125
- export type GridProps = ComponentProps<typeof GridStyled> & {
126
- as?: ElementType
127
- children: React.ReactNode,
128
- areas?: string
129
- }
130
-
131
-
132
- export function Grid({ children, ...props }: GridProps) {
133
- return (
134
- <GridStyled {...props}>
135
- {children}
136
- </GridStyled>
137
- )
1
+ import { ComponentProps, ElementType } from 'react';
2
+ import { styled } from '../styles'
3
+ import { Grid as GridRadix } from "@radix-ui/themes";
4
+ export const GridStyled = styled(GridRadix, {
5
+ display: 'grid',
6
+ variants: {
7
+ display: {
8
+ 'grid': { display: 'grid' },
9
+ 'inline-grid': { display: 'inline-grid' },
10
+ },
11
+ align: {
12
+ start: { alignItems: 'start' },
13
+ center: { alignItems: 'center' },
14
+ end: { alignItems: 'end' },
15
+ stretch: { alignItems: 'stretch' },
16
+ },
17
+ justify: {
18
+ start: { justifyContent: 'start' },
19
+ center: { justifyContent: 'center' },
20
+ end: { justifyContent: 'end' },
21
+ between: { justifyContent: 'space-between' },
22
+ },
23
+ flow: {
24
+ row: { gridAutoFlow: 'row' },
25
+ column: { gridAutoFlow: 'column' },
26
+ 'row-dense': { gridAutoFlow: 'row dense' },
27
+ 'column-dense': { gridAutoFlow: 'column dense' },
28
+ },
29
+ columns: {
30
+ 1: { gridTemplateColumns: 'repeat(1, 1fr)' },
31
+ 2: { gridTemplateColumns: 'repeat(2, 1fr)' },
32
+ 3: { gridTemplateColumns: 'repeat(3, 1fr)' },
33
+ 4: { gridTemplateColumns: 'repeat(4, 1fr)' },
34
+ 6: { gridTemplateColumns: 'repeat(6, 1fr)' },
35
+ 12: { gridTemplateColumns: 'repeat(12, 1fr)' },
36
+ },
37
+ rows: {
38
+ 1: { gridTemplateRows: 'repeat(1, 1fr)' },
39
+ 2: { gridTemplateRows: 'repeat(2, 1fr)' },
40
+ 3: { gridTemplateRows: 'repeat(3, 1fr)' },
41
+ 4: { gridTemplateRows: 'repeat(4, 1fr)' },
42
+ 5: { gridTemplateRows: 'repeat(5, 1fr)' },
43
+ 6: { gridTemplateRows: 'repeat(6, 1fr)' },
44
+ 7: { gridTemplateRows: 'repeat(7, 1fr)' },
45
+ 8: { gridTemplateRows: 'repeat(8, 1fr)' },
46
+ 9: { gridTemplateRows: 'repeat(9, 1fr)' },
47
+ 10: { gridTemplateRows: 'repeat(10, 1fr)' },
48
+ 11: { gridTemplateRows: 'repeat(11, 1fr)' },
49
+ 12: { gridTemplateRows: 'repeat(12, 1fr)' },
50
+ auto: { gridTemplateRows: 'auto' },
51
+ },
52
+ gap: {
53
+ 2: { gap: '$2' },
54
+ 4: { gap: '$4' },
55
+ 6: { gap: '$6' },
56
+ 8: { gap: '$8' },
57
+ 10: { gap: '$10' },
58
+ 12: { gap: '$12' },
59
+ 14: { gap: '$14' },
60
+ 16: { gap: '$16' },
61
+ 20: { gap: '$20' },
62
+ 22: { gap: '$22' },
63
+ 24: { gap: '$24' },
64
+ 32: { gap: '$32' },
65
+ 36: { gap: '$36' },
66
+ 40: { gap: '$40' },
67
+ 48: { gap: '$48' },
68
+ 56: { gap: '$56' },
69
+ 64: { gap: '$64' },
70
+ 72: { gap: '$72' },
71
+ 80: { gap: '$80' },
72
+ full: { gap: '$full' },
73
+ },
74
+ gapX: {
75
+ 2: { gap: '$2' },
76
+ 4: { gap: '$4' },
77
+ 6: { gap: '$6' },
78
+ 8: { gap: '$8' },
79
+ 10: { gap: '$10' },
80
+ 12: { gap: '$12' },
81
+ 14: { gap: '$14' },
82
+ 16: { gap: '$16' },
83
+ 20: { gap: '$20' },
84
+ 22: { gap: '$22' },
85
+ 24: { gap: '$24' },
86
+ 32: { gap: '$32' },
87
+ 36: { gap: '$36' },
88
+ 40: { gap: '$40' },
89
+ 48: { gap: '$48' },
90
+ 56: { gap: '$56' },
91
+ 64: { gap: '$64' },
92
+ 72: { gap: '$72' },
93
+ 80: { gap: '$80' },
94
+ full: { gap: '$full' },
95
+ },
96
+ gapY: {
97
+ 2: { gap: '$2' },
98
+ 4: { gap: '$4' },
99
+ 6: { gap: '$6' },
100
+ 8: { gap: '$8' },
101
+ 10: { gap: '$10' },
102
+ 12: { gap: '$12' },
103
+ 14: { gap: '$14' },
104
+ 16: { gap: '$16' },
105
+ 20: { gap: '$20' },
106
+ 22: { gap: '$22' },
107
+ 24: { gap: '$24' },
108
+ 32: { gap: '$32' },
109
+ 36: { gap: '$36' },
110
+ 40: { gap: '$40' },
111
+ 48: { gap: '$48' },
112
+ 56: { gap: '$56' },
113
+ 64: { gap: '$64' },
114
+ 72: { gap: '$72' },
115
+ 80: { gap: '$80' },
116
+ full: { gap: '$full' },
117
+ },
118
+ },
119
+ defaultVariants: {
120
+ gap: 10,
121
+ }
122
+
123
+ })
124
+
125
+ export type GridProps = ComponentProps<typeof GridStyled> & {
126
+ as?: ElementType
127
+ children: React.ReactNode,
128
+ areas?: string
129
+ }
130
+
131
+
132
+ export function Grid({ children, ...props }: GridProps) {
133
+ return (
134
+ <GridStyled {...props}>
135
+ {children}
136
+ </GridStyled>
137
+ )
138
138
  }
@@ -1,48 +1,48 @@
1
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2
- import { library } from "@fortawesome/fontawesome-svg-core";
3
- import { fas } from "@fortawesome/free-solid-svg-icons";
4
- import { far } from "@fortawesome/free-regular-svg-icons";
5
- import { fab } from "@fortawesome/free-brands-svg-icons";
6
- import { IconName, IconPrefix } from "@fortawesome/fontawesome-svg-core";
7
- import { FontAwesomeIconProps } from "@fortawesome/react-fontawesome";
8
- import PropTypes from "prop-types";
9
-
10
- library.add(fas, far, fab);
11
-
12
- export interface IconProps extends Omit<FontAwesomeIconProps, "icon" | "size"> {
13
- name: IconName;
14
- size?: 'xs' | 'sm' | 'md' | 'xl';
15
- prefix?: IconPrefix;
16
- }
17
-
18
- export const Icon = ({ name, prefix = "fas", size = "sm", color = "currentColor", className = "", ...props }: IconProps) => {
19
- const sizeMap = {
20
-
21
- 'xs': { width: '0.625rem', height: '0.625rem', fontSize: '0.625rem' },
22
- 'sm': { width: '0.625rem', height: '0.625rem', fontSize: '0.625rem' },
23
- 'md': { width: '0.75rem', height: '0.75rem', fontSize: '0.75rem' },
24
- 'xl': { width: '1rem', height: '1rem', fontSize: '1rem' },
25
- undefined: { width: '0.75rem', height: '0.75rem', fontSize: '0.75rem' },
26
- } as const;
27
-
28
- return (
29
- <FontAwesomeIcon
30
- icon={[prefix, name]}
31
- style={sizeMap[size]}
32
- color={color}
33
- className={className}
34
- {...props}
35
- width={sizeMap[size]?.width}
36
- height={sizeMap[size]?.height}
37
- />
38
- );
39
- };
40
- Icon.propTypes = {
41
- name: PropTypes.string.isRequired,
42
- prefix: PropTypes.string,
43
- size: PropTypes.string,
44
- color: PropTypes.string,
45
- className: PropTypes.string,
46
- };
47
-
1
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
2
+ import { library } from "@fortawesome/fontawesome-svg-core";
3
+ import { fas } from "@fortawesome/free-solid-svg-icons";
4
+ import { far } from "@fortawesome/free-regular-svg-icons";
5
+ import { fab } from "@fortawesome/free-brands-svg-icons";
6
+ import { IconName, IconPrefix } from "@fortawesome/fontawesome-svg-core";
7
+ import { FontAwesomeIconProps } from "@fortawesome/react-fontawesome";
8
+ import PropTypes from "prop-types";
9
+
10
+ library.add(fas, far, fab);
11
+
12
+ export interface IconProps extends Omit<FontAwesomeIconProps, "icon" | "size"> {
13
+ name: IconName;
14
+ size?: 'xs' | 'sm' | 'md' | 'xl';
15
+ prefix?: IconPrefix;
16
+ }
17
+
18
+ export const Icon = ({ name, prefix = "fas", size = "sm", color = "currentColor", className = "", ...props }: IconProps) => {
19
+ const sizeMap = {
20
+
21
+ 'xs': { width: '0.625rem', height: '0.625rem', fontSize: '0.625rem' },
22
+ 'sm': { width: '0.625rem', height: '0.625rem', fontSize: '0.625rem' },
23
+ 'md': { width: '0.75rem', height: '0.75rem', fontSize: '0.75rem' },
24
+ 'xl': { width: '1rem', height: '1rem', fontSize: '1rem' },
25
+ undefined: { width: '0.75rem', height: '0.75rem', fontSize: '0.75rem' },
26
+ } as const;
27
+
28
+ return (
29
+ <FontAwesomeIcon
30
+ icon={[prefix, name]}
31
+ style={sizeMap[size]}
32
+ color={color}
33
+ className={className}
34
+ {...props}
35
+ width={sizeMap[size]?.width}
36
+ height={sizeMap[size]?.height}
37
+ />
38
+ );
39
+ };
40
+ Icon.propTypes = {
41
+ name: PropTypes.string.isRequired,
42
+ prefix: PropTypes.string,
43
+ size: PropTypes.string,
44
+ color: PropTypes.string,
45
+ className: PropTypes.string,
46
+ };
47
+
48
48
  export default Icon;
@@ -1,38 +1,38 @@
1
- import React, { ReactNode, HTMLAttributes, useRef } from "react";
2
- import {
3
- MenuDropdownContainerStyled,
4
- TriggerButtonStyled,
5
- MenuItemsContainerStyled,
6
- } from "./styledComponents";
7
- import Icon from "../Icon";
8
- import { useOnClickOutside } from "../../hooks/useOnClickOutside";
9
-
10
- export type MenuDropdownProps = HTMLAttributes<HTMLDivElement> & {
11
- children: ReactNode;
12
- isOpen: boolean;
13
- setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
14
- };
15
-
16
- export function MenuDropdown({
17
- children,
18
- isOpen,
19
- setIsOpen,
20
- }: MenuDropdownProps) {
21
- const dropdownItemsContainerRef = useRef<HTMLDivElement>(null);
22
-
23
- useOnClickOutside(dropdownItemsContainerRef, () => {
24
- setIsOpen(false);
25
- });
26
- return (
27
- <MenuDropdownContainerStyled>
28
- <TriggerButtonStyled onClick={() => setIsOpen(!isOpen)}>
29
- <Icon name="ellipsis" size="xl" color="#FFFFFF" />
30
- </TriggerButtonStyled>
31
- {isOpen && (
32
- <MenuItemsContainerStyled ref={dropdownItemsContainerRef}>
33
- {children}
34
- </MenuItemsContainerStyled>
35
- )}
36
- </MenuDropdownContainerStyled>
37
- );
38
- }
1
+ import React, { ReactNode, HTMLAttributes, useRef } from "react";
2
+ import {
3
+ MenuDropdownContainerStyled,
4
+ TriggerButtonStyled,
5
+ MenuItemsContainerStyled,
6
+ } from "./styledComponents";
7
+ import Icon from "../Icon";
8
+ import { useOnClickOutside } from "../../hooks/useOnClickOutside";
9
+
10
+ export type MenuDropdownProps = HTMLAttributes<HTMLDivElement> & {
11
+ children: ReactNode;
12
+ isOpen: boolean;
13
+ setIsOpen: React.Dispatch<React.SetStateAction<boolean>>;
14
+ };
15
+
16
+ export function MenuDropdown({
17
+ children,
18
+ isOpen,
19
+ setIsOpen,
20
+ }: MenuDropdownProps) {
21
+ const dropdownItemsContainerRef = useRef<HTMLDivElement>(null);
22
+
23
+ useOnClickOutside(dropdownItemsContainerRef, () => {
24
+ setIsOpen(false);
25
+ });
26
+ return (
27
+ <MenuDropdownContainerStyled>
28
+ <TriggerButtonStyled onClick={() => setIsOpen(!isOpen)}>
29
+ <Icon name="ellipsis" size="xl" color="#FFFFFF" />
30
+ </TriggerButtonStyled>
31
+ {isOpen && (
32
+ <MenuItemsContainerStyled ref={dropdownItemsContainerRef}>
33
+ {children}
34
+ </MenuItemsContainerStyled>
35
+ )}
36
+ </MenuDropdownContainerStyled>
37
+ );
38
+ }
@@ -1,31 +1,31 @@
1
- import { styled } from "../../styles";
2
-
3
- export const MenuDropdownContainerStyled = styled("div", {
4
- position: "relative",
5
- width: "fit-content",
6
- });
7
- export const TriggerButtonStyled = styled("button", {
8
- backgroundColor: "$brand500",
9
- boxShadow: "0px 4px 4px 0px #23354314",
10
- borderRadius: "$full",
11
- border: "none",
12
- height: "1.875rem",
13
- width: "1.875rem",
14
- cursor: "pointer",
15
- });
16
- export const MenuItemsContainerStyled = styled("div", {
17
- position: "absolute",
18
- right: 0,
19
- top: "2.125rem",
20
- zIndex: "999",
21
- width: "fit-content",
22
- minWidth: "5rem",
23
- background: "#fff",
24
- maxWidth: "18.75rem",
25
- margin: "auto",
26
- boxShadow: "0px 4px 4px 0px rgba(35, 53, 67, 0.0784313725)",
27
- border: "1px solid $dark300",
28
- borderRadius: "0.5rem",
29
- padding: "0.5rem 0",
30
- height: "fit-content",
31
- });
1
+ import { styled } from "../../styles";
2
+
3
+ export const MenuDropdownContainerStyled = styled("div", {
4
+ position: "relative",
5
+ width: "fit-content",
6
+ });
7
+ export const TriggerButtonStyled = styled("button", {
8
+ backgroundColor: "$brand500",
9
+ boxShadow: "0px 4px 4px 0px #23354314",
10
+ borderRadius: "$full",
11
+ border: "none",
12
+ height: "1.875rem",
13
+ width: "1.875rem",
14
+ cursor: "pointer",
15
+ });
16
+ export const MenuItemsContainerStyled = styled("div", {
17
+ position: "absolute",
18
+ right: 0,
19
+ top: "2.125rem",
20
+ zIndex: "999",
21
+ width: "fit-content",
22
+ minWidth: "5rem",
23
+ background: "#fff",
24
+ maxWidth: "18.75rem",
25
+ margin: "auto",
26
+ boxShadow: "0px 4px 4px 0px rgba(35, 53, 67, 0.0784313725)",
27
+ border: "1px solid $dark300",
28
+ borderRadius: "0.5rem",
29
+ padding: "0.5rem 0",
30
+ height: "fit-content",
31
+ });