@lets-events/react 11.6.4 → 11.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +18 -20
  3. package/CHANGELOG.md +12 -0
  4. package/dist/index.css +171 -0
  5. package/dist/index.d.mts +65 -435
  6. package/dist/index.d.ts +65 -435
  7. package/dist/index.js +364 -269
  8. package/dist/index.mjs +365 -264
  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 -194
  25. package/src/components/Filter.tsx +164 -164
  26. package/src/components/Flex.tsx +118 -118
  27. package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
  28. package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
  29. package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -45
  30. package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
  31. package/src/components/FormFields/AddressFormFields/index.tsx +141 -139
  32. package/src/components/FormFields/BirthDateFormField.tsx +85 -87
  33. package/src/components/FormFields/CNPJFormField.tsx +87 -89
  34. package/src/components/FormFields/CPFFormField.tsx +77 -79
  35. package/src/components/FormFields/CheckboxGroupFormField.tsx +90 -90
  36. package/src/components/FormFields/Form.tsx +28 -29
  37. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +40 -42
  38. package/src/components/FormFields/MultiSelectFormField.tsx +55 -59
  39. package/src/components/FormFields/PhoneFormField.tsx +40 -130
  40. package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
  41. package/src/components/FormFields/SelectFormField.tsx +93 -93
  42. package/src/components/FormFields/TextAreaFormField.tsx +48 -48
  43. package/src/components/FormFields/TextFormField.tsx +107 -76
  44. package/src/components/FormFields/{ErrorFormMessage.tsx → subComponents/ErrorFormMessage.tsx} +36 -36
  45. package/src/components/FormFields/{FormLabel.tsx → subComponents/FormLabel.tsx} +29 -29
  46. package/src/components/FormFields/utils/validation.ts +20 -0
  47. package/src/components/Grid.tsx +137 -137
  48. package/src/components/Icon.tsx +47 -47
  49. package/src/components/MenuDropdown/index.tsx +30 -30
  50. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  51. package/src/components/Modal.tsx +90 -90
  52. package/src/components/MultiSelect.tsx +218 -218
  53. package/src/components/RadioGroup.tsx +210 -210
  54. package/src/components/Section.tsx +33 -33
  55. package/src/components/Step.tsx +164 -164
  56. package/src/components/Switch.tsx +108 -108
  57. package/src/components/Text.tsx +38 -38
  58. package/src/components/TextField.tsx +316 -312
  59. package/src/components/TextareaField.tsx +128 -128
  60. package/src/components/TimePicker.tsx +298 -298
  61. package/src/components/Toast/components/ToastItem.tsx +41 -41
  62. package/src/components/Toast/components/ToastProvider.tsx +63 -63
  63. package/src/components/Toast/hooks/useToast.ts +12 -12
  64. package/src/components/Toast/index.tsx +5 -5
  65. package/src/components/Toast/styles/index.ts +135 -135
  66. package/src/components/Toast/types/index.ts +46 -46
  67. package/src/components/Tooltip/index.tsx +66 -66
  68. package/src/components/Tooltip/styles.ts +77 -77
  69. package/src/hooks/useCountries.ts +41 -41
  70. package/src/hooks/useOnClickOutside.tsx +20 -20
  71. package/src/index.tsx +54 -54
  72. package/src/styles/index.ts +38 -38
  73. package/src/types/typographyValues.ts +178 -178
  74. package/src/utils/getNestedValue.ts +3 -3
  75. package/src/utils/states.ts +29 -29
  76. package/tsconfig.json +3 -3
@@ -1,194 +1,302 @@
1
- import { useState, ComponentProps, ElementType } from "react";
2
- import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
3
- import { Theme, DropdownMenu as DropdownMenuRadix } from "@radix-ui/themes";
4
- import { typographyLabelValues } from "../types/typographyValues";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import { colors } from "@lets-events/tokens";
7
- import { styled } from "../styles";
8
-
9
- const DropdownMenuItemStyled = styled(DropdownMenuRadix.Item, {
10
- fontFamily: "$default",
11
- color: "$dark600",
12
- letterSpacing: "0px",
13
- padding: "$8 $16",
14
- "&:hover, &:focus": {
15
- backgroundColor: "$dark100",
16
- border: "none",
17
- outline: "none",
18
- cursor: "pointer",
19
- },
20
- variants: {
21
- typography: typographyLabelValues,
22
- fontWeight: {
23
- regular: { fontWeight: "$regular" },
24
- medium: { fontWeight: "$medium" },
25
- semibold: { fontWeight: "$semibold" },
26
- bold: { fontWeight: "$bold" },
27
- },
28
- },
29
- });
30
-
31
- const DropdownMenuStyled = styled("div", {
32
- fontFamily: "$default",
33
- color: "$dark600",
34
- letterSpacing: "0px",
35
- cursor: "pointer",
36
- border: "1px solid $dark300",
37
- borderRadius: "$xs",
38
- padding: "$8 $12",
39
- width: "100%",
40
- display: "flex",
41
- button: {
42
- fontFamily: "$default",
43
- color: "$dark600",
44
- letterSpacing: "0px",
45
- backgroundColor: "transparent",
46
- border: "none",
47
- width: "100%",
48
- outline: "none",
49
- display: "flex",
50
- alignItems: "center",
51
- gap: "$8",
52
- cursor: "pointer",
53
- svg: {
54
- marginLeft: "auto",
55
- },
56
- },
57
- variants: {
58
- typography: {
59
- labelLarge: {
60
- button: {
61
- fontSize: "$labelLarge",
62
- lineHeight: "$labelLarge",
63
- },
64
- },
65
- labelMedium: {
66
- button: {
67
- fontSize: "$labelMedium",
68
- lineHeight: "$labelMedium",
69
- },
70
- },
71
- labelSmall: {
72
- button: {
73
- fontSize: "$labelSmall",
74
- lineHeight: "$labelSmall",
75
- },
76
- },
77
- labelExtraSmall: {
78
- button: {
79
- fontSize: "$labelExtraSmall",
80
- lineHeight: "$labelExtraSmall",
81
- },
82
- },
83
- },
84
- fontWeight: {
85
- regular: { button: { fontWeight: "$regular" } },
86
- medium: { button: { fontWeight: "$medium" } },
87
- semibold: { button: { fontWeight: "$semibold" } },
88
- bold: { button: { fontWeight: "$bold" } },
89
- },
90
- color: {
91
- default: {
92
- border: "1px solid $dark300",
93
- },
94
- error: {
95
- border: "1px solid $error400",
96
- },
97
- },
98
- },
99
- });
100
-
101
- const DropdownMenuContentStyled = styled(DropdownMenuRadix.Content, {
102
- background: "white",
103
- border: "1px solid $dark300",
104
- borderRadius: "$xs",
105
- boxShadow: "0px 4px 4px 0px rgba(35, 53, 67, 0.08)",
106
- width: "100%",
107
- minWidth: "100%",
108
- marginTop: "3px",
109
- maxHeight: "400px",
110
- height: "100%",
111
- position: "relative",
112
- overflow: "auto",
113
- zIndex: 9999999999,
114
- });
115
-
116
- export type DropdownMenuProps = ComponentProps<
117
- typeof DropdownMenuRadix.Root
118
- > & {
119
- as?: ElementType;
120
- placeholder?: string;
121
- fontWeight: "regular" | "medium" | "semibold" | "bold";
122
- typography: "labelExtraSmall" | "labelSmall" | "labelMedium" | "labelLarge";
123
- children: React.ReactNode;
124
- color?: "default" | "error";
125
- };
126
-
127
- export type DropdownMenuItemProps = ComponentProps<
128
- typeof DropdownMenuItemStyled
129
- > & {
130
- as?: ElementType;
131
- value: string;
132
- typography: DropdownMenuProps["typography"];
133
- fontWeight: DropdownMenuProps["fontWeight"];
134
- };
135
-
136
- /* Componente principal */
137
- export function DropdownMenu({
138
- children,
139
- placeholder,
140
- typography,
141
- color,
142
- fontWeight,
143
- ...props
144
- }: DropdownMenuProps) {
145
- const [isOpen, setIsOpen] = useState(false);
146
- return (
147
- <Theme>
148
- <DropdownMenuRadix.Root open={isOpen} onOpenChange={setIsOpen} {...props}>
149
- <DropdownMenuStyled
150
- typography={typography}
151
- fontWeight={fontWeight}
152
- color={color}
153
- >
154
- <DropdownMenuRadix.Trigger>
155
- <button aria-label={placeholder || "Filtrar"}>
156
- <span>{placeholder || "Filtrar"}</span>
157
- <FontAwesomeIcon
158
- icon={isOpen ? faChevronUp : faChevronDown}
159
- size="sm"
160
- color={colors.dark600}
161
- />
162
- </button>
163
- </DropdownMenuRadix.Trigger>
164
- <DropdownMenuContentStyled
165
- container={document.body}
166
- avoidCollisions={false}
167
- align="start"
168
- alignOffset={-14}
169
- >
170
- <DropdownMenuRadix.Group>{children}</DropdownMenuRadix.Group>
171
- </DropdownMenuContentStyled>
172
- </DropdownMenuStyled>
173
- </DropdownMenuRadix.Root>
174
- </Theme>
175
- );
176
- }
177
-
178
- /* Componente de item */
179
- export function DropdownMenuItem({
180
- children,
181
- typography,
182
- fontWeight,
183
- ...props
184
- }: DropdownMenuItemProps) {
185
- return (
186
- <DropdownMenuItemStyled
187
- typography={typography}
188
- fontWeight={fontWeight}
189
- {...props}
190
- >
191
- {children}
192
- </DropdownMenuItemStyled>
193
- );
194
- }
1
+ import React, {
2
+ useState,
3
+ useRef,
4
+ useEffect,
5
+ ElementType,
6
+ ReactNode,
7
+ KeyboardEvent,
8
+ MouseEvent,
9
+ } from "react";
10
+ import { faChevronDown, faChevronUp } from "@fortawesome/free-solid-svg-icons";
11
+ import { typographyLabelValues } from "../types/typographyValues";
12
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
13
+ import { colors } from "@lets-events/tokens";
14
+ import { styled } from "../styles";
15
+
16
+ const DropdownMenuItemStyled = styled("div", {
17
+ fontFamily: "$default",
18
+ color: "$dark600",
19
+ letterSpacing: "0px",
20
+ padding: "$8 $16",
21
+ cursor: "pointer",
22
+ "&:hover, &:focus": {
23
+ backgroundColor: "$dark100",
24
+ border: "none",
25
+ outline: "none",
26
+ },
27
+ variants: {
28
+ typography: typographyLabelValues,
29
+ fontWeight: {
30
+ regular: { fontWeight: "$regular" },
31
+ medium: { fontWeight: "$medium" },
32
+ semibold: { fontWeight: "$semibold" },
33
+ bold: { fontWeight: "$bold" },
34
+ },
35
+ },
36
+ });
37
+
38
+ const DropdownMenuStyled = styled("div", {
39
+ boxSizing: "border-box",
40
+ fontFamily: "$default",
41
+ color: "$dark600",
42
+ letterSpacing: "0px",
43
+ cursor: "pointer",
44
+ border: "1px solid $dark300",
45
+ borderRadius: "$xs",
46
+ maxWidth: "100%",
47
+ display: "flex",
48
+ position: "relative",
49
+ button: {
50
+ boxSizing: "border-box",
51
+ fontFamily: "$default",
52
+ color: "$dark600",
53
+ letterSpacing: "0px",
54
+ backgroundColor: "transparent",
55
+ border: "none",
56
+ width: "100%",
57
+ outline: "none",
58
+ display: "flex",
59
+ alignItems: "center",
60
+ gap: "$8",
61
+ padding: "$8 $12",
62
+ cursor: "pointer",
63
+ svg: {
64
+ marginLeft: "auto",
65
+ },
66
+ },
67
+ variants: {
68
+ typography: {
69
+ labelLarge: {
70
+ button: {
71
+ fontSize: "$labelLarge",
72
+ lineHeight: "$labelLarge",
73
+ },
74
+ },
75
+ labelMedium: {
76
+ button: {
77
+ fontSize: "$labelMedium",
78
+ lineHeight: "$labelMedium",
79
+ },
80
+ },
81
+ labelSmall: {
82
+ button: {
83
+ fontSize: "$labelSmall",
84
+ lineHeight: "$labelSmall",
85
+ },
86
+ },
87
+ labelExtraSmall: {
88
+ button: {
89
+ fontSize: "$labelExtraSmall",
90
+ lineHeight: "$labelExtraSmall",
91
+ },
92
+ },
93
+ },
94
+ fontWeight: {
95
+ regular: { button: { fontWeight: "$regular" } },
96
+ medium: { button: { fontWeight: "$medium" } },
97
+ semibold: { button: { fontWeight: "$semibold" } },
98
+ bold: { button: { fontWeight: "$bold" } },
99
+ },
100
+ color: {
101
+ default: {
102
+ border: "1px solid $dark300",
103
+ },
104
+ error: {
105
+ border: "1px solid $error400",
106
+ },
107
+ },
108
+ },
109
+ });
110
+
111
+ const DropdownMenuContentStyled = styled("div", {
112
+ position: "absolute",
113
+ top: "100%",
114
+ left: 0,
115
+ width: "100%",
116
+ background: "white",
117
+ border: "1px solid $dark300",
118
+ borderRadius: "$xs",
119
+ boxShadow: "0px 4px 4px 0px rgba(35, 53, 67, 0.08)",
120
+ marginTop: "3px",
121
+ maxHeight: "400px",
122
+ overflow: "auto",
123
+ zIndex: 9999999999,
124
+ });
125
+
126
+ export type DropdownMenuProps = {
127
+ as?: ElementType;
128
+ placeholder?: string;
129
+ fontWeight: "regular" | "medium" | "semibold" | "bold";
130
+ typography: "labelExtraSmall" | "labelSmall" | "labelMedium" | "labelLarge";
131
+ children: ReactNode;
132
+ color?: "default" | "error";
133
+ open?: boolean;
134
+ onOpenChange?: (open: boolean) => void;
135
+ defaultOpen?: boolean;
136
+ };
137
+
138
+ export type DropdownMenuItemProps = {
139
+ as?: ElementType;
140
+ value: string;
141
+ typography: DropdownMenuProps["typography"];
142
+ fontWeight: DropdownMenuProps["fontWeight"];
143
+ children: ReactNode;
144
+ onSelect?: (value: string) => void;
145
+ onClick?: (event: MouseEvent<HTMLDivElement>) => void;
146
+ };
147
+
148
+ export function DropdownMenu({
149
+ children,
150
+ placeholder,
151
+ typography,
152
+ color = "default",
153
+ fontWeight,
154
+ open: controlledOpen,
155
+ onOpenChange,
156
+ defaultOpen = false,
157
+ ...props
158
+ }: DropdownMenuProps) {
159
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
160
+ const dropdownRef = useRef<HTMLDivElement>(null);
161
+ const isControlled = controlledOpen !== undefined;
162
+ const isOpen = isControlled ? controlledOpen : internalOpen;
163
+
164
+ const handleToggle = () => {
165
+ const newOpen = !isOpen;
166
+ if (!isControlled) {
167
+ setInternalOpen(newOpen);
168
+ }
169
+ onOpenChange?.(newOpen);
170
+ };
171
+
172
+ const handleClose = () => {
173
+ if (!isControlled) {
174
+ setInternalOpen(false);
175
+ }
176
+ onOpenChange?.(false);
177
+ };
178
+
179
+ useEffect(() => {
180
+ const handleClickOutside = (event: Event) => {
181
+ if (
182
+ dropdownRef.current &&
183
+ !dropdownRef.current.contains(event.target as Node)
184
+ ) {
185
+ handleClose();
186
+ }
187
+ };
188
+
189
+ const handleEscape = (event: KeyboardEvent) => {
190
+ if (event.key === "Escape") {
191
+ handleClose();
192
+ }
193
+ };
194
+
195
+ if (isOpen) {
196
+ document.addEventListener("mousedown", handleClickOutside);
197
+ document.addEventListener("keydown", handleEscape as any);
198
+ }
199
+
200
+ return () => {
201
+ document.removeEventListener("mousedown", handleClickOutside);
202
+ document.removeEventListener("keydown", handleEscape as any);
203
+ };
204
+ }, [isOpen]);
205
+
206
+ return (
207
+ <DropdownMenuStyled
208
+ ref={dropdownRef}
209
+ typography={typography}
210
+ fontWeight={fontWeight}
211
+ color={color}
212
+ {...props}
213
+ >
214
+ <button
215
+ aria-label={placeholder || "Filtrar"}
216
+ aria-expanded={isOpen}
217
+ aria-haspopup="listbox"
218
+ onClick={handleToggle}
219
+ type="button"
220
+ onKeyDown={(e) => {
221
+ if (e.key === "Enter" || e.key === " ") {
222
+ e.preventDefault();
223
+ handleToggle();
224
+ }
225
+ }}
226
+ >
227
+ <span>{placeholder || "Filtrar"}</span>
228
+ <FontAwesomeIcon
229
+ icon={isOpen ? faChevronUp : faChevronDown}
230
+ size="sm"
231
+ color={colors.dark600}
232
+ />
233
+ </button>
234
+
235
+ {isOpen && (
236
+ <DropdownMenuContentStyled role="listbox">
237
+ <DropdownMenuProvider onItemSelect={handleClose}>
238
+ {children}
239
+ </DropdownMenuProvider>
240
+ </DropdownMenuContentStyled>
241
+ )}
242
+ </DropdownMenuStyled>
243
+ );
244
+ }
245
+
246
+ const DropdownMenuContext = React.createContext<{
247
+ onItemSelect: () => void;
248
+ } | null>(null);
249
+
250
+ function DropdownMenuProvider({
251
+ children,
252
+ onItemSelect,
253
+ }: {
254
+ children: ReactNode;
255
+ onItemSelect: () => void;
256
+ }) {
257
+ return (
258
+ <DropdownMenuContext.Provider value={{ onItemSelect }}>
259
+ {children}
260
+ </DropdownMenuContext.Provider>
261
+ );
262
+ }
263
+
264
+ export function DropdownMenuItem({
265
+ children,
266
+ typography,
267
+ fontWeight,
268
+ value,
269
+ onSelect,
270
+ onClick,
271
+ ...props
272
+ }: DropdownMenuItemProps) {
273
+ const context = React.useContext(DropdownMenuContext);
274
+
275
+ const handleClick = (event: MouseEvent<HTMLDivElement>) => {
276
+ onClick?.(event);
277
+ onSelect?.(value);
278
+ context?.onItemSelect();
279
+ };
280
+
281
+ const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
282
+ if (event.key === "Enter" || event.key === " ") {
283
+ event.preventDefault();
284
+ onSelect?.(value);
285
+ context?.onItemSelect();
286
+ }
287
+ };
288
+
289
+ return (
290
+ <DropdownMenuItemStyled
291
+ typography={typography}
292
+ fontWeight={fontWeight}
293
+ onClick={handleClick}
294
+ onKeyDown={handleKeyDown}
295
+ tabIndex={0}
296
+ role="option"
297
+ {...props}
298
+ >
299
+ {children}
300
+ </DropdownMenuItemStyled>
301
+ );
302
+ }