@team-monolith/cds 1.115.0 → 1.115.2

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.
@@ -15,6 +15,7 @@ import { css, useTheme } from "@emotion/react";
15
15
  import * as React from "react";
16
16
  import styled from "@emotion/styled";
17
17
  import { ZINDEX } from "../utils/zIndex";
18
+ const DEFAULT_CHECKBOX_SIZE = 16;
18
19
  export const checkboxInputClasses = {
19
20
  root: "CheckboxInput",
20
21
  checkbox: "CheckboxInput-checkbox",
@@ -39,6 +40,11 @@ const CHECKBOX_ICON_STYLE = (theme, type, disabled) => ({
39
40
  stroke: ${theme.color.background.primary};
40
41
  }
41
42
  }
43
+ input[type="checkbox"]:focus-visible + & {
44
+ rect {
45
+ stroke: ${theme.color.background.primary};
46
+ }
47
+ }
42
48
  `}
43
49
  `,
44
50
  checked: css `
@@ -66,6 +72,12 @@ const CHECKBOX_ICON_STYLE = (theme, type, disabled) => ({
66
72
  stroke: ${theme.color.background.primaryActive};
67
73
  }
68
74
  }
75
+ input[type="checkbox"]:focus-visible + & {
76
+ rect {
77
+ fill: ${theme.color.background.primaryActive};
78
+ stroke: ${theme.color.background.primaryActive};
79
+ }
80
+ }
69
81
  `}
70
82
  `,
71
83
  partial: css `
@@ -98,6 +110,15 @@ const CHECKBOX_ICON_STYLE = (theme, type, disabled) => ({
98
110
  stroke: none;
99
111
  }
100
112
  }
113
+ input[type="checkbox"]:focus-visible + & {
114
+ rect {
115
+ stroke: ${theme.color.background.primaryActive};
116
+ }
117
+ rect + rect {
118
+ fill: ${theme.color.background.primaryActive};
119
+ stroke: none;
120
+ }
121
+ }
101
122
  `}
102
123
  `,
103
124
  })[type];
@@ -125,37 +146,68 @@ export const CheckboxInput = React.forwardRef(function CheckboxInput(props, ref)
125
146
  `, children: label })] })));
126
147
  });
127
148
  const Checkbox = React.forwardRef(function Checkbox(props, ref) {
128
- const { className, checked, partial, disabled = false, spacer = false, onChange, onClick, inputProps, hitAreaSize = 16 } = props, other = __rest(props, ["className", "checked", "partial", "disabled", "spacer", "onChange", "onClick", "inputProps", "hitAreaSize"]);
149
+ const { className, checked, partial, disabled = false, spacer = false, onChange, onClick, inputProps, hitAreaSize = DEFAULT_CHECKBOX_SIZE } = props, other = __rest(props, ["className", "checked", "partial", "disabled", "spacer", "onChange", "onClick", "inputProps", "hitAreaSize"]);
129
150
  const type = checked
130
151
  ? "checked"
131
152
  : partial
132
153
  ? "partial"
133
154
  : "default";
134
- return (_jsxs(CheckboxContainer, Object.assign({ className: className, spacer: spacer, disabled: disabled, size: hitAreaSize, ref: ref }, other, { children: [_jsx(StyledInput, Object.assign({ type: "checkbox" }, inputProps, { checked: checked, disabled: disabled, onClick: onClick, onChange: onChange, size: hitAreaSize })), _jsx(CheckboxIcon, { type: type, disabled: disabled })] })));
155
+ const clampedSize = Math.max(hitAreaSize, DEFAULT_CHECKBOX_SIZE);
156
+ return (_jsxs(CheckboxContainer, Object.assign({ className: className, spacer: spacer, disabled: disabled, size: clampedSize, ref: ref }, other, { children: [_jsx(StyledInput, Object.assign({ type: "checkbox" }, inputProps, { checked: checked, disabled: disabled, onClick: onClick, onChange: onChange, size: clampedSize })), _jsx(CheckboxIcon, { type: type, disabled: disabled })] })));
135
157
  });
136
- const CheckboxContainer = styled.span(({ spacer, disabled, size }) => css `
158
+ const CheckboxContainer = styled.span(({ theme, spacer, disabled, size }) => css `
137
159
  display: flex;
138
160
  align-items: center;
139
161
  justify-content: center;
140
162
  position: relative;
141
- width: ${size}px;
142
- height: ${size}px;
163
+ width: ${DEFAULT_CHECKBOX_SIZE}px;
164
+ height: ${DEFAULT_CHECKBOX_SIZE}px;
143
165
  cursor: ${disabled ? "default" : "pointer"};
144
166
  margin-bottom: ${spacer ? "8px" : "0"};
167
+
168
+ svg {
169
+ z-index: 1;
170
+ pointer-events: none;
171
+ }
172
+
173
+ ${size > DEFAULT_CHECKBOX_SIZE &&
174
+ css `
175
+ &::before {
176
+ content: "";
177
+ position: absolute;
178
+ top: 50%;
179
+ left: 50%;
180
+ transform: translate(-50%, -50%);
181
+ width: ${size}px;
182
+ height: ${size}px;
183
+ border-radius: 50%;
184
+ background: ${theme.color.background.neutralAltActive};
185
+ opacity: 0;
186
+ pointer-events: none;
187
+ }
188
+ `}
189
+ ${!disabled &&
190
+ css `
191
+ &:hover::before,
192
+ &:focus-visible::before {
193
+ opacity: 0.5; /* input 영역 hover 및 focus 시 표시 */
194
+ }
195
+ `}
145
196
  `);
146
197
  const StyledInput = styled.input(({ size }) => css `
147
- cursor: inherit;
148
- position: absolute;
149
- top: 0;
150
- left: 0;
151
- opacity: 0;
152
- width: ${size}px;
153
- height: ${size}px;
154
- margin: 0;
155
- padding: 0;
156
- // input 컴포넌트는 보이지 않지만, 클릭이 가능하게 z-index를 설정합니다.
157
- z-index: ${ZINDEX.inputBase};
158
- `);
198
+ cursor: inherit;
199
+ position: absolute;
200
+ top: 50%;
201
+ left: 50%;
202
+ transform: translate(-50%, -50%);
203
+ opacity: 0;
204
+ width: ${size}px;
205
+ height: ${size}px;
206
+ margin: 0;
207
+ padding: 0;
208
+ // input 컴포넌트는 보이지 않지만, 클릭이 가능하게 z-index 설정합니다.
209
+ z-index: ${ZINDEX.inputBase};
210
+ `);
159
211
  const Label = styled.label `
160
212
  display: flex;
161
213
  position: relative;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.115.0",
3
+ "version": "1.115.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,