@team-monolith/cds 0.4.0 → 0.4.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/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/package.json +5 -1
- package/public/favicon.ico +0 -0
- package/public/index.html +0 -43
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +0 -25
- package/public/robots.txt +0 -3
- package/src/App.tsx +0 -7
- package/src/cds/CodleDesignSystemProvider.tsx +0 -93
- package/src/cds/README.md +0 -23
- package/src/cds/components/AlertDialog/AlertDialog.tsx +0 -101
- package/src/cds/components/AlertDialog/AlertDialogActions.tsx +0 -34
- package/src/cds/components/AlertDialog/AlertDialogContent.tsx +0 -36
- package/src/cds/components/AlertDialog/AlertDialogTitle.tsx +0 -63
- package/src/cds/components/AlertDialog/index.tsx +0 -4
- package/src/cds/components/Banner.tsx +0 -176
- package/src/cds/components/Button.tsx +0 -256
- package/src/cds/components/CheckboxInput.tsx +0 -270
- package/src/cds/components/Input.tsx +0 -171
- package/src/cds/components/InputBase.tsx +0 -226
- package/src/cds/components/Pagination.tsx +0 -99
- package/src/cds/components/PinInput.tsx +0 -322
- package/src/cds/components/RadioInput.tsx +0 -226
- package/src/cds/components/SquareButton.tsx +0 -229
- package/src/cds/components/Switch.tsx +0 -129
- package/src/cds/components/Tag.tsx +0 -155
- package/src/cds/components/Tooltip.tsx +0 -104
- package/src/cds/foundation/color.ts +0 -83
- package/src/cds/foundation/shadows.ts +0 -17
- package/src/cds/icons/Arrows/index.ts +0 -2
- package/src/cds/icons/Media/index.ts +0 -2
- package/src/cds/icons/System/index.ts +0 -2
- package/src/cds/icons/arrows.tsx +0 -116
- package/src/cds/icons/brand.tsx +0 -13
- package/src/cds/icons/design.tsx +0 -15
- package/src/cds/icons/map.tsx +0 -14
- package/src/cds/icons/system.tsx +0 -143
- package/src/cds/index.ts +0 -64
- package/src/cds/patterns/Card/Card.tsx +0 -294
- package/src/cds/patterns/Card/class-icon.svg +0 -28
- package/src/cds/patterns/Card/index.tsx +0 -2
- package/src/cds/patterns/Card/material-icon.svg +0 -25
- package/src/cds/patterns/Card/problem-icon.svg +0 -25
- package/src/cds/patterns/Card/thumbnail/sample.png +0 -0
- package/src/cds/patterns/Dialog/Dialog.tsx +0 -57
- package/src/cds/patterns/Dialog/DialogContent.tsx +0 -28
- package/src/cds/patterns/Dialog/DialogNavigation.tsx +0 -29
- package/src/cds/patterns/Dialog/DialogNavigationContext.tsx +0 -9
- package/src/cds/patterns/Dialog/DialogNavigationItem.tsx +0 -42
- package/src/cds/patterns/Dialog/DialogPanel.tsx +0 -40
- package/src/cds/patterns/Dialog/DialogPanels.tsx +0 -24
- package/src/cds/patterns/Dialog/DialogPanelsContext.tsx +0 -9
- package/src/cds/patterns/Dialog/DialogTitle.tsx +0 -55
- package/src/cds/patterns/Dialog/index.tsx +0 -7
- package/src/cds/patterns/Dropdown/Dropdown.tsx +0 -111
- package/src/cds/patterns/Dropdown/DropdownItem.tsx +0 -203
- package/src/cds/patterns/Dropdown/DropdownMenu.tsx +0 -176
- package/src/cds/patterns/Dropdown/index.tsx +0 -2
- package/src/cds/patterns/EmptyState/EmptyState.tsx +0 -91
- package/src/cds/patterns/EmptyState/empty-state-icon.svg +0 -36
- package/src/cds/patterns/EmptyState/index.tsx +0 -2
- package/src/cds/patterns/Navigation/NavigationContext.tsx +0 -9
- package/src/cds/patterns/Navigation/NavigationHorizontal.tsx +0 -32
- package/src/cds/patterns/Navigation/NavigationItem.tsx +0 -36
- package/src/cds/patterns/Navigation/NavigationVertical.tsx +0 -39
- package/src/cds/patterns/Navigation/index.tsx +0 -3
- package/src/cds/patterns/SegmentedControl/SegmentedControlButton.tsx +0 -55
- package/src/cds/patterns/SegmentedControl/SegmentedControlGroup.tsx +0 -81
- package/src/cds/patterns/SegmentedControl/SegmentedControlGroupPropsContext.tsx +0 -9
- package/src/cds/patterns/SegmentedControl/SegmentedControlSquareButton.tsx +0 -51
- package/src/cds/patterns/SegmentedControl/index.ts +0 -3
- package/src/cds/patterns/Table/Table.tsx +0 -62
- package/src/cds/patterns/Table/TableBody.tsx +0 -30
- package/src/cds/patterns/Table/TableCell.tsx +0 -253
- package/src/cds/patterns/Table/TableHead.tsx +0 -30
- package/src/cds/patterns/Table/TablePropsContext.tsx +0 -9
- package/src/cds/patterns/Table/TableRow.tsx +0 -70
- package/src/cds/patterns/Table/TableVariantContext.tsx +0 -9
- package/src/cds/patterns/Table/index.tsx +0 -15
- package/src/cds/utils/hover.tsx +0 -24
- package/src/cds/utils/reset.tsx +0 -19
- package/src/cds/utils/zIndex.tsx +0 -3
- package/src/index.tsx +0 -10
- package/tsconfig.json +0 -22
- /package/{src/cds → @types}/emotion.d.ts +0 -0
- /package/{src/cds → @types}/svg.d.ts +0 -0
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import { css, SerializedStyles, Theme, useTheme } from "@emotion/react";
|
|
3
|
-
import styled from "@emotion/styled";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import { HOVER } from "../utils/hover";
|
|
6
|
-
import { PolymorphicProps } from "@mui/base";
|
|
7
|
-
|
|
8
|
-
export type ButtonColor =
|
|
9
|
-
| "primary"
|
|
10
|
-
| "secondary"
|
|
11
|
-
| "danger"
|
|
12
|
-
| "textNeutral"
|
|
13
|
-
| "textDanger"
|
|
14
|
-
| "textPrimary";
|
|
15
|
-
|
|
16
|
-
export type ButtonSize = "large" | "medium" | "small" | "xsmall";
|
|
17
|
-
|
|
18
|
-
const COLOR_TO_BUTTON_STYLE = (theme: Theme, color: ButtonColor) =>
|
|
19
|
-
({
|
|
20
|
-
primary: css`
|
|
21
|
-
background: ${theme.color.background.primary};
|
|
22
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
23
|
-
|
|
24
|
-
${HOVER(css`
|
|
25
|
-
background: ${theme.color.background.primaryActive};
|
|
26
|
-
`)}
|
|
27
|
-
&:disabled {
|
|
28
|
-
background: ${theme.color.background.primaryDisabled};
|
|
29
|
-
}
|
|
30
|
-
`,
|
|
31
|
-
secondary: css`
|
|
32
|
-
background: ${theme.color.background.neutralAlt};
|
|
33
|
-
color: ${theme.color.foreground.neutralBase};
|
|
34
|
-
|
|
35
|
-
${HOVER(css`
|
|
36
|
-
background: ${theme.color.background.neutralAltActive};
|
|
37
|
-
color: ${theme.color.foreground.neutralBase};
|
|
38
|
-
`)}
|
|
39
|
-
&:disabled {
|
|
40
|
-
background: ${theme.color.background.neutralAlt};
|
|
41
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
42
|
-
}
|
|
43
|
-
`,
|
|
44
|
-
danger: css`
|
|
45
|
-
background: ${theme.color.background.danger};
|
|
46
|
-
color: ${theme.color.foreground.neutralAlt};
|
|
47
|
-
|
|
48
|
-
${HOVER(css`
|
|
49
|
-
background: ${theme.color.background.dangerActive};
|
|
50
|
-
`)}
|
|
51
|
-
&:disabled {
|
|
52
|
-
background: ${theme.color.background.dangerDisabled};
|
|
53
|
-
}
|
|
54
|
-
`,
|
|
55
|
-
textNeutral: css`
|
|
56
|
-
background: none;
|
|
57
|
-
color: ${theme.color.foreground.neutralBase};
|
|
58
|
-
|
|
59
|
-
${HOVER(css`
|
|
60
|
-
background: ${theme.color.background.neutralAltActive};
|
|
61
|
-
color: ${theme.color.foreground.neutralBase};
|
|
62
|
-
`)}
|
|
63
|
-
&:disabled {
|
|
64
|
-
background: none;
|
|
65
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
66
|
-
}
|
|
67
|
-
`,
|
|
68
|
-
textDanger: css`
|
|
69
|
-
background: none;
|
|
70
|
-
color: ${theme.color.foreground.danger};
|
|
71
|
-
|
|
72
|
-
${HOVER(css`
|
|
73
|
-
background: ${theme.color.background.neutralAltActive};
|
|
74
|
-
color: ${theme.color.foreground.danger};
|
|
75
|
-
`)}
|
|
76
|
-
&:disabled {
|
|
77
|
-
background: none;
|
|
78
|
-
color: ${theme.color.foreground.dangerDisabled};
|
|
79
|
-
}
|
|
80
|
-
`,
|
|
81
|
-
textPrimary: css`
|
|
82
|
-
background: none;
|
|
83
|
-
color: ${theme.color.foreground.primary};
|
|
84
|
-
|
|
85
|
-
${HOVER(css`
|
|
86
|
-
background: ${theme.color.background.neutralAltActive};
|
|
87
|
-
color: ${theme.color.foreground.primary};
|
|
88
|
-
`)}
|
|
89
|
-
&:disabled {
|
|
90
|
-
background: none;
|
|
91
|
-
color: ${theme.color.foreground.primaryDisabled};
|
|
92
|
-
}
|
|
93
|
-
`,
|
|
94
|
-
}[color]);
|
|
95
|
-
|
|
96
|
-
const SIZE_TO_BUTTON_STYLE: { [K in ButtonSize]: SerializedStyles } = {
|
|
97
|
-
large: css`
|
|
98
|
-
padding: 16px 20px;
|
|
99
|
-
gap: 10px;
|
|
100
|
-
|
|
101
|
-
svg {
|
|
102
|
-
width: 24px;
|
|
103
|
-
height: 24px;
|
|
104
|
-
}
|
|
105
|
-
`,
|
|
106
|
-
medium: css`
|
|
107
|
-
padding: 14px 16px;
|
|
108
|
-
gap: 8px;
|
|
109
|
-
|
|
110
|
-
svg {
|
|
111
|
-
width: 20px;
|
|
112
|
-
height: 20px;
|
|
113
|
-
}
|
|
114
|
-
`,
|
|
115
|
-
small: css`
|
|
116
|
-
padding: 10px 12px;
|
|
117
|
-
gap: 8px;
|
|
118
|
-
|
|
119
|
-
svg {
|
|
120
|
-
width: 16px;
|
|
121
|
-
height: 16px;
|
|
122
|
-
}
|
|
123
|
-
`,
|
|
124
|
-
xsmall: css`
|
|
125
|
-
padding: 6px 8px;
|
|
126
|
-
gap: 4px;
|
|
127
|
-
|
|
128
|
-
svg {
|
|
129
|
-
width: 12px;
|
|
130
|
-
height: 12px;
|
|
131
|
-
}
|
|
132
|
-
`,
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
const SIZE_TO_LABEL_STYLE: { [K in ButtonSize]: SerializedStyles } = {
|
|
136
|
-
large: css`
|
|
137
|
-
font-size: 20px;
|
|
138
|
-
line-height: 24px;
|
|
139
|
-
`,
|
|
140
|
-
medium: css`
|
|
141
|
-
font-size: 18px;
|
|
142
|
-
line-height: 20px;
|
|
143
|
-
`,
|
|
144
|
-
small: css`
|
|
145
|
-
font-size: 14px;
|
|
146
|
-
line-height: 16px;
|
|
147
|
-
`,
|
|
148
|
-
xsmall: css`
|
|
149
|
-
font-size: 14px;
|
|
150
|
-
line-height: 16px;
|
|
151
|
-
`,
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export interface ButtonOwnProps<RootComponentType extends React.ElementType> {
|
|
155
|
-
className?: string;
|
|
156
|
-
component?: RootComponentType;
|
|
157
|
-
|
|
158
|
-
/** 비활성화 여부 */
|
|
159
|
-
disabled?: boolean;
|
|
160
|
-
|
|
161
|
-
/** 컴포넌트 색상 */
|
|
162
|
-
color: ButtonColor;
|
|
163
|
-
|
|
164
|
-
/** 컴포넌트 크기 */
|
|
165
|
-
size: ButtonSize;
|
|
166
|
-
|
|
167
|
-
/** 컴포넌트 좌측에 표기될 아이콘 */
|
|
168
|
-
startIcon?: React.ReactNode;
|
|
169
|
-
|
|
170
|
-
/** 컴포넌트 우측에 표기될 아이콘 */
|
|
171
|
-
endIcon?: React.ReactNode;
|
|
172
|
-
|
|
173
|
-
/** 컴포넌트 내 표기될 문자열 */
|
|
174
|
-
label: string;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export type ButtonProps<
|
|
178
|
-
RootComponentType extends React.ElementType = ButtonTypeMap["defaultComponent"]
|
|
179
|
-
> = PolymorphicProps<ButtonTypeMap<RootComponentType>, RootComponentType>;
|
|
180
|
-
|
|
181
|
-
export interface ButtonTypeMap<
|
|
182
|
-
RootComponentType extends React.ElementType = "button"
|
|
183
|
-
> {
|
|
184
|
-
props: ButtonOwnProps<RootComponentType>;
|
|
185
|
-
defaultComponent: RootComponentType;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
type ButtonComponent = <RootComponentType extends React.ElementType = "button">(
|
|
189
|
-
props: ButtonProps<RootComponentType>
|
|
190
|
-
) => React.ReactElement | null;
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=20-173&t=cXcCv3QijbX7MkoC-0)
|
|
194
|
-
*/
|
|
195
|
-
const Button: ButtonComponent = React.forwardRef(function Button<
|
|
196
|
-
RootComponentType extends React.ElementType = "button"
|
|
197
|
-
>(
|
|
198
|
-
props: ButtonProps<RootComponentType>,
|
|
199
|
-
ref: React.ComponentPropsWithRef<RootComponentType>['ref']
|
|
200
|
-
): React.ReactElement {
|
|
201
|
-
const {
|
|
202
|
-
className,
|
|
203
|
-
component: Component = "button",
|
|
204
|
-
disabled,
|
|
205
|
-
color,
|
|
206
|
-
size,
|
|
207
|
-
startIcon,
|
|
208
|
-
endIcon,
|
|
209
|
-
label,
|
|
210
|
-
...other
|
|
211
|
-
} = props;
|
|
212
|
-
const theme = useTheme();
|
|
213
|
-
|
|
214
|
-
return (
|
|
215
|
-
<Component
|
|
216
|
-
type="button"
|
|
217
|
-
{...other}
|
|
218
|
-
className={className}
|
|
219
|
-
ref={ref}
|
|
220
|
-
css={[
|
|
221
|
-
css`
|
|
222
|
-
display: inline-flex;
|
|
223
|
-
align-items: center;
|
|
224
|
-
gap: 8px;
|
|
225
|
-
|
|
226
|
-
border: none;
|
|
227
|
-
border-radius: 8px;
|
|
228
|
-
|
|
229
|
-
cursor: pointer;
|
|
230
|
-
&:disabled {
|
|
231
|
-
cursor: default;
|
|
232
|
-
pointer-events: none;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
font: inherit;
|
|
236
|
-
text-decoration: none;
|
|
237
|
-
`,
|
|
238
|
-
COLOR_TO_BUTTON_STYLE(theme, color),
|
|
239
|
-
SIZE_TO_BUTTON_STYLE[size],
|
|
240
|
-
]}
|
|
241
|
-
disabled={disabled}
|
|
242
|
-
>
|
|
243
|
-
{startIcon}
|
|
244
|
-
<Label size={size}>{label}</Label>
|
|
245
|
-
{endIcon}
|
|
246
|
-
</Component>
|
|
247
|
-
);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
const Label = styled.span<{ size: ButtonSize }>`
|
|
251
|
-
font-weight: 400;
|
|
252
|
-
white-space: nowrap;
|
|
253
|
-
${({ size }) => SIZE_TO_LABEL_STYLE[size]}
|
|
254
|
-
`;
|
|
255
|
-
|
|
256
|
-
export default Button;
|
|
@@ -1,270 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import { SerializedStyles, css, Theme, useTheme } from "@emotion/react";
|
|
3
|
-
import * as React from "react";
|
|
4
|
-
import styled from "@emotion/styled";
|
|
5
|
-
import { ZINDEX } from "../utils/zIndex";
|
|
6
|
-
import { InputHTMLAttributes } from "react";
|
|
7
|
-
|
|
8
|
-
export type CheckboxInputType = "default" | "checked" | "partial";
|
|
9
|
-
|
|
10
|
-
const CHECKBOX_ICON_STYLE = (
|
|
11
|
-
theme: Theme,
|
|
12
|
-
type: CheckboxInputType,
|
|
13
|
-
disabled: boolean
|
|
14
|
-
): SerializedStyles => {
|
|
15
|
-
return {
|
|
16
|
-
default: css`
|
|
17
|
-
rect {
|
|
18
|
-
fill: ${theme.color.background.neutralBase};
|
|
19
|
-
stroke: ${theme.color.background.neutralAltActive};
|
|
20
|
-
}
|
|
21
|
-
${disabled
|
|
22
|
-
? css`
|
|
23
|
-
rect {
|
|
24
|
-
fill: ${theme.color.background.neutralAlt};
|
|
25
|
-
stroke: ${theme.color.background.neutralAltActive};
|
|
26
|
-
}
|
|
27
|
-
`
|
|
28
|
-
: css`
|
|
29
|
-
input[type="checkbox"]:hover + & {
|
|
30
|
-
rect {
|
|
31
|
-
stroke: ${theme.color.background.primary};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
`}
|
|
35
|
-
`,
|
|
36
|
-
checked: css`
|
|
37
|
-
rect {
|
|
38
|
-
fill: ${theme.color.background.primary};
|
|
39
|
-
stroke: ${theme.color.background.primary};
|
|
40
|
-
}
|
|
41
|
-
path {
|
|
42
|
-
fill: ${theme.color.background.neutralBase};
|
|
43
|
-
}
|
|
44
|
-
${disabled
|
|
45
|
-
? css`
|
|
46
|
-
rect {
|
|
47
|
-
fill: ${theme.color.background.neutralAlt};
|
|
48
|
-
stroke: ${theme.color.background.primaryDisabled};
|
|
49
|
-
}
|
|
50
|
-
path {
|
|
51
|
-
fill: ${theme.color.background.primaryDisabled};
|
|
52
|
-
}
|
|
53
|
-
`
|
|
54
|
-
: css`
|
|
55
|
-
input[type="checkbox"]:hover + & {
|
|
56
|
-
rect {
|
|
57
|
-
fill: ${theme.color.background.primaryActive};
|
|
58
|
-
stroke: ${theme.color.background.primaryActive};
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
`}
|
|
62
|
-
`,
|
|
63
|
-
partial: css`
|
|
64
|
-
rect {
|
|
65
|
-
fill: ${theme.color.background.neutralBase};
|
|
66
|
-
stroke: ${theme.color.background.primary};
|
|
67
|
-
}
|
|
68
|
-
rect + rect {
|
|
69
|
-
fill: ${theme.color.background.primary};
|
|
70
|
-
stroke: none;
|
|
71
|
-
}
|
|
72
|
-
${disabled
|
|
73
|
-
? css`
|
|
74
|
-
rect {
|
|
75
|
-
fill: ${theme.color.background.neutralAlt};
|
|
76
|
-
stroke: ${theme.color.background.primaryDisabled};
|
|
77
|
-
}
|
|
78
|
-
rect + rect {
|
|
79
|
-
fill: ${theme.color.background.primaryDisabled};
|
|
80
|
-
stroke: none;
|
|
81
|
-
}
|
|
82
|
-
`
|
|
83
|
-
: css`
|
|
84
|
-
input[type="checkbox"]:hover + & {
|
|
85
|
-
rect {
|
|
86
|
-
stroke: ${theme.color.background.primaryActive};
|
|
87
|
-
}
|
|
88
|
-
rect + rect {
|
|
89
|
-
fill: ${theme.color.background.primaryActive};
|
|
90
|
-
stroke: none;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
`}
|
|
94
|
-
`,
|
|
95
|
-
}[type];
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export interface CheckboxInputProps {
|
|
99
|
-
className?: string;
|
|
100
|
-
// component: React.ElementType; // 불필요한 dom 중첩을 막기 위해 사용하지 않습니다.
|
|
101
|
-
|
|
102
|
-
/** 체크박스의 체크 여부(Controlled) */
|
|
103
|
-
checked: boolean;
|
|
104
|
-
/** 체크박스의 라벨 */
|
|
105
|
-
label?: string;
|
|
106
|
-
/** 체크박스의 하단 마진(8px) 여부 */
|
|
107
|
-
spacer?: boolean;
|
|
108
|
-
/** 체크박스의 비활성화 여부 */
|
|
109
|
-
disabled?: boolean;
|
|
110
|
-
/** 체크박스의 partial 여부. 체크여부가 우선합니다. */
|
|
111
|
-
partial?: boolean;
|
|
112
|
-
/** 체크박스 값 변경시 호출되는 함수 */
|
|
113
|
-
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
114
|
-
/** 체크박스 클릭시 호출되는 함수 */
|
|
115
|
-
onClick?: (event: React.MouseEvent<HTMLInputElement>) => void;
|
|
116
|
-
/** HTML input 태그에 전달될 props */
|
|
117
|
-
inputProps?: InputHTMLAttributes<HTMLInputElement>;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=36-907&t=G4t39O7uXZvsGQ9u-0)
|
|
122
|
-
*/
|
|
123
|
-
const CheckboxInput = React.forwardRef<any, CheckboxInputProps>(
|
|
124
|
-
(props, ref) => {
|
|
125
|
-
const {
|
|
126
|
-
className,
|
|
127
|
-
checked,
|
|
128
|
-
label,
|
|
129
|
-
spacer,
|
|
130
|
-
disabled,
|
|
131
|
-
partial,
|
|
132
|
-
onChange,
|
|
133
|
-
onClick,
|
|
134
|
-
...other
|
|
135
|
-
} = props;
|
|
136
|
-
if (!label) {
|
|
137
|
-
return <Checkbox {...props} ref={ref} />;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const checkboxProps = { checked, spacer, disabled, partial, onChange };
|
|
141
|
-
return (
|
|
142
|
-
<Label className={className} ref={ref} {...other}>
|
|
143
|
-
<Checkbox {...checkboxProps} />
|
|
144
|
-
<span
|
|
145
|
-
css={css`
|
|
146
|
-
margin-left: 8px;
|
|
147
|
-
`}
|
|
148
|
-
>
|
|
149
|
-
{label}
|
|
150
|
-
</span>
|
|
151
|
-
</Label>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
);
|
|
155
|
-
|
|
156
|
-
const Checkbox = React.forwardRef<any, CheckboxInputProps>((props, ref) => {
|
|
157
|
-
const {
|
|
158
|
-
className,
|
|
159
|
-
checked,
|
|
160
|
-
partial,
|
|
161
|
-
disabled = false,
|
|
162
|
-
spacer = false,
|
|
163
|
-
onChange,
|
|
164
|
-
onClick,
|
|
165
|
-
inputProps,
|
|
166
|
-
...other
|
|
167
|
-
} = props;
|
|
168
|
-
const type: CheckboxInputType = checked
|
|
169
|
-
? "checked"
|
|
170
|
-
: partial
|
|
171
|
-
? "partial"
|
|
172
|
-
: "default";
|
|
173
|
-
|
|
174
|
-
return (
|
|
175
|
-
<CheckboxContainer
|
|
176
|
-
className={className}
|
|
177
|
-
spacer={spacer}
|
|
178
|
-
disabled={disabled}
|
|
179
|
-
ref={ref}
|
|
180
|
-
{...other}
|
|
181
|
-
>
|
|
182
|
-
<StyledInput
|
|
183
|
-
type="checkbox"
|
|
184
|
-
{...inputProps}
|
|
185
|
-
checked={checked}
|
|
186
|
-
disabled={disabled}
|
|
187
|
-
onClick={onClick}
|
|
188
|
-
onChange={onChange}
|
|
189
|
-
/>
|
|
190
|
-
<CheckboxIcon type={type} disabled={disabled} />
|
|
191
|
-
</CheckboxContainer>
|
|
192
|
-
);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
const CheckboxContainer = styled.span<{
|
|
196
|
-
spacer: boolean;
|
|
197
|
-
disabled: boolean;
|
|
198
|
-
}>(
|
|
199
|
-
({ spacer, disabled }) => css`
|
|
200
|
-
display: inline-block;
|
|
201
|
-
position: relative;
|
|
202
|
-
width: 16px;
|
|
203
|
-
height: 16px;
|
|
204
|
-
cursor: ${disabled ? "default" : "pointer"};
|
|
205
|
-
margin-bottom: ${spacer ? "8px" : "0"};
|
|
206
|
-
`
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
const StyledInput = styled.input`
|
|
210
|
-
cursor: inherit;
|
|
211
|
-
position: absolute;
|
|
212
|
-
top: 0;
|
|
213
|
-
left: 0;
|
|
214
|
-
opacity: 0;
|
|
215
|
-
width: 16px;
|
|
216
|
-
height: 16px;
|
|
217
|
-
margin: 0;
|
|
218
|
-
padding: 0;
|
|
219
|
-
// input 컴포넌트는 보이지 않지만, 클릭이 가능하게 z-index를 설정합니다.
|
|
220
|
-
z-index: ${ZINDEX.inputBase};
|
|
221
|
-
`;
|
|
222
|
-
|
|
223
|
-
const Label = styled.label`
|
|
224
|
-
display: flex;
|
|
225
|
-
position: relative;
|
|
226
|
-
width: fit-content;
|
|
227
|
-
font-size: 14px;
|
|
228
|
-
font-weight: 500;
|
|
229
|
-
line-height: 16px;
|
|
230
|
-
color: ${({ theme }) => theme.color.foreground.neutralBase};
|
|
231
|
-
align-self: center;
|
|
232
|
-
`;
|
|
233
|
-
|
|
234
|
-
const CheckboxIcon = (props: {
|
|
235
|
-
type: CheckboxInputType;
|
|
236
|
-
disabled: boolean;
|
|
237
|
-
}) => {
|
|
238
|
-
const theme = useTheme();
|
|
239
|
-
return (
|
|
240
|
-
<svg
|
|
241
|
-
width="16"
|
|
242
|
-
height="16"
|
|
243
|
-
viewBox="0 0 16 16"
|
|
244
|
-
fill="none"
|
|
245
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
246
|
-
css={CHECKBOX_ICON_STYLE(theme, props.type, props.disabled)}
|
|
247
|
-
>
|
|
248
|
-
<rect
|
|
249
|
-
x="0.5"
|
|
250
|
-
y="0.5"
|
|
251
|
-
width="15"
|
|
252
|
-
height="15"
|
|
253
|
-
rx="1.5"
|
|
254
|
-
fill="currentColor"
|
|
255
|
-
stroke="currentColor"
|
|
256
|
-
/>
|
|
257
|
-
{props.type === "checked" && (
|
|
258
|
-
<path
|
|
259
|
-
d="M7.10545 12.6041L7.08783 12.6217L2.68799 8.22185L4.12067 6.78917L7.10551 9.77402L11.8795 5L13.3122 6.43268L7.12313 12.6218L7.10545 12.6041Z"
|
|
260
|
-
fill="currentColor"
|
|
261
|
-
/>
|
|
262
|
-
)}
|
|
263
|
-
{props.type === "partial" && (
|
|
264
|
-
<rect x="4" y="4" width="8" height="8" fill="currentColor" />
|
|
265
|
-
)}
|
|
266
|
-
</svg>
|
|
267
|
-
);
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
export default CheckboxInput;
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import { Theme, css } from "@emotion/react";
|
|
3
|
-
import styled from "@emotion/styled";
|
|
4
|
-
import React from "react";
|
|
5
|
-
import {
|
|
6
|
-
InputBase,
|
|
7
|
-
InputBaseColor,
|
|
8
|
-
InputBaseProps,
|
|
9
|
-
InputBaseSize,
|
|
10
|
-
} from "./InputBase";
|
|
11
|
-
|
|
12
|
-
export type InputColor = InputBaseColor;
|
|
13
|
-
|
|
14
|
-
export type InputSize = InputBaseSize;
|
|
15
|
-
|
|
16
|
-
export interface InputProps extends InputBaseProps {
|
|
17
|
-
/** Input 컴포넌트 상단에 노출될 문자열 */
|
|
18
|
-
label?: string;
|
|
19
|
-
|
|
20
|
-
/** Input 컴포넌트 하단에 노출될 문자열 */
|
|
21
|
-
hintText?: string;
|
|
22
|
-
|
|
23
|
-
/** hint 영역 좌측에 노출될 아이콘 */
|
|
24
|
-
hintIcon?: React.ReactNode;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const COLOR_TO_HINT_STYLES = (
|
|
28
|
-
theme: Theme,
|
|
29
|
-
color: InputColor,
|
|
30
|
-
disabled?: boolean
|
|
31
|
-
) =>
|
|
32
|
-
disabled
|
|
33
|
-
? css`
|
|
34
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
35
|
-
`
|
|
36
|
-
: {
|
|
37
|
-
default: css`
|
|
38
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
39
|
-
`,
|
|
40
|
-
activePrimary: css`
|
|
41
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
42
|
-
`,
|
|
43
|
-
activeDanger: css`
|
|
44
|
-
color: ${theme.color.foreground.danger};
|
|
45
|
-
`,
|
|
46
|
-
activeSuccess: css`
|
|
47
|
-
color: ${theme.color.foreground.success};
|
|
48
|
-
`,
|
|
49
|
-
}[color];
|
|
50
|
-
|
|
51
|
-
const SIZE_TO_FONT_STYLES = (size: InputSize) =>
|
|
52
|
-
({
|
|
53
|
-
small: css`
|
|
54
|
-
font-size: 14px;
|
|
55
|
-
line-height: 20px;
|
|
56
|
-
svg {
|
|
57
|
-
width: 16px;
|
|
58
|
-
height: 16px;
|
|
59
|
-
}
|
|
60
|
-
`,
|
|
61
|
-
medium: css`
|
|
62
|
-
font-size: 16px;
|
|
63
|
-
line-height: 24px;
|
|
64
|
-
svg {
|
|
65
|
-
width: 16px;
|
|
66
|
-
height: 16px;
|
|
67
|
-
}
|
|
68
|
-
`,
|
|
69
|
-
large: css`
|
|
70
|
-
font-size: 18px;
|
|
71
|
-
line-height: 28px;
|
|
72
|
-
svg {
|
|
73
|
-
width: 18px;
|
|
74
|
-
height: 18px;
|
|
75
|
-
}
|
|
76
|
-
`,
|
|
77
|
-
}[size]);
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=26-10284&t=HnIfxpf8uR6WmzMW-0)
|
|
81
|
-
*/
|
|
82
|
-
const Input = React.forwardRef<any, InputProps>(
|
|
83
|
-
(props, ref): React.ReactElement => {
|
|
84
|
-
const {
|
|
85
|
-
label,
|
|
86
|
-
hintText,
|
|
87
|
-
hintIcon,
|
|
88
|
-
className,
|
|
89
|
-
color,
|
|
90
|
-
size,
|
|
91
|
-
placeholder,
|
|
92
|
-
disabled,
|
|
93
|
-
startIcon,
|
|
94
|
-
startLabel,
|
|
95
|
-
endLabel,
|
|
96
|
-
endIcon,
|
|
97
|
-
inputProps,
|
|
98
|
-
inputRef,
|
|
99
|
-
fullWidth,
|
|
100
|
-
onChange,
|
|
101
|
-
onClear,
|
|
102
|
-
defaultValue,
|
|
103
|
-
value,
|
|
104
|
-
...other
|
|
105
|
-
} = props;
|
|
106
|
-
|
|
107
|
-
const {
|
|
108
|
-
className: _className,
|
|
109
|
-
...inputBaseProps
|
|
110
|
-
} = props;
|
|
111
|
-
|
|
112
|
-
return (
|
|
113
|
-
<InputWrapper
|
|
114
|
-
className={props.className}
|
|
115
|
-
size={props.size}
|
|
116
|
-
fullWidth={props.fullWidth}
|
|
117
|
-
ref={ref}
|
|
118
|
-
{...other}
|
|
119
|
-
>
|
|
120
|
-
{label ? (
|
|
121
|
-
<Label disabled={props.disabled}>
|
|
122
|
-
{label} <InputBase {...inputBaseProps} />
|
|
123
|
-
</Label>
|
|
124
|
-
) : (
|
|
125
|
-
<InputBase {...inputBaseProps} />
|
|
126
|
-
)}
|
|
127
|
-
{hintText && (
|
|
128
|
-
<Hint color={props.color} disabled={props.disabled}>
|
|
129
|
-
{hintIcon}
|
|
130
|
-
{hintText}
|
|
131
|
-
</Hint>
|
|
132
|
-
)}
|
|
133
|
-
</InputWrapper>
|
|
134
|
-
);
|
|
135
|
-
}
|
|
136
|
-
);
|
|
137
|
-
|
|
138
|
-
const InputWrapper = styled.span<{ size: InputSize; fullWidth?: boolean }>`
|
|
139
|
-
display: inline-flex;
|
|
140
|
-
flex-direction: column;
|
|
141
|
-
gap: 8px;
|
|
142
|
-
${({ size }) => SIZE_TO_FONT_STYLES(size)}
|
|
143
|
-
${({ fullWidth }) => fullWidth && `width: 100%;`}
|
|
144
|
-
|
|
145
|
-
position: relative;
|
|
146
|
-
`;
|
|
147
|
-
|
|
148
|
-
const Label = styled.label<{ disabled?: boolean }>`
|
|
149
|
-
display: flex;
|
|
150
|
-
flex-direction: column;
|
|
151
|
-
gap: 8px;
|
|
152
|
-
${({ theme, disabled }) =>
|
|
153
|
-
disabled &&
|
|
154
|
-
css`
|
|
155
|
-
color: ${theme.color.foreground.neutralBaseDisabled};
|
|
156
|
-
`}
|
|
157
|
-
`;
|
|
158
|
-
|
|
159
|
-
const Hint = styled.div<{
|
|
160
|
-
color: InputColor;
|
|
161
|
-
disabled?: boolean;
|
|
162
|
-
}>(
|
|
163
|
-
({ theme, color, disabled }) => css`
|
|
164
|
-
display: flex;
|
|
165
|
-
align-items: center;
|
|
166
|
-
gap: 4px;
|
|
167
|
-
${COLOR_TO_HINT_STYLES(theme, color, disabled)};
|
|
168
|
-
`
|
|
169
|
-
);
|
|
170
|
-
|
|
171
|
-
export default Input;
|