@lunit/design-system 1.0.0-a.2 → 1.0.0-a.3
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/.babelrc.json +16 -0
- package/dist/cjs/components/Alert/index.js +1 -1
- package/dist/cjs/components/Alert/index.js.map +1 -1
- package/dist/cjs/components/Button/index.js +1 -1
- package/dist/cjs/components/Button/index.js.map +1 -1
- package/dist/cjs/components/Chip/index.js +1 -1
- package/dist/cjs/components/Chip/index.js.map +1 -1
- package/dist/cjs/components/TextField/index.js +1 -1
- package/dist/cjs/components/TextField/index.js.map +1 -1
- package/dist/cjs/components/ToggleButton/index.js +1 -1
- package/dist/cjs/components/ToggleButton/index.js.map +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/components/Alert/Alert.js +16 -4
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/Alert/Alert.styled.js +48 -0
- package/dist/components/Alert/Alert.styled.js.map +1 -0
- package/dist/components/Alert/Alert.types.js +2 -0
- package/dist/components/Alert/Alert.types.js.map +1 -0
- package/dist/components/Alert/Alert.utils..js +38 -0
- package/dist/components/Alert/Alert.utils..js.map +1 -0
- package/dist/components/Button/Button.js +1 -1
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.styled.js +31 -21
- package/dist/components/Button/Button.styled.js.map +1 -1
- package/dist/components/Button/utils/getHoverStyle.js +7 -0
- package/dist/components/Button/utils/getHoverStyle.js.map +1 -0
- package/dist/components/Chip/Chip.js +1 -1
- package/dist/components/Chip/Chip.js.map +1 -1
- package/dist/components/Chip/Chip.styled.js +2 -3
- package/dist/components/Chip/Chip.styled.js.map +1 -1
- package/dist/components/TextField/TextField.js +15 -3
- package/dist/components/TextField/TextField.js.map +1 -1
- package/dist/components/TextField/TextField.style.js +245 -0
- package/dist/components/TextField/TextField.style.js.map +1 -0
- package/dist/components/TextField/TextField.types.js +2 -0
- package/dist/components/TextField/TextField.types.js.map +1 -0
- package/dist/components/TextField/TextFieldIcon.js +7 -0
- package/dist/components/TextField/TextFieldIcon.js.map +1 -0
- package/dist/components/Toast/Toast.js +26 -0
- package/dist/components/Toast/Toast.js.map +1 -0
- package/dist/components/Toast/Toast.styled.js +49 -0
- package/dist/components/Toast/Toast.styled.js.map +1 -0
- package/dist/components/Toast/Toast.types.js +2 -0
- package/dist/components/Toast/Toast.types.js.map +1 -0
- package/dist/components/Toast/Toast.utils.js +14 -0
- package/dist/components/Toast/Toast.utils.js.map +1 -0
- package/dist/components/Toast/index.js +2 -0
- package/dist/components/Toast/index.js.map +1 -0
- package/dist/foundation/colors/base/grey.js +16 -0
- package/dist/foundation/colors/base/grey.js.map +1 -1
- package/dist/foundation/colors/base/lunitGreen.js +2 -2
- package/dist/foundation/colors/base/lunitGreen.js.map +1 -1
- package/dist/foundation/colors/base/lunitTeal.js +5 -5
- package/dist/foundation/colors/base/lunitTeal.js.map +1 -1
- package/dist/foundation/colors/base/red.js +2 -2
- package/dist/foundation/colors/index.js +24 -4
- package/dist/foundation/colors/index.js.map +1 -1
- package/dist/foundation/colors/token/component.js +265 -291
- package/dist/foundation/colors/token/component.js.map +1 -1
- package/dist/foundation/colors/token/core.js +132 -125
- package/dist/foundation/colors/token/core.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/theme.js +5 -0
- package/dist/theme.js.map +1 -1
- package/dist/types/components/Alert/Alert.d.ts +3 -1
- package/dist/types/components/Alert/Alert.styled.d.ts +6 -0
- package/dist/types/components/Alert/Alert.types.d.ts +9 -0
- package/dist/types/components/Alert/Alert.utils..d.ts +4 -0
- package/dist/types/components/Button/Button.d.ts +1 -1
- package/dist/types/components/Button/Button.styled.d.ts +26 -2
- package/dist/types/components/Button/Button.types.d.ts +4 -4
- package/dist/types/components/Button/utils/getHoverStyle.d.ts +6 -0
- package/dist/types/components/Chip/Chip.styled.d.ts +9 -9
- package/dist/types/components/Chip/Chip.types.d.ts +1 -1
- package/dist/types/components/TextField/TextField.d.ts +2 -1
- package/dist/types/components/TextField/TextField.style.d.ts +9 -0
- package/dist/types/components/TextField/TextField.types.d.ts +29 -0
- package/dist/types/components/TextField/TextFieldIcon.d.ts +8 -0
- package/dist/types/components/TextField/index.d.ts +1 -0
- package/dist/types/components/Toast/Toast.d.ts +4 -0
- package/dist/types/components/Toast/Toast.styled.d.ts +1 -0
- package/dist/types/components/Toast/Toast.types.d.ts +4 -0
- package/dist/types/components/Toast/Toast.utils.d.ts +2 -0
- package/dist/types/components/Toast/index.d.ts +1 -0
- package/dist/types/components/ToggleButton/ToggleButton.styled.d.ts +1 -1
- package/dist/types/components/ToggleButton/ToggleButton.types.d.ts +4 -4
- package/dist/types/foundation/colors/base/grey.d.ts +16 -0
- package/dist/types/foundation/colors/base/lunitGreen.d.ts +2 -2
- package/dist/types/foundation/colors/base/lunitTeal.d.ts +2 -2
- package/dist/types/foundation/colors/index.d.ts +42 -9
- package/dist/types/foundation/colors/types.d.ts +1 -3
- package/dist/types/foundation/index.d.ts +37 -5
- package/dist/types/index.d.ts +1 -0
- package/package.json +21 -16
- package/src/components/Alert/Alert.styled.ts +60 -0
- package/src/components/Alert/Alert.tsx +49 -5
- package/src/components/Alert/Alert.types.ts +10 -0
- package/src/components/Alert/Alert.utils..ts +41 -0
- package/src/components/Button/Button.styled.ts +33 -21
- package/src/components/Button/Button.tsx +1 -5
- package/src/components/Button/Button.types.ts +4 -4
- package/src/components/Button/utils/getHoverStyle.ts +7 -0
- package/src/components/Chip/Chip.styled.ts +6 -4
- package/src/components/Chip/Chip.tsx +1 -1
- package/src/components/Chip/Chip.types.ts +2 -2
- package/src/components/TextField/TextField.style.ts +316 -0
- package/src/components/TextField/TextField.tsx +75 -3
- package/src/components/TextField/TextField.types.ts +38 -0
- package/src/components/TextField/TextFieldIcon.tsx +24 -0
- package/src/components/TextField/index.ts +6 -0
- package/src/components/Toast/Toast.styled.ts +49 -0
- package/src/components/Toast/Toast.tsx +66 -0
- package/src/components/Toast/Toast.types.ts +14 -0
- package/src/components/Toast/Toast.utils.ts +15 -0
- package/src/components/Toast/index.tsx +1 -0
- package/src/components/ToggleButton/ToggleButton.types.ts +4 -7
- package/src/foundation/colors/base/grey.ts +17 -0
- package/src/foundation/colors/base/lunitGreen.ts +2 -2
- package/src/foundation/colors/base/lunitTeal.ts +5 -5
- package/src/foundation/colors/base/red.ts +2 -2
- package/src/foundation/colors/index.ts +29 -8
- package/src/foundation/colors/token/component.ts +300 -326
- package/src/foundation/colors/token/core.ts +152 -145
- package/src/foundation/colors/types.ts +1 -3
- package/src/index.ts +1 -0
- package/src/stories/components/Alert/Alert.stories.tsx +148 -4
- package/src/stories/components/Button/BasicButton.stories.tsx +19 -28
- package/src/stories/components/Button/IconButton.stories.tsx +39 -28
- package/src/stories/components/Button/Kind.stories.tsx +83 -57
- package/src/stories/components/Chip/Chip.stories.tsx +94 -82
- package/src/stories/components/DataTable/DataTable.stories.tsx +6 -4
- package/src/stories/components/DatePicker/DatePicker.stories.tsx +6 -4
- package/src/stories/components/Dropdown/Dropdown.stories.tsx +12 -6
- package/src/stories/components/Modal/Modal.stories.tsx +6 -4
- package/src/stories/components/SelectControl/Checkbox.stories.tsx +31 -23
- package/src/stories/components/SelectControl/RadioGroup.stories.tsx +6 -5
- package/src/stories/components/SelectControl/RadioStatus.stories.tsx +6 -4
- package/src/stories/components/SelectControl/Toggle.stories.tsx +33 -19
- package/src/stories/components/TextField/TextFieldMulti.stories.tsx +137 -0
- package/src/stories/components/TextField/TextFieldSingle.stories.tsx +283 -0
- package/src/stories/components/TextField/TextFieldSize.stories.tsx +134 -0
- package/src/stories/components/Toast/Toast.stories.tsx +152 -0
- package/src/stories/components/ToggleButton/Basic.stories.tsx +35 -31
- package/src/stories/components/ToggleButton/Group.stories.tsx +21 -21
- package/src/stories/components/ToggleButton/ToggleButtonKind.stories.tsx +53 -43
- package/src/stories/components/ToggleButton/WithIcon.stories.tsx +35 -36
- package/src/stories/components/Tooltip/Tooltip.stories.tsx +6 -4
- package/src/stories/foundation/Elevation/Elevation.stories.tsx +10 -6
- package/src/stories/foundation/Typography/{Typography.stories.mdx → Typography.mdx} +10 -5
- package/src/stories/foundation/Typography/Typography.stories.tsx +46 -36
- package/src/stories/foundation/Typography/TypographyExamples.stories.tsx +44 -0
- package/src/stories/foundation/colors/Colors.stories.tsx +7 -5
- package/src/stories/foundation/colors/Mui.stories.tsx +18 -0
- package/src/stories/foundation/colors/Token.inComponent.stories.tsx +2 -2
- package/src/stories/foundation/colors/TokenPaletteTable.stories.tsx +28 -0
- package/src/stories/foundation/colors/TokenPaletteTable.tsx +127 -0
- package/src/theme.ts +5 -0
- package/src/stories/components/TextField/TextField.stories.tsx +0 -13
- package/src/stories/foundation/colors/Token.stories.tsx +0 -190
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import theme from "@/theme";
|
|
2
|
+
import { AlertColor } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
export const getBackgroundColor = (severity: AlertColor | undefined) => {
|
|
5
|
+
switch (severity) {
|
|
6
|
+
case "info":
|
|
7
|
+
return theme.palette.token.component.alert_info_bg;
|
|
8
|
+
case "warning":
|
|
9
|
+
return theme.palette.token.component.alert_warning_bg;
|
|
10
|
+
case "error":
|
|
11
|
+
return theme.palette.token.component.alert_error_bg;
|
|
12
|
+
default:
|
|
13
|
+
return theme.palette.token.component.alert_success_bg;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const getBorderColor = (severity: AlertColor | undefined) => {
|
|
18
|
+
switch (severity) {
|
|
19
|
+
case "info":
|
|
20
|
+
return theme.palette.token.component.alert_info_border;
|
|
21
|
+
case "warning":
|
|
22
|
+
return theme.palette.token.component.alert_warning_border;
|
|
23
|
+
case "error":
|
|
24
|
+
return theme.palette.token.component.alert_error_border;
|
|
25
|
+
default:
|
|
26
|
+
return theme.palette.token.component.alert_success_border;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const getIconColor = (severity: AlertColor | undefined) => {
|
|
31
|
+
switch (severity) {
|
|
32
|
+
case "info":
|
|
33
|
+
return theme.palette.token.core.icon_info_02;
|
|
34
|
+
case "warning":
|
|
35
|
+
return theme.palette.token.core.icon_warning_02;
|
|
36
|
+
case "error":
|
|
37
|
+
return theme.palette.token.core.icon_error_02;
|
|
38
|
+
default:
|
|
39
|
+
return theme.palette.token.core.icon_success_02;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
@@ -5,6 +5,7 @@ import { ColorToken } from "@/foundation/colors/types";
|
|
|
5
5
|
import { PADDING_OF_FOCUS, OUTLINED_BORDER_WIDTH } from "./const";
|
|
6
6
|
import { getButtonPaddingBySizeAndKind } from "./utils/getButtonPaddingBySizeAndKind";
|
|
7
7
|
import { getIconButtonPaddingBySizeAndKind } from "./utils/getIconButtonPaddingBySizeAndKind";
|
|
8
|
+
import getHoverStyle from "./utils/getHoverStyle";
|
|
8
9
|
|
|
9
10
|
import type { ButtonProps } from "./Button.types";
|
|
10
11
|
import type { ToggleButtonProps } from "../ToggleButton/ToggleButton.types";
|
|
@@ -22,6 +23,8 @@ type sizeStyleParams = Pick<
|
|
|
22
23
|
> &
|
|
23
24
|
Pick<ToggleButtonProps, "selected"> & { typography: Typography };
|
|
24
25
|
|
|
26
|
+
const borderRadius = "8px";
|
|
27
|
+
|
|
25
28
|
export const sizeStyle = ({
|
|
26
29
|
size,
|
|
27
30
|
kind,
|
|
@@ -67,9 +70,7 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
67
70
|
color === "primary" && {
|
|
68
71
|
color: token.component.btn_contained_primary_text,
|
|
69
72
|
backgroundColor: token.component.btn_contained_primary_bg,
|
|
70
|
-
"&:hover":
|
|
71
|
-
backgroundColor: token.component.btn_contained_primary_bg,
|
|
72
|
-
},
|
|
73
|
+
"&:hover": getHoverStyle(token.component.btn_contained_primary_bg),
|
|
73
74
|
"&.Mui-disabled": {
|
|
74
75
|
opacity: 0.38,
|
|
75
76
|
border: "none",
|
|
@@ -79,10 +80,9 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
79
80
|
...(kind === "contained" &&
|
|
80
81
|
color === "secondary" && {
|
|
81
82
|
color: token.component.btn_contained_secondary_text,
|
|
83
|
+
|
|
82
84
|
backgroundColor: token.component.btn_contained_secondary_bg,
|
|
83
|
-
"&:hover":
|
|
84
|
-
backgroundColor: token.component.btn_contained_secondary_bg,
|
|
85
|
-
},
|
|
85
|
+
"&:hover": getHoverStyle(token.component.btn_contained_secondary_bg),
|
|
86
86
|
"&.Mui-disabled": {
|
|
87
87
|
opacity: 0.38,
|
|
88
88
|
border: "none",
|
|
@@ -93,9 +93,7 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
93
93
|
color === "error" && {
|
|
94
94
|
color: token.component.btn_contained_error_text,
|
|
95
95
|
backgroundColor: token.component.btn_contained_error_bg,
|
|
96
|
-
"&:hover":
|
|
97
|
-
backgroundColor: token.component.btn_contained_error_bg,
|
|
98
|
-
},
|
|
96
|
+
"&:hover": getHoverStyle(token.component.btn_contained_error_bg),
|
|
99
97
|
"&.Mui-disabled": {
|
|
100
98
|
opacity: 0.38,
|
|
101
99
|
border: "none",
|
|
@@ -107,9 +105,7 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
107
105
|
color === "primary" && {
|
|
108
106
|
color: token.component.btn_ghost_primary_text,
|
|
109
107
|
border: "none",
|
|
110
|
-
"&:hover":
|
|
111
|
-
backgroundColor: "rgba(0, 0, 0, 0.06)",
|
|
112
|
-
},
|
|
108
|
+
"&:hover": getHoverStyle("none"),
|
|
113
109
|
"&.Mui-disabled": {
|
|
114
110
|
opacity: 0.38,
|
|
115
111
|
border: "none",
|
|
@@ -120,9 +116,7 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
120
116
|
color === "secondary" && {
|
|
121
117
|
color: token.component.btn_ghost_secondary_text,
|
|
122
118
|
border: "none",
|
|
123
|
-
"&:hover":
|
|
124
|
-
backgroundColor: "rgba(0, 0, 0, 0.06)",
|
|
125
|
-
},
|
|
119
|
+
"&:hover": getHoverStyle("none"),
|
|
126
120
|
"&.Mui-disabled": {
|
|
127
121
|
opacity: 0.38,
|
|
128
122
|
border: "none",
|
|
@@ -132,9 +126,7 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
132
126
|
...(kind === "ghost" &&
|
|
133
127
|
color === "error" && {
|
|
134
128
|
color: token.component.btn_ghost_error_text,
|
|
135
|
-
"&:hover":
|
|
136
|
-
backgroundColor: "rgba(0, 0, 0, 0.06)",
|
|
137
|
-
},
|
|
129
|
+
"&:hover": getHoverStyle("none"),
|
|
138
130
|
"&.Mui-disabled": {
|
|
139
131
|
opacity: 0.38,
|
|
140
132
|
border: "none",
|
|
@@ -146,8 +138,17 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
146
138
|
color === "primary" && {
|
|
147
139
|
color: token.component.btn_outlined_primary_text,
|
|
148
140
|
border: `${OUTLINED_BORDER_WIDTH}px solid ${token.component.btn_outlined_primary_border}`,
|
|
149
|
-
"&:hover":
|
|
150
|
-
|
|
141
|
+
"&:hover": getHoverStyle("none"),
|
|
142
|
+
"&:hover:before": {
|
|
143
|
+
content: "''",
|
|
144
|
+
position: "absolute",
|
|
145
|
+
left: "-1px",
|
|
146
|
+
top: "-1px",
|
|
147
|
+
width: "calc(100% + 2px)",
|
|
148
|
+
height: "calc(100% + 2px)",
|
|
149
|
+
zIndex: -1,
|
|
150
|
+
backgroundColor: token.core.hover,
|
|
151
|
+
borderRadius,
|
|
151
152
|
},
|
|
152
153
|
"&.Mui-disabled": {
|
|
153
154
|
opacity: 0.38,
|
|
@@ -159,7 +160,7 @@ export const kindStyle = ({ kind, color, token }: KindStyleParams) => ({
|
|
|
159
160
|
export const commonStyle = ({ token }: { token: ColorToken }) =>
|
|
160
161
|
({
|
|
161
162
|
fontWeight: "500",
|
|
162
|
-
borderRadius
|
|
163
|
+
borderRadius,
|
|
163
164
|
textTransform: "initial",
|
|
164
165
|
"&.Mui-focusVisible": {
|
|
165
166
|
"&::after": {
|
|
@@ -172,6 +173,17 @@ export const commonStyle = ({ token }: { token: ColorToken }) =>
|
|
|
172
173
|
boxSizing: "border-box",
|
|
173
174
|
},
|
|
174
175
|
},
|
|
176
|
+
"&:hover:before": {
|
|
177
|
+
content: "''",
|
|
178
|
+
position: "absolute",
|
|
179
|
+
left: 0,
|
|
180
|
+
top: 0,
|
|
181
|
+
width: "100%",
|
|
182
|
+
height: "100%",
|
|
183
|
+
zIndex: -1,
|
|
184
|
+
backgroundColor: token.core.hover,
|
|
185
|
+
borderRadius,
|
|
186
|
+
},
|
|
175
187
|
} as const);
|
|
176
188
|
|
|
177
189
|
export const iconStyle = ({
|
|
@@ -4,7 +4,7 @@ import { CustomButton } from "./Button.styled";
|
|
|
4
4
|
|
|
5
5
|
import type { ButtonProps } from "./Button.types";
|
|
6
6
|
|
|
7
|
-
const Button = (props:
|
|
7
|
+
const Button = (props: ButtonProps) => {
|
|
8
8
|
const {
|
|
9
9
|
kind = "contained",
|
|
10
10
|
size = "small",
|
|
@@ -26,8 +26,6 @@ const Button = (props: Omit<ButtonProps, "hasIconOnly">) => {
|
|
|
26
26
|
size={size}
|
|
27
27
|
startIcon={icon}
|
|
28
28
|
hasIconOnly={hasIconOnly}
|
|
29
|
-
disableRipple
|
|
30
|
-
disableFocusRipple
|
|
31
29
|
{...buttonProps}
|
|
32
30
|
>
|
|
33
31
|
{!hasIconOnly && <>{children}</>}
|
|
@@ -40,8 +38,6 @@ const Button = (props: Omit<ButtonProps, "hasIconOnly">) => {
|
|
|
40
38
|
size={size}
|
|
41
39
|
startIcon={icon}
|
|
42
40
|
hasIconOnly={hasIconOnly}
|
|
43
|
-
disableRipple
|
|
44
|
-
disableFocusRipple
|
|
45
41
|
{...buttonProps}
|
|
46
42
|
>
|
|
47
43
|
{!hasIconOnly && <>{children}</>}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { ButtonProps as MuiButtonProps } from "@mui/material";
|
|
2
2
|
|
|
3
|
-
interface BaseButtonProps extends MuiButtonProps {
|
|
3
|
+
interface BaseButtonProps extends Omit<MuiButtonProps, "variant"> {
|
|
4
4
|
icon?: React.ReactNode;
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
interface ContainedButtonProps extends
|
|
7
|
+
interface ContainedButtonProps extends BaseButtonProps {
|
|
8
8
|
kind?: "contained";
|
|
9
9
|
color?: "primary" | "secondary" | "error";
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
interface GhostButtonProps extends
|
|
12
|
+
interface GhostButtonProps extends BaseButtonProps {
|
|
13
13
|
kind?: "ghost";
|
|
14
14
|
color?: "primary" | "secondary" | "error";
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
interface OutlinedButtonProps extends
|
|
17
|
+
interface OutlinedButtonProps extends BaseButtonProps {
|
|
18
18
|
kind?: "outlined";
|
|
19
19
|
color?: "primary";
|
|
20
20
|
}
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ChipColor,
|
|
7
7
|
OutlinedChipProps,
|
|
8
8
|
BaseContainedChipProps,
|
|
9
|
+
EnableContainedChipProps,
|
|
9
10
|
} from "./Chip.types";
|
|
10
11
|
|
|
11
12
|
const COMMON_STYLES = {
|
|
@@ -13,6 +14,7 @@ const COMMON_STYLES = {
|
|
|
13
14
|
height: "22px",
|
|
14
15
|
width: "auto",
|
|
15
16
|
minWidth: "22px",
|
|
17
|
+
boxShadow: "none",
|
|
16
18
|
},
|
|
17
19
|
"&.Mui-disabled": {
|
|
18
20
|
opacity: 1,
|
|
@@ -110,7 +112,7 @@ export const StyledContainedChipBase = styled(MuiChip, {
|
|
|
110
112
|
|
|
111
113
|
export const StyledContainedChipEnable = styled(StyledContainedChipBase, {
|
|
112
114
|
shouldForwardProp: (prop) => !["color"].includes(prop.toString()),
|
|
113
|
-
})<
|
|
115
|
+
})<EnableContainedChipProps>(() => ({ theme, color }) => ({
|
|
114
116
|
/**
|
|
115
117
|
* Setting the z-index of the chip to 0 and the z-index of the pseudo element to -1
|
|
116
118
|
* allows the pseudo element(hover layer) to be rendered between the chip and the chip's children.
|
|
@@ -137,9 +139,9 @@ export const StyledContainedChipEnable = styled(StyledContainedChipBase, {
|
|
|
137
139
|
},
|
|
138
140
|
}));
|
|
139
141
|
|
|
140
|
-
export const StyledContainedChipDeletable = styled(
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
export const StyledContainedChipDeletable = styled(
|
|
143
|
+
StyledContainedChipBase
|
|
144
|
+
)<BaseContainedChipProps>(() => ({ theme }) => ({
|
|
143
145
|
"& .MuiChip-deleteIcon": {
|
|
144
146
|
marginLeft: "4px",
|
|
145
147
|
marginRight: "3px",
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { CHIP_COLORS } from "./consts";
|
|
2
2
|
|
|
3
|
-
import type { ChipProps as MuiChipProps
|
|
3
|
+
import type { ChipProps as MuiChipProps } from "@mui/material";
|
|
4
4
|
|
|
5
5
|
type ColorKeys = keyof typeof CHIP_COLORS;
|
|
6
|
-
export type ChipColor = typeof CHIP_COLORS[ColorKeys];
|
|
6
|
+
export type ChipColor = (typeof CHIP_COLORS)[ColorKeys];
|
|
7
7
|
export type ChipThumbnail = string | JSX.Element;
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import MuiTextField from "@mui/material/TextField";
|
|
2
|
+
import { styled } from "@mui/material/styles";
|
|
3
|
+
|
|
4
|
+
import type { ColorToken } from "@/foundation/colors/types";
|
|
5
|
+
import type { Typography } from "@mui/material/styles/createTypography";
|
|
6
|
+
import type { TextFieldProps, TextFieldSize } from "./TextField.types";
|
|
7
|
+
|
|
8
|
+
type BaseTextFieldProps = Omit<TextFieldProps, "size"> & {
|
|
9
|
+
textFieldSize: TextFieldSize;
|
|
10
|
+
hasLeftIcon?: boolean;
|
|
11
|
+
hasRightIcon?: boolean;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
interface GetTextFieldPaddingBySizeParams {
|
|
15
|
+
multiline?: boolean;
|
|
16
|
+
size: TextFieldSize;
|
|
17
|
+
hasLeftIcon?: boolean;
|
|
18
|
+
hasRightIcon?: boolean;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const getSinglelineTextFieldPaddingByIconAndSize = ({
|
|
22
|
+
size,
|
|
23
|
+
hasLeftIcon,
|
|
24
|
+
hasRightIcon,
|
|
25
|
+
}: Pick<
|
|
26
|
+
GetTextFieldPaddingBySizeParams,
|
|
27
|
+
"size" | "hasLeftIcon" | "hasRightIcon"
|
|
28
|
+
>) => {
|
|
29
|
+
switch (size) {
|
|
30
|
+
case "small":
|
|
31
|
+
return `4px ${hasRightIcon ? "8px" : "12px"} 4px ${
|
|
32
|
+
hasLeftIcon ? "8px" : "12px"
|
|
33
|
+
}}`;
|
|
34
|
+
case "medium":
|
|
35
|
+
return `8px ${hasRightIcon ? "12px" : "16px"} 8px ${
|
|
36
|
+
hasLeftIcon ? "12px" : "16px"
|
|
37
|
+
}}`;
|
|
38
|
+
case "large":
|
|
39
|
+
return `10px ${hasRightIcon ? "12px" : "16px"} 10px ${
|
|
40
|
+
hasLeftIcon ? "12px" : "16px"
|
|
41
|
+
}}`;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getMultilineTextFieldPaddingByIconAndSize = ({
|
|
46
|
+
size,
|
|
47
|
+
}: Pick<GetTextFieldPaddingBySizeParams, "size">) => {
|
|
48
|
+
switch (size) {
|
|
49
|
+
case "small":
|
|
50
|
+
return "4px 4px 4px 12px";
|
|
51
|
+
case "medium":
|
|
52
|
+
return "8px 4px 8px 16px";
|
|
53
|
+
case "large":
|
|
54
|
+
return "10px 4px 10px 16px";
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getTextFieldPaddingBySize = ({
|
|
59
|
+
size,
|
|
60
|
+
multiline,
|
|
61
|
+
hasLeftIcon,
|
|
62
|
+
hasRightIcon,
|
|
63
|
+
}: GetTextFieldPaddingBySizeParams) => {
|
|
64
|
+
return multiline
|
|
65
|
+
? getMultilineTextFieldPaddingByIconAndSize({ size })
|
|
66
|
+
: getSinglelineTextFieldPaddingByIconAndSize({
|
|
67
|
+
size,
|
|
68
|
+
hasLeftIcon,
|
|
69
|
+
hasRightIcon,
|
|
70
|
+
});
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const commonStyle = ({ token }: { token: ColorToken }) => ({
|
|
74
|
+
"& .MuiOutlinedInput-root": {
|
|
75
|
+
borderRadius: "8px",
|
|
76
|
+
width: "100%",
|
|
77
|
+
|
|
78
|
+
"& fieldset": {
|
|
79
|
+
border: "none",
|
|
80
|
+
},
|
|
81
|
+
"&.Mui-error fieldset": {
|
|
82
|
+
border: `1px solid ${token.component.textfield_border_error}`,
|
|
83
|
+
},
|
|
84
|
+
"&.Mui-focused fieldset": {
|
|
85
|
+
border: `1px solid ${token.core.focused}`,
|
|
86
|
+
},
|
|
87
|
+
"&.Mui-disabled": {
|
|
88
|
+
opacity: 0.38,
|
|
89
|
+
"&:hover::before": {
|
|
90
|
+
backgroundColor: token.component.textfield_bg,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
"& input, textarea": {
|
|
94
|
+
padding: 0,
|
|
95
|
+
textOverflow: "ellipsis",
|
|
96
|
+
"&::placeholder": {
|
|
97
|
+
color: token.core.text_medium,
|
|
98
|
+
opacity: 1,
|
|
99
|
+
WebkitTextFillColor: token.core.text_medium,
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
"& textarea": {
|
|
103
|
+
height: "100% !important",
|
|
104
|
+
overflowY: "scroll !important",
|
|
105
|
+
"&::-webkit-scrollbar": {
|
|
106
|
+
width: "6px",
|
|
107
|
+
},
|
|
108
|
+
"&::-webkit-scrollbar-thumb": {
|
|
109
|
+
borderRadius: "6px",
|
|
110
|
+
backgroundColor: token.component.scrollbars_bg,
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
background: token.component.textfield_bg,
|
|
114
|
+
overflow: "hidden",
|
|
115
|
+
color: token.core.text_normal,
|
|
116
|
+
"&:hover": {
|
|
117
|
+
position: "relative",
|
|
118
|
+
zIndex: 0,
|
|
119
|
+
backgroundColor: token.component.textfield_bg,
|
|
120
|
+
},
|
|
121
|
+
"&:hover::before": {
|
|
122
|
+
content: '""',
|
|
123
|
+
position: "absolute",
|
|
124
|
+
top: 0,
|
|
125
|
+
left: 0,
|
|
126
|
+
width: "100%",
|
|
127
|
+
height: "100%",
|
|
128
|
+
zIndex: -1,
|
|
129
|
+
backgroundColor: token.core.hover,
|
|
130
|
+
},
|
|
131
|
+
"&.Mui-focused": {
|
|
132
|
+
"&:hover::before": {
|
|
133
|
+
backgroundColor: token.component.textfield_bg,
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
"& .MuiFormHelperText-root": {
|
|
138
|
+
"&.Mui-disabled": {
|
|
139
|
+
opacity: 0.38,
|
|
140
|
+
},
|
|
141
|
+
"&.Mui-error": {
|
|
142
|
+
color: token.core.text_error,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
const sizeStyle = ({
|
|
148
|
+
token,
|
|
149
|
+
textFieldSize,
|
|
150
|
+
hasLeftIcon,
|
|
151
|
+
hasRightIcon,
|
|
152
|
+
typography,
|
|
153
|
+
multiline,
|
|
154
|
+
}: Pick<
|
|
155
|
+
BaseTextFieldProps,
|
|
156
|
+
"textFieldSize" | "hasLeftIcon" | "hasRightIcon" | "multiline"
|
|
157
|
+
> & { token: ColorToken; typography: Typography }) => ({
|
|
158
|
+
...(textFieldSize === "small" && {
|
|
159
|
+
"& .MuiInputBase-root": {
|
|
160
|
+
padding: getTextFieldPaddingBySize({
|
|
161
|
+
size: textFieldSize,
|
|
162
|
+
hasLeftIcon,
|
|
163
|
+
hasRightIcon,
|
|
164
|
+
multiline,
|
|
165
|
+
}),
|
|
166
|
+
"& input, textarea": {
|
|
167
|
+
...typography.body2_14_regular,
|
|
168
|
+
},
|
|
169
|
+
"& input": {
|
|
170
|
+
height: "20px",
|
|
171
|
+
},
|
|
172
|
+
"& textarea": {
|
|
173
|
+
minHeight: "92px",
|
|
174
|
+
paddingRight: "2px",
|
|
175
|
+
},
|
|
176
|
+
},
|
|
177
|
+
"& .MuiFormHelperText-root": {
|
|
178
|
+
...typography.body2_14_regular,
|
|
179
|
+
color: token.core.text_medium,
|
|
180
|
+
margin: 0,
|
|
181
|
+
marginTop: "4px",
|
|
182
|
+
paddingLeft: "4px",
|
|
183
|
+
|
|
184
|
+
"&.Mui-disabled": {
|
|
185
|
+
color: token.core.text_medium,
|
|
186
|
+
opacity: 0.38,
|
|
187
|
+
},
|
|
188
|
+
"&.Mui-error": {
|
|
189
|
+
color: token.core.text_error,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
}),
|
|
193
|
+
...(textFieldSize === "medium" && {
|
|
194
|
+
"& .MuiInputBase-root": {
|
|
195
|
+
padding: getTextFieldPaddingBySize({
|
|
196
|
+
size: textFieldSize,
|
|
197
|
+
hasLeftIcon,
|
|
198
|
+
hasRightIcon,
|
|
199
|
+
multiline,
|
|
200
|
+
}),
|
|
201
|
+
"& input, textarea": {
|
|
202
|
+
...typography.body2_14_regular,
|
|
203
|
+
},
|
|
204
|
+
"& input": {
|
|
205
|
+
height: "20px",
|
|
206
|
+
},
|
|
207
|
+
"& textarea": {
|
|
208
|
+
minHeight: "84px",
|
|
209
|
+
paddingRight: "6px",
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
"& .MuiFormHelperText-root": {
|
|
213
|
+
...typography.body2_14_regular,
|
|
214
|
+
color: token.core.text_medium,
|
|
215
|
+
margin: 0,
|
|
216
|
+
marginTop: "4px",
|
|
217
|
+
paddingLeft: "4px",
|
|
218
|
+
|
|
219
|
+
"&.Mui-disabled": {
|
|
220
|
+
color: token.core.text_medium,
|
|
221
|
+
opacity: 0.38,
|
|
222
|
+
},
|
|
223
|
+
"&.Mui-error": {
|
|
224
|
+
color: token.core.text_error,
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
}),
|
|
228
|
+
...(textFieldSize === "large" && {
|
|
229
|
+
"& .MuiInputBase-root": {
|
|
230
|
+
padding: getTextFieldPaddingBySize({
|
|
231
|
+
size: textFieldSize,
|
|
232
|
+
hasLeftIcon,
|
|
233
|
+
hasRightIcon,
|
|
234
|
+
multiline,
|
|
235
|
+
}),
|
|
236
|
+
"& input, textarea": {
|
|
237
|
+
...typography.body1_16_regular,
|
|
238
|
+
},
|
|
239
|
+
"& input": {
|
|
240
|
+
height: "24px",
|
|
241
|
+
},
|
|
242
|
+
"& textarea": {
|
|
243
|
+
minHeight: "80px",
|
|
244
|
+
paddingRight: "6px",
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
"& .MuiFormHelperText-root": {
|
|
248
|
+
...typography.body1_16_regular,
|
|
249
|
+
color: token.core.text_medium,
|
|
250
|
+
margin: 0,
|
|
251
|
+
marginTop: "4px",
|
|
252
|
+
paddingLeft: "4px",
|
|
253
|
+
|
|
254
|
+
"&.Mui-disabled": {
|
|
255
|
+
color: token.core.text_medium,
|
|
256
|
+
opacity: 0.38,
|
|
257
|
+
},
|
|
258
|
+
"&.Mui-error": {
|
|
259
|
+
color: token.core.text_error,
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
}),
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
const BaseTextField = styled(MuiTextField, {
|
|
266
|
+
shouldForwardProp: (prop: string) =>
|
|
267
|
+
![
|
|
268
|
+
"leftIconSx",
|
|
269
|
+
"rightIconSx",
|
|
270
|
+
"leftIcon",
|
|
271
|
+
"rightIcon",
|
|
272
|
+
"textFieldSize",
|
|
273
|
+
"hasLeftIcon",
|
|
274
|
+
"hasRightIcon",
|
|
275
|
+
"onLeftIconClick",
|
|
276
|
+
"onRightIconClick",
|
|
277
|
+
].includes(prop),
|
|
278
|
+
})<BaseTextFieldProps>(
|
|
279
|
+
({
|
|
280
|
+
theme: {
|
|
281
|
+
typography,
|
|
282
|
+
palette: { token },
|
|
283
|
+
},
|
|
284
|
+
multiline,
|
|
285
|
+
textFieldSize,
|
|
286
|
+
hasLeftIcon,
|
|
287
|
+
hasRightIcon,
|
|
288
|
+
}) => ({
|
|
289
|
+
...commonStyle({ token }),
|
|
290
|
+
...sizeStyle({
|
|
291
|
+
token,
|
|
292
|
+
textFieldSize,
|
|
293
|
+
hasLeftIcon,
|
|
294
|
+
hasRightIcon,
|
|
295
|
+
typography,
|
|
296
|
+
multiline,
|
|
297
|
+
}),
|
|
298
|
+
})
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
const IconWrapper = styled("div")(({ theme }) => ({
|
|
302
|
+
display: "flex",
|
|
303
|
+
alignItems: "center",
|
|
304
|
+
justifyContent: "center",
|
|
305
|
+
minWidth: "28px",
|
|
306
|
+
minHeight: "28px",
|
|
307
|
+
margin: "-4px 0",
|
|
308
|
+
|
|
309
|
+
"& svg": {
|
|
310
|
+
width: "20px",
|
|
311
|
+
height: "20px",
|
|
312
|
+
color: theme.palette.token.core.text_normal,
|
|
313
|
+
},
|
|
314
|
+
}));
|
|
315
|
+
|
|
316
|
+
export { BaseTextField, IconWrapper };
|
|
@@ -1,8 +1,80 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Box } from "@mui/material";
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import TextFieldIcon from "./TextFieldIcon";
|
|
4
|
+
import { BaseTextField } from "./TextField.style";
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
TextFieldProps,
|
|
8
|
+
MultiTextFieldProps,
|
|
9
|
+
SingleTextFieldProps,
|
|
10
|
+
} from "./TextField.types";
|
|
11
|
+
|
|
12
|
+
const SingleTextField = (props: SingleTextFieldProps) => {
|
|
13
|
+
const {
|
|
14
|
+
size,
|
|
15
|
+
leftIcon,
|
|
16
|
+
rightIcon,
|
|
17
|
+
leftIconSx,
|
|
18
|
+
rightIconSx,
|
|
19
|
+
onLeftIconClick,
|
|
20
|
+
onRightIconClick,
|
|
21
|
+
...restProps
|
|
22
|
+
} = props;
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<BaseTextField
|
|
26
|
+
{...restProps}
|
|
27
|
+
textFieldSize={size}
|
|
28
|
+
hasLeftIcon={Boolean(leftIcon)}
|
|
29
|
+
hasRightIcon={Boolean(rightIcon)}
|
|
30
|
+
InputProps={{
|
|
31
|
+
startAdornment: leftIcon && (
|
|
32
|
+
<TextFieldIcon
|
|
33
|
+
sx={{ marginRight: "4px", ...leftIconSx }}
|
|
34
|
+
icon={leftIcon}
|
|
35
|
+
onIconClick={onLeftIconClick}
|
|
36
|
+
/>
|
|
37
|
+
),
|
|
38
|
+
endAdornment: rightIcon && (
|
|
39
|
+
<TextFieldIcon
|
|
40
|
+
sx={{ marginLeft: "4px", ...rightIconSx }}
|
|
41
|
+
icon={rightIcon}
|
|
42
|
+
onIconClick={onRightIconClick}
|
|
43
|
+
/>
|
|
44
|
+
),
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const MultiTextField = ({
|
|
51
|
+
size,
|
|
52
|
+
onChange,
|
|
53
|
+
...restProps
|
|
54
|
+
}: MultiTextFieldProps) => {
|
|
55
|
+
return <BaseTextField {...restProps} textFieldSize={size} multiline />;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const TextField = (props: TextFieldProps) => {
|
|
59
|
+
const {
|
|
60
|
+
rows,
|
|
61
|
+
size = "small",
|
|
62
|
+
multiline = false,
|
|
63
|
+
variant = "outlined",
|
|
64
|
+
...restProps
|
|
65
|
+
} = props;
|
|
66
|
+
|
|
67
|
+
return multiline ? (
|
|
68
|
+
<MultiTextField
|
|
69
|
+
{...restProps}
|
|
70
|
+
maxRows={Infinity}
|
|
71
|
+
size={size}
|
|
72
|
+
variant={variant}
|
|
73
|
+
rows={rows}
|
|
74
|
+
/>
|
|
75
|
+
) : (
|
|
76
|
+
<SingleTextField {...restProps} size={size} variant={variant} />
|
|
77
|
+
);
|
|
6
78
|
};
|
|
7
79
|
|
|
8
80
|
export default TextField;
|