@lets-events/react 11.5.0 → 11.5.2

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 (59) 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.d.mts +2 -1
  5. package/dist/index.d.ts +2 -1
  6. package/dist/index.js +3 -2
  7. package/dist/index.mjs +3 -2
  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 +196 -196
  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 +167 -167
  24. package/src/components/Filter.tsx +164 -164
  25. package/src/components/Flex.tsx +118 -118
  26. package/src/components/FormFields/ErrorFormMessage.tsx +36 -36
  27. package/src/components/FormFields/Form.tsx +25 -25
  28. package/src/components/FormFields/FormLabel.tsx +29 -29
  29. package/src/components/FormFields/MultiSelectFormField.tsx +59 -59
  30. package/src/components/FormFields/PhoneFormField.tsx +130 -130
  31. package/src/components/FormFields/TextAreaFormField.tsx +49 -46
  32. package/src/components/FormFields/TextFormField.tsx +46 -46
  33. package/src/components/Grid.tsx +137 -137
  34. package/src/components/Icon.tsx +47 -47
  35. package/src/components/MenuDropdown/index.tsx +30 -30
  36. package/src/components/MenuDropdown/styledComponents.ts +31 -31
  37. package/src/components/Modal.tsx +90 -90
  38. package/src/components/MultiSelect.tsx +218 -218
  39. package/src/components/RadioGroup.tsx +210 -210
  40. package/src/components/Section.tsx +33 -33
  41. package/src/components/Step.tsx +164 -164
  42. package/src/components/Switch.tsx +108 -108
  43. package/src/components/Text.tsx +38 -38
  44. package/src/components/TextField.tsx +315 -315
  45. package/src/components/TextareaField.tsx +128 -128
  46. package/src/components/TimePicker.tsx +298 -298
  47. package/src/components/Toast/components/ToastItem.tsx +41 -41
  48. package/src/components/Toast/components/ToastProvider.tsx +63 -63
  49. package/src/components/Toast/hooks/useToast.ts +12 -12
  50. package/src/components/Toast/index.tsx +5 -5
  51. package/src/components/Toast/styles/index.ts +135 -135
  52. package/src/components/Toast/types/index.ts +46 -46
  53. package/src/components/Tooltip/index.tsx +66 -66
  54. package/src/components/Tooltip/styles.ts +77 -77
  55. package/src/hooks/useOnClickOutside.tsx +20 -20
  56. package/src/index.tsx +45 -45
  57. package/src/styles/index.ts +38 -38
  58. package/src/types/typographyValues.ts +178 -178
  59. package/tsconfig.json +3 -3
@@ -1,90 +1,90 @@
1
- import { ComponentProps } from "react";
2
- import { styled } from "../styles";
3
- import { Dialog as ModalRadix } from "radix-ui";
4
- import Icon from "./Icon";
5
- import { Box } from "./Box";
6
- import { Text } from "./Text";
7
-
8
- const ModalContentStyled = styled(ModalRadix.Content, {
9
- fontFamily: "$default",
10
- lineHeight: "$base",
11
- fontSize: "$13",
12
- maxWidth: "502px",
13
- width: "100%",
14
- border: "1px solid $neutral",
15
- borderRadius: "$2xl",
16
- boxShadow:
17
- "0px 4px 4px 0px rgba(35, 53, 67, 0.08), 0px 2px 4px 0px rgba(35, 53, 67, 0.16)",
18
- position: "fixed",
19
- top: "50%",
20
- left: "50%",
21
- transform: "translate(-50%, -50%)",
22
- backgroundColor: "$dark50",
23
- zIndex: '10001'
24
- });
25
-
26
- const ModalOverlay = styled(ModalRadix.Overlay, {
27
- position: "fixed",
28
- inset: 0,
29
- opacity: 1,
30
- backgroundColor: "rgba(0, 0, 0, .5)",
31
- zIndex: '10000'
32
- });
33
-
34
- const ModalHeaderStyled = styled("div", {
35
- borderBottom: "1px solid $neutral300",
36
- padding: "$18 $24",
37
- textAlign: "center",
38
- position: "relative",
39
- display: "flex",
40
- alignItems: "center",
41
- justifyContent: "center",
42
- });
43
-
44
- const ModalIconClose = styled(Icon, {
45
- position: "absolute",
46
- right: "$24",
47
- cursor: "pointer",
48
- });
49
-
50
- const ModalTitleStyled = styled(ModalRadix.Title, {
51
- fontFamily: "$default",
52
- lineHeight: "$base",
53
- fontSize: "$18",
54
- fontWeight: "medium",
55
- fontStyle: "normal",
56
- textTransform: "uppercase",
57
- });
58
-
59
- export type ModalProps = ComponentProps<typeof ModalRadix.Root> & {
60
- trigger?: React.ReactNode;
61
- title?: string;
62
- children: React.ReactNode;
63
- };
64
-
65
- export function Modal({ children, title, trigger, ...props }: ModalProps) {
66
- return (
67
- <ModalRadix.Root {...props}>
68
- {trigger && <ModalRadix.Trigger asChild>{trigger}</ModalRadix.Trigger>}
69
- <ModalRadix.Portal>
70
- <ModalOverlay>
71
- <ModalContentStyled>
72
- {title && (
73
- <ModalHeaderStyled>
74
- <ModalTitleStyled asChild>
75
- <Text typography={"headline6"} fontWeight={"medium"}>
76
- {title}
77
- </Text>
78
- </ModalTitleStyled>
79
- <ModalRadix.Close asChild>
80
- <ModalIconClose name="close" size="xl" />
81
- </ModalRadix.Close>
82
- </ModalHeaderStyled>
83
- )}
84
- <Box>{children}</Box>
85
- </ModalContentStyled>
86
- </ModalOverlay>
87
- </ModalRadix.Portal>
88
- </ModalRadix.Root>
89
- );
90
- }
1
+ import { ComponentProps } from "react";
2
+ import { styled } from "../styles";
3
+ import { Dialog as ModalRadix } from "radix-ui";
4
+ import Icon from "./Icon";
5
+ import { Box } from "./Box";
6
+ import { Text } from "./Text";
7
+
8
+ const ModalContentStyled = styled(ModalRadix.Content, {
9
+ fontFamily: "$default",
10
+ lineHeight: "$base",
11
+ fontSize: "$13",
12
+ maxWidth: "502px",
13
+ width: "100%",
14
+ border: "1px solid $neutral",
15
+ borderRadius: "$2xl",
16
+ boxShadow:
17
+ "0px 4px 4px 0px rgba(35, 53, 67, 0.08), 0px 2px 4px 0px rgba(35, 53, 67, 0.16)",
18
+ position: "fixed",
19
+ top: "50%",
20
+ left: "50%",
21
+ transform: "translate(-50%, -50%)",
22
+ backgroundColor: "$dark50",
23
+ zIndex: '10001'
24
+ });
25
+
26
+ const ModalOverlay = styled(ModalRadix.Overlay, {
27
+ position: "fixed",
28
+ inset: 0,
29
+ opacity: 1,
30
+ backgroundColor: "rgba(0, 0, 0, .5)",
31
+ zIndex: '10000'
32
+ });
33
+
34
+ const ModalHeaderStyled = styled("div", {
35
+ borderBottom: "1px solid $neutral300",
36
+ padding: "$18 $24",
37
+ textAlign: "center",
38
+ position: "relative",
39
+ display: "flex",
40
+ alignItems: "center",
41
+ justifyContent: "center",
42
+ });
43
+
44
+ const ModalIconClose = styled(Icon, {
45
+ position: "absolute",
46
+ right: "$24",
47
+ cursor: "pointer",
48
+ });
49
+
50
+ const ModalTitleStyled = styled(ModalRadix.Title, {
51
+ fontFamily: "$default",
52
+ lineHeight: "$base",
53
+ fontSize: "$18",
54
+ fontWeight: "medium",
55
+ fontStyle: "normal",
56
+ textTransform: "uppercase",
57
+ });
58
+
59
+ export type ModalProps = ComponentProps<typeof ModalRadix.Root> & {
60
+ trigger?: React.ReactNode;
61
+ title?: string;
62
+ children: React.ReactNode;
63
+ };
64
+
65
+ export function Modal({ children, title, trigger, ...props }: ModalProps) {
66
+ return (
67
+ <ModalRadix.Root {...props}>
68
+ {trigger && <ModalRadix.Trigger asChild>{trigger}</ModalRadix.Trigger>}
69
+ <ModalRadix.Portal>
70
+ <ModalOverlay>
71
+ <ModalContentStyled>
72
+ {title && (
73
+ <ModalHeaderStyled>
74
+ <ModalTitleStyled asChild>
75
+ <Text typography={"headline6"} fontWeight={"medium"}>
76
+ {title}
77
+ </Text>
78
+ </ModalTitleStyled>
79
+ <ModalRadix.Close asChild>
80
+ <ModalIconClose name="close" size="xl" />
81
+ </ModalRadix.Close>
82
+ </ModalHeaderStyled>
83
+ )}
84
+ <Box>{children}</Box>
85
+ </ModalContentStyled>
86
+ </ModalOverlay>
87
+ </ModalRadix.Portal>
88
+ </ModalRadix.Root>
89
+ );
90
+ }
@@ -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
+ );