@team-monolith/cds 1.28.1 → 1.29.0
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.js +1 -1
- package/dist/patterns/SegmentedControl/SegmentedControlButton.d.ts +10 -4
- package/dist/patterns/SegmentedControl/SegmentedControlButton.js +3 -1
- package/dist/patterns/SegmentedControl/SegmentedControlGroup.d.ts +8 -6
- package/dist/patterns/SegmentedControl/SegmentedControlGroup.js +6 -3
- package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.d.ts +4 -3
- package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.js +1 -0
- package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.d.ts +9 -4
- package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.js +3 -1
- package/package.json +1 -1
|
@@ -229,7 +229,7 @@ const Button = React.forwardRef(function Button(props, ref) {
|
|
|
229
229
|
`,
|
|
230
230
|
COLOR_TO_BUTTON_STYLE(theme, color, Boolean(disabled)),
|
|
231
231
|
SIZE_TO_BUTTON_STYLE[size],
|
|
232
|
-
], disabled: disabled }, { children: [startIcon, _jsx(Label, Object.assign({ size: size, bold: bold }, { children: label })), endIcon] })));
|
|
232
|
+
], disabled: disabled }, { children: [startIcon, label && (_jsx(Label, Object.assign({ size: size, bold: bold }, { children: label }))), endIcon] })));
|
|
233
233
|
});
|
|
234
234
|
const Label = styled.span `
|
|
235
235
|
font-weight: ${({ bold }) => (bold ? 700 : 400)};
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ButtonProps } from "../..";
|
|
3
|
-
export
|
|
4
|
-
value:
|
|
3
|
+
export type SegmentedControlButtonProps<T> = Omit<ButtonProps, "color" | "size" | "startIcon" | "endIcon" | "value"> & {
|
|
4
|
+
value: T;
|
|
5
5
|
startIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
|
|
6
6
|
endIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
|
|
7
|
-
}
|
|
7
|
+
};
|
|
8
8
|
/**
|
|
9
9
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
10
10
|
*/
|
|
11
|
-
export declare const SegmentedControlButton:
|
|
11
|
+
export declare const SegmentedControlButton: <T>(props: Omit<ButtonProps<"button">, "color" | "value" | "size" | "startIcon" | "endIcon"> & {
|
|
12
|
+
value: T;
|
|
13
|
+
startIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
|
|
14
|
+
endIcon?: React.ReactNode | ((isActive: boolean) => React.ReactNode);
|
|
15
|
+
} & {
|
|
16
|
+
ref?: React.ComponentPropsWithRef<"button">["ref"];
|
|
17
|
+
}) => React.ReactElement;
|
|
@@ -14,11 +14,13 @@ import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
|
14
14
|
import styled from "@emotion/styled";
|
|
15
15
|
import { css } from "@emotion/react";
|
|
16
16
|
import React, { useContext } from "react";
|
|
17
|
-
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
17
|
+
import { SegmentedControlGroupPropsContext, } from "./SegmentedControlGroupPropsContext";
|
|
18
18
|
import { Button, shadows } from "../..";
|
|
19
19
|
/**
|
|
20
20
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
21
21
|
*/
|
|
22
|
+
// https://fettblog.eu/typescript-react-generic-forward-refs/
|
|
23
|
+
// type assertion
|
|
22
24
|
export const SegmentedControlButton = React.forwardRef(function SegmentedControlButton(props, ref) {
|
|
23
25
|
const { onClick, startIcon, endIcon } = props, other = __rest(props, ["onClick", "startIcon", "endIcon"]);
|
|
24
26
|
const context = useContext(SegmentedControlGroupPropsContext);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ButtonSize, SquareButtonSize } from "../..";
|
|
2
2
|
import React from "react";
|
|
3
|
-
export type SegmentedControlGroupProps = {
|
|
3
|
+
export type SegmentedControlGroupProps<T = string> = {
|
|
4
4
|
className?: string;
|
|
5
5
|
component?: React.ElementType;
|
|
6
6
|
children?: React.ReactNode;
|
|
@@ -14,14 +14,16 @@ export type SegmentedControlGroupProps = {
|
|
|
14
14
|
/** 중복 선택 가능 유무 */
|
|
15
15
|
multiSelect?: false;
|
|
16
16
|
/** 선택된 값 */
|
|
17
|
-
value:
|
|
18
|
-
onChange?: (newValue:
|
|
17
|
+
value: T | undefined;
|
|
18
|
+
onChange?: (newValue: T) => void;
|
|
19
19
|
} | {
|
|
20
20
|
multiSelect: true;
|
|
21
|
-
value:
|
|
22
|
-
onChange?: (newValue:
|
|
21
|
+
value: T[];
|
|
22
|
+
onChange?: (newValue: T[]) => void;
|
|
23
23
|
});
|
|
24
24
|
/**
|
|
25
25
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
26
26
|
*/
|
|
27
|
-
export declare const SegmentedControlGroup:
|
|
27
|
+
export declare const SegmentedControlGroup: <T>(props: SegmentedControlGroupProps<T> & {
|
|
28
|
+
ref?: React.ComponentPropsWithRef<"div">["ref"];
|
|
29
|
+
}) => React.ReactElement;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
2
2
|
/** @jsxImportSource @emotion/react */
|
|
3
3
|
import { css, useTheme } from "@emotion/react";
|
|
4
|
-
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
4
|
+
import { SegmentedControlGroupPropsContext, } from "./SegmentedControlGroupPropsContext";
|
|
5
5
|
import React from "react";
|
|
6
6
|
/**
|
|
7
7
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
8
8
|
*/
|
|
9
|
+
// https://fettblog.eu/typescript-react-generic-forward-refs/
|
|
10
|
+
// type assertion
|
|
9
11
|
export const SegmentedControlGroup = React.forwardRef(function SegmentedControlGroup(props, ref) {
|
|
10
|
-
const { component: Component = "div", className, children, fullWidth,
|
|
12
|
+
const { component: Component = "div", className, children, fullWidth, multiSelect, } = props;
|
|
11
13
|
const theme = useTheme();
|
|
14
|
+
const Context = SegmentedControlGroupPropsContext;
|
|
12
15
|
return (_jsx(Component, Object.assign({ ref: ref, className: className, css: css `
|
|
13
16
|
display: flex;
|
|
14
17
|
padding: 4px;
|
|
@@ -17,7 +20,7 @@ export const SegmentedControlGroup = React.forwardRef(function SegmentedControlG
|
|
|
17
20
|
background-color: ${theme.color.background.neutralAlt};
|
|
18
21
|
border-radius: 8px;
|
|
19
22
|
border: 1px solid ${theme.color.background.neutralAltActive};
|
|
20
|
-
` }, { children: _jsx(
|
|
23
|
+
` }, { children: _jsx(Context.Provider, Object.assign({ value: Object.assign(Object.assign({}, props), { onClick: (newValue) => {
|
|
21
24
|
var _a, _b, _c;
|
|
22
25
|
if (multiSelect) {
|
|
23
26
|
if (props.value.includes(newValue)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SegmentedControlGroupProps } from "./SegmentedControlGroup";
|
|
3
|
-
export
|
|
4
|
-
onClick?: (
|
|
5
|
-
}
|
|
3
|
+
export type SegmentedControlGroupPropsContextType<T> = SegmentedControlGroupProps<T> & {
|
|
4
|
+
onClick?: (newValue: T) => void;
|
|
5
|
+
};
|
|
6
|
+
export declare const SegmentedControlGroupPropsContext: import("react").Context<SegmentedControlGroupPropsContextType<any>>;
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { SquareButtonProps } from "../..";
|
|
3
|
-
export
|
|
4
|
-
value:
|
|
3
|
+
export type SegmentedControlSquareButtonProps<T> = Omit<SquareButtonProps, "color" | "size" | "icon"> & {
|
|
4
|
+
value: T;
|
|
5
5
|
icon: React.ReactNode | ((isActive: boolean) => React.ReactNode);
|
|
6
|
-
}
|
|
6
|
+
};
|
|
7
7
|
/**
|
|
8
8
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
9
9
|
*/
|
|
10
|
-
export declare const SegmentedControlSquareButton:
|
|
10
|
+
export declare const SegmentedControlSquareButton: <T>(props: Omit<SquareButtonProps<"span">, "color" | "icon" | "size"> & {
|
|
11
|
+
value: T;
|
|
12
|
+
icon: React.ReactNode | ((isActive: boolean) => React.ReactNode);
|
|
13
|
+
} & {
|
|
14
|
+
ref?: React.ComponentPropsWithRef<"button">["ref"];
|
|
15
|
+
}) => React.ReactElement;
|
|
@@ -15,10 +15,12 @@ import styled from "@emotion/styled";
|
|
|
15
15
|
import { css } from "@emotion/react";
|
|
16
16
|
import React, { useContext } from "react";
|
|
17
17
|
import { shadows, SquareButton } from "../..";
|
|
18
|
-
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
18
|
+
import { SegmentedControlGroupPropsContext, } from "./SegmentedControlGroupPropsContext";
|
|
19
19
|
/**
|
|
20
20
|
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
21
21
|
*/
|
|
22
|
+
// https://fettblog.eu/typescript-react-generic-forward-refs/
|
|
23
|
+
// type assertion
|
|
22
24
|
export const SegmentedControlSquareButton = React.forwardRef(function SegmentedControlSquareButton(props, ref) {
|
|
23
25
|
const { onClick, icon } = props, other = __rest(props, ["onClick", "icon"]);
|
|
24
26
|
const context = useContext(SegmentedControlGroupPropsContext);
|