@lets-events/react 11.6.5 → 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 +6 -0
  4. package/dist/index.css +171 -0
  5. package/dist/index.d.mts +9 -12
  6. package/dist/index.d.ts +9 -12
  7. package/dist/index.js +200 -188
  8. package/dist/index.mjs +205 -191
  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 -302
  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,218 +1,218 @@
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
- faX,
11
- } from "@fortawesome/free-solid-svg-icons";
12
- import { colors } from "@lets-events/tokens";
13
- import { ComponentProps, useCallback, useMemo, useRef, useState } from "react";
14
- import { Flex } from "./Flex";
15
- import { CSS } from "@stitches/react";
16
- import React from "react";
17
- import { Badge } from "./Badge";
18
-
19
- const StyledContent = styled(DropdownMenu.Content, {
20
- backgroundColor: "$dark50",
21
- borderRadius: "$sm",
22
- padding: "$8 0",
23
- boxShadow: "0px 2px 4px 0px #23354329, 0px 4px 4px 0px #23354314",
24
- boxSizing: "border-box",
25
- border: "1px solid $dark300",
26
- });
27
-
28
- const StyledTrigger = styled("div", {
29
- minHeight: "40px",
30
- borderRadius: "$sm",
31
- cursor: "pointer",
32
- display: "flex",
33
- justifyContent: "start",
34
- alignItems: "center",
35
- padding: "$6 $14",
36
- boxSizing: "border-box",
37
- gap: "4px",
38
-
39
- variants: {
40
- color: {
41
- default: {
42
- border: "1px solid $dark300",
43
- },
44
- error: {
45
- border: "1px solid $error400",
46
- },
47
- },
48
- },
49
-
50
- defaultVariants: {
51
- color: "default",
52
- },
53
- });
54
-
55
- const itemStyle: CSS = {
56
- padding: "$4 $16",
57
- minHeight: "$32",
58
- boxSizing: "border-box",
59
- backgroundColor: "$dark50",
60
- display: "block",
61
-
62
- "&:hover": {
63
- backgroundColor: "$dark100",
64
- },
65
- };
66
-
67
- const BadgeWrapper = styled("div", {
68
- flex: "1",
69
- display: "flex",
70
- justifyContent: "start",
71
- flexWrap: "wrap",
72
- gap: "4px",
73
- });
74
-
75
- const BadgeCloseBtn = styled("div", {
76
- borderRadius: "100%",
77
- width: "16px",
78
- height: "16px",
79
- minWidth: "16px",
80
- minHeight: "16px",
81
- display: "flex",
82
- justifyContent: "center",
83
- alignItems: "center",
84
-
85
- "&:hover": {
86
- backgroundColor: "$dark600",
87
- },
88
- });
89
-
90
- export type MultiSelectProps = ComponentProps<typeof StyledTrigger> & {
91
- placeholder?: string;
92
- value?: string[];
93
- onValueChange?: (v: string[]) => void;
94
- options: Array<{
95
- label: string;
96
- value: string;
97
- }>;
98
- width?: string;
99
- zIndex?: string;
100
- };
101
-
102
- export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
103
- (
104
- {
105
- placeholder,
106
- value: selectedValues = [],
107
- onValueChange,
108
- options,
109
- color,
110
- width = "100%",
111
- zIndex = "auto",
112
- },
113
- fowardedRef
114
- ) => {
115
- const [isOpen, setIsOpen] = useState(false);
116
-
117
- const triggerRef = useRef<HTMLDivElement>(null);
118
-
119
- const labelByValue = useMemo(() => {
120
- return options.reduce<{ [key: string]: string }>((prev, curr) => {
121
- return {
122
- ...prev,
123
- [curr.value]: curr.label,
124
- };
125
- }, {});
126
- }, [options]);
127
-
128
- const handleRemove = useCallback(
129
- (value: string) => {
130
- const newValue = selectedValues.filter((v) => v !== value);
131
- onValueChange?.(newValue);
132
- },
133
- [selectedValues, onValueChange]
134
- );
135
-
136
- const menuWidth = triggerRef.current?.offsetWidth;
137
-
138
- return (
139
- <Theme>
140
- <DropdownMenu.Root open={isOpen} onOpenChange={() => setIsOpen(false)}>
141
- <DropdownMenu.Trigger onClick={() => setIsOpen(true)}>
142
- <StyledTrigger
143
- css={{
144
- width,
145
- }}
146
- ref={(r) => {
147
- if (!r) return;
148
- triggerRef.current = r;
149
- if (fowardedRef) {
150
- if (typeof fowardedRef === "function") fowardedRef(r);
151
- else {
152
- fowardedRef.current = r;
153
- }
154
- }
155
- }}
156
- color={color}
157
- >
158
- {selectedValues.length === 0 ? (
159
- <Text typography={"labelMedium"} css={{ flex: 1 }}>
160
- {placeholder ?? "Selecione"}
161
- </Text>
162
- ) : (
163
- <BadgeWrapper>
164
- {selectedValues.map((value) => {
165
- return (
166
- <Badge key={value} size={"sm"} color={"dark"}>
167
- <Flex justify={"between"} align={"center"}>
168
- <Text typography={"badgeSmall"} color="dark100">
169
- {labelByValue[value]}
170
- </Text>
171
- <BadgeCloseBtn
172
- onClick={(e) => {
173
- e.stopPropagation();
174
- handleRemove(value);
175
- }}
176
- role="button"
177
- >
178
- <FontAwesomeIcon icon={faX} size="xs" />
179
- </BadgeCloseBtn>
180
- </Flex>
181
- </Badge>
182
- );
183
- })}
184
- </BadgeWrapper>
185
- )}
186
- <FontAwesomeIcon
187
- icon={isOpen ? faChevronUp : faChevronDown}
188
- size="sm"
189
- color={colors.dark600}
190
- />
191
- </StyledTrigger>
192
- </DropdownMenu.Trigger>
193
- <StyledContent
194
- css={{
195
- width: menuWidth ? menuWidth + "px" : width,
196
- zIndex,
197
- }}
198
- >
199
- <CheckboxGroup
200
- value={selectedValues}
201
- onValueChange={(v) => {
202
- onValueChange?.(v);
203
- }}
204
- >
205
- <Flex direction={"column"} gap={8}>
206
- {options.map(({ value, label }, i) => (
207
- <CheckboxItem value={value} css={itemStyle} key={i}>
208
- <Text typography={"labelSmall"}>{label}</Text>
209
- </CheckboxItem>
210
- ))}
211
- </Flex>
212
- </CheckboxGroup>
213
- </StyledContent>
214
- </DropdownMenu.Root>
215
- </Theme>
216
- );
217
- }
218
- );
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
+ faX,
11
+ } from "@fortawesome/free-solid-svg-icons";
12
+ import { colors } from "@lets-events/tokens";
13
+ import { ComponentProps, useCallback, useMemo, useRef, useState } from "react";
14
+ import { Flex } from "./Flex";
15
+ import { CSS } from "@stitches/react";
16
+ import React from "react";
17
+ import { Badge } from "./Badge";
18
+
19
+ const StyledContent = styled(DropdownMenu.Content, {
20
+ backgroundColor: "$dark50",
21
+ borderRadius: "$sm",
22
+ padding: "$8 0",
23
+ boxShadow: "0px 2px 4px 0px #23354329, 0px 4px 4px 0px #23354314",
24
+ boxSizing: "border-box",
25
+ border: "1px solid $dark300",
26
+ });
27
+
28
+ const StyledTrigger = styled("div", {
29
+ minHeight: "40px",
30
+ borderRadius: "$sm",
31
+ cursor: "pointer",
32
+ display: "flex",
33
+ justifyContent: "start",
34
+ alignItems: "center",
35
+ padding: "$6 $14",
36
+ boxSizing: "border-box",
37
+ gap: "4px",
38
+
39
+ variants: {
40
+ color: {
41
+ default: {
42
+ border: "1px solid $dark300",
43
+ },
44
+ error: {
45
+ border: "1px solid $error400",
46
+ },
47
+ },
48
+ },
49
+
50
+ defaultVariants: {
51
+ color: "default",
52
+ },
53
+ });
54
+
55
+ const itemStyle: CSS = {
56
+ padding: "$4 $16",
57
+ minHeight: "$32",
58
+ boxSizing: "border-box",
59
+ backgroundColor: "$dark50",
60
+ display: "block",
61
+
62
+ "&:hover": {
63
+ backgroundColor: "$dark100",
64
+ },
65
+ };
66
+
67
+ const BadgeWrapper = styled("div", {
68
+ flex: "1",
69
+ display: "flex",
70
+ justifyContent: "start",
71
+ flexWrap: "wrap",
72
+ gap: "4px",
73
+ });
74
+
75
+ const BadgeCloseBtn = styled("div", {
76
+ borderRadius: "100%",
77
+ width: "16px",
78
+ height: "16px",
79
+ minWidth: "16px",
80
+ minHeight: "16px",
81
+ display: "flex",
82
+ justifyContent: "center",
83
+ alignItems: "center",
84
+
85
+ "&:hover": {
86
+ backgroundColor: "$dark600",
87
+ },
88
+ });
89
+
90
+ export type MultiSelectProps = ComponentProps<typeof StyledTrigger> & {
91
+ placeholder?: string;
92
+ value?: string[];
93
+ onValueChange?: (v: string[]) => void;
94
+ options: Array<{
95
+ label: string;
96
+ value: string;
97
+ }>;
98
+ width?: string;
99
+ zIndex?: string;
100
+ };
101
+
102
+ export const MultiSelect = React.forwardRef<HTMLDivElement, MultiSelectProps>(
103
+ (
104
+ {
105
+ placeholder,
106
+ value: selectedValues = [],
107
+ onValueChange,
108
+ options,
109
+ color,
110
+ width = "100%",
111
+ zIndex = "auto",
112
+ },
113
+ fowardedRef
114
+ ) => {
115
+ const [isOpen, setIsOpen] = useState(false);
116
+
117
+ const triggerRef = useRef<HTMLDivElement>(null);
118
+
119
+ const labelByValue = useMemo(() => {
120
+ return options.reduce<{ [key: string]: string }>((prev, curr) => {
121
+ return {
122
+ ...prev,
123
+ [curr.value]: curr.label,
124
+ };
125
+ }, {});
126
+ }, [options]);
127
+
128
+ const handleRemove = useCallback(
129
+ (value: string) => {
130
+ const newValue = selectedValues.filter((v) => v !== value);
131
+ onValueChange?.(newValue);
132
+ },
133
+ [selectedValues, onValueChange]
134
+ );
135
+
136
+ const menuWidth = triggerRef.current?.offsetWidth;
137
+
138
+ return (
139
+ <Theme>
140
+ <DropdownMenu.Root open={isOpen} onOpenChange={() => setIsOpen(false)}>
141
+ <DropdownMenu.Trigger onClick={() => setIsOpen(true)}>
142
+ <StyledTrigger
143
+ css={{
144
+ width,
145
+ }}
146
+ ref={(r) => {
147
+ if (!r) return;
148
+ triggerRef.current = r;
149
+ if (fowardedRef) {
150
+ if (typeof fowardedRef === "function") fowardedRef(r);
151
+ else {
152
+ fowardedRef.current = r;
153
+ }
154
+ }
155
+ }}
156
+ color={color}
157
+ >
158
+ {selectedValues.length === 0 ? (
159
+ <Text typography={"labelMedium"} css={{ flex: 1 }}>
160
+ {placeholder ?? "Selecione"}
161
+ </Text>
162
+ ) : (
163
+ <BadgeWrapper>
164
+ {selectedValues.map((value) => {
165
+ return (
166
+ <Badge key={value} size={"sm"} color={"dark"}>
167
+ <Flex justify={"between"} align={"center"}>
168
+ <Text typography={"badgeSmall"} color="dark100">
169
+ {labelByValue[value]}
170
+ </Text>
171
+ <BadgeCloseBtn
172
+ onClick={(e) => {
173
+ e.stopPropagation();
174
+ handleRemove(value);
175
+ }}
176
+ role="button"
177
+ >
178
+ <FontAwesomeIcon icon={faX} size="xs" />
179
+ </BadgeCloseBtn>
180
+ </Flex>
181
+ </Badge>
182
+ );
183
+ })}
184
+ </BadgeWrapper>
185
+ )}
186
+ <FontAwesomeIcon
187
+ icon={isOpen ? faChevronUp : faChevronDown}
188
+ size="sm"
189
+ color={colors.dark600}
190
+ />
191
+ </StyledTrigger>
192
+ </DropdownMenu.Trigger>
193
+ <StyledContent
194
+ css={{
195
+ width: menuWidth ? menuWidth + "px" : width,
196
+ zIndex,
197
+ }}
198
+ >
199
+ <CheckboxGroup
200
+ value={selectedValues}
201
+ onValueChange={(v) => {
202
+ onValueChange?.(v);
203
+ }}
204
+ >
205
+ <Flex direction={"column"} gap={8}>
206
+ {options.map(({ value, label }, i) => (
207
+ <CheckboxItem value={value} css={itemStyle} key={i}>
208
+ <Text typography={"labelSmall"}>{label}</Text>
209
+ </CheckboxItem>
210
+ ))}
211
+ </Flex>
212
+ </CheckboxGroup>
213
+ </StyledContent>
214
+ </DropdownMenu.Root>
215
+ </Theme>
216
+ );
217
+ }
218
+ );