@lets-events/react 11.7.4 → 11.7.6

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 +20 -18
  3. package/CHANGELOG.md +12 -0
  4. package/dist/index.d.mts +5 -374
  5. package/dist/index.d.ts +5 -374
  6. package/dist/index.js +55 -58
  7. package/dist/index.mjs +24 -27
  8. package/package.json +1 -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 -176
  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 +302 -302
  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 -111
  27. package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
  28. package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
  29. package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
  30. package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
  31. package/src/components/FormFields/BirthDateFormField.tsx +85 -85
  32. package/src/components/FormFields/CNPJFormField.tsx +87 -87
  33. package/src/components/FormFields/CPFFormField.tsx +77 -77
  34. package/src/components/FormFields/CheckboxGroupFormField.tsx +90 -90
  35. package/src/components/FormFields/EmailFormField.tsx +27 -27
  36. package/src/components/FormFields/Form.tsx +39 -39
  37. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +40 -40
  38. package/src/components/FormFields/MultiSelectFormField.tsx +55 -55
  39. package/src/components/FormFields/PhoneFormField.tsx +40 -40
  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 +112 -112
  44. package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
  45. package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
  46. package/src/components/FormFields/utils/validation.ts +23 -23
  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 -316
  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
  77. package/dist/index.css +0 -171
@@ -1,302 +1,302 @@
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
- }
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
+ }