@lets-events/react 12.3.10 → 12.4.1
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/.eslintrc.json +2 -2
- package/.turbo/turbo-build.log +19 -21
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +35 -3
- package/dist/index.d.ts +35 -3
- package/dist/index.js +562 -344
- package/dist/index.mjs +535 -319
- package/package.json +1 -1
- package/src/components/Alert.tsx +303 -303
- package/src/components/Avatar.tsx +55 -55
- package/src/components/Badge.tsx +125 -125
- package/src/components/Box.tsx +3 -3
- package/src/components/Button/index.tsx +45 -45
- package/src/components/Button/styledComponents.ts +313 -313
- package/src/components/ButtonGroup.tsx +484 -484
- package/src/components/Calendar/index.tsx +148 -148
- package/src/components/Calendar/styledComponents.ts +259 -250
- package/src/components/Card.tsx +67 -67
- package/src/components/CheckboxGroup.tsx +176 -176
- package/src/components/Container.tsx +39 -39
- package/src/components/Divider.tsx +7 -7
- package/src/components/DoubleCalendar/index.tsx +166 -0
- package/src/components/Drawer/index.tsx +98 -98
- package/src/components/Drawer/styledComponents.ts +103 -103
- package/src/components/Dropdown.tsx +302 -302
- package/src/components/Filter.tsx +164 -164
- package/src/components/Flex.tsx +118 -118
- package/src/components/FormFields/AddressFormFields/CityFormField.tsx +111 -111
- package/src/components/FormFields/AddressFormFields/CountryFormField.tsx +33 -33
- package/src/components/FormFields/AddressFormFields/PostalCodeFormField.tsx +39 -39
- package/src/components/FormFields/AddressFormFields/StateFormField.tsx +32 -32
- package/src/components/FormFields/AddressFormFields/index.tsx +141 -141
- package/src/components/FormFields/BirthDateFormField.tsx +84 -84
- package/src/components/FormFields/CNPJFormField.tsx +87 -87
- package/src/components/FormFields/CPFFormField.tsx +78 -78
- package/src/components/FormFields/CalendarFormField.tsx +95 -95
- package/src/components/FormFields/CheckboxGroupFormField.tsx +91 -91
- package/src/components/FormFields/DoubleCalendarFormField.tsx +90 -0
- package/src/components/FormFields/EmailFormField.tsx +27 -27
- package/src/components/FormFields/Form.tsx +39 -39
- package/src/components/FormFields/IdentityDocumentNumberFormField.tsx +32 -32
- package/src/components/FormFields/MultiSelectFormField.tsx +64 -64
- package/src/components/FormFields/PhoneFormField.tsx +40 -40
- package/src/components/FormFields/RadioGroupFormField.tsx +84 -84
- package/src/components/FormFields/RichEditorFormField.tsx +103 -103
- package/src/components/FormFields/SelectFormField.tsx +93 -93
- package/src/components/FormFields/SwitchFormField.tsx +46 -46
- package/src/components/FormFields/TextAreaFormField.tsx +59 -57
- package/src/components/FormFields/TextFormField.tsx +112 -112
- package/src/components/FormFields/TimePickerFormField.tsx +88 -88
- package/src/components/FormFields/subComponents/ErrorFormMessage.tsx +36 -36
- package/src/components/FormFields/subComponents/FormLabel.tsx +29 -29
- package/src/components/FormFields/utils/validation.ts +23 -23
- package/src/components/Grid.tsx +137 -137
- package/src/components/Icon.tsx +47 -47
- package/src/components/MenuDropdown/index.tsx +38 -38
- package/src/components/MenuDropdown/styledComponents.ts +31 -31
- package/src/components/Modal.tsx +110 -110
- package/src/components/MultiSelect/index.tsx +243 -243
- package/src/components/MultiSelect/styledComponents.ts +160 -160
- package/src/components/RadioGroup.tsx +210 -210
- package/src/components/RichEditor/QuillComponent.tsx +457 -457
- package/src/components/RichEditor/RichEditor.tsx +49 -49
- package/src/components/RichEditor/index.ts +2 -2
- package/src/components/RichEditor/styledComponents.ts +1151 -1151
- package/src/components/Section.tsx +33 -33
- package/src/components/Step.tsx +164 -164
- package/src/components/Switch.tsx +108 -108
- package/src/components/Text.tsx +38 -38
- package/src/components/TextField.tsx +372 -372
- package/src/components/TextareaField.tsx +138 -127
- package/src/components/TimePicker.tsx +328 -328
- package/src/components/Toast/components/ToastItem.tsx +41 -41
- package/src/components/Toast/components/ToastProvider.tsx +63 -63
- package/src/components/Toast/hooks/useToast.ts +12 -12
- package/src/components/Toast/index.tsx +5 -5
- package/src/components/Toast/styles/index.ts +135 -135
- package/src/components/Toast/types/index.ts +46 -46
- package/src/components/Tooltip/index.tsx +66 -66
- package/src/components/Tooltip/styles.ts +77 -77
- package/src/hooks/useCountries.ts +41 -41
- package/src/hooks/useImageUpload.ts +139 -139
- package/src/hooks/useOnClickOutside.tsx +42 -42
- package/src/index.tsx +71 -69
- package/src/styles/index.ts +41 -41
- package/src/types/typographyValues.ts +178 -178
- package/src/utils/getNestedValue.ts +3 -3
- package/src/utils/states.ts +29 -29
- package/src/utils/uploadService.ts +180 -180
- package/tsconfig.json +3 -3
- package/tsup.config.ts +38 -38
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import { ComponentProps, ElementType } from 'react';
|
|
2
|
-
import { styled } from '../styles';
|
|
3
|
-
import { Section as SectionRadix } from '@radix-ui/themes';
|
|
4
|
-
|
|
5
|
-
export const SectionStyled = styled(SectionRadix, {
|
|
6
|
-
variants: {
|
|
7
|
-
size: {
|
|
8
|
-
xs: { maxWidth: '576px' },
|
|
9
|
-
sm: { minWidth: '577px', maxWidth: '767px' },
|
|
10
|
-
md: { mixWidth: '768px', maxWidth: '991px' },
|
|
11
|
-
lg: { mixWidth: '992px', maxWidth: '1199px' },
|
|
12
|
-
xl: { mixWidth: '1200px', maxWidth: '1399px' },
|
|
13
|
-
xxl: { mixWidth: '1400px' },
|
|
14
|
-
responsive: { width: '100%', maxWidth: '100%', minWidth: '100%' }
|
|
15
|
-
},
|
|
16
|
-
display: {
|
|
17
|
-
none: { display: 'none' },
|
|
18
|
-
initial: { display: 'initial' },
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
defaultVariants: {
|
|
22
|
-
size: 'md',
|
|
23
|
-
display: 'initial'
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
export type SectionProps = ComponentProps<typeof SectionStyled> & {
|
|
28
|
-
as?: ElementType;
|
|
29
|
-
children: React.ReactNode;
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
export function Section({ children, ...props }: SectionProps) {
|
|
33
|
-
return <SectionStyled {...props}>{children}</SectionStyled>;
|
|
1
|
+
import { ComponentProps, ElementType } from 'react';
|
|
2
|
+
import { styled } from '../styles';
|
|
3
|
+
import { Section as SectionRadix } from '@radix-ui/themes';
|
|
4
|
+
|
|
5
|
+
export const SectionStyled = styled(SectionRadix, {
|
|
6
|
+
variants: {
|
|
7
|
+
size: {
|
|
8
|
+
xs: { maxWidth: '576px' },
|
|
9
|
+
sm: { minWidth: '577px', maxWidth: '767px' },
|
|
10
|
+
md: { mixWidth: '768px', maxWidth: '991px' },
|
|
11
|
+
lg: { mixWidth: '992px', maxWidth: '1199px' },
|
|
12
|
+
xl: { mixWidth: '1200px', maxWidth: '1399px' },
|
|
13
|
+
xxl: { mixWidth: '1400px' },
|
|
14
|
+
responsive: { width: '100%', maxWidth: '100%', minWidth: '100%' }
|
|
15
|
+
},
|
|
16
|
+
display: {
|
|
17
|
+
none: { display: 'none' },
|
|
18
|
+
initial: { display: 'initial' },
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
defaultVariants: {
|
|
22
|
+
size: 'md',
|
|
23
|
+
display: 'initial'
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
export type SectionProps = ComponentProps<typeof SectionStyled> & {
|
|
28
|
+
as?: ElementType;
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export function Section({ children, ...props }: SectionProps) {
|
|
33
|
+
return <SectionStyled {...props}>{children}</SectionStyled>;
|
|
34
34
|
}
|
package/src/components/Step.tsx
CHANGED
|
@@ -1,164 +1,164 @@
|
|
|
1
|
-
import React, { ComponentProps, ElementType } from "react";
|
|
2
|
-
import { styled } from "../styles";
|
|
3
|
-
import { Box, Tabs as StepRadix } from "@radix-ui/themes";
|
|
4
|
-
|
|
5
|
-
export const StepStyled = styled("div", {
|
|
6
|
-
fontFamily: "$default",
|
|
7
|
-
color: "$gray100",
|
|
8
|
-
letterSpacing: "0px",
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
const StepTriggerStyled = styled(StepRadix.Trigger, {
|
|
12
|
-
all: "unset",
|
|
13
|
-
position: "relative",
|
|
14
|
-
display: "flex",
|
|
15
|
-
alignItems: "center",
|
|
16
|
-
justifyContent: "center",
|
|
17
|
-
fontSize: "$16",
|
|
18
|
-
fontWeight: "$medium",
|
|
19
|
-
|
|
20
|
-
minWidth: "32px",
|
|
21
|
-
minHeight: "32px",
|
|
22
|
-
marginRight: "40px",
|
|
23
|
-
|
|
24
|
-
"&:last-of-type": {
|
|
25
|
-
marginRight: 0,
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
"& > span:first-of-type": {
|
|
29
|
-
width: "32px",
|
|
30
|
-
height: "32px",
|
|
31
|
-
borderRadius: "$full",
|
|
32
|
-
backgroundColor: "$neutral50",
|
|
33
|
-
border: "1px solid $neutral200",
|
|
34
|
-
color: "$gray700",
|
|
35
|
-
display: "flex",
|
|
36
|
-
alignItems: "center",
|
|
37
|
-
justifyContent: "center",
|
|
38
|
-
zIndex: 1,
|
|
39
|
-
position: "relative",
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
'&[data-state="active"] > span:first-of-type': {
|
|
43
|
-
backgroundColor: "$blue500",
|
|
44
|
-
borderColor: "$blue500",
|
|
45
|
-
color: "white",
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
"& > span:last-of-type": {
|
|
49
|
-
display: "none",
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
"&:not(:first-of-type)::before": {
|
|
53
|
-
content: '""',
|
|
54
|
-
position: "absolute",
|
|
55
|
-
top: "50%",
|
|
56
|
-
right: "calc(100% + 4px)",
|
|
57
|
-
transform: "translateY(-50%)",
|
|
58
|
-
width: "32px",
|
|
59
|
-
height: "8px",
|
|
60
|
-
borderRadius: "$sm",
|
|
61
|
-
backgroundColor: "$neutral50",
|
|
62
|
-
zIndex: 0,
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
'&[data-state="active"]::before': {
|
|
66
|
-
backgroundColor: "$blue500",
|
|
67
|
-
},
|
|
68
|
-
|
|
69
|
-
'&[data-filled="true"] > span:first-of-type': {
|
|
70
|
-
backgroundColor: "$blue500",
|
|
71
|
-
borderColor: "$blue500",
|
|
72
|
-
color: "white",
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
'&[data-filled="true"]::before': {
|
|
76
|
-
backgroundColor: "$blue500",
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
const StepListStyled = styled(StepRadix.List, {
|
|
81
|
-
display: "flex",
|
|
82
|
-
alignItems: "center",
|
|
83
|
-
justifyContent: "flex-start",
|
|
84
|
-
gap: "$4",
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
export type StepProps = ComponentProps<typeof StepStyled> & {
|
|
88
|
-
children: React.ReactNode;
|
|
89
|
-
defaultValue: number;
|
|
90
|
-
};
|
|
91
|
-
export function Step({ children, defaultValue, ...props }: StepProps) {
|
|
92
|
-
return (
|
|
93
|
-
<StepRadix.Root defaultValue={String(defaultValue)}>
|
|
94
|
-
<StepStyled {...props}>{children}</StepStyled>
|
|
95
|
-
</StepRadix.Root>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export function StepTrigger({
|
|
100
|
-
value,
|
|
101
|
-
children,
|
|
102
|
-
currentStep,
|
|
103
|
-
...props
|
|
104
|
-
}: {
|
|
105
|
-
value: number;
|
|
106
|
-
children: React.ReactNode | string;
|
|
107
|
-
currentStep?: number;
|
|
108
|
-
onClick: () => void;
|
|
109
|
-
}) {
|
|
110
|
-
const isActiveOrPrevious = currentStep !== undefined && value <= currentStep;
|
|
111
|
-
return (
|
|
112
|
-
<StepTriggerStyled
|
|
113
|
-
data-filled={isActiveOrPrevious}
|
|
114
|
-
value={String(value)}
|
|
115
|
-
{...props}
|
|
116
|
-
>
|
|
117
|
-
{children}
|
|
118
|
-
</StepTriggerStyled>
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function StepContent({
|
|
123
|
-
value,
|
|
124
|
-
children,
|
|
125
|
-
...props
|
|
126
|
-
}: {
|
|
127
|
-
value: number;
|
|
128
|
-
children: React.ReactNode;
|
|
129
|
-
}) {
|
|
130
|
-
return (
|
|
131
|
-
<StepRadix.Content value={String(value)} {...props}>
|
|
132
|
-
{children}
|
|
133
|
-
</StepRadix.Content>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function StepList({
|
|
138
|
-
children,
|
|
139
|
-
currentStep,
|
|
140
|
-
...props
|
|
141
|
-
}: {
|
|
142
|
-
children: React.ReactNode;
|
|
143
|
-
currentStep: number;
|
|
144
|
-
}) {
|
|
145
|
-
return (
|
|
146
|
-
<StepListStyled {...props}>
|
|
147
|
-
{React.Children.map(children, (child) => {
|
|
148
|
-
if (React.isValidElement(child) && child.type === StepTrigger) {
|
|
149
|
-
return React.cloneElement(child, { currentStep } as any);
|
|
150
|
-
}
|
|
151
|
-
return child;
|
|
152
|
-
})}
|
|
153
|
-
</StepListStyled>
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export function StepWrapper({
|
|
158
|
-
children,
|
|
159
|
-
...props
|
|
160
|
-
}: {
|
|
161
|
-
children: React.ReactNode;
|
|
162
|
-
}) {
|
|
163
|
-
return <Box {...props}>{children}</Box>;
|
|
164
|
-
}
|
|
1
|
+
import React, { ComponentProps, ElementType } from "react";
|
|
2
|
+
import { styled } from "../styles";
|
|
3
|
+
import { Box, Tabs as StepRadix } from "@radix-ui/themes";
|
|
4
|
+
|
|
5
|
+
export const StepStyled = styled("div", {
|
|
6
|
+
fontFamily: "$default",
|
|
7
|
+
color: "$gray100",
|
|
8
|
+
letterSpacing: "0px",
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
const StepTriggerStyled = styled(StepRadix.Trigger, {
|
|
12
|
+
all: "unset",
|
|
13
|
+
position: "relative",
|
|
14
|
+
display: "flex",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
justifyContent: "center",
|
|
17
|
+
fontSize: "$16",
|
|
18
|
+
fontWeight: "$medium",
|
|
19
|
+
|
|
20
|
+
minWidth: "32px",
|
|
21
|
+
minHeight: "32px",
|
|
22
|
+
marginRight: "40px",
|
|
23
|
+
|
|
24
|
+
"&:last-of-type": {
|
|
25
|
+
marginRight: 0,
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
"& > span:first-of-type": {
|
|
29
|
+
width: "32px",
|
|
30
|
+
height: "32px",
|
|
31
|
+
borderRadius: "$full",
|
|
32
|
+
backgroundColor: "$neutral50",
|
|
33
|
+
border: "1px solid $neutral200",
|
|
34
|
+
color: "$gray700",
|
|
35
|
+
display: "flex",
|
|
36
|
+
alignItems: "center",
|
|
37
|
+
justifyContent: "center",
|
|
38
|
+
zIndex: 1,
|
|
39
|
+
position: "relative",
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
'&[data-state="active"] > span:first-of-type': {
|
|
43
|
+
backgroundColor: "$blue500",
|
|
44
|
+
borderColor: "$blue500",
|
|
45
|
+
color: "white",
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
"& > span:last-of-type": {
|
|
49
|
+
display: "none",
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
"&:not(:first-of-type)::before": {
|
|
53
|
+
content: '""',
|
|
54
|
+
position: "absolute",
|
|
55
|
+
top: "50%",
|
|
56
|
+
right: "calc(100% + 4px)",
|
|
57
|
+
transform: "translateY(-50%)",
|
|
58
|
+
width: "32px",
|
|
59
|
+
height: "8px",
|
|
60
|
+
borderRadius: "$sm",
|
|
61
|
+
backgroundColor: "$neutral50",
|
|
62
|
+
zIndex: 0,
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
'&[data-state="active"]::before': {
|
|
66
|
+
backgroundColor: "$blue500",
|
|
67
|
+
},
|
|
68
|
+
|
|
69
|
+
'&[data-filled="true"] > span:first-of-type': {
|
|
70
|
+
backgroundColor: "$blue500",
|
|
71
|
+
borderColor: "$blue500",
|
|
72
|
+
color: "white",
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
'&[data-filled="true"]::before': {
|
|
76
|
+
backgroundColor: "$blue500",
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const StepListStyled = styled(StepRadix.List, {
|
|
81
|
+
display: "flex",
|
|
82
|
+
alignItems: "center",
|
|
83
|
+
justifyContent: "flex-start",
|
|
84
|
+
gap: "$4",
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
export type StepProps = ComponentProps<typeof StepStyled> & {
|
|
88
|
+
children: React.ReactNode;
|
|
89
|
+
defaultValue: number;
|
|
90
|
+
};
|
|
91
|
+
export function Step({ children, defaultValue, ...props }: StepProps) {
|
|
92
|
+
return (
|
|
93
|
+
<StepRadix.Root defaultValue={String(defaultValue)}>
|
|
94
|
+
<StepStyled {...props}>{children}</StepStyled>
|
|
95
|
+
</StepRadix.Root>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function StepTrigger({
|
|
100
|
+
value,
|
|
101
|
+
children,
|
|
102
|
+
currentStep,
|
|
103
|
+
...props
|
|
104
|
+
}: {
|
|
105
|
+
value: number;
|
|
106
|
+
children: React.ReactNode | string;
|
|
107
|
+
currentStep?: number;
|
|
108
|
+
onClick: () => void;
|
|
109
|
+
}) {
|
|
110
|
+
const isActiveOrPrevious = currentStep !== undefined && value <= currentStep;
|
|
111
|
+
return (
|
|
112
|
+
<StepTriggerStyled
|
|
113
|
+
data-filled={isActiveOrPrevious}
|
|
114
|
+
value={String(value)}
|
|
115
|
+
{...props}
|
|
116
|
+
>
|
|
117
|
+
{children}
|
|
118
|
+
</StepTriggerStyled>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export function StepContent({
|
|
123
|
+
value,
|
|
124
|
+
children,
|
|
125
|
+
...props
|
|
126
|
+
}: {
|
|
127
|
+
value: number;
|
|
128
|
+
children: React.ReactNode;
|
|
129
|
+
}) {
|
|
130
|
+
return (
|
|
131
|
+
<StepRadix.Content value={String(value)} {...props}>
|
|
132
|
+
{children}
|
|
133
|
+
</StepRadix.Content>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function StepList({
|
|
138
|
+
children,
|
|
139
|
+
currentStep,
|
|
140
|
+
...props
|
|
141
|
+
}: {
|
|
142
|
+
children: React.ReactNode;
|
|
143
|
+
currentStep: number;
|
|
144
|
+
}) {
|
|
145
|
+
return (
|
|
146
|
+
<StepListStyled {...props}>
|
|
147
|
+
{React.Children.map(children, (child) => {
|
|
148
|
+
if (React.isValidElement(child) && child.type === StepTrigger) {
|
|
149
|
+
return React.cloneElement(child, { currentStep } as any);
|
|
150
|
+
}
|
|
151
|
+
return child;
|
|
152
|
+
})}
|
|
153
|
+
</StepListStyled>
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function StepWrapper({
|
|
158
|
+
children,
|
|
159
|
+
...props
|
|
160
|
+
}: {
|
|
161
|
+
children: React.ReactNode;
|
|
162
|
+
}) {
|
|
163
|
+
return <Box {...props}>{children}</Box>;
|
|
164
|
+
}
|
|
@@ -1,109 +1,109 @@
|
|
|
1
|
-
import { Switch as RadixSwitch } from '@radix-ui/themes'
|
|
2
|
-
import type { ComponentProps } from 'react'
|
|
3
|
-
import { styled } from '../styles'
|
|
4
|
-
|
|
5
|
-
export const SwitchStyled = styled(RadixSwitch, {
|
|
6
|
-
all: 'unset',
|
|
7
|
-
borderRadius: '$full',
|
|
8
|
-
position: 'relative',
|
|
9
|
-
display: 'flex',
|
|
10
|
-
alignItems: 'center',
|
|
11
|
-
justifyContent: 'center',
|
|
12
|
-
transition: 'all 0.3s',
|
|
13
|
-
cursor: 'pointer',
|
|
14
|
-
|
|
15
|
-
'&::before': {
|
|
16
|
-
content: '""',
|
|
17
|
-
position: 'absolute',
|
|
18
|
-
borderRadius: '$full',
|
|
19
|
-
pointerEvents: 'none',
|
|
20
|
-
cursor: 'pointer',
|
|
21
|
-
},
|
|
22
|
-
'span': {
|
|
23
|
-
position: 'absolute',
|
|
24
|
-
top: '50%',
|
|
25
|
-
left: 0,
|
|
26
|
-
transform: 'translate(0, -50%)',
|
|
27
|
-
borderRadius: '50%',
|
|
28
|
-
transition: 'all 0.3s',
|
|
29
|
-
cursor: 'pointer',
|
|
30
|
-
borderWidth: '1px',
|
|
31
|
-
borderStyle: 'solid',
|
|
32
|
-
boxShadow: '0px 0px 4px 0px rgba(0, 0, 0, 0.24)',
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
'&[data-state="checked"] span': {
|
|
36
|
-
left: 'auto',
|
|
37
|
-
transform: 'translate(50%, -50%)',
|
|
38
|
-
},
|
|
39
|
-
|
|
40
|
-
variants: {
|
|
41
|
-
color: {
|
|
42
|
-
brand: {
|
|
43
|
-
'&::before': {
|
|
44
|
-
backgroundColor: '$brand50',
|
|
45
|
-
},
|
|
46
|
-
'span': {
|
|
47
|
-
backgroundColor: '$dark50',
|
|
48
|
-
borderColor: '$neutral300',
|
|
49
|
-
},
|
|
50
|
-
'&[data-state="checked"] span': {
|
|
51
|
-
backgroundColor: '$brand500',
|
|
52
|
-
borderColor: '$brand500',
|
|
53
|
-
},
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
size: {
|
|
57
|
-
sm: {
|
|
58
|
-
width: '32px',
|
|
59
|
-
height: '20px',
|
|
60
|
-
'&::before': {
|
|
61
|
-
width: '$32',
|
|
62
|
-
height: '$12',
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
'span': {
|
|
66
|
-
width: '$20',
|
|
67
|
-
height: '$20',
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
md: {
|
|
71
|
-
width: '40px',
|
|
72
|
-
height: '20px',
|
|
73
|
-
'&::before': {
|
|
74
|
-
width: '40px',
|
|
75
|
-
height: '16px',
|
|
76
|
-
},
|
|
77
|
-
'span': {
|
|
78
|
-
width: '24px',
|
|
79
|
-
height: '24px',
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
lg: {
|
|
83
|
-
width: '56px',
|
|
84
|
-
height: '32px',
|
|
85
|
-
'&::before': {
|
|
86
|
-
width: '56px',
|
|
87
|
-
height: '24px',
|
|
88
|
-
},
|
|
89
|
-
'span': {
|
|
90
|
-
width: '32px',
|
|
91
|
-
height: '32px',
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
defaultVariants: {
|
|
97
|
-
size: 'md',
|
|
98
|
-
color: 'brand',
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
})
|
|
102
|
-
export type SwitchProps = ComponentProps<typeof RadixSwitch> & {
|
|
103
|
-
color?: 'brand'
|
|
104
|
-
size?: 'sm' | 'md' | 'lg'
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
export function Switch(props: SwitchProps) {
|
|
108
|
-
return <SwitchStyled color="brand" defaultChecked {...props} />
|
|
1
|
+
import { Switch as RadixSwitch } from '@radix-ui/themes'
|
|
2
|
+
import type { ComponentProps } from 'react'
|
|
3
|
+
import { styled } from '../styles'
|
|
4
|
+
|
|
5
|
+
export const SwitchStyled = styled(RadixSwitch, {
|
|
6
|
+
all: 'unset',
|
|
7
|
+
borderRadius: '$full',
|
|
8
|
+
position: 'relative',
|
|
9
|
+
display: 'flex',
|
|
10
|
+
alignItems: 'center',
|
|
11
|
+
justifyContent: 'center',
|
|
12
|
+
transition: 'all 0.3s',
|
|
13
|
+
cursor: 'pointer',
|
|
14
|
+
|
|
15
|
+
'&::before': {
|
|
16
|
+
content: '""',
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
borderRadius: '$full',
|
|
19
|
+
pointerEvents: 'none',
|
|
20
|
+
cursor: 'pointer',
|
|
21
|
+
},
|
|
22
|
+
'span': {
|
|
23
|
+
position: 'absolute',
|
|
24
|
+
top: '50%',
|
|
25
|
+
left: 0,
|
|
26
|
+
transform: 'translate(0, -50%)',
|
|
27
|
+
borderRadius: '50%',
|
|
28
|
+
transition: 'all 0.3s',
|
|
29
|
+
cursor: 'pointer',
|
|
30
|
+
borderWidth: '1px',
|
|
31
|
+
borderStyle: 'solid',
|
|
32
|
+
boxShadow: '0px 0px 4px 0px rgba(0, 0, 0, 0.24)',
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
'&[data-state="checked"] span': {
|
|
36
|
+
left: 'auto',
|
|
37
|
+
transform: 'translate(50%, -50%)',
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
variants: {
|
|
41
|
+
color: {
|
|
42
|
+
brand: {
|
|
43
|
+
'&::before': {
|
|
44
|
+
backgroundColor: '$brand50',
|
|
45
|
+
},
|
|
46
|
+
'span': {
|
|
47
|
+
backgroundColor: '$dark50',
|
|
48
|
+
borderColor: '$neutral300',
|
|
49
|
+
},
|
|
50
|
+
'&[data-state="checked"] span': {
|
|
51
|
+
backgroundColor: '$brand500',
|
|
52
|
+
borderColor: '$brand500',
|
|
53
|
+
},
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
size: {
|
|
57
|
+
sm: {
|
|
58
|
+
width: '32px',
|
|
59
|
+
height: '20px',
|
|
60
|
+
'&::before': {
|
|
61
|
+
width: '$32',
|
|
62
|
+
height: '$12',
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
'span': {
|
|
66
|
+
width: '$20',
|
|
67
|
+
height: '$20',
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
md: {
|
|
71
|
+
width: '40px',
|
|
72
|
+
height: '20px',
|
|
73
|
+
'&::before': {
|
|
74
|
+
width: '40px',
|
|
75
|
+
height: '16px',
|
|
76
|
+
},
|
|
77
|
+
'span': {
|
|
78
|
+
width: '24px',
|
|
79
|
+
height: '24px',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
lg: {
|
|
83
|
+
width: '56px',
|
|
84
|
+
height: '32px',
|
|
85
|
+
'&::before': {
|
|
86
|
+
width: '56px',
|
|
87
|
+
height: '24px',
|
|
88
|
+
},
|
|
89
|
+
'span': {
|
|
90
|
+
width: '32px',
|
|
91
|
+
height: '32px',
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
defaultVariants: {
|
|
97
|
+
size: 'md',
|
|
98
|
+
color: 'brand',
|
|
99
|
+
},
|
|
100
|
+
|
|
101
|
+
})
|
|
102
|
+
export type SwitchProps = ComponentProps<typeof RadixSwitch> & {
|
|
103
|
+
color?: 'brand'
|
|
104
|
+
size?: 'sm' | 'md' | 'lg'
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function Switch(props: SwitchProps) {
|
|
108
|
+
return <SwitchStyled color="brand" defaultChecked {...props} />
|
|
109
109
|
}
|