@team-monolith/cds 1.54.0 → 1.54.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.
package/dist/index.d.ts CHANGED
@@ -43,4 +43,4 @@ export * from "./patterns/Dropdown";
43
43
  export * from "./patterns/SegmentedControl";
44
44
  export * from "./patterns/LexicalEditor";
45
45
  export * from "./patterns/Accordion";
46
- export * from "./patterns/NestedSwitchButton";
46
+ export * from "./patterns/ToggleButtonGroup";
package/dist/index.js CHANGED
@@ -43,4 +43,4 @@ export * from "./patterns/Dropdown";
43
43
  export * from "./patterns/SegmentedControl";
44
44
  export * from "./patterns/LexicalEditor";
45
45
  export * from "./patterns/Accordion";
46
- export * from "./patterns/NestedSwitchButton";
46
+ export * from "./patterns/ToggleButtonGroup";
@@ -1,7 +1,7 @@
1
- import { SwitchButtonDatum } from "./NestedSwitchButton";
2
- /** 하나의 SwitchButton을 그립니다. */
3
- export declare function SwitchButton(props: {
4
- datum: SwitchButtonDatum;
1
+ import { ToggleButtonDatum } from "./ToggleButtonGroup";
2
+ /** 하나의 ToggleButton을 그립니다. */
3
+ export declare function ToggleButton(props: {
4
+ datum: ToggleButtonDatum;
5
5
  /** tooltip의 placement */
6
6
  placement: "bottom-start" | "bottom" | "bottom-end";
7
7
  isActive: boolean;
@@ -2,15 +2,15 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
2
  import styled from "@emotion/styled";
3
3
  import { HOVER, Tooltip } from "../..";
4
4
  import { css } from "@emotion/react";
5
- import { NestedSwitchButtonClasses, } from "./NestedSwitchButton";
6
- /** 하나의 SwitchButton을 그립니다. */
7
- export function SwitchButton(props) {
5
+ import { toggleButtonGroupClasses, } from "./ToggleButtonGroup";
6
+ /** 하나의 ToggleButton을 그립니다. */
7
+ export function ToggleButton(props) {
8
8
  const { datum, placement, isActive, onClick } = props;
9
9
  const { label, onIcon, offIcon } = datum;
10
10
  if (isActive) {
11
- return (_jsxs(Active, Object.assign({ className: NestedSwitchButtonClasses.switchButton.active, onClick: onClick }, { children: [onIcon, label] })));
11
+ return (_jsxs(Active, Object.assign({ className: toggleButtonGroupClasses.toggleButton.active, onClick: onClick }, { children: [onIcon, label] })));
12
12
  }
13
- return (_jsx(Tooltip, Object.assign({ placement: placement, text: label }, { children: _jsx(Inactive, Object.assign({ className: NestedSwitchButtonClasses.switchButton.inactive, onClick: onClick }, { children: offIcon })) })));
13
+ return (_jsx(Tooltip, Object.assign({ placement: placement, text: label }, { children: _jsx(Inactive, Object.assign({ className: toggleButtonGroupClasses.toggleButton.inactive, onClick: onClick }, { children: offIcon })) })));
14
14
  }
15
15
  const Active = styled.div(({ theme }) => css `
16
16
  cursor: pointer;
@@ -0,0 +1,29 @@
1
+ /// <reference types="react" />
2
+ export declare const toggleButtonGroupClasses: {
3
+ readonly container: "ToggleButtonGroup-container";
4
+ readonly toggleButton: {
5
+ readonly active: "ToggleButtonGroup-ToggleButton-active";
6
+ readonly inactive: "ToggleButtonGroup-ToggleButton-inactive";
7
+ };
8
+ };
9
+ export interface ToggleButtonDatum {
10
+ /** ToggleButton의 레이블. 호버시 툴팁 또는 활성화시 나타납니다. */
11
+ label: React.ReactNode;
12
+ /** on 일때의 아이콘. 내부에서 사이즈가 24x24로 조정됩니다. */
13
+ onIcon: React.ReactNode;
14
+ /** off 일때의 아이콘. 내부에서 사이즈가 24x24로 조정됩니다.*/
15
+ offIcon: React.ReactNode;
16
+ }
17
+ /** n개의 toggleButton이 모여있는 형태를 나타내는 컴포넌트입니다.
18
+ * 동작은 SegmentedControl과 비슷합니다.
19
+ * 렉시컬 블록으로 활용하기 위해 선택된 버튼의 인덱스 상태를 외부에서 관리합니다.
20
+ */
21
+ export declare function ToggleButtonGroup(props: {
22
+ className?: string;
23
+ /** ToggleButton의 데이터 배열 */
24
+ data: ToggleButtonDatum[];
25
+ /** 활성화될 ToggleButton의 index */
26
+ activeIndex: number | null;
27
+ /** activeIndex set 함수 */
28
+ setActiveIndex: (index: number | null) => void;
29
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,42 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import styled from "@emotion/styled";
3
+ import { ToggleButton } from "./ToggleButton";
4
+ export const toggleButtonGroupClasses = {
5
+ container: "ToggleButtonGroup-container",
6
+ toggleButton: {
7
+ active: "ToggleButtonGroup-ToggleButton-active",
8
+ inactive: "ToggleButtonGroup-ToggleButton-inactive",
9
+ },
10
+ };
11
+ /** n개의 toggleButton이 모여있는 형태를 나타내는 컴포넌트입니다.
12
+ * 동작은 SegmentedControl과 비슷합니다.
13
+ * 렉시컬 블록으로 활용하기 위해 선택된 버튼의 인덱스 상태를 외부에서 관리합니다.
14
+ */
15
+ export function ToggleButtonGroup(props) {
16
+ const { className, data, activeIndex, setActiveIndex } = props;
17
+ return (_jsx(Container, Object.assign({ className: `${className} ${toggleButtonGroupClasses.container}` }, { children: data.map((datum, index) => {
18
+ const isFirst = index === 0;
19
+ const isLast = index === data.length - 1;
20
+ const isFirstAndLast = isFirst && isLast;
21
+ const isActive = activeIndex === index;
22
+ return (_jsx(ToggleButton, { isActive: isActive, onClick: () => {
23
+ setActiveIndex(isActive ? null : index);
24
+ }, datum: datum, placement: isFirstAndLast
25
+ ? "bottom"
26
+ : isFirst
27
+ ? "bottom-start"
28
+ : isLast
29
+ ? "bottom-end"
30
+ : "bottom" }, index));
31
+ }) })));
32
+ }
33
+ const Container = styled.div `
34
+ display: flex;
35
+ padding: 4px;
36
+ justify-content: space-between;
37
+ align-items: center;
38
+ flex: 1 0 0;
39
+
40
+ border-radius: 24px;
41
+ background: linear-gradient(90deg, #eff7ed 0%, #faefe3 100%);
42
+ `;
@@ -0,0 +1 @@
1
+ export * from "./ToggleButtonGroup";
@@ -0,0 +1 @@
1
+ export * from "./ToggleButtonGroup";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@team-monolith/cds",
3
- "version": "1.54.0",
3
+ "version": "1.54.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "sideEffects": false,
@@ -1,29 +0,0 @@
1
- /// <reference types="react" />
2
- export declare const NestedSwitchButtonClasses: {
3
- readonly container: "NestedSwitchButton-container";
4
- readonly switchButton: {
5
- readonly active: "NestedSwitchButton-SwitchButton-active";
6
- readonly inactive: "NestedSwitchButton-SwitchButton-inactive";
7
- };
8
- };
9
- export interface SwitchButtonDatum {
10
- /** SwitchButton의 레이블. 호버시 툴팁 또는 활성화시 나타납니다. */
11
- label: React.ReactNode;
12
- /** on 일때의 아이콘. 내부에서 사이즈가 24x24로 조정됩니다. */
13
- onIcon: React.ReactNode;
14
- /** off 일때의 아이콘. 내부에서 사이즈가 24x24로 조정됩니다.*/
15
- offIcon: React.ReactNode;
16
- }
17
- /** n개의 SwitchButton이 모여있는 형태를 나타내는 컴포넌트입니다.
18
- * 동작은 SegmentedControl과 비슷합니다.
19
- * components/SwitchButton과는 관련이 없습니다.
20
- */
21
- export declare function NestedSwitchButton(props: {
22
- className?: string;
23
- /** SwitchButton의 데이터 배열 */
24
- data: SwitchButtonDatum[];
25
- /** 활성화될 SwitchButton의 index */
26
- activeIndex: number | null;
27
- /** activeIndex set 함수 */
28
- setActiveIndex: (index: number | null) => void;
29
- }): import("react/jsx-runtime").JSX.Element;
@@ -1,44 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { css } from "@emotion/react";
3
- import styled from "@emotion/styled";
4
- import { SwitchButton } from "./SwitchButton";
5
- export const NestedSwitchButtonClasses = {
6
- container: "NestedSwitchButton-container",
7
- switchButton: {
8
- active: "NestedSwitchButton-SwitchButton-active",
9
- inactive: "NestedSwitchButton-SwitchButton-inactive",
10
- },
11
- };
12
- /** n개의 SwitchButton이 모여있는 형태를 나타내는 컴포넌트입니다.
13
- * 동작은 SegmentedControl과 비슷합니다.
14
- * components/SwitchButton과는 관련이 없습니다.
15
- */
16
- export function NestedSwitchButton(props) {
17
- const { className, data, activeIndex, setActiveIndex } = props;
18
- return (_jsx(Container, Object.assign({ className: `${className} ${NestedSwitchButtonClasses.container}` }, { children: data.map((datum, index) => {
19
- const isFirst = index === 0;
20
- const isLast = index === data.length - 1;
21
- const isFirstAndLast = isFirst && isLast;
22
- const isActive = activeIndex === index;
23
- return (_jsx(SwitchButton, { isActive: isActive, onClick: () => {
24
- setActiveIndex(isActive ? null : index);
25
- }, datum: datum, placement: isFirstAndLast
26
- ? "bottom"
27
- : isFirst
28
- ? "bottom-start"
29
- : isLast
30
- ? "bottom-end"
31
- : "bottom" }, index));
32
- }) })));
33
- }
34
- const Container = styled.div(({ theme }) => css `
35
- display: flex;
36
- padding: 4px;
37
- justify-content: space-between;
38
- align-items: center;
39
- flex: 1 0 0;
40
-
41
- border-radius: 24px;
42
- // fixme: 이 배경색이 의도가 맞는지 확인해야 합니다.
43
- background: linear-gradient(90deg, #eff7ed 0%, #faefe3 100%);
44
- `);
@@ -1 +0,0 @@
1
- export * from "./NestedSwitchButton";
@@ -1 +0,0 @@
1
- export * from "./NestedSwitchButton";