@team-monolith/cds 0.2.12 → 0.3.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/dist/components/Button.d.ts +0 -2
- package/dist/components/Button.js +2 -2
- package/dist/components/Input.js +2 -1
- package/dist/patterns/SegmentedControl/SegmentedControlButton.js +25 -9
- package/package.json +3 -2
- package/src/cds/components/Button.tsx +0 -5
- package/src/cds/components/Input.tsx +7 -2
- package/src/cds/foundation/shadows.ts +1 -1
- package/src/cds/patterns/SegmentedControl/SegmentedControlButton.tsx +22 -8
|
@@ -17,8 +17,6 @@ export interface ButtonOwnProps<RootComponentType extends React.ElementType> {
|
|
|
17
17
|
endIcon?: React.ReactNode;
|
|
18
18
|
/** 컴포넌트 내 표기될 문자열 */
|
|
19
19
|
label: string;
|
|
20
|
-
/** 버튼 클릭 시 호출될 콜백 함수 */
|
|
21
|
-
onClick?: () => void;
|
|
22
20
|
}
|
|
23
21
|
export type ButtonProps<RootComponentType extends React.ElementType = ButtonTypeMap["defaultComponent"]> = PolymorphicProps<ButtonTypeMap<RootComponentType>, RootComponentType>;
|
|
24
22
|
export interface ButtonTypeMap<RootComponentType extends React.ElementType = "button"> {
|
|
@@ -56,13 +56,13 @@ var SIZE_TO_LABEL_STYLE = {
|
|
|
56
56
|
* [피그마](https://www.figma.com/file/yhrRFizzmhPoHdw9FbYow2/Codle-PD-Kit---Components?type=design&node-id=20-173&t=cXcCv3QijbX7MkoC-0)
|
|
57
57
|
*/
|
|
58
58
|
var Button = React.forwardRef(function Button(props, ref) {
|
|
59
|
-
var className = props.className, _a = props.component, Component = _a === void 0 ? "button" : _a, disabled = props.disabled, color = props.color, size = props.size, startIcon = props.startIcon, endIcon = props.endIcon, label = props.label,
|
|
59
|
+
var className = props.className, _a = props.component, Component = _a === void 0 ? "button" : _a, disabled = props.disabled, color = props.color, size = props.size, startIcon = props.startIcon, endIcon = props.endIcon, label = props.label, other = __rest(props, ["className", "component", "disabled", "color", "size", "startIcon", "endIcon", "label"]);
|
|
60
60
|
var theme = useTheme();
|
|
61
61
|
return (_jsxs(Component, __assign({}, other, { className: className, ref: ref, css: [
|
|
62
62
|
css(templateObject_21 || (templateObject_21 = __makeTemplateObject(["\n display: inline-flex;\n align-items: center;\n gap: 8px;\n\n border: none;\n border-radius: 8px;\n\n cursor: pointer;\n &:disabled {\n cursor: default;\n pointer-events: none;\n }\n\n font: inherit;\n text-decoration: none;\n "], ["\n display: inline-flex;\n align-items: center;\n gap: 8px;\n\n border: none;\n border-radius: 8px;\n\n cursor: pointer;\n &:disabled {\n cursor: default;\n pointer-events: none;\n }\n\n font: inherit;\n text-decoration: none;\n "]))),
|
|
63
63
|
COLOR_TO_BUTTON_STYLE(theme, color),
|
|
64
64
|
SIZE_TO_BUTTON_STYLE[size],
|
|
65
|
-
], disabled: disabled
|
|
65
|
+
], disabled: disabled }, { children: [startIcon, _jsx(Label, __assign({ size: size }, { children: label })), endIcon] })));
|
|
66
66
|
});
|
|
67
67
|
var Label = styled.span(templateObject_22 || (templateObject_22 = __makeTemplateObject(["\n font-weight: 400;\n white-space: nowrap;\n ", "\n"], ["\n font-weight: 400;\n white-space: nowrap;\n ", "\n"])), function (_a) {
|
|
68
68
|
var size = _a.size;
|
package/dist/components/Input.js
CHANGED
|
@@ -51,7 +51,8 @@ var SIZE_TO_FONT_STYLES = function (size) {
|
|
|
51
51
|
*/
|
|
52
52
|
var Input = React.forwardRef(function (props, ref) {
|
|
53
53
|
var label = props.label, hintText = props.hintText, hintIcon = props.hintIcon, className = props.className, color = props.color, size = props.size, placeholder = props.placeholder, disabled = props.disabled, startIcon = props.startIcon, startLabel = props.startLabel, endLabel = props.endLabel, endIcon = props.endIcon, inputProps = props.inputProps, inputRef = props.inputRef, fullWidth = props.fullWidth, onChange = props.onChange, onClear = props.onClear, defaultValue = props.defaultValue, value = props.value, other = __rest(props, ["label", "hintText", "hintIcon", "className", "color", "size", "placeholder", "disabled", "startIcon", "startLabel", "endLabel", "endIcon", "inputProps", "inputRef", "fullWidth", "onChange", "onClear", "defaultValue", "value"]);
|
|
54
|
-
|
|
54
|
+
var _className = props.className, inputBaseProps = __rest(props, ["className"]);
|
|
55
|
+
return (_jsxs(InputWrapper, __assign({ className: props.className, size: props.size, fullWidth: props.fullWidth, ref: ref }, other, { children: [label ? (_jsxs(Label, __assign({ disabled: props.disabled }, { children: [label, " ", _jsx(InputBase, __assign({}, inputBaseProps))] }))) : (_jsx(InputBase, __assign({}, inputBaseProps))), hintText && (_jsxs(Hint, __assign({ color: props.color, disabled: props.disabled }, { children: [hintIcon, hintText] })))] })));
|
|
55
56
|
});
|
|
56
57
|
var InputWrapper = styled.span(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n display: inline-flex;\n flex-direction: column;\n gap: 8px;\n ", "\n ", "\n\n position: relative;\n"], ["\n display: inline-flex;\n flex-direction: column;\n gap: 8px;\n ", "\n ", "\n\n position: relative;\n"])), function (_a) {
|
|
57
58
|
var size = _a.size;
|
|
@@ -13,29 +13,45 @@ var __assign = (this && this.__assign) || function () {
|
|
|
13
13
|
};
|
|
14
14
|
return __assign.apply(this, arguments);
|
|
15
15
|
};
|
|
16
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
17
|
+
var t = {};
|
|
18
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
19
|
+
t[p] = s[p];
|
|
20
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
21
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
22
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
23
|
+
t[p[i]] = s[p[i]];
|
|
24
|
+
}
|
|
25
|
+
return t;
|
|
26
|
+
};
|
|
16
27
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
17
28
|
/** @jsxImportSource @emotion/react */
|
|
18
|
-
import
|
|
29
|
+
import { css } from "@emotion/react";
|
|
19
30
|
import { useContext } from "react";
|
|
20
31
|
import Button from "../../components/Button";
|
|
21
32
|
import shadows from "../../foundation/shadows";
|
|
22
33
|
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
34
|
+
import styled from "@emotion/styled";
|
|
23
35
|
/**
|
|
24
36
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
25
37
|
*/
|
|
26
38
|
export function SegmentedControlButton(props) {
|
|
39
|
+
var onClick = props.onClick, other = __rest(props, ["onClick"]);
|
|
27
40
|
var context = useContext(SegmentedControlGroupPropsContext);
|
|
28
|
-
var
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
41
|
+
var handleClick = function (e) {
|
|
42
|
+
var _a;
|
|
43
|
+
(_a = context.onClick) === null || _a === void 0 ? void 0 : _a.call(context, props.value);
|
|
44
|
+
onClick === null || onClick === void 0 ? void 0 : onClick(e);
|
|
45
|
+
};
|
|
46
|
+
var isActive = context.multiSelect
|
|
47
|
+
? context.value.includes(props.value)
|
|
48
|
+
: context.value === props.value;
|
|
49
|
+
return (_jsx(StyledButton, __assign({ css: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n ", "\n "], ["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n ", "\n "])), isActive && "box-shadow: ".concat(shadows.shadow04, ";")) }, props, { isActive: isActive, color: isActive ? "primary" : "textNeutral", size: context.size, onClick: handleClick })));
|
|
34
50
|
}
|
|
35
51
|
var StyledButton = styled(Button, {
|
|
36
52
|
shouldForwardProp: function (prop) { return prop !== "isActive"; },
|
|
37
|
-
})(
|
|
53
|
+
})(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n ", "\n"], ["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n ", "\n"])), function (_a) {
|
|
38
54
|
var isActive = _a.isActive;
|
|
39
55
|
return isActive && "box-shadow: ".concat(shadows.shadow04, ";");
|
|
40
56
|
});
|
|
41
|
-
var templateObject_1;
|
|
57
|
+
var templateObject_1, templateObject_2;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@team-monolith/cds",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
@@ -39,6 +39,7 @@
|
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"copyfiles": "^2.4.1"
|
|
42
|
+
"copyfiles": "^2.4.1",
|
|
43
|
+
"rimraf": "^5.0.1"
|
|
43
44
|
}
|
|
44
45
|
}
|
|
@@ -172,9 +172,6 @@ export interface ButtonOwnProps<RootComponentType extends React.ElementType> {
|
|
|
172
172
|
|
|
173
173
|
/** 컴포넌트 내 표기될 문자열 */
|
|
174
174
|
label: string;
|
|
175
|
-
|
|
176
|
-
/** 버튼 클릭 시 호출될 콜백 함수 */
|
|
177
|
-
onClick?: () => void;
|
|
178
175
|
}
|
|
179
176
|
|
|
180
177
|
export type ButtonProps<
|
|
@@ -210,7 +207,6 @@ const Button: ButtonComponent = React.forwardRef(function Button<
|
|
|
210
207
|
startIcon,
|
|
211
208
|
endIcon,
|
|
212
209
|
label,
|
|
213
|
-
onClick,
|
|
214
210
|
...other
|
|
215
211
|
} = props;
|
|
216
212
|
const theme = useTheme();
|
|
@@ -242,7 +238,6 @@ const Button: ButtonComponent = React.forwardRef(function Button<
|
|
|
242
238
|
SIZE_TO_BUTTON_STYLE[size],
|
|
243
239
|
]}
|
|
244
240
|
disabled={disabled}
|
|
245
|
-
onClick={onClick}
|
|
246
241
|
>
|
|
247
242
|
{startIcon}
|
|
248
243
|
<Label size={size}>{label}</Label>
|
|
@@ -104,6 +104,11 @@ const Input = React.forwardRef<any, InputProps>(
|
|
|
104
104
|
...other
|
|
105
105
|
} = props;
|
|
106
106
|
|
|
107
|
+
const {
|
|
108
|
+
className: _className,
|
|
109
|
+
...inputBaseProps
|
|
110
|
+
} = props;
|
|
111
|
+
|
|
107
112
|
return (
|
|
108
113
|
<InputWrapper
|
|
109
114
|
className={props.className}
|
|
@@ -114,10 +119,10 @@ const Input = React.forwardRef<any, InputProps>(
|
|
|
114
119
|
>
|
|
115
120
|
{label ? (
|
|
116
121
|
<Label disabled={props.disabled}>
|
|
117
|
-
{label} <InputBase {...
|
|
122
|
+
{label} <InputBase {...inputBaseProps} />
|
|
118
123
|
</Label>
|
|
119
124
|
) : (
|
|
120
|
-
<InputBase {...
|
|
125
|
+
<InputBase {...inputBaseProps} />
|
|
121
126
|
)}
|
|
122
127
|
{hintText && (
|
|
123
128
|
<Hint color={props.color} disabled={props.disabled}>
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
/** @jsxImportSource @emotion/react */
|
|
2
|
-
import
|
|
2
|
+
import { css } from "@emotion/react";
|
|
3
3
|
import { useContext } from "react";
|
|
4
4
|
import Button, { ButtonProps } from "../../components/Button";
|
|
5
5
|
import shadows from "../../foundation/shadows";
|
|
6
6
|
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
7
|
+
import styled from "@emotion/styled";
|
|
7
8
|
|
|
8
|
-
export interface SegmentedControlButtonProps
|
|
9
|
+
export interface SegmentedControlButtonProps
|
|
10
|
+
extends Omit<ButtonProps, "color" | "size"> {
|
|
9
11
|
value: string;
|
|
10
12
|
}
|
|
11
13
|
|
|
@@ -13,20 +15,32 @@ export interface SegmentedControlButtonProps extends Omit<ButtonProps, "color" |
|
|
|
13
15
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
14
16
|
*/
|
|
15
17
|
export function SegmentedControlButton(props: SegmentedControlButtonProps) {
|
|
18
|
+
const { onClick, ...other } = props;
|
|
19
|
+
|
|
16
20
|
const context = useContext(SegmentedControlGroupPropsContext);
|
|
17
21
|
|
|
18
|
-
const
|
|
22
|
+
const handleClick: React.MouseEventHandler<HTMLButtonElement> = (e) => {
|
|
23
|
+
context.onClick?.(props.value);
|
|
24
|
+
onClick?.(e);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
const isActive = context.multiSelect
|
|
28
|
+
? context.value.includes(props.value)
|
|
29
|
+
: context.value === props.value;
|
|
19
30
|
|
|
20
31
|
return (
|
|
21
32
|
<StyledButton
|
|
33
|
+
css={css`
|
|
34
|
+
display: flex;
|
|
35
|
+
justify-content: center;
|
|
36
|
+
flex-grow: 1;
|
|
37
|
+
${isActive && `box-shadow: ${shadows.shadow04};`}
|
|
38
|
+
`}
|
|
22
39
|
{...props}
|
|
23
40
|
isActive={isActive}
|
|
24
41
|
color={isActive ? "primary" : "textNeutral"}
|
|
25
42
|
size={context.size}
|
|
26
|
-
onClick={
|
|
27
|
-
context.onClick?.(props.value);
|
|
28
|
-
props.onClick?.();
|
|
29
|
-
}}
|
|
43
|
+
onClick={handleClick}
|
|
30
44
|
/>
|
|
31
45
|
);
|
|
32
46
|
}
|
|
@@ -38,4 +52,4 @@ const StyledButton = styled(Button, {
|
|
|
38
52
|
justify-content: center;
|
|
39
53
|
flex-grow: 1;
|
|
40
54
|
${({ isActive }) => isActive && `box-shadow: ${shadows.shadow04};`}
|
|
41
|
-
`;
|
|
55
|
+
`;
|