@lets-events/react 11.2.0 → 11.4.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.
- package/.turbo/turbo-build.log +8 -8
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +1728 -209
- package/dist/index.d.ts +1728 -209
- package/dist/index.js +524 -176
- package/dist/index.mjs +496 -148
- package/package.json +1 -1
- package/src/components/Badge.tsx +1 -4
- package/src/components/Button/index.tsx +12 -9
- package/src/components/Button/styledComponents.ts +14 -3
- package/src/components/CheckboxGroup.tsx +129 -147
- package/src/components/Drawer/index.tsx +48 -0
- package/src/components/Drawer/styledComponents.ts +46 -0
- package/src/components/FormFields/MultiSelectFormField.tsx +65 -0
- package/src/components/MenuDropdown/index.tsx +30 -0
- package/src/components/MenuDropdown/styledComponents.ts +31 -0
- package/src/components/MultiSelect.tsx +216 -0
- package/src/components/Text.tsx +1 -2
- package/src/index.tsx +4 -0
package/package.json
CHANGED
package/src/components/Badge.tsx
CHANGED
|
@@ -6,9 +6,6 @@ export const BadgeStyled = styled(BadgeRadix, {
|
|
|
6
6
|
fontFamily: '$default',
|
|
7
7
|
borderRadius: '$sm',
|
|
8
8
|
verticalAlign: 'middle',
|
|
9
|
-
'svg': {
|
|
10
|
-
marginRight: '10px',
|
|
11
|
-
},
|
|
12
9
|
variants: {
|
|
13
10
|
color: {
|
|
14
11
|
primary: {
|
|
@@ -111,9 +108,9 @@ export const BadgeStyled = styled(BadgeRadix, {
|
|
|
111
108
|
export type BadgeProps = ComponentProps<typeof BadgeStyled> & {
|
|
112
109
|
as?: ElementType
|
|
113
110
|
icon?: boolean
|
|
114
|
-
size: 'md',
|
|
115
111
|
children: React.ReactNode
|
|
116
112
|
}
|
|
113
|
+
|
|
117
114
|
export function Badge({ asChild, children, ...props }: BadgeProps) {
|
|
118
115
|
return (
|
|
119
116
|
<BadgeStyled {...props}>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { ComponentProps } from
|
|
2
|
-
import { ButtonStyled } from
|
|
3
|
-
import { Button as ButtonRadix } from
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { ButtonStyled } from "./styledComponents";
|
|
3
|
+
import { Button as ButtonRadix } from "@radix-ui/themes";
|
|
4
|
+
import type { VariantProps } from "@stitches/react";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
export interface ButtonProps
|
|
7
|
-
|
|
6
|
+
type ButtonVariantProps = VariantProps<typeof ButtonStyled>;
|
|
7
|
+
export interface ButtonProps
|
|
8
|
+
extends ComponentProps<typeof ButtonStyled>,
|
|
9
|
+
ButtonVariantProps {
|
|
10
|
+
asChild?: boolean;
|
|
8
11
|
}
|
|
9
12
|
|
|
10
13
|
export function Button({ asChild, ...props }: ButtonProps) {
|
|
11
|
-
const Component = asChild ? ButtonRadix :
|
|
12
|
-
return <ButtonStyled as={Component} {...props}
|
|
13
|
-
}
|
|
14
|
+
const Component = asChild ? ButtonRadix : "button";
|
|
15
|
+
return <ButtonStyled as={Component} {...props} />;
|
|
16
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Button as ButtonRadix } from "@radix-ui/themes";
|
|
2
|
-
import { typographyButtonValues } from "../../types/typographyValues";
|
|
3
2
|
|
|
4
3
|
import { styled } from "../../styles";
|
|
5
4
|
|
|
@@ -8,7 +7,6 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
8
7
|
$$buttonBgColor: "$colors$grey50",
|
|
9
8
|
$$buttonBorderColor: "inherit",
|
|
10
9
|
$$buttonOutlinedColor: "inherit",
|
|
11
|
-
|
|
12
10
|
fontFamily: "$default",
|
|
13
11
|
letterSpacing: 0,
|
|
14
12
|
border: 0,
|
|
@@ -223,7 +221,7 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
223
221
|
boxShadow: "none",
|
|
224
222
|
padding: 0,
|
|
225
223
|
border: 0,
|
|
226
|
-
height:
|
|
224
|
+
height: "unset",
|
|
227
225
|
color: "$$buttonColor",
|
|
228
226
|
},
|
|
229
227
|
contained: {
|
|
@@ -247,6 +245,19 @@ export const ButtonStyled = styled(ButtonRadix, {
|
|
|
247
245
|
$$buttonColor: "$colors$neutral300",
|
|
248
246
|
},
|
|
249
247
|
},
|
|
248
|
+
menuDropdownItem: {
|
|
249
|
+
backgroundColor: "transparent",
|
|
250
|
+
boxShadow: "none",
|
|
251
|
+
padding: "0.25rem 0.5rem",
|
|
252
|
+
border: 0,
|
|
253
|
+
height: "unset",
|
|
254
|
+
color: "$$buttonColor",
|
|
255
|
+
width: "100%",
|
|
256
|
+
borderRadius: 0,
|
|
257
|
+
"&:hover": {
|
|
258
|
+
backgroundColor: "$dark100",
|
|
259
|
+
},
|
|
260
|
+
},
|
|
250
261
|
},
|
|
251
262
|
fontWeight: {
|
|
252
263
|
regular: { fontWeight: "$regular" },
|
|
@@ -1,214 +1,196 @@
|
|
|
1
|
-
import { ComponentProps } from
|
|
2
|
-
import { styled } from
|
|
1
|
+
import { ComponentProps } from "react";
|
|
2
|
+
import { styled } from "../styles";
|
|
3
3
|
import { CheckboxGroup as CheckboxGroupRadix } from "@radix-ui/themes";
|
|
4
4
|
import { typographyLabelValues } from "../types/typographyValues";
|
|
5
5
|
|
|
6
6
|
export const CheckboxGroupStyled = styled(CheckboxGroupRadix.Root, {
|
|
7
|
-
fontFamily:
|
|
8
|
-
|
|
9
|
-
display:
|
|
7
|
+
fontFamily: "$default",
|
|
8
|
+
svg: {
|
|
9
|
+
display: "none",
|
|
10
10
|
},
|
|
11
|
-
|
|
12
|
-
display:
|
|
13
|
-
alignItems:
|
|
14
|
-
gap:
|
|
15
|
-
cursor:
|
|
16
|
-
|
|
17
|
-
transition:
|
|
18
|
-
boxShadow:
|
|
19
|
-
}
|
|
11
|
+
label: {
|
|
12
|
+
display: "flex",
|
|
13
|
+
alignItems: "center",
|
|
14
|
+
gap: "$8",
|
|
15
|
+
cursor: "pointer",
|
|
16
|
+
"&:focus button, &:hover button": {
|
|
17
|
+
transition: "all 300ms ease-out",
|
|
18
|
+
boxShadow: "0px 0px 0px 4px rgba(56, 129, 255, 0.50)",
|
|
19
|
+
},
|
|
20
20
|
},
|
|
21
|
-
|
|
22
|
-
backgroundColor:
|
|
23
|
-
borderRadius:
|
|
24
|
-
height:
|
|
25
|
-
width:
|
|
26
|
-
position:
|
|
27
|
-
border:
|
|
28
|
-
cursor:
|
|
21
|
+
"label button": {
|
|
22
|
+
backgroundColor: "$white",
|
|
23
|
+
borderRadius: "2px",
|
|
24
|
+
height: "$16",
|
|
25
|
+
width: "$16",
|
|
26
|
+
position: "relative",
|
|
27
|
+
border: "2px solid $dark300",
|
|
28
|
+
cursor: "pointer",
|
|
29
29
|
},
|
|
30
|
-
|
|
31
|
-
backgroundColor:
|
|
32
|
-
content:
|
|
33
|
-
width:
|
|
34
|
-
height:
|
|
35
|
-
position:
|
|
36
|
-
top:
|
|
37
|
-
right:
|
|
30
|
+
"label button[data-state=checked]:before": {
|
|
31
|
+
backgroundColor: "$dark50",
|
|
32
|
+
content: "",
|
|
33
|
+
width: "8px",
|
|
34
|
+
height: "8px",
|
|
35
|
+
position: "absolute",
|
|
36
|
+
top: "2px",
|
|
37
|
+
right: "2px",
|
|
38
38
|
zIndex: 2,
|
|
39
39
|
},
|
|
40
|
-
|
|
41
|
-
backgroundColor:
|
|
42
|
-
content:
|
|
43
|
-
height:
|
|
44
|
-
width:
|
|
45
|
-
position:
|
|
46
|
-
top:
|
|
47
|
-
right:
|
|
48
|
-
borderRadius:
|
|
40
|
+
"label button[data-state=checked]:after": {
|
|
41
|
+
backgroundColor: "$brand500",
|
|
42
|
+
content: "",
|
|
43
|
+
height: "$16",
|
|
44
|
+
width: "$16",
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: "-2px",
|
|
47
|
+
right: "-2px",
|
|
48
|
+
borderRadius: "2px",
|
|
49
49
|
zIndex: 1,
|
|
50
50
|
},
|
|
51
51
|
|
|
52
52
|
variants: {
|
|
53
53
|
color: {
|
|
54
54
|
success: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
boxShadow:
|
|
58
|
-
}
|
|
55
|
+
label: {
|
|
56
|
+
"&:focus button, &:hover button": {
|
|
57
|
+
boxShadow: "0px 0px 0px 4px rgba(38, 167, 67, 0.50)",
|
|
58
|
+
},
|
|
59
59
|
},
|
|
60
|
-
|
|
61
|
-
borderColor:
|
|
62
|
-
backgroundColor:
|
|
60
|
+
"label button": {
|
|
61
|
+
borderColor: "$green500",
|
|
62
|
+
backgroundColor: "$dark50",
|
|
63
63
|
},
|
|
64
|
-
|
|
65
|
-
backgroundColor:
|
|
64
|
+
"label button[data-state=checked]:after": {
|
|
65
|
+
backgroundColor: "$green500",
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
68
|
blue: {},
|
|
69
69
|
error: {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
boxShadow:
|
|
73
|
-
}
|
|
70
|
+
label: {
|
|
71
|
+
"&:focus button, &:hover button": {
|
|
72
|
+
boxShadow: "0px 0px 0px 4px rgba(225, 86, 98, 0.50)",
|
|
73
|
+
},
|
|
74
74
|
},
|
|
75
|
-
|
|
76
|
-
borderColor:
|
|
77
|
-
backgroundColor:
|
|
75
|
+
"label button": {
|
|
76
|
+
borderColor: "$error400",
|
|
77
|
+
backgroundColor: "$dark50",
|
|
78
78
|
},
|
|
79
|
-
|
|
80
|
-
backgroundColor:
|
|
79
|
+
"label button[data-state=checked]:after": {
|
|
80
|
+
backgroundColor: "$error600",
|
|
81
81
|
},
|
|
82
|
-
}
|
|
82
|
+
},
|
|
83
83
|
},
|
|
84
84
|
disabled: {
|
|
85
85
|
true: {
|
|
86
|
-
|
|
87
|
-
cursor:
|
|
86
|
+
label: {
|
|
87
|
+
cursor: "not-allowed",
|
|
88
88
|
opacity: 0.5,
|
|
89
|
-
|
|
90
|
-
boxShadow:
|
|
91
|
-
}
|
|
89
|
+
"&:focus button, &:hover button": {
|
|
90
|
+
boxShadow: "none",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
"label button": {
|
|
94
|
+
cursor: "not-allowed",
|
|
92
95
|
},
|
|
93
|
-
'label button': {
|
|
94
|
-
cursor: 'not-allowed',
|
|
95
|
-
}
|
|
96
96
|
},
|
|
97
|
-
false: {}
|
|
97
|
+
false: {},
|
|
98
98
|
},
|
|
99
99
|
typography: typographyLabelValues,
|
|
100
100
|
fontWeight: {
|
|
101
|
-
regular: { fontWeight:
|
|
102
|
-
medium: { fontWeight:
|
|
103
|
-
semibold: { fontWeight:
|
|
104
|
-
bold: { fontWeight:
|
|
101
|
+
regular: { fontWeight: "$regular" },
|
|
102
|
+
medium: { fontWeight: "$medium" },
|
|
103
|
+
semibold: { fontWeight: "$semibold" },
|
|
104
|
+
bold: { fontWeight: "$bold" },
|
|
105
105
|
},
|
|
106
106
|
},
|
|
107
107
|
|
|
108
108
|
compoundVariants: [
|
|
109
|
-
|
|
110
109
|
{
|
|
111
|
-
color:
|
|
110
|
+
color: "blue",
|
|
112
111
|
disabled: false,
|
|
113
112
|
css: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
boxShadow:
|
|
117
|
-
}
|
|
113
|
+
label: {
|
|
114
|
+
"&:focus button, &:hover button": {
|
|
115
|
+
boxShadow: "0px 0px 0px 4px rgba(56, 129, 255, 0.50)",
|
|
116
|
+
},
|
|
118
117
|
},
|
|
119
|
-
|
|
120
|
-
borderColor:
|
|
118
|
+
"label button": {
|
|
119
|
+
borderColor: "$dark300",
|
|
121
120
|
},
|
|
122
|
-
|
|
123
|
-
backgroundColor:
|
|
121
|
+
"label button[data-state=checked]:after": {
|
|
122
|
+
backgroundColor: "$brand500",
|
|
124
123
|
},
|
|
125
|
-
}
|
|
124
|
+
},
|
|
126
125
|
},
|
|
127
126
|
|
|
128
127
|
{
|
|
129
|
-
color:
|
|
128
|
+
color: "blue",
|
|
130
129
|
disabled: true,
|
|
131
130
|
css: {
|
|
132
|
-
|
|
133
|
-
borderColor:
|
|
134
|
-
backgroundColor:
|
|
131
|
+
"label button": {
|
|
132
|
+
borderColor: "$brand100",
|
|
133
|
+
backgroundColor: "$dark50",
|
|
135
134
|
},
|
|
136
|
-
|
|
137
|
-
backgroundColor:
|
|
135
|
+
"label button[data-state=checked]:after": {
|
|
136
|
+
backgroundColor: "$brand100",
|
|
138
137
|
},
|
|
139
|
-
}
|
|
138
|
+
},
|
|
140
139
|
},
|
|
141
140
|
|
|
142
141
|
{
|
|
143
|
-
color:
|
|
142
|
+
color: "success",
|
|
144
143
|
disabled: true,
|
|
145
144
|
css: {
|
|
146
|
-
|
|
147
|
-
borderColor:
|
|
148
|
-
backgroundColor:
|
|
149
|
-
},
|
|
150
|
-
|
|
151
|
-
backgroundColor:
|
|
152
|
-
}
|
|
153
|
-
}
|
|
145
|
+
"label button": {
|
|
146
|
+
borderColor: "$success100",
|
|
147
|
+
backgroundColor: "$dark50",
|
|
148
|
+
},
|
|
149
|
+
"label button[data-state=checked]:after": {
|
|
150
|
+
backgroundColor: "$success100",
|
|
151
|
+
},
|
|
152
|
+
},
|
|
154
153
|
},
|
|
155
154
|
|
|
156
155
|
{
|
|
157
|
-
color:
|
|
156
|
+
color: "error",
|
|
158
157
|
disabled: true,
|
|
159
158
|
css: {
|
|
160
|
-
|
|
161
|
-
borderColor:
|
|
162
|
-
backgroundColor:
|
|
163
|
-
},
|
|
164
|
-
|
|
165
|
-
backgroundColor:
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
}
|
|
159
|
+
"label button": {
|
|
160
|
+
borderColor: "$error100",
|
|
161
|
+
backgroundColor: "$dark50",
|
|
162
|
+
},
|
|
163
|
+
"label button[data-state=checked]:after": {
|
|
164
|
+
backgroundColor: "$error100",
|
|
165
|
+
},
|
|
166
|
+
},
|
|
167
|
+
},
|
|
169
168
|
],
|
|
170
169
|
defaultVariants: {
|
|
171
|
-
color:
|
|
172
|
-
disabled: false
|
|
173
|
-
}
|
|
174
|
-
})
|
|
175
|
-
|
|
176
|
-
export type CheckboxGroupProps = ComponentProps<typeof CheckboxGroupStyled> & {
|
|
177
|
-
placeholder?: string
|
|
178
|
-
children?: React.ReactNode
|
|
179
|
-
color?: string
|
|
180
|
-
disabled?: boolean
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
export type CheckboxItemProps = {
|
|
184
|
-
children?: React.ReactNode
|
|
185
|
-
value: string,
|
|
186
|
-
style?: React.CSSProperties
|
|
187
|
-
}
|
|
170
|
+
color: "blue",
|
|
171
|
+
disabled: false,
|
|
172
|
+
},
|
|
173
|
+
});
|
|
188
174
|
|
|
189
|
-
|
|
190
|
-
children,
|
|
175
|
+
const StyledItem = styled(CheckboxGroupRadix.Item, {});
|
|
191
176
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
177
|
+
export type CheckboxGroupProps = ComponentProps<typeof CheckboxGroupStyled> & {
|
|
178
|
+
placeholder?: string;
|
|
179
|
+
children?: React.ReactNode;
|
|
180
|
+
color?: string;
|
|
181
|
+
disabled?: boolean;
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export type CheckboxItemProps = ComponentProps<typeof StyledItem> & {
|
|
185
|
+
children?: React.ReactNode;
|
|
186
|
+
value: string;
|
|
187
|
+
style?: React.CSSProperties;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
export function CheckboxGroup({ children, ...props }: CheckboxGroupProps) {
|
|
191
|
+
return <CheckboxGroupStyled {...props}>{children}</CheckboxGroupStyled>;
|
|
199
192
|
}
|
|
200
193
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
children,
|
|
204
|
-
|
|
205
|
-
...props
|
|
206
|
-
}: CheckboxItemProps) {
|
|
207
|
-
return (
|
|
208
|
-
<CheckboxGroupRadix.Item {...props}>
|
|
209
|
-
{children}
|
|
210
|
-
</CheckboxGroupRadix.Item>
|
|
211
|
-
)
|
|
194
|
+
export function CheckboxItem({ children, ...props }: CheckboxItemProps) {
|
|
195
|
+
return <StyledItem {...props}>{children}</StyledItem>;
|
|
212
196
|
}
|
|
213
|
-
|
|
214
|
-
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { colors, Colors } from "@lets-events/tokens";
|
|
3
|
+
import Icon from "../Icon";
|
|
4
|
+
import {
|
|
5
|
+
DrawerOverlayStyled,
|
|
6
|
+
DrawerContainerStyled,
|
|
7
|
+
DrawerHeaderDiv,
|
|
8
|
+
DrawerHeaderTitle,
|
|
9
|
+
DrawerHeaderCloseButton,
|
|
10
|
+
} from "./styledComponents";
|
|
11
|
+
|
|
12
|
+
export type DrawerProps = ComponentProps<typeof DrawerOverlayStyled> & {
|
|
13
|
+
isOpen: boolean;
|
|
14
|
+
onClose: () => void;
|
|
15
|
+
width?: string;
|
|
16
|
+
backgroundColor?: keyof Colors;
|
|
17
|
+
title: string;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function Drawer({
|
|
22
|
+
isOpen,
|
|
23
|
+
onClose,
|
|
24
|
+
width,
|
|
25
|
+
backgroundColor,
|
|
26
|
+
title,
|
|
27
|
+
children,
|
|
28
|
+
}: DrawerProps) {
|
|
29
|
+
if (!isOpen) return null;
|
|
30
|
+
return (
|
|
31
|
+
<DrawerOverlayStyled>
|
|
32
|
+
<DrawerContainerStyled
|
|
33
|
+
style={{
|
|
34
|
+
width: width ?? "34.25rem",
|
|
35
|
+
backgroundColor: colors[backgroundColor ?? "neutral50"],
|
|
36
|
+
}}
|
|
37
|
+
>
|
|
38
|
+
<DrawerHeaderDiv>
|
|
39
|
+
<DrawerHeaderTitle>{title}</DrawerHeaderTitle>
|
|
40
|
+
<DrawerHeaderCloseButton onClick={onClose}>
|
|
41
|
+
<Icon size={"xl"} color="$dark600" name="xmark" />
|
|
42
|
+
</DrawerHeaderCloseButton>
|
|
43
|
+
</DrawerHeaderDiv>
|
|
44
|
+
{children}
|
|
45
|
+
</DrawerContainerStyled>
|
|
46
|
+
</DrawerOverlayStyled>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { styled } from "../../styles";
|
|
2
|
+
|
|
3
|
+
export const DrawerOverlayStyled = styled("div", {
|
|
4
|
+
position: "fixed",
|
|
5
|
+
top: 0,
|
|
6
|
+
right: 0,
|
|
7
|
+
width: "100vw",
|
|
8
|
+
height: "100vh",
|
|
9
|
+
background: "rgba(0, 0, 0, 0.4)",
|
|
10
|
+
zIndex: 1000,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export const DrawerContainerStyled = styled("div", {
|
|
14
|
+
position: "absolute",
|
|
15
|
+
top: 0,
|
|
16
|
+
right: 0,
|
|
17
|
+
maxWidth: "calc(100% - 2rem)",
|
|
18
|
+
height: "100%",
|
|
19
|
+
background: "$neutral50",
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "column",
|
|
22
|
+
boxShadow: "-4px 0 12px rgba(0, 0, 0, 0.2)",
|
|
23
|
+
padding: "1.5rem 0",
|
|
24
|
+
overflowY: "auto",
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export const DrawerHeaderDiv = styled("div", {
|
|
28
|
+
display: "flex",
|
|
29
|
+
justifyContent: "space-between",
|
|
30
|
+
alignItems: "center",
|
|
31
|
+
borderBottom: "1px solid $neutral300",
|
|
32
|
+
padding: "0 1.5rem 1rem",
|
|
33
|
+
position: "relative",
|
|
34
|
+
});
|
|
35
|
+
export const DrawerHeaderTitle = styled("h2", {
|
|
36
|
+
fontSize: "1.125rem",
|
|
37
|
+
fontWeight: "400",
|
|
38
|
+
fontFamily: "Work Sans",
|
|
39
|
+
color: "$dark800",
|
|
40
|
+
margin: "0",
|
|
41
|
+
});
|
|
42
|
+
export const DrawerHeaderCloseButton = styled("button", {
|
|
43
|
+
background: "none",
|
|
44
|
+
border: "none",
|
|
45
|
+
cursor: "pointer",
|
|
46
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useController, useFormContext } from "react-hook-form";
|
|
2
|
+
import { Flex } from "../Flex";
|
|
3
|
+
import { FormLabel } from "./FormLabel";
|
|
4
|
+
import { ErrorFormMessage } from "./ErrorFormMessage";
|
|
5
|
+
import { MultiSelect, MultiSelectProps } from "../MultiSelect";
|
|
6
|
+
|
|
7
|
+
export type MultiSelectFormFieldProps = MultiSelectProps & {
|
|
8
|
+
name: string;
|
|
9
|
+
label?: string;
|
|
10
|
+
required?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const MultiSelectFormField = ({
|
|
14
|
+
name,
|
|
15
|
+
label,
|
|
16
|
+
required,
|
|
17
|
+
...rest
|
|
18
|
+
}: MultiSelectFormFieldProps) => {
|
|
19
|
+
const {
|
|
20
|
+
formState: { errors },
|
|
21
|
+
} = useFormContext();
|
|
22
|
+
|
|
23
|
+
const { field } = useController({
|
|
24
|
+
name,
|
|
25
|
+
rules: {
|
|
26
|
+
required
|
|
27
|
+
},
|
|
28
|
+
defaultValue: [],
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const { value, onChange, ref, onBlur, disabled } = field;
|
|
32
|
+
|
|
33
|
+
const haveError = !!errors[name];
|
|
34
|
+
|
|
35
|
+
const errorMsg = errors[name]?.message;
|
|
36
|
+
|
|
37
|
+
const handleChange = (v: any) => {
|
|
38
|
+
onChange(v);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<Flex direction={"column"}>
|
|
43
|
+
<FormLabel
|
|
44
|
+
name={name}
|
|
45
|
+
label={label}
|
|
46
|
+
required={required}
|
|
47
|
+
haveError={haveError}
|
|
48
|
+
/>
|
|
49
|
+
<MultiSelect
|
|
50
|
+
value={value}
|
|
51
|
+
onValueChange={handleChange}
|
|
52
|
+
ref={ref}
|
|
53
|
+
color={haveError ? "error" : "default"}
|
|
54
|
+
{...rest}
|
|
55
|
+
/>
|
|
56
|
+
{/* <TextareaField
|
|
57
|
+
{...register(name, { required })}
|
|
58
|
+
placeholder={placeholder}
|
|
59
|
+
color={haveError ? "error" : "default"}
|
|
60
|
+
aria-labelledby={`${name}-label`}
|
|
61
|
+
/> */}
|
|
62
|
+
<ErrorFormMessage message={errorMsg} />
|
|
63
|
+
</Flex>
|
|
64
|
+
);
|
|
65
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode, useState } from "react";
|
|
2
|
+
import {
|
|
3
|
+
MenuDropdownContainerStyled,
|
|
4
|
+
TriggerButtonStyled,
|
|
5
|
+
MenuItemsContainerStyled,
|
|
6
|
+
} from "./styledComponents";
|
|
7
|
+
import Icon from "../Icon";
|
|
8
|
+
|
|
9
|
+
export type MenuDropdownProps = ComponentProps<
|
|
10
|
+
typeof MenuDropdownContainerStyled
|
|
11
|
+
> & {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export function MenuDropdown({ children }: MenuDropdownProps) {
|
|
16
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
17
|
+
function handleMenuDropdown() {
|
|
18
|
+
setIsOpen(!isOpen);
|
|
19
|
+
}
|
|
20
|
+
return (
|
|
21
|
+
<MenuDropdownContainerStyled>
|
|
22
|
+
<TriggerButtonStyled onClick={handleMenuDropdown}>
|
|
23
|
+
<Icon name="ellipsis" size="xl" color="#FFFFFF" />
|
|
24
|
+
</TriggerButtonStyled>
|
|
25
|
+
{isOpen && (
|
|
26
|
+
<MenuItemsContainerStyled>{children}</MenuItemsContainerStyled>
|
|
27
|
+
)}
|
|
28
|
+
</MenuDropdownContainerStyled>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { styled } from "../../styles";
|
|
2
|
+
|
|
3
|
+
export const MenuDropdownContainerStyled = styled("div", {
|
|
4
|
+
position: "relative",
|
|
5
|
+
width: "fit-content",
|
|
6
|
+
});
|
|
7
|
+
export const TriggerButtonStyled = styled("button", {
|
|
8
|
+
backgroundColor: "$brand500",
|
|
9
|
+
boxShadow: "0px 4px 4px 0px #23354314",
|
|
10
|
+
borderRadius: "$full",
|
|
11
|
+
border: "none",
|
|
12
|
+
height: "1.875rem",
|
|
13
|
+
width: "1.875rem",
|
|
14
|
+
cursor: "pointer",
|
|
15
|
+
});
|
|
16
|
+
export const MenuItemsContainerStyled = styled("div", {
|
|
17
|
+
position: "absolute",
|
|
18
|
+
right: 0,
|
|
19
|
+
top: "2.125rem",
|
|
20
|
+
zIndex: "999",
|
|
21
|
+
width: "fit-content",
|
|
22
|
+
minWidth: "5rem",
|
|
23
|
+
background: "#fff",
|
|
24
|
+
maxWidth: "18.75rem",
|
|
25
|
+
margin: "auto",
|
|
26
|
+
boxShadow: "0px 4px 4px 0px rgba(35, 53, 67, 0.0784313725)",
|
|
27
|
+
border: "1px solid $dark300",
|
|
28
|
+
borderRadius: "0.5rem",
|
|
29
|
+
padding: "0.5rem 0",
|
|
30
|
+
height: "fit-content",
|
|
31
|
+
});
|