@lets-events/react 11.8.1 → 12.1.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 (87) hide show
  1. package/.eslintrc.json +2 -2
  2. package/.turbo/turbo-build.log +21 -18
  3. package/CHANGELOG.md +12 -0
  4. package/dist/index.d.mts +139 -11
  5. package/dist/index.d.ts +139 -11
  6. package/dist/index.js +1260 -361
  7. package/dist/index.mjs +1251 -358
  8. package/package.json +7 -2
  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 +288 -287
  15. package/src/components/ButtonGroup.tsx +484 -484
  16. package/src/components/Calendar/index.tsx +146 -136
  17. package/src/components/Calendar/styledComponents.ts +250 -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 +129 -55
  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 +84 -84
  32. package/src/components/FormFields/CNPJFormField.tsx +87 -87
  33. package/src/components/FormFields/CPFFormField.tsx +78 -78
  34. package/src/components/FormFields/CalendarFormField.tsx +92 -0
  35. package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
  36. package/src/components/FormFields/EmailFormField.tsx +27 -27
  37. package/src/components/FormFields/Form.tsx +39 -39
  38. package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +37 -40
  39. package/src/components/FormFields/MultiSelectFormField.tsx +64 -55
  40. package/src/components/FormFields/PhoneFormField.tsx +40 -40
  41. package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
  42. package/src/components/FormFields/RichEditorFormField.tsx +69 -0
  43. package/src/components/FormFields/SelectFormField.tsx +93 -93
  44. package/src/components/FormFields/TextAreaFormField.tsx +57 -48
  45. package/src/components/FormFields/TextFormField.tsx +112 -112
  46. package/src/components/FormFields/TimePickerFormField.tsx +88 -0
  47. package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
  48. package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
  49. package/src/components/FormFields/utils/validation.ts +23 -23
  50. package/src/components/Grid.tsx +137 -137
  51. package/src/components/Icon.tsx +47 -47
  52. package/src/components/MenuDropdown/index.tsx +38 -38
  53. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  54. package/src/components/Modal.tsx +90 -90
  55. package/src/components/MultiSelect.tsx +311 -267
  56. package/src/components/RadioGroup.tsx +210 -210
  57. package/src/components/RichEditor/QuillComponent.tsx +413 -0
  58. package/src/components/RichEditor/RichEditor.tsx +38 -0
  59. package/src/components/RichEditor/index.ts +2 -0
  60. package/src/components/RichEditor/styledComponents.ts +62 -0
  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 -365
  66. package/src/components/TextareaField.tsx +128 -128
  67. package/src/components/TimePicker.tsx +325 -298
  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 -0
  78. package/src/hooks/useOnClickOutside.tsx +42 -20
  79. package/src/index.tsx +67 -55
  80. package/src/styles/index.ts +38 -38
  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 -0
  85. package/tsconfig.json +3 -3
  86. package/tsup.config.ts +38 -0
  87. package/dist/index.css +0 -171
@@ -1,267 +1,311 @@
1
- import { DropdownMenu, Theme } from "@radix-ui/themes";
2
- import { Button } from "./Button";
3
- import { CheckboxGroup, CheckboxItem } from "./CheckboxGroup";
4
- import { styled, css } from "../styles";
5
- import { Text } from "./Text";
6
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
7
- import {
8
- faChevronDown,
9
- faChevronUp,
10
- faSquareXmark,
11
- faX,
12
- } from "@fortawesome/free-solid-svg-icons";
13
- import { colors } from "@lets-events/tokens";
14
- import { ComponentProps, useCallback, useMemo, useRef, useState } from "react";
15
- import { Flex } from "./Flex";
16
- import { CSS } from "@stitches/react";
17
- import React from "react";
18
- import { Badge } from "./Badge";
19
-
20
- const StyledContent = styled(DropdownMenu.Content, {
21
- backgroundColor: "$dark50",
22
- borderRadius: "$sm",
23
- padding: "$8 0",
24
- boxShadow: "0px 2px 4px 0px #23354329, 0px 4px 4px 0px #23354314",
25
- boxSizing: "border-box",
26
- border: "1px solid $dark300",
27
- });
28
-
29
- const StyledTrigger = styled("div", {
30
- minHeight: "40px",
31
- borderRadius: "$sm",
32
- cursor: "pointer",
33
- display: "flex",
34
- justifyContent: "start",
35
- alignItems: "center",
36
- padding: "$6 $14",
37
- boxSizing: "border-box",
38
- gap: "4px",
39
-
40
- variants: {
41
- color: {
42
- default: {
43
- border: "1px solid $dark300",
44
- },
45
- error: {
46
- border: "1px solid $error400",
47
- },
48
- },
49
- disabled: {
50
- true: {
51
- cursor: "not-allowed",
52
- border: "1px solid $dark100",
53
- },
54
- },
55
- },
56
-
57
- defaultVariants: {
58
- color: "default",
59
- },
60
- });
61
-
62
- const itemStyle: CSS = {
63
- padding: "$4 $16",
64
- minHeight: "$32",
65
- boxSizing: "border-box",
66
- backgroundColor: "$dark50",
67
- display: "block",
68
- cursor: "pointer",
69
-
70
- "&:hover": {
71
- backgroundColor: "$dark100",
72
- },
73
- };
74
-
75
- const StyledItem = styled("div", {
76
- ...itemStyle,
77
- });
78
-
79
- const BadgeWrapper = styled("div", {
80
- flex: "1",
81
- display: "flex",
82
- gap: "4px",
83
- marginTop: "8px",
84
- flexDirection: "column",
85
- });
86
-
87
- const BadgeCloseBtn = styled("div", {
88
- cursor: "pointer",
89
- });
90
-
91
- export type MultiSelectProps = ComponentProps<typeof StyledTrigger> & {
92
- placeholder?: string;
93
- value?: string[];
94
- onValueChange?: (v: string[]) => void;
95
- options: Array<{
96
- label: string;
97
- value: string;
98
- }>;
99
- width?: string;
100
- zIndex?: string;
101
- showSelectedValues?: boolean;
102
- singleSelect?: boolean;
103
- disabled?: boolean;
104
- };
105
-
106
- export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
107
- (
108
- {
109
- placeholder,
110
- value: selectedValues = [],
111
- onValueChange,
112
- options,
113
- color,
114
- width = "100%",
115
- zIndex = "auto",
116
- showSelectedValues = true,
117
- singleSelect = false,
118
- disabled = false,
119
- },
120
- fowardedRef
121
- ) => {
122
- const [isOpen, setIsOpen] = useState(false);
123
-
124
- const triggerRef = useRef<HTMLDivElement>(null);
125
-
126
- const labelByValue = useMemo(() => {
127
- return options.reduce<{ [key: string]: string }>((prev, curr) => {
128
- return {
129
- ...prev,
130
- [curr.value]: curr.label,
131
- };
132
- }, {});
133
- }, [options]);
134
-
135
- const handleRemove = useCallback(
136
- (value: string) => {
137
- const newValue = selectedValues.filter((v) => v !== value);
138
- onValueChange?.(newValue);
139
- },
140
- [selectedValues, onValueChange]
141
- );
142
-
143
- const menuWidth = triggerRef.current?.offsetWidth;
144
-
145
- const text = useMemo(() => {
146
- if (selectedValues.length > 0 && singleSelect) {
147
- const value = selectedValues[0];
148
- return labelByValue[value];
149
- }
150
-
151
- return placeholder ?? "Selecione";
152
- }, [selectedValues, placeholder, singleSelect]);
153
-
154
- const handleItemClick = (v: string) => {
155
- onValueChange?.([v]);
156
- setIsOpen(false);
157
- };
158
-
159
- return (
160
- <Theme>
161
- <DropdownMenu.Root open={isOpen} onOpenChange={() => setIsOpen(false)}>
162
- <DropdownMenu.Trigger
163
- onClick={() => {
164
- if (disabled) return;
165
- setIsOpen(true);
166
- }}
167
- >
168
- <StyledTrigger
169
- css={{
170
- width,
171
- }}
172
- ref={(r) => {
173
- if (!r) return;
174
- triggerRef.current = r;
175
- if (fowardedRef) {
176
- if (typeof fowardedRef === "function") fowardedRef(r);
177
- else {
178
- fowardedRef.current = r;
179
- }
180
- }
181
- }}
182
- color={color}
183
- disabled={disabled}
184
- >
185
- <Text
186
- typography={"labelMedium"}
187
- css={{
188
- flex: 1,
189
- overflow: "hidden",
190
- whiteSpace: "nowrap",
191
- textOverflow: "ellipsis",
192
- }}
193
- color={disabled ? "dark400" : undefined}
194
- >
195
- {text}
196
- </Text>
197
- <FontAwesomeIcon
198
- icon={isOpen ? faChevronUp : faChevronDown}
199
- size="sm"
200
- color={disabled ? colors.dark400 : colors.dark600}
201
- />
202
- </StyledTrigger>
203
- </DropdownMenu.Trigger>
204
- <StyledContent
205
- css={{
206
- width: menuWidth ? menuWidth + "px" : width,
207
- zIndex,
208
- }}
209
- >
210
- {!singleSelect ? (
211
- <CheckboxGroup
212
- value={selectedValues}
213
- onValueChange={(v) => {
214
- onValueChange?.(v);
215
- }}
216
- >
217
- <Flex direction={"column"} gap={8}>
218
- {options.map(({ value, label }, i) => (
219
- <CheckboxItem value={value} css={itemStyle} key={i}>
220
- <Text typography={"labelSmall"}>{label}</Text>
221
- </CheckboxItem>
222
- ))}
223
- </Flex>
224
- </CheckboxGroup>
225
- ) : (
226
- <Flex direction={"column"} gap={8}>
227
- {options.map(({ value, label }, i) => (
228
- <StyledItem key={i} onClick={() => handleItemClick(value)}>
229
- <Text typography={"labelSmall"}>{label}</Text>
230
- </StyledItem>
231
- ))}
232
- </Flex>
233
- )}
234
- </StyledContent>
235
- </DropdownMenu.Root>
236
- {selectedValues.length > 0 && showSelectedValues && (
237
- <>
238
- <BadgeWrapper>
239
- {selectedValues.map((value) => {
240
- return (
241
- <Flex gap={4}>
242
- <BadgeCloseBtn
243
- onClick={(e) => {
244
- e.stopPropagation();
245
- handleRemove(value);
246
- }}
247
- role="button"
248
- >
249
- <FontAwesomeIcon icon={faSquareXmark} size="sm" />
250
- </BadgeCloseBtn>
251
- <Text
252
- typography={"captionMedium"}
253
- fontWeight={"regular"}
254
- color="dark600"
255
- >
256
- {labelByValue[value]}
257
- </Text>
258
- </Flex>
259
- );
260
- })}
261
- </BadgeWrapper>
262
- </>
263
- )}
264
- </Theme>
265
- );
266
- }
267
- );
1
+ import React, { useCallback, useRef, useState } from "react";
2
+ import { DropdownMenu, Theme } from "@radix-ui/themes";
3
+ import { CheckboxGroup, CheckboxItem } from "./CheckboxGroup";
4
+ import { styled } from "../styles";
5
+ import { Text } from "./Text";
6
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
7
+ import {
8
+ faChevronDown,
9
+ faChevronUp,
10
+ faSquareXmark,
11
+ } from "@fortawesome/free-solid-svg-icons";
12
+ import { colors } from "@lets-events/tokens";
13
+ import { ComponentProps, useMemo } from "react";
14
+ import { Flex } from "./Flex";
15
+ import { CSS } from "@stitches/react";
16
+
17
+ const StyledContent = styled(DropdownMenu.Content, {
18
+ backgroundColor: "$dark50",
19
+ borderRadius: "$sm",
20
+ padding: "$8 0",
21
+ boxShadow: "0px 2px 4px 0px #23354329, 0px 4px 4px 0px #23354314",
22
+ boxSizing: "border-box",
23
+ border: "1px solid $dark300",
24
+ zIndex: 999999,
25
+ minWidth: "var(--radix-dropdown-menu-trigger-width)",
26
+ maxWidth: "var(--radix-dropdown-menu-trigger-width)",
27
+ });
28
+
29
+ const StyledTrigger = styled("div", {
30
+ minHeight: "40px",
31
+ borderRadius: "$sm",
32
+ cursor: "pointer",
33
+ display: "flex",
34
+ justifyContent: "start",
35
+ alignItems: "center",
36
+ padding: "$6 $14",
37
+ boxSizing: "border-box",
38
+ gap: "4px",
39
+ width: "100%",
40
+
41
+ variants: {
42
+ color: {
43
+ default: {
44
+ border: "1px solid $dark300",
45
+ },
46
+ error: {
47
+ border: "1px solid $error400",
48
+ },
49
+ },
50
+ disabled: {
51
+ true: {
52
+ cursor: "not-allowed",
53
+ border: "1px solid $dark100",
54
+ },
55
+ },
56
+ },
57
+
58
+ defaultVariants: {
59
+ color: "default",
60
+ },
61
+ });
62
+
63
+ const itemStyle: CSS = {
64
+ padding: "$4 $16",
65
+ minHeight: "$32",
66
+ boxSizing: "border-box",
67
+ backgroundColor: "$dark50",
68
+ display: "block",
69
+ cursor: "pointer",
70
+
71
+ "&:hover": {
72
+ backgroundColor: "$dark100",
73
+ },
74
+ };
75
+
76
+ const StyledItem = styled("div", {
77
+ ...itemStyle,
78
+ });
79
+
80
+ const BadgeCloseBtn = styled("div", {
81
+ cursor: "pointer",
82
+ });
83
+
84
+ const StyledFlexWithMaxHeight = styled(Flex, {
85
+ variants: {
86
+ hasMaxHeight: {
87
+ true: {
88
+ overflowY: "auto",
89
+ "&::-webkit-scrollbar": {
90
+ width: "4px",
91
+ },
92
+ "&::-webkit-scrollbar-track": {
93
+ backgroundColor: "$dark100",
94
+ borderRadius: "2px",
95
+ },
96
+ "&::-webkit-scrollbar-thumb": {
97
+ backgroundColor: "$dark300",
98
+ borderRadius: "2px",
99
+ "&:hover": {
100
+ backgroundColor: "$dark400",
101
+ },
102
+ },
103
+ },
104
+ },
105
+ },
106
+
107
+ defaultVariants: {
108
+ hasMaxHeight: false,
109
+ },
110
+ });
111
+ const StyledText = styled(Text, {
112
+ flex: 1,
113
+ overflow: "hidden",
114
+ whiteSpace: "nowrap",
115
+ textOverflow: "ellipsis",
116
+ });
117
+
118
+ export type MultiSelectProps = ComponentProps<typeof StyledTrigger> & {
119
+ placeholder?: string;
120
+ value?: string[];
121
+ onValueChange?: (v: string[]) => void;
122
+ options: Array<{
123
+ label: string;
124
+ value: string;
125
+ }>;
126
+ width?: string;
127
+ zIndex?: string;
128
+ showSelectedValues?: boolean;
129
+ singleSelect?: boolean;
130
+ selectedOrientation?: "row" | "column";
131
+ disabled?: boolean;
132
+ maxHeight?: string;
133
+ };
134
+
135
+ export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
136
+ (
137
+ {
138
+ placeholder,
139
+ value: selectedValues = [],
140
+ onValueChange,
141
+ options,
142
+ color,
143
+ width = "100%",
144
+ zIndex = "auto",
145
+ showSelectedValues = true,
146
+ singleSelect = false,
147
+ selectedOrientation = "column",
148
+ disabled = false,
149
+ maxHeight,
150
+ },
151
+ fowardedRef
152
+ ) => {
153
+ const [isOpen, setIsOpen] = useState(false);
154
+
155
+ const triggerRef = useRef<HTMLDivElement>(null);
156
+ const labelByValue = useMemo(() => {
157
+ return options.reduce<{ [key: string]: string }>((prev, curr) => {
158
+ return {
159
+ ...prev,
160
+ [curr.value]: curr.label,
161
+ };
162
+ }, {});
163
+ }, [options]);
164
+
165
+ const handleRemove = useCallback(
166
+ (value: string) => {
167
+ const newValue = selectedValues.filter((v) => v !== value);
168
+ onValueChange?.(newValue);
169
+ },
170
+ [selectedValues, onValueChange]
171
+ );
172
+
173
+ const text = useMemo(() => {
174
+ if (selectedValues.length > 0 && singleSelect) {
175
+ const value = selectedValues[0];
176
+ return labelByValue[value];
177
+ }
178
+
179
+ return placeholder ?? "Selecione";
180
+ }, [selectedValues, placeholder, singleSelect]);
181
+
182
+ const handleItemClick = (v: string) => {
183
+ onValueChange?.([v]);
184
+ setIsOpen(false);
185
+ };
186
+ const handleToggle = useCallback(
187
+ (e: React.MouseEvent) => {
188
+ e.preventDefault();
189
+ e.stopPropagation();
190
+ if (disabled) return;
191
+ setIsOpen((prev) => !prev);
192
+ },
193
+ [disabled]
194
+ );
195
+
196
+ return (
197
+ <Theme>
198
+ <DropdownMenu.Root>
199
+ <DropdownMenu.Trigger>
200
+ <StyledTrigger
201
+ ref={(r) => {
202
+ if (!r) return;
203
+ triggerRef.current = r;
204
+ if (fowardedRef) {
205
+ if (typeof fowardedRef === "function") fowardedRef(r);
206
+ else {
207
+ fowardedRef.current = r;
208
+ }
209
+ }
210
+ }}
211
+ color={color}
212
+ disabled={disabled}
213
+ style={width !== "100%" ? { width } : undefined}
214
+ onClick={handleToggle}
215
+ >
216
+ <StyledText
217
+ typography={"labelMedium"}
218
+ color={disabled ? "dark400" : undefined}
219
+ >
220
+ {text}
221
+ </StyledText>
222
+ <FontAwesomeIcon
223
+ icon={isOpen ? faChevronUp : faChevronDown}
224
+ size="sm"
225
+ color={disabled ? colors.dark400 : colors.dark600}
226
+ />
227
+ </StyledTrigger>
228
+ </DropdownMenu.Trigger>
229
+ <StyledContent
230
+ css={{
231
+ width: "100%",
232
+ zIndex: zIndex === "auto" ? 999999 : zIndex,
233
+ }}
234
+ >
235
+ {!singleSelect ? (
236
+ <CheckboxGroup
237
+ value={selectedValues}
238
+ onValueChange={(v) => {
239
+ onValueChange?.(v);
240
+ }}
241
+ >
242
+ <StyledFlexWithMaxHeight
243
+ direction={"column"}
244
+ gap={8}
245
+ hasMaxHeight={!!maxHeight}
246
+ style={maxHeight ? { maxHeight } : undefined}
247
+ >
248
+ {options.map(({ value, label }, i) => (
249
+ <CheckboxItem value={value} css={itemStyle} key={i}>
250
+ <Text typography={"labelSmall"}>{label}</Text>
251
+ </CheckboxItem>
252
+ ))}
253
+ </StyledFlexWithMaxHeight>
254
+ </CheckboxGroup>
255
+ ) : (
256
+ <StyledFlexWithMaxHeight
257
+ direction={"column"}
258
+ gap={8}
259
+ hasMaxHeight={!!maxHeight}
260
+ style={maxHeight ? { maxHeight } : undefined}
261
+ >
262
+ {options.map(({ value, label }, i) => (
263
+ <StyledItem key={i} onClick={() => handleItemClick(value)}>
264
+ <Text typography={"labelSmall"}>{label}</Text>
265
+ </StyledItem>
266
+ ))}
267
+ </StyledFlexWithMaxHeight>
268
+ )}
269
+ </StyledContent>
270
+ </DropdownMenu.Root>
271
+ {selectedValues.length > 0 && showSelectedValues && (
272
+ <>
273
+ <Flex
274
+ direction={selectedOrientation}
275
+ gap={8}
276
+ align={selectedOrientation === "column" ? "start" : "center"}
277
+ justify={"start"}
278
+ css={{ margin: "8px 0" }}
279
+ >
280
+ {selectedValues.map((value) => (
281
+ <Flex
282
+ key={value}
283
+ gap={4}
284
+ align={"center"}
285
+ css={{ flexWrap: "wrap" }}
286
+ >
287
+ <BadgeCloseBtn
288
+ onClick={(e) => {
289
+ e.stopPropagation();
290
+ handleRemove(value);
291
+ }}
292
+ role="button"
293
+ >
294
+ <FontAwesomeIcon icon={faSquareXmark} size="sm" />
295
+ </BadgeCloseBtn>
296
+ <Text
297
+ typography={"captionMedium"}
298
+ fontWeight={"regular"}
299
+ color="dark600"
300
+ >
301
+ {labelByValue[value]}
302
+ </Text>
303
+ </Flex>
304
+ ))}
305
+ </Flex>
306
+ </>
307
+ )}
308
+ </Theme>
309
+ );
310
+ }
311
+ );