@team-monolith/cds 0.4.1 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/components/InputBase.js +1 -1
  2. package/dist/index.d.ts +0 -2
  3. package/dist/index.js +0 -2
  4. package/package.json +4 -1
  5. package/dist/emotion.d.ts +0 -70
  6. package/dist/svg.d.ts +0 -10
  7. package/public/favicon.ico +0 -0
  8. package/public/index.html +0 -43
  9. package/public/logo192.png +0 -0
  10. package/public/logo512.png +0 -0
  11. package/public/manifest.json +0 -25
  12. package/public/robots.txt +0 -3
  13. package/src/App.tsx +0 -7
  14. package/src/cds/CodleDesignSystemProvider.tsx +0 -93
  15. package/src/cds/README.md +0 -23
  16. package/src/cds/components/AlertDialog/AlertDialog.tsx +0 -101
  17. package/src/cds/components/AlertDialog/AlertDialogActions.tsx +0 -34
  18. package/src/cds/components/AlertDialog/AlertDialogContent.tsx +0 -36
  19. package/src/cds/components/AlertDialog/AlertDialogTitle.tsx +0 -63
  20. package/src/cds/components/AlertDialog/index.tsx +0 -4
  21. package/src/cds/components/Banner.tsx +0 -176
  22. package/src/cds/components/Button.tsx +0 -256
  23. package/src/cds/components/CheckboxInput.tsx +0 -270
  24. package/src/cds/components/Input.tsx +0 -171
  25. package/src/cds/components/InputBase.tsx +0 -226
  26. package/src/cds/components/Pagination.tsx +0 -99
  27. package/src/cds/components/PinInput.tsx +0 -322
  28. package/src/cds/components/RadioInput.tsx +0 -226
  29. package/src/cds/components/SquareButton.tsx +0 -229
  30. package/src/cds/components/Switch.tsx +0 -129
  31. package/src/cds/components/Tag.tsx +0 -155
  32. package/src/cds/components/Tooltip.tsx +0 -104
  33. package/src/cds/emotion.d.ts +0 -70
  34. package/src/cds/foundation/color.ts +0 -83
  35. package/src/cds/foundation/shadows.ts +0 -17
  36. package/src/cds/icons/Arrows/index.ts +0 -2
  37. package/src/cds/icons/Media/index.ts +0 -2
  38. package/src/cds/icons/System/index.ts +0 -2
  39. package/src/cds/icons/arrows.tsx +0 -116
  40. package/src/cds/icons/brand.tsx +0 -13
  41. package/src/cds/icons/design.tsx +0 -15
  42. package/src/cds/icons/map.tsx +0 -14
  43. package/src/cds/icons/system.tsx +0 -143
  44. package/src/cds/index.ts +0 -68
  45. package/src/cds/patterns/Card/Card.tsx +0 -294
  46. package/src/cds/patterns/Card/class-icon.svg +0 -28
  47. package/src/cds/patterns/Card/index.tsx +0 -2
  48. package/src/cds/patterns/Card/material-icon.svg +0 -25
  49. package/src/cds/patterns/Card/problem-icon.svg +0 -25
  50. package/src/cds/patterns/Card/thumbnail/sample.png +0 -0
  51. package/src/cds/patterns/Dialog/Dialog.tsx +0 -57
  52. package/src/cds/patterns/Dialog/DialogContent.tsx +0 -28
  53. package/src/cds/patterns/Dialog/DialogNavigation.tsx +0 -29
  54. package/src/cds/patterns/Dialog/DialogNavigationContext.tsx +0 -9
  55. package/src/cds/patterns/Dialog/DialogNavigationItem.tsx +0 -42
  56. package/src/cds/patterns/Dialog/DialogPanel.tsx +0 -40
  57. package/src/cds/patterns/Dialog/DialogPanels.tsx +0 -24
  58. package/src/cds/patterns/Dialog/DialogPanelsContext.tsx +0 -9
  59. package/src/cds/patterns/Dialog/DialogTitle.tsx +0 -55
  60. package/src/cds/patterns/Dialog/index.tsx +0 -7
  61. package/src/cds/patterns/Dropdown/Dropdown.tsx +0 -111
  62. package/src/cds/patterns/Dropdown/DropdownItem.tsx +0 -203
  63. package/src/cds/patterns/Dropdown/DropdownMenu.tsx +0 -176
  64. package/src/cds/patterns/Dropdown/index.tsx +0 -2
  65. package/src/cds/patterns/EmptyState/EmptyState.tsx +0 -91
  66. package/src/cds/patterns/EmptyState/empty-state-icon.svg +0 -36
  67. package/src/cds/patterns/EmptyState/index.tsx +0 -2
  68. package/src/cds/patterns/Navigation/NavigationContext.tsx +0 -9
  69. package/src/cds/patterns/Navigation/NavigationHorizontal.tsx +0 -32
  70. package/src/cds/patterns/Navigation/NavigationItem.tsx +0 -36
  71. package/src/cds/patterns/Navigation/NavigationVertical.tsx +0 -39
  72. package/src/cds/patterns/Navigation/index.tsx +0 -3
  73. package/src/cds/patterns/SegmentedControl/SegmentedControlButton.tsx +0 -55
  74. package/src/cds/patterns/SegmentedControl/SegmentedControlGroup.tsx +0 -81
  75. package/src/cds/patterns/SegmentedControl/SegmentedControlGroupPropsContext.tsx +0 -9
  76. package/src/cds/patterns/SegmentedControl/SegmentedControlSquareButton.tsx +0 -51
  77. package/src/cds/patterns/SegmentedControl/index.ts +0 -3
  78. package/src/cds/patterns/Table/Table.tsx +0 -62
  79. package/src/cds/patterns/Table/TableBody.tsx +0 -30
  80. package/src/cds/patterns/Table/TableCell.tsx +0 -253
  81. package/src/cds/patterns/Table/TableHead.tsx +0 -30
  82. package/src/cds/patterns/Table/TablePropsContext.tsx +0 -9
  83. package/src/cds/patterns/Table/TableRow.tsx +0 -70
  84. package/src/cds/patterns/Table/TableVariantContext.tsx +0 -9
  85. package/src/cds/patterns/Table/index.tsx +0 -15
  86. package/src/cds/svg.d.ts +0 -10
  87. package/src/cds/utils/hover.tsx +0 -24
  88. package/src/cds/utils/reset.tsx +0 -19
  89. package/src/cds/utils/zIndex.tsx +0 -3
  90. package/src/index.tsx +0 -10
  91. package/tsconfig.json +0 -23
@@ -1,176 +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 COLOR from "../foundation/color";
6
- import { CloseFillIcon } from "../icons/system";
7
- import { RESET_BUTTON } from "../utils/reset";
8
-
9
- export type BannerColor = "red" | "blue" | "green" | "yellow";
10
-
11
- export interface BannerProps {
12
- className?: string;
13
- component?: React.ElementType;
14
-
15
- /** 컴포넌트 내 헤드라인으로 표기될 문자열 */
16
- headline?: string;
17
-
18
- /** 컴포넌트 내용으로 표기될 값 */
19
- content?: React.ReactNode;
20
-
21
- /** 컴포넌트 좌측에 표기될 아이콘 */
22
- icon?: React.ReactNode;
23
-
24
- /** 컴포넌트의 색상 */
25
- color: BannerColor;
26
-
27
- /** 컴포넌트 우측에 표기될 버튼의 라벨 */
28
- buttonLabel?: string;
29
-
30
- /** 컴포넌트 우측 버튼 클릭 시 호출될 콜백 함수 */
31
- onButtonClick?: () => void;
32
-
33
- /** 컴포넌트 우측에 표기될 닫기 버튼 유무 */
34
- close?: boolean;
35
-
36
- /** 닫기 버튼 클릭 시 호출될 콜백 함수 */
37
- onClose?: () => void;
38
-
39
- /** 전체 너비 유무 */
40
- fullWidth?: boolean;
41
- }
42
-
43
- const COLOR_TO_STYLE = (theme: Theme, color: BannerColor): SerializedStyles =>
44
- ({
45
- red: css`
46
- background: ${theme.color.container.dangerContainer};
47
- color: ${theme.color.container.dangerOnContainer};
48
- `,
49
- blue: css`
50
- background: ${theme.color.container.primaryContainer};
51
- color: ${theme.color.container.primaryOnContainer};
52
- `,
53
- green: css`
54
- background: ${theme.color.container.successContainer};
55
- color: ${theme.color.container.successOnContainer};
56
- `,
57
- yellow: css`
58
- background: ${theme.color.container.warningContainer};
59
- color: ${theme.color.container.warningOnContainer};
60
- `,
61
- }[color]);
62
-
63
- /**
64
- * [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=44-2847&t=bhnL1ombbddld3RQ-0)
65
- */
66
- const Banner = React.forwardRef<any, BannerProps>(
67
- (props, ref): React.ReactElement => {
68
- const {
69
- className,
70
- component: Component = "div",
71
- headline,
72
- content,
73
- icon,
74
- color,
75
- buttonLabel,
76
- onButtonClick,
77
- close,
78
- onClose,
79
- fullWidth,
80
- ...other
81
- } = props;
82
- const theme = useTheme();
83
- return (
84
- <Component
85
- {...other}
86
- ref={ref}
87
- className={className}
88
- css={[
89
- css`
90
- box-sizing: border-box;
91
- display: flex;
92
- align-items: center;
93
- color: ${COLOR.white};
94
- line-height: 125%;
95
- `,
96
- COLOR_TO_STYLE(theme, color),
97
- fullWidth
98
- ? css`
99
- width: 100%;
100
- `
101
- : css`
102
- border-radius: 12px;
103
- width: fit-content;
104
- min-width: 343px;
105
- `,
106
- ]}
107
- >
108
- {icon && <IconDiv>{icon}</IconDiv>}
109
- <TextContainer setPaddingRight={!close && !buttonLabel}>
110
- {headline && <HeadlineDiv>{headline}</HeadlineDiv>}
111
- {content && <div>{content}</div>}
112
- </TextContainer>
113
- {buttonLabel && (
114
- <BannerButton onClick={onButtonClick}>{buttonLabel}</BannerButton>
115
- )}
116
- {close && (
117
- <CloseButton onClick={onClose}>
118
- <StyledCloseFillIcon />
119
- </CloseButton>
120
- )}
121
- </Component>
122
- );
123
- }
124
- );
125
-
126
- const StyledCloseFillIcon = styled(CloseFillIcon)`
127
- display: block;
128
- padding: 14px;
129
- width: 20px;
130
- height: 20px;
131
-
132
- color: currentColor;
133
- `;
134
-
135
- const IconDiv = styled.div`
136
- display: flex;
137
- align-items: center;
138
- padding: 16px 0px 16px 16px;
139
- `;
140
-
141
- const HeadlineDiv = styled.div`
142
- font-weight: 700;
143
- `;
144
-
145
- const TextContainer = styled.div<{ setPaddingRight: boolean }>`
146
- flex: 1;
147
-
148
- display: flex;
149
- flex-direction: column;
150
- align-items: flex-start;
151
- padding: 16px 0px 16px 16px;
152
- gap: 4px;
153
- ${(props) =>
154
- props.setPaddingRight &&
155
- css`
156
- padding-right: 16px;
157
- `};
158
- `;
159
-
160
- const BannerButton = styled.button`
161
- ${RESET_BUTTON}
162
- display: flex;
163
- justify-content: center;
164
- align-items: center;
165
- padding: 10px 12px;
166
- cursor: pointer;
167
- color: currentColor;
168
- `;
169
-
170
- const CloseButton = styled.button`
171
- ${RESET_BUTTON}
172
- cursor: pointer;
173
- color: currentColor;
174
- `;
175
-
176
- export default Banner;
@@ -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;