@lets-events/react 12.9.3 → 12.9.4
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.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +15 -2
- package/dist/index.d.ts +15 -2
- package/dist/index.js +300 -201
- package/dist/index.mjs +268 -170
- package/package.json +1 -1
- package/src/components/Button/index.tsx +14 -2
- package/src/components/Button/styledComponents.ts +42 -1
- package/src/components/Drawer/index.tsx +4 -1
- package/src/components/MenuDropdown/styledComponents.ts +1 -1
- package/src/components/ToggleElement/index.tsx +58 -0
- package/src/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -6,6 +6,18 @@ import Icon, { IconProps } from "../Icon";
|
|
|
6
6
|
import { Flex } from "../Flex";
|
|
7
7
|
|
|
8
8
|
type ButtonVariantProps = VariantProps<typeof ButtonStyled>;
|
|
9
|
+
|
|
10
|
+
const getJustifyByTextAlign = (textAlign: ButtonVariantProps["textAlign"]) => {
|
|
11
|
+
switch (textAlign) {
|
|
12
|
+
case "left":
|
|
13
|
+
return "start";
|
|
14
|
+
case "right":
|
|
15
|
+
return "end";
|
|
16
|
+
default:
|
|
17
|
+
return "center";
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
9
21
|
export interface ButtonProps
|
|
10
22
|
extends ComponentProps<typeof ButtonStyled>,
|
|
11
23
|
ButtonVariantProps {
|
|
@@ -15,7 +27,7 @@ export interface ButtonProps
|
|
|
15
27
|
|
|
16
28
|
export function Button({ asChild, children, loading, ...props }: ButtonProps) {
|
|
17
29
|
const Component = asChild ? ButtonRadix : "button";
|
|
18
|
-
const { size, disabled } = props;
|
|
30
|
+
const { size, disabled, textAlign = "center" } = props;
|
|
19
31
|
|
|
20
32
|
const spinnerSize = useMemo((): IconProps["size"] => {
|
|
21
33
|
switch (size) {
|
|
@@ -36,7 +48,7 @@ export function Button({ asChild, children, loading, ...props }: ButtonProps) {
|
|
|
36
48
|
<ButtonStyled as={Component} {...props} disabled={disabled || loading}>
|
|
37
49
|
<div style={{ position: "relative" }}>
|
|
38
50
|
<Flex
|
|
39
|
-
justify={
|
|
51
|
+
justify={getJustifyByTextAlign(textAlign)}
|
|
40
52
|
align={"center"}
|
|
41
53
|
css={{ visibility: loading ? "hidden" : undefined }}
|
|
42
54
|
>
|
|
@@ -7,6 +7,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
7
7
|
$$buttonBgColor: "$colors$grey50",
|
|
8
8
|
$$buttonBorderColor: "inherit",
|
|
9
9
|
$$buttonOutlinedColor: "inherit",
|
|
10
|
+
$$buttonToggleBgColor: "transparent",
|
|
10
11
|
fontFamily: "$default",
|
|
11
12
|
letterSpacing: 0,
|
|
12
13
|
border: 0,
|
|
@@ -30,6 +31,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
30
31
|
$$buttonColor: "$colors$brand500",
|
|
31
32
|
$$buttonBorderColor: "$colors$brand600",
|
|
32
33
|
$$buttonOutlinedColor: "$$buttonColor",
|
|
34
|
+
$$buttonToggleBgColor: "rgba(0, 78, 210, 0.2)",
|
|
33
35
|
"&:hover": {
|
|
34
36
|
$$buttonColor: "$colors$brand600",
|
|
35
37
|
$$buttonBorderColor: "$colors$brand700",
|
|
@@ -49,6 +51,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
49
51
|
$$buttonColor: "$colors$purple500",
|
|
50
52
|
$$buttonBorderColor: "$colors$purple300",
|
|
51
53
|
$$buttonOutlinedColor: "$$buttonColor",
|
|
54
|
+
$$buttonToggleBgColor: "rgba(137, 97, 216, 0.2)",
|
|
52
55
|
"&:hover": {
|
|
53
56
|
$$buttonColor: "$colors$purple600",
|
|
54
57
|
$$buttonBorderColor: "$colors$purple700",
|
|
@@ -72,6 +75,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
72
75
|
$$buttonColor: "$colors$error600",
|
|
73
76
|
$$buttonBorderColor: "$colors$error500",
|
|
74
77
|
$$buttonOutlinedColor: " $colors$error500",
|
|
78
|
+
$$buttonToggleBgColor: "rgba(219, 54, 68, 0.2)",
|
|
75
79
|
"&:hover": {
|
|
76
80
|
$$buttonColor: "$colors$error600",
|
|
77
81
|
$$buttonBorderColor: "$colors$error700",
|
|
@@ -92,6 +96,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
92
96
|
$$buttonColor: "$colors$info500",
|
|
93
97
|
$$buttonBorderColor: "$colors$info600",
|
|
94
98
|
$$buttonOutlinedColor: "$$buttonColor",
|
|
99
|
+
$$buttonToggleBgColor: "rgba(2, 120, 254, 0.2)",
|
|
95
100
|
"&:hover": {
|
|
96
101
|
$$buttonColor: "$colors$info600",
|
|
97
102
|
$$buttonBorderColor: "$colors$info700",
|
|
@@ -112,6 +117,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
112
117
|
$$buttonColor: "$colors$success500",
|
|
113
118
|
$$buttonBorderColor: "$colors$success600",
|
|
114
119
|
$$buttonOutlinedColor: "$$buttonColor",
|
|
120
|
+
$$buttonToggleBgColor: "rgba(38, 167, 67, 0.2)",
|
|
115
121
|
"&:hover": {
|
|
116
122
|
$$buttonColor: "$colors$success600",
|
|
117
123
|
$$buttonBorderColor: "$colors$success700",
|
|
@@ -132,6 +138,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
132
138
|
$$buttonColor: "$colors$warning500",
|
|
133
139
|
$$buttonBorderColor: "$colors$warning600",
|
|
134
140
|
$$buttonOutlinedColor: "$$buttonColor",
|
|
141
|
+
$$buttonToggleBgColor: "rgba(255, 193, 7, 0.2)",
|
|
135
142
|
"&:hover": {
|
|
136
143
|
$$buttonColor: "$colors$warning600",
|
|
137
144
|
$$buttonBorderColor: "$colors$warning700",
|
|
@@ -152,6 +159,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
152
159
|
$$buttonColor: "$colors$neutral600",
|
|
153
160
|
$$buttonBorderColor: "$colors$neutral300",
|
|
154
161
|
$$buttonOutlinedColor: "$$buttonColor",
|
|
162
|
+
$$buttonToggleBgColor: "rgba(76, 79, 84, 0.2)",
|
|
155
163
|
"&:hover": {
|
|
156
164
|
$$buttonColor: "$colors$neutral700",
|
|
157
165
|
$$buttonBgColor: "$colors$neutral100",
|
|
@@ -172,6 +180,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
172
180
|
$$buttonColor: "$colors$neutral50",
|
|
173
181
|
$$buttonBorderColor: "$colors$neutral300",
|
|
174
182
|
$$buttonOutlinedColor: "$colors$neutral50",
|
|
183
|
+
$$buttonToggleBgColor: "rgba(255, 255, 255, 0.2)",
|
|
175
184
|
"&:hover": {
|
|
176
185
|
$$buttonColor: "$colors$neutral100",
|
|
177
186
|
$$buttonBorderColor: "$colors$neutral300",
|
|
@@ -224,6 +233,18 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
224
233
|
height: "unset",
|
|
225
234
|
color: "$$buttonColor",
|
|
226
235
|
},
|
|
236
|
+
toggle: {
|
|
237
|
+
backgroundColor: "transparent",
|
|
238
|
+
boxShadow: "none",
|
|
239
|
+
padding: "$6 $12",
|
|
240
|
+
border: 0,
|
|
241
|
+
height: "2rem",
|
|
242
|
+
color: "$$buttonColor",
|
|
243
|
+
borderRadius: ".5rem",
|
|
244
|
+
"&:hover": {
|
|
245
|
+
backgroundColor: "$$buttonToggleBgColor",
|
|
246
|
+
},
|
|
247
|
+
},
|
|
227
248
|
contained: {
|
|
228
249
|
color: "$grey50",
|
|
229
250
|
backgroundColor: "$$buttonColor",
|
|
@@ -249,7 +270,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
249
270
|
menuDropdownItem: {
|
|
250
271
|
backgroundColor: "transparent",
|
|
251
272
|
boxShadow: "none",
|
|
252
|
-
padding: "0.
|
|
273
|
+
padding: "0.5rem 1rem",
|
|
253
274
|
border: 0,
|
|
254
275
|
height: "unset",
|
|
255
276
|
color: "$$buttonColor",
|
|
@@ -260,6 +281,20 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
260
281
|
backgroundColor: "$dark100",
|
|
261
282
|
},
|
|
262
283
|
},
|
|
284
|
+
menuDropdownItemDelete: {
|
|
285
|
+
backgroundColor: "transparent",
|
|
286
|
+
boxShadow: "none",
|
|
287
|
+
padding: "0.5rem 1rem",
|
|
288
|
+
border: 0,
|
|
289
|
+
height: "unset",
|
|
290
|
+
color: "$$buttonColor",
|
|
291
|
+
width: "100%",
|
|
292
|
+
borderRadius: 0,
|
|
293
|
+
whiteSpace: "nowrap",
|
|
294
|
+
"&:hover": {
|
|
295
|
+
backgroundColor: "$red100",
|
|
296
|
+
},
|
|
297
|
+
}
|
|
263
298
|
},
|
|
264
299
|
fontWeight: {
|
|
265
300
|
regular: { fontWeight: "$regular" },
|
|
@@ -267,6 +302,11 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
267
302
|
semibold: { fontWeight: "$semibold" },
|
|
268
303
|
bold: { fontWeight: "$bold" },
|
|
269
304
|
},
|
|
305
|
+
textAlign: {
|
|
306
|
+
center: { textAlign: "center", justifyContent: "center" },
|
|
307
|
+
left: { textAlign: "left", justifyContent: "flex-start" },
|
|
308
|
+
right: { textAlign: "right", justifyContent: "flex-end" },
|
|
309
|
+
},
|
|
270
310
|
outlinedBgColor: {
|
|
271
311
|
neutral: {},
|
|
272
312
|
transparent: {
|
|
@@ -302,6 +342,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
302
342
|
color: "brand",
|
|
303
343
|
size: "medium",
|
|
304
344
|
fontWeight: "medium",
|
|
345
|
+
textAlign: "center",
|
|
305
346
|
outlinedBgColor: "transparent",
|
|
306
347
|
},
|
|
307
348
|
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ReactNode, useState } from "react";
|
|
2
|
+
import { Button, ButtonProps } from "../Button";
|
|
3
|
+
import { Icon } from "../Icon";
|
|
4
|
+
|
|
5
|
+
export interface ToggleElementProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
label: ReactNode;
|
|
8
|
+
openedLabel?: ReactNode;
|
|
9
|
+
defaultOpen?: boolean;
|
|
10
|
+
open?: boolean;
|
|
11
|
+
hideButtonWhenOpen?: boolean;
|
|
12
|
+
buttonProps?: Omit<ButtonProps, "children" | "onClick">;
|
|
13
|
+
onOpenChange?: (open: boolean) => void;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function ToggleElement({
|
|
17
|
+
children,
|
|
18
|
+
label,
|
|
19
|
+
openedLabel,
|
|
20
|
+
defaultOpen = false,
|
|
21
|
+
open,
|
|
22
|
+
hideButtonWhenOpen = true,
|
|
23
|
+
buttonProps,
|
|
24
|
+
onOpenChange,
|
|
25
|
+
}: ToggleElementProps) {
|
|
26
|
+
const [internalOpen, setInternalOpen] = useState(defaultOpen);
|
|
27
|
+
const isControlled = open !== undefined;
|
|
28
|
+
const isOpen = isControlled ? open : internalOpen;
|
|
29
|
+
|
|
30
|
+
const handleClick = () => {
|
|
31
|
+
const nextOpen = !isOpen;
|
|
32
|
+
|
|
33
|
+
if (!isControlled) {
|
|
34
|
+
setInternalOpen(nextOpen);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
onOpenChange?.(nextOpen);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<>
|
|
42
|
+
{(!isOpen || !hideButtonWhenOpen) && (
|
|
43
|
+
<Button
|
|
44
|
+
type="button"
|
|
45
|
+
variant="toggle"
|
|
46
|
+
color="brand"
|
|
47
|
+
size="small"
|
|
48
|
+
{...buttonProps}
|
|
49
|
+
onClick={handleClick}
|
|
50
|
+
>
|
|
51
|
+
{!isOpen && <Icon name="plus" size="md" />}
|
|
52
|
+
{isOpen ? openedLabel ?? label : label}
|
|
53
|
+
</Button>
|
|
54
|
+
)}
|
|
55
|
+
{isOpen && children}
|
|
56
|
+
</>
|
|
57
|
+
);
|
|
58
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -29,7 +29,7 @@ export * from "./components/Toast";
|
|
|
29
29
|
export * from "./components/Tooltip";
|
|
30
30
|
export * from "./components/MultiSelect";
|
|
31
31
|
export * from "./components/Divider";
|
|
32
|
-
|
|
32
|
+
export * from "./components/ToggleElement";
|
|
33
33
|
// Layouts
|
|
34
34
|
export * from "./components/Flex";
|
|
35
35
|
export * from "./components/Box";
|