@team-monolith/cds 0.1.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/README.md +46 -0
- package/dist/CodleDesignSystemProvider.d.ts +5 -0
- package/dist/CodleDesignSystemProvider.js +96 -0
- package/dist/components/AlertDialog/AlertDialog.d.ts +14 -0
- package/dist/components/AlertDialog/AlertDialog.js +45 -0
- package/dist/components/AlertDialog/AlertDialogActions.d.ts +8 -0
- package/dist/components/AlertDialog/AlertDialogActions.js +35 -0
- package/dist/components/AlertDialog/AlertDialogContent.d.ts +8 -0
- package/dist/components/AlertDialog/AlertDialogContent.js +36 -0
- package/dist/components/AlertDialog/AlertDialogTitle.d.ts +13 -0
- package/dist/components/AlertDialog/AlertDialogTitle.js +38 -0
- package/dist/components/AlertDialog/index.d.ts +4 -0
- package/dist/components/AlertDialog/index.js +4 -0
- package/dist/components/Banner.d.ts +29 -0
- package/dist/components/Banner.js +65 -0
- package/dist/components/Button.d.ts +26 -0
- package/dist/components/Button.js +72 -0
- package/dist/components/CheckboxInput.d.ts +27 -0
- package/dist/components/CheckboxInput.js +77 -0
- package/dist/components/Input.d.ts +17 -0
- package/dist/components/Input.js +72 -0
- package/dist/components/InputBase.d.ts +42 -0
- package/dist/components/InputBase.js +52 -0
- package/dist/components/Pagination.d.ts +27 -0
- package/dist/components/Pagination.js +32 -0
- package/dist/components/PinInput.d.ts +36 -0
- package/dist/components/PinInput.js +154 -0
- package/dist/components/RadioInput.d.ts +23 -0
- package/dist/components/RadioInput.js +78 -0
- package/dist/components/SquareButton.d.ts +26 -0
- package/dist/components/SquareButton.js +80 -0
- package/dist/components/Switch.d.ts +19 -0
- package/dist/components/Switch.js +59 -0
- package/dist/components/Tag.d.ts +21 -0
- package/dist/components/Tag.js +61 -0
- package/dist/components/Tooltip.d.ts +26 -0
- package/dist/components/Tooltip.js +50 -0
- package/dist/foundation/color.d.ts +75 -0
- package/dist/foundation/color.js +75 -0
- package/dist/foundation/shadows.d.ts +9 -0
- package/dist/foundation/shadows.js +10 -0
- package/dist/icons/arrows.d.ts +16 -0
- package/dist/icons/arrows.js +17 -0
- package/dist/icons/brand.d.ts +4 -0
- package/dist/icons/brand.js +13 -0
- package/dist/icons/map.d.ts +4 -0
- package/dist/icons/map.js +13 -0
- package/dist/icons/system.d.ts +25 -0
- package/dist/icons/system.js +20 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/patterns/Dropdown/Dropdown.d.ts +27 -0
- package/dist/patterns/Dropdown/Dropdown.js +41 -0
- package/dist/patterns/Dropdown/DropdownItem.d.ts +42 -0
- package/dist/patterns/Dropdown/DropdownItem.js +89 -0
- package/dist/patterns/Dropdown/DropdownMenu.d.ts +30 -0
- package/dist/patterns/Dropdown/DropdownMenu.js +85 -0
- package/dist/patterns/Dropdown/index.d.ts +2 -0
- package/dist/patterns/Dropdown/index.js +2 -0
- package/dist/patterns/EmptyState/EmptyState.d.ts +16 -0
- package/dist/patterns/EmptyState/EmptyState.js +36 -0
- package/dist/patterns/EmptyState/index.d.ts +2 -0
- package/dist/patterns/EmptyState/index.js +2 -0
- package/dist/patterns/Grid/EnhancedTableCell.d.ts +9 -0
- package/dist/patterns/Grid/EnhancedTableCell.js +122 -0
- package/dist/patterns/Grid/Grid.d.ts +51 -0
- package/dist/patterns/Grid/Grid.js +140 -0
- package/dist/patterns/Grid/index.d.ts +3 -0
- package/dist/patterns/Grid/index.js +2 -0
- package/dist/patterns/SegmentedControl/SegmentedControlButton.d.ts +8 -0
- package/dist/patterns/SegmentedControl/SegmentedControlButton.js +41 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroup.d.ts +26 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroup.js +50 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.d.ts +5 -0
- package/dist/patterns/SegmentedControl/SegmentedControlGroupPropsContext.js +5 -0
- package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.d.ts +8 -0
- package/dist/patterns/SegmentedControl/SegmentedControlSquareButton.js +45 -0
- package/dist/patterns/SegmentedControl/index.d.ts +3 -0
- package/dist/patterns/SegmentedControl/index.js +3 -0
- package/dist/patterns/Table/Table.d.ts +16 -0
- package/dist/patterns/Table/Table.js +33 -0
- package/dist/patterns/Table/TableBody.d.ts +8 -0
- package/dist/patterns/Table/TableBody.js +26 -0
- package/dist/patterns/Table/TableCell.d.ts +15 -0
- package/dist/patterns/Table/TableCell.js +78 -0
- package/dist/patterns/Table/TableHead.d.ts +8 -0
- package/dist/patterns/Table/TableHead.js +26 -0
- package/dist/patterns/Table/TableRow.d.ts +12 -0
- package/dist/patterns/Table/TableRow.js +29 -0
- package/dist/patterns/Table/TableSizeContext.d.ts +7 -0
- package/dist/patterns/Table/TableSizeContext.js +3 -0
- package/dist/patterns/Table/TableVariantContext.d.ts +6 -0
- package/dist/patterns/Table/TableVariantContext.js +3 -0
- package/dist/patterns/Table/index.d.ts +7 -0
- package/dist/patterns/Table/index.js +6 -0
- package/dist/utils/hover.d.ts +3 -0
- package/dist/utils/hover.js +14 -0
- package/dist/utils/reset.d.ts +2 -0
- package/dist/utils/reset.js +8 -0
- package/dist/utils/zIndex.d.ts +3 -0
- package/dist/utils/zIndex.js +3 -0
- package/package.json +52 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +43 -0
- package/public/logo192.png +0 -0
- package/public/logo512.png +0 -0
- package/public/manifest.json +25 -0
- package/public/robots.txt +3 -0
- package/src/App.tsx +7 -0
- package/src/cds/CodleDesignSystemProvider.tsx +93 -0
- package/src/cds/README.md +23 -0
- package/src/cds/components/AlertDialog/AlertDialog.tsx +101 -0
- package/src/cds/components/AlertDialog/AlertDialogActions.tsx +34 -0
- package/src/cds/components/AlertDialog/AlertDialogContent.tsx +38 -0
- package/src/cds/components/AlertDialog/AlertDialogTitle.tsx +63 -0
- package/src/cds/components/AlertDialog/index.tsx +4 -0
- package/src/cds/components/Banner.tsx +176 -0
- package/src/cds/components/Button.tsx +239 -0
- package/src/cds/components/CheckboxInput.tsx +270 -0
- package/src/cds/components/Input.tsx +166 -0
- package/src/cds/components/InputBase.tsx +226 -0
- package/src/cds/components/Pagination.tsx +99 -0
- package/src/cds/components/PinInput.tsx +322 -0
- package/src/cds/components/RadioInput.tsx +226 -0
- package/src/cds/components/SquareButton.tsx +229 -0
- package/src/cds/components/Switch.tsx +129 -0
- package/src/cds/components/Tag.tsx +155 -0
- package/src/cds/components/Tooltip.tsx +104 -0
- package/src/cds/emotion.d.ts +70 -0
- package/src/cds/foundation/color.ts +83 -0
- package/src/cds/foundation/shadows.ts +17 -0
- package/src/cds/icons/arrows.tsx +61 -0
- package/src/cds/icons/brand.tsx +13 -0
- package/src/cds/icons/map.tsx +14 -0
- package/src/cds/icons/system.tsx +113 -0
- package/src/cds/index.ts +3 -0
- package/src/cds/patterns/Dropdown/Dropdown.tsx +111 -0
- package/src/cds/patterns/Dropdown/DropdownItem.tsx +203 -0
- package/src/cds/patterns/Dropdown/DropdownMenu.tsx +176 -0
- package/src/cds/patterns/Dropdown/index.tsx +2 -0
- package/src/cds/patterns/EmptyState/EmptyState.tsx +91 -0
- package/src/cds/patterns/EmptyState/empty-state-icon.svg +36 -0
- package/src/cds/patterns/EmptyState/index.tsx +2 -0
- package/src/cds/patterns/Grid/EnhancedTableCell.tsx +180 -0
- package/src/cds/patterns/Grid/Grid.tsx +360 -0
- package/src/cds/patterns/Grid/index.tsx +4 -0
- package/src/cds/patterns/SegmentedControl/SegmentedControlButton.tsx +41 -0
- package/src/cds/patterns/SegmentedControl/SegmentedControlGroup.tsx +81 -0
- package/src/cds/patterns/SegmentedControl/SegmentedControlGroupPropsContext.tsx +9 -0
- package/src/cds/patterns/SegmentedControl/SegmentedControlSquareButton.tsx +51 -0
- package/src/cds/patterns/SegmentedControl/index.ts +3 -0
- package/src/cds/patterns/Table/Table.tsx +56 -0
- package/src/cds/patterns/Table/TableBody.tsx +30 -0
- package/src/cds/patterns/Table/TableCell.tsx +242 -0
- package/src/cds/patterns/Table/TableHead.tsx +30 -0
- package/src/cds/patterns/Table/TableRow.tsx +54 -0
- package/src/cds/patterns/Table/TableSizeContext.tsx +10 -0
- package/src/cds/patterns/Table/TableVariantContext.tsx +9 -0
- package/src/cds/patterns/Table/index.tsx +15 -0
- package/src/cds/utils/hover.tsx +24 -0
- package/src/cds/utils/reset.tsx +19 -0
- package/src/cds/utils/zIndex.tsx +3 -0
- package/src/index.tsx +10 -0
- package/src/react-app-env.d.ts +1 -0
- package/tsconfig.json +22 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "@emotion/react/jsx-runtime";
|
|
17
|
+
/** @jsxImportSource @emotion/react */
|
|
18
|
+
import { flexRender, } from "@tanstack/react-table";
|
|
19
|
+
import { useRef, useState } from "react";
|
|
20
|
+
import { css } from "@emotion/react";
|
|
21
|
+
import DropdownMenu from "../Dropdown/DropdownMenu";
|
|
22
|
+
import { TableCell } from "../Table";
|
|
23
|
+
import styled from "@emotion/styled";
|
|
24
|
+
// 두 Set의 합집합을 구하는 함수
|
|
25
|
+
function union(setA, setB) {
|
|
26
|
+
var _union = new Set(setA);
|
|
27
|
+
setB.forEach(function (elem) {
|
|
28
|
+
_union.add(elem);
|
|
29
|
+
});
|
|
30
|
+
return _union;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Sort, Filter, Resize 등의 기능이 추가된 Cell입니다.
|
|
34
|
+
*/
|
|
35
|
+
export default function EnhancedTableCell(props) {
|
|
36
|
+
var _a;
|
|
37
|
+
var table = props.table, header = props.header;
|
|
38
|
+
var _b = useState(false), open = _b[0], setOpen = _b[1];
|
|
39
|
+
var menuRef = useRef(null);
|
|
40
|
+
var filterDropdownMenu = null;
|
|
41
|
+
if (header.column.getCanFilter()) {
|
|
42
|
+
// 필터 내의 드롭다운 메뉴 아이템 정렬에서 사용할 firstValue 값
|
|
43
|
+
// 이 값이 number 타입인지, string 타입인지에 따라 아이템 정렬 함수를 다르게 설정합니다.
|
|
44
|
+
var firstValue = (_a = table
|
|
45
|
+
.getPreFilteredRowModel()
|
|
46
|
+
.flatRows[0]) === null || _a === void 0 ? void 0 : _a.getValue(header.column.id);
|
|
47
|
+
// 한 열에서 중복값이 제거된 고유값들을 받아옵니다.
|
|
48
|
+
var uniqueValues = header.column.getFacetedUniqueValues().keys();
|
|
49
|
+
var currentFilterValue_1 = header.column.getFilterValue();
|
|
50
|
+
// 열의 고유값의 배열과 현재 필터가 걸려있는 값의 배열들을 합집합시킵니다.
|
|
51
|
+
var filterMenuValues = Array.from(union(new Set(uniqueValues), currentFilterValue_1 !== null && currentFilterValue_1 !== void 0 ? currentFilterValue_1 : new Set()));
|
|
52
|
+
// 타입에 따라서 필터 메뉴를 오름차순 정렬합니다.
|
|
53
|
+
var sortedFilterMenuValues = typeof firstValue === "number"
|
|
54
|
+
? filterMenuValues.sort(function (a, b) { return Number(a) - Number(b); })
|
|
55
|
+
: filterMenuValues.sort();
|
|
56
|
+
/**
|
|
57
|
+
* val 값에 해당하는 필터를 토글하는 함수
|
|
58
|
+
* 모든 값이 해제되었을때, 빈 배열이 아닌 undefined 값을 필터 값으로 설정하여야
|
|
59
|
+
* 필터가 정상적으로 해제됩니다.
|
|
60
|
+
*/
|
|
61
|
+
var toggleFilterValue_1 = function (val) {
|
|
62
|
+
if (currentFilterValue_1 === null || currentFilterValue_1 === void 0 ? void 0 : currentFilterValue_1.has(val)) {
|
|
63
|
+
header.column.setFilterValue(function (old) {
|
|
64
|
+
if (!old) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
var newFilterValue = new Set(old);
|
|
68
|
+
newFilterValue.delete(val);
|
|
69
|
+
if (newFilterValue.size === 0) {
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
return newFilterValue;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
header.column.setFilterValue(function (old) {
|
|
79
|
+
if (!old) {
|
|
80
|
+
return new Set().add(val);
|
|
81
|
+
}
|
|
82
|
+
return new Set(old).add(val);
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
filterDropdownMenu = (_jsx(DropdownMenu, { itemsProps: sortedFilterMenuValues.map(function (val) {
|
|
87
|
+
var _a;
|
|
88
|
+
return ({
|
|
89
|
+
label: val,
|
|
90
|
+
checkbox: true,
|
|
91
|
+
checkboxProps: {
|
|
92
|
+
checked: (_a = currentFilterValue_1 === null || currentFilterValue_1 === void 0 ? void 0 : currentFilterValue_1.has(val)) !== null && _a !== void 0 ? _a : false,
|
|
93
|
+
onChange: function (event) { return toggleFilterValue_1(val); },
|
|
94
|
+
},
|
|
95
|
+
onClick: function () { return toggleFilterValue_1(val); },
|
|
96
|
+
});
|
|
97
|
+
}), open: open, anchorEl: menuRef.current, anchorOrigin: { vertical: "bottom", horizontal: "right" }, transformOrigin: { vertical: "top", horizontal: "right" }, onClose: function () { return setOpen(false); } }));
|
|
98
|
+
}
|
|
99
|
+
// 정렬 옵션, 현재 정렬 상태에 따라 TableCell에 전달할 sort 인자를 계산합니다.
|
|
100
|
+
var sort = header.column.getIsSorted() ||
|
|
101
|
+
(header.column.getCanSort() ? "none" : undefined);
|
|
102
|
+
// 필터 옵션, 현재 필터 상태에 따라 TableCell에 전달할 filter 인자를 계산합니다.
|
|
103
|
+
var isFilterActive = header.column.getIsFiltered() ||
|
|
104
|
+
(header.column.getCanFilter() ? false : undefined);
|
|
105
|
+
return (_jsxs(TableCell, __assign({ colSpan: header.colSpan, sort: sort, onSortClick: header.column.getToggleSortingHandler(), isFilterActive: isFilterActive, onFilterClick: function () { return setOpen(true); }, filterButttonRef: menuRef, css: [
|
|
106
|
+
css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: ", "px;\n "], ["\n width: ", "px;\n "])), header.getSize()),
|
|
107
|
+
// Resize 관련 속성
|
|
108
|
+
header.column.getCanResize() && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n position: relative;\n "], ["\n position: relative;\n "]))),
|
|
109
|
+
] }, { children: [header.isPlaceholder
|
|
110
|
+
? null
|
|
111
|
+
: flexRender(header.column.columnDef.header, header.getContext()), header.column.getCanResize() && (_jsx(Resizer, { onMouseDown: header.getResizeHandler(), onTouchStart: header.getResizeHandler() })), filterDropdownMenu] })));
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Resize 핸들이 2px일때는 너무 얇아서 클릭이 어렵습니다.
|
|
115
|
+
* 따라서 4px인 클릭 영역을 먼저 만들고
|
|
116
|
+
* &::after 가상선택자를 이용하여 2px인 핸들을 그립니다.
|
|
117
|
+
*/
|
|
118
|
+
var Resizer = styled.div(function (_a) {
|
|
119
|
+
var theme = _a.theme;
|
|
120
|
+
return css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n position: absolute;\n right: 0;\n top: calc(50% - 8px);\n height: 16px;\n width: 4px;\n\n cursor: col-resize;\n user-select: none;\n touch-action: none;\n &::after {\n position: absolute;\n background: ", ";\n content: \"\";\n width: 2px;\n height: 100%;\n left: calc(50% - 2px);\n }\n "], ["\n position: absolute;\n right: 0;\n top: calc(50% - 8px);\n height: 16px;\n width: 4px;\n\n cursor: col-resize;\n user-select: none;\n touch-action: none;\n &::after {\n position: absolute;\n background: ", ";\n content: \"\";\n width: 2px;\n height: 100%;\n left: calc(50% - 2px);\n }\n "])), theme.color.background.neutralAltActive);
|
|
121
|
+
});
|
|
122
|
+
var templateObject_1, templateObject_2, templateObject_3;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** @jsxImportSource @emotion/react */
|
|
2
|
+
import { Cell, ColumnDef, Row, RowData, Table as TableType } from "@tanstack/react-table";
|
|
3
|
+
import React, { RefObject } from "react";
|
|
4
|
+
import { DropdownItemProps } from "../Dropdown/DropdownItem";
|
|
5
|
+
import { TableSize } from "../Table";
|
|
6
|
+
export interface CellClickedEvent<TData> {
|
|
7
|
+
cell: Cell<TData, any>;
|
|
8
|
+
table: TableType<TData>;
|
|
9
|
+
}
|
|
10
|
+
export interface SelectedRowMenuOnClickArgs<TData> {
|
|
11
|
+
rows: Row<TData>[];
|
|
12
|
+
table: TableType<TData>;
|
|
13
|
+
setDropdownOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
14
|
+
}
|
|
15
|
+
export interface GridApi<TData> {
|
|
16
|
+
table: TableType<TData>;
|
|
17
|
+
}
|
|
18
|
+
export interface GridProps<TData> {
|
|
19
|
+
className?: string;
|
|
20
|
+
component?: React.ElementType;
|
|
21
|
+
/** Grid API를 담는 Ref 객체 */
|
|
22
|
+
gridApiRef: RefObject<GridApi<TData>>;
|
|
23
|
+
/** Table Cell의 크기 옵션*/
|
|
24
|
+
size: TableSize;
|
|
25
|
+
/** Table의 fullWidth 여부
|
|
26
|
+
* @default true */
|
|
27
|
+
fullWidth?: boolean;
|
|
28
|
+
/** 행 Data */
|
|
29
|
+
rowData: TData[];
|
|
30
|
+
/** 열 정의 객체 */
|
|
31
|
+
columns: ColumnDef<TData, any>[];
|
|
32
|
+
/** Table의 열 크기를 resize 할 수 있는지 여부*/
|
|
33
|
+
resizable?: boolean;
|
|
34
|
+
/** 한 페이지 당 보여질 row의 갯수. 입력하지 않으면 페이지네이션이 비활성화됩니다. */
|
|
35
|
+
paginationPageSize?: number;
|
|
36
|
+
/** Cell을 클릭했을 때 호출되는 콜백 */
|
|
37
|
+
onCellClicked?: (event: CellClickedEvent<TData>) => void;
|
|
38
|
+
/** 행 선택 기능 활성화 여부 */
|
|
39
|
+
enableRowSelection?: boolean;
|
|
40
|
+
/** 행 선택 기능에서 '선택한 항목을' DropdownMenu 관련 속성 */
|
|
41
|
+
selectedRowMenuProps?: {
|
|
42
|
+
items: (Omit<DropdownItemProps, "onClick"> & {
|
|
43
|
+
onClick: (args: SelectedRowMenuOnClickArgs<TData>) => void;
|
|
44
|
+
})[];
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* CDS Table과 TanStack Table을 이용하여
|
|
49
|
+
* data-processing, state-management 등의 로직이 들어있는 컴포넌트입니다.
|
|
50
|
+
*/
|
|
51
|
+
export default function Grid<TData extends RowData>(props: GridProps<TData>): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
17
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18
|
+
if (ar || !(i in from)) {
|
|
19
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
20
|
+
ar[i] = from[i];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24
|
+
};
|
|
25
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@emotion/react/jsx-runtime";
|
|
26
|
+
/** @jsxImportSource @emotion/react */
|
|
27
|
+
import { flexRender, getCoreRowModel, getFacetedRowModel, getFacetedUniqueValues, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, useReactTable, } from "@tanstack/react-table";
|
|
28
|
+
import { useImperativeHandle, useRef, useState } from "react";
|
|
29
|
+
import styled from "@emotion/styled";
|
|
30
|
+
import { css } from "@emotion/react";
|
|
31
|
+
import Pagination from "../../components/Pagination";
|
|
32
|
+
import CheckboxInput from "../../components/CheckboxInput";
|
|
33
|
+
import Button from "../../components/Button";
|
|
34
|
+
import DropdownMenu from "../Dropdown/DropdownMenu";
|
|
35
|
+
import { ArrowDropDownFillIcon } from "../../icons/arrows";
|
|
36
|
+
import { Table, TableBody, TableCell, TableHead, TableRow, } from "../Table";
|
|
37
|
+
import EnhancedTableCell from "./EnhancedTableCell";
|
|
38
|
+
// TanStack Table의 기본 Filter 함수들은 단일 Filter 값만 지원하도록 되어있습니다.
|
|
39
|
+
// CDS에서는 여러개 필터값을 선택할 수 있으므로,
|
|
40
|
+
// FilterValue를 Set 형식으로 지정하고, 이 형식에 맞는 Filter 함수를 정의하여
|
|
41
|
+
// 각 columnDef의 인자로 전달하여 적용합니다.
|
|
42
|
+
var MultiFilterFn = function (row, columnId, filterValues) {
|
|
43
|
+
return filterValues.has(row.getValue(columnId));
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* CDS Table과 TanStack Table을 이용하여
|
|
47
|
+
* data-processing, state-management 등의 로직이 들어있는 컴포넌트입니다.
|
|
48
|
+
*/
|
|
49
|
+
export default function Grid(props) {
|
|
50
|
+
var _a;
|
|
51
|
+
var className = props.className, _b = props.component, Component = _b === void 0 ? "div" : _b, gridApiRef = props.gridApiRef, size = props.size, _c = props.fullWidth, fullWidth = _c === void 0 ? true : _c, rowData = props.rowData, columns = props.columns, onCellClicked = props.onCellClicked, resizable = props.resizable, selectedRowMenuProps = props.selectedRowMenuProps, paginationPageSize = props.paginationPageSize, enableRowSelection = props.enableRowSelection;
|
|
52
|
+
var _d = useState([]), sorting = _d[0], setSorting = _d[1];
|
|
53
|
+
var _e = useState({}), rowSelection = _e[0], setRowSelection = _e[1];
|
|
54
|
+
var _f = useState([]), columnFilters = _f[0], setColumnFilters = _f[1];
|
|
55
|
+
var _g = useState({
|
|
56
|
+
pageIndex: 0,
|
|
57
|
+
pageSize: 0,
|
|
58
|
+
}), pageIndex = _g[0].pageIndex, setPagination = _g[1];
|
|
59
|
+
var _h = useState(false), selectedRowMenuOpen = _h[0], setSelectedRowMenuOpen = _h[1];
|
|
60
|
+
// resize가 활성화 되었을 때만 전달되는 Table Option
|
|
61
|
+
var resizeOption = resizable
|
|
62
|
+
? {
|
|
63
|
+
enableColumnResizing: true,
|
|
64
|
+
columnResizeMode: "onChange",
|
|
65
|
+
}
|
|
66
|
+
: { enableColumnResizing: false };
|
|
67
|
+
// rowSelection이 활성화 되었을 때만 전달되는 Table Option
|
|
68
|
+
var rowSelectionOption = enableRowSelection
|
|
69
|
+
? {
|
|
70
|
+
enableRowSelection: true,
|
|
71
|
+
onRowSelectionChange: setRowSelection,
|
|
72
|
+
}
|
|
73
|
+
: {};
|
|
74
|
+
// rowSelection이 활성화 되었을 때, 다음 column을 가장 처음 열에 추가합니다.
|
|
75
|
+
var selectColumn = {
|
|
76
|
+
id: "grid-selectable-column",
|
|
77
|
+
header: function (_a) {
|
|
78
|
+
var table = _a.table;
|
|
79
|
+
return (_jsx(CheckboxInput, { checked: table.getIsAllRowsSelected(), partial: table.getIsSomeRowsSelected(), onChange: table.getToggleAllRowsSelectedHandler() }));
|
|
80
|
+
},
|
|
81
|
+
cell: function (_a) {
|
|
82
|
+
var row = _a.row;
|
|
83
|
+
return (_jsx(CheckboxInput, { checked: row.getIsSelected(), disabled: !row.getCanSelect(), partial: row.getIsSomeSelected(), onChange: row.getToggleSelectedHandler() }));
|
|
84
|
+
},
|
|
85
|
+
enableResizing: false,
|
|
86
|
+
enableColumnFilter: false,
|
|
87
|
+
enableSorting: false,
|
|
88
|
+
size: 0,
|
|
89
|
+
};
|
|
90
|
+
// pagination이 활성화 되었을 때만 전달되는 Table Option
|
|
91
|
+
var paginationOption = paginationPageSize
|
|
92
|
+
? {
|
|
93
|
+
onPaginationChange: setPagination,
|
|
94
|
+
getPaginationRowModel: getPaginationRowModel(),
|
|
95
|
+
}
|
|
96
|
+
: {};
|
|
97
|
+
var pagination = {
|
|
98
|
+
pageIndex: pageIndex,
|
|
99
|
+
pageSize: paginationPageSize !== null && paginationPageSize !== void 0 ? paginationPageSize : 0,
|
|
100
|
+
};
|
|
101
|
+
// 여러 값으로 된 필터를 선택할 수 있도록 filterFn을 교체합니다.
|
|
102
|
+
var columnWithFilterFn = columns.map(function (colDef) { return (__assign(__assign({}, colDef), { filterFn: MultiFilterFn })); });
|
|
103
|
+
var table = useReactTable(__assign(__assign(__assign(__assign({ data: rowData, columns: enableRowSelection
|
|
104
|
+
? __spreadArray([selectColumn], columnWithFilterFn, true) : columnWithFilterFn, state: {
|
|
105
|
+
columnFilters: columnFilters,
|
|
106
|
+
sorting: sorting,
|
|
107
|
+
rowSelection: rowSelection,
|
|
108
|
+
pagination: pagination,
|
|
109
|
+
} }, resizeOption), rowSelectionOption), paginationOption), { getCoreRowModel: getCoreRowModel(), onSortingChange: setSorting, getSortedRowModel: getSortedRowModel(), onColumnFiltersChange: setColumnFilters, getFilteredRowModel: getFilteredRowModel(), getFacetedRowModel: getFacetedRowModel(), getFacetedUniqueValues: getFacetedUniqueValues() }));
|
|
110
|
+
useImperativeHandle(gridApiRef, function () { return ({
|
|
111
|
+
table: table,
|
|
112
|
+
}); });
|
|
113
|
+
var enablePagination = Boolean(paginationPageSize);
|
|
114
|
+
var menuRef = useRef(null);
|
|
115
|
+
// selectedRowMenuProps의 onClick 인자에 rows, table, setDropdownOpen을 전달하여
|
|
116
|
+
// 콜백 내부에서 접근 가능하게 합니다.
|
|
117
|
+
var itemProps = (_a = selectedRowMenuProps === null || selectedRowMenuProps === void 0 ? void 0 : selectedRowMenuProps.items.map(function (itemProp) {
|
|
118
|
+
return __assign(__assign({}, itemProp), { onClick: function () {
|
|
119
|
+
itemProp.onClick({
|
|
120
|
+
rows: table.getSelectedRowModel().flatRows,
|
|
121
|
+
table: table,
|
|
122
|
+
setDropdownOpen: setSelectedRowMenuOpen,
|
|
123
|
+
});
|
|
124
|
+
} });
|
|
125
|
+
})) !== null && _a !== void 0 ? _a : [];
|
|
126
|
+
return (_jsxs(Component, __assign({ className: className, css: [
|
|
127
|
+
css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: inline-flex;\n flex-direction: column;\n "], ["\n display: inline-flex;\n flex-direction: column;\n "]))),
|
|
128
|
+
fullWidth && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "]))),
|
|
129
|
+
] }, { children: [_jsx("div", __assign({ css: css(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n // Table\uC744 div\uC73C\uB85C \uAC10\uC2F8 overflow \uC18D\uC131\uC744 \uCD94\uAC00\uD558\uC5EC \uC2A4\uD06C\uB864 \uAC00\uB2A5\uD558\uAC8C \uD569\uB2C8\uB2E4.\n // Table \uC790\uCCB4\uC5D0 css\uB97C \uC801\uC6A9\uD558\uBA74 display: table \uC18D\uC131\uC73C\uB85C \uC778\uD574 \uC801\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.\n overflow: auto;\n "], ["\n // Table\uC744 div\uC73C\uB85C \uAC10\uC2F8 overflow \uC18D\uC131\uC744 \uCD94\uAC00\uD558\uC5EC \uC2A4\uD06C\uB864 \uAC00\uB2A5\uD558\uAC8C \uD569\uB2C8\uB2E4.\n // Table \uC790\uCCB4\uC5D0 css\uB97C \uC801\uC6A9\uD558\uBA74 display: table \uC18D\uC131\uC73C\uB85C \uC778\uD574 \uC801\uC6A9\uB418\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.\n overflow: auto;\n "]))) }, { children: _jsxs(Table, __assign({}, { size: size, fullWidth: fullWidth }, { children: [_jsx(TableHead, { children: table.getHeaderGroups().map(function (headerGroup) { return (_jsx(TableRow, { children: headerGroup.headers.map(function (header) { return (_jsx(EnhancedTableCell, { table: table, header: header }, header.id)); }) }, headerGroup.id)); }) }), _jsxs(TableBody, { children: [table.getRowModel().rows.length === 0 && (_jsx(TableRow, __assign({ disableHover: true }, { children: _jsx(TableCell, __assign({ colSpan: table.getAllColumns().length, css: css(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n text-align: center;\n "], ["\n text-align: center;\n "]))) }, { children: "\uB370\uC774\uD130\uAC00 \uC874\uC7AC\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4." })) }))), table.getRowModel().rows.map(function (row) { return (_jsx(TableRow, __assign({ isSelected: row.getIsSelected() }, { children: row.getVisibleCells().map(function (cell) { return (_jsx(TableCell, __assign({ onClick: function () { return onCellClicked === null || onCellClicked === void 0 ? void 0 : onCellClicked({ cell: cell, table: table }); } }, { children: flexRender(cell.column.columnDef.cell, cell.getContext()) }), cell.id)); }) }), row.id)); })] })] })) })), (enableRowSelection || enablePagination) && (_jsxs(TableFooter, __assign({ enableRowSelection: enableRowSelection !== null && enableRowSelection !== void 0 ? enableRowSelection : false, enablePagination: enablePagination }, { children: [enableRowSelection && (_jsxs(_Fragment, { children: [_jsx(Button, { color: "secondary", size: "small", label: "\uC120\uD0DD\uD55C \uD56D\uBAA9\uC744", ref: menuRef, endIcon: _jsx(ArrowDropDownFillIcon, {}), disabled: !(table.getIsAllRowsSelected() ||
|
|
130
|
+
table.getIsSomeRowsSelected()), onClick: function () { return setSelectedRowMenuOpen(true); } }), _jsx(DropdownMenu, { itemsProps: itemProps, open: selectedRowMenuOpen, anchorEl: menuRef.current, onClose: function () { return setSelectedRowMenuOpen(false); } })] })), enablePagination && (_jsx(Pagination, { page: table.getState().pagination.pageIndex + 1, count: table.getPageCount(), onChange: function (event, page) {
|
|
131
|
+
table.setPageIndex(page - 1);
|
|
132
|
+
} }))] })))] })));
|
|
133
|
+
}
|
|
134
|
+
var TableFooter = styled.div(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n align-items: center;\n\n ", "\n margin: 16px 12px;\n"], ["\n display: flex;\n align-items: center;\n\n ", "\n margin: 16px 12px;\n"])), function (_a) {
|
|
135
|
+
var enableRowSelection = _a.enableRowSelection, enablePagination = _a.enablePagination;
|
|
136
|
+
return !enablePagination
|
|
137
|
+
? css(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n justify-content: flex-start;\n "], ["\n justify-content: flex-start;\n "]))) : enableRowSelection
|
|
138
|
+
? css(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n justify-content: space-between;\n "], ["\n justify-content: space-between;\n "]))) : css(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n justify-content: center;\n "], ["\n justify-content: center;\n "])));
|
|
139
|
+
});
|
|
140
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ButtonProps } from "../../components/Button";
|
|
2
|
+
export interface SegmentedControlButtonProps extends Omit<ButtonProps, "color" | "size"> {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
7
|
+
*/
|
|
8
|
+
export declare function SegmentedControlButton(props: SegmentedControlButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
17
|
+
/** @jsxImportSource @emotion/react */
|
|
18
|
+
import styled from "@emotion/styled";
|
|
19
|
+
import { useContext } from "react";
|
|
20
|
+
import Button from "../../components/Button";
|
|
21
|
+
import shadows from "../../foundation/shadows";
|
|
22
|
+
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
23
|
+
/**
|
|
24
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
25
|
+
*/
|
|
26
|
+
export function SegmentedControlButton(props) {
|
|
27
|
+
var context = useContext(SegmentedControlGroupPropsContext);
|
|
28
|
+
var isActive = context.multiSelect ? context.value.includes(props.value) : context.value === props.value;
|
|
29
|
+
return (_jsx(StyledButton, __assign({}, props, { isActive: isActive, color: isActive ? "primary" : "textNeutral", size: context.size, onClick: function () {
|
|
30
|
+
var _a, _b;
|
|
31
|
+
(_a = context.onClick) === null || _a === void 0 ? void 0 : _a.call(context, props.value);
|
|
32
|
+
(_b = props.onClick) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
33
|
+
} })));
|
|
34
|
+
}
|
|
35
|
+
var StyledButton = styled(Button, {
|
|
36
|
+
shouldForwardProp: function (prop) { return prop !== "isActive"; },
|
|
37
|
+
})(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"])), function (_a) {
|
|
38
|
+
var isActive = _a.isActive;
|
|
39
|
+
return isActive && "box-shadow: ".concat(shadows.shadow04, ";");
|
|
40
|
+
});
|
|
41
|
+
var templateObject_1;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ButtonSize } from "../../components/Button";
|
|
3
|
+
import { SquareButtonSize } from "../../components/SquareButton";
|
|
4
|
+
export type SegmentedControlGroupProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
component?: React.ElementType;
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** 컴포넌트 크기 */
|
|
9
|
+
size: ButtonSize | SquareButtonSize;
|
|
10
|
+
/** 전체 너비 유무 */
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
} & ({
|
|
13
|
+
/** 중복 선택 가능 유무 */
|
|
14
|
+
multiSelect?: false;
|
|
15
|
+
/** 선택된 값 */
|
|
16
|
+
value: string | undefined;
|
|
17
|
+
onChange?: (newValue: string) => void;
|
|
18
|
+
} | {
|
|
19
|
+
multiSelect: true;
|
|
20
|
+
value: string[];
|
|
21
|
+
onChange?: (newValue: string[]) => void;
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
25
|
+
*/
|
|
26
|
+
export declare function SegmentedControlGroup(props: SegmentedControlGroupProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
17
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
18
|
+
if (ar || !(i in from)) {
|
|
19
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
20
|
+
ar[i] = from[i];
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
24
|
+
};
|
|
25
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
26
|
+
/** @jsxImportSource @emotion/react */
|
|
27
|
+
import { css, useTheme } from "@emotion/react";
|
|
28
|
+
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
29
|
+
/**
|
|
30
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
31
|
+
*/
|
|
32
|
+
export function SegmentedControlGroup(props) {
|
|
33
|
+
var _a = props.component, Component = _a === void 0 ? "div" : _a, className = props.className, children = props.children, fullWidth = props.fullWidth, multiSelect = props.multiSelect;
|
|
34
|
+
var theme = useTheme();
|
|
35
|
+
return (_jsx(Component, __assign({ className: className, css: css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n gap: 4px;\n\n width: ", ";\n background-color: ", ";\n border-radius: 8px;\n border: 1px solid ", ";\n "], ["\n display: flex;\n gap: 4px;\n\n width: ", ";\n background-color: ", ";\n border-radius: 8px;\n border: 1px solid ", ";\n "])), fullWidth ? "100%" : "fit-content", theme.color.background.neutralAlt, theme.color.background.neutralAltActive) }, { children: _jsx(SegmentedControlGroupPropsContext.Provider, __assign({ value: __assign(__assign({}, props), { onClick: function (newValue) {
|
|
36
|
+
var _a, _b, _c;
|
|
37
|
+
if (multiSelect) {
|
|
38
|
+
if (props.value.includes(newValue)) {
|
|
39
|
+
(_a = props.onChange) === null || _a === void 0 ? void 0 : _a.call(props, props.value.filter(function (value) { return value !== newValue; }));
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
(_b = props.onChange) === null || _b === void 0 ? void 0 : _b.call(props, __spreadArray(__spreadArray([], props.value, true), [newValue], false));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
(_c = props.onChange) === null || _c === void 0 ? void 0 : _c.call(props, newValue);
|
|
47
|
+
}
|
|
48
|
+
} }) }, { children: children })) })));
|
|
49
|
+
}
|
|
50
|
+
var templateObject_1;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { SegmentedControlGroupProps } from "./SegmentedControlGroup";
|
|
3
|
+
export declare const SegmentedControlGroupPropsContext: import("react").Context<SegmentedControlGroupProps & {
|
|
4
|
+
onClick?: ((newValue: string) => void) | undefined;
|
|
5
|
+
}>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SquareButtonProps } from "../../components/SquareButton";
|
|
2
|
+
export interface SegmentedControlSquareButtonProps extends Omit<SquareButtonProps, "color" | "size"> {
|
|
3
|
+
value: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
7
|
+
*/
|
|
8
|
+
export declare function SegmentedControlSquareButton(props: SegmentedControlSquareButtonProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
17
|
+
/** @jsxImportSource @emotion/react */
|
|
18
|
+
import styled from "@emotion/styled";
|
|
19
|
+
import { useContext } from "react";
|
|
20
|
+
import SquareButton from "../../components/SquareButton";
|
|
21
|
+
import shadows from "../../foundation/shadows";
|
|
22
|
+
import { SegmentedControlGroupPropsContext } from "./SegmentedControlGroupPropsContext";
|
|
23
|
+
/**
|
|
24
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?node-id=181%3A89883)
|
|
25
|
+
*/
|
|
26
|
+
export function SegmentedControlSquareButton(props) {
|
|
27
|
+
var context = useContext(SegmentedControlGroupPropsContext);
|
|
28
|
+
var isActive = context.multiSelect
|
|
29
|
+
? context.value.includes(props.value)
|
|
30
|
+
: context.value === props.value;
|
|
31
|
+
return (_jsx(StyledSquareButton, __assign({}, props, { isActive: isActive, color: isActive ? "primary" : "icon", size: context.size, fullWidth: context.fullWidth, onClick: function () {
|
|
32
|
+
var _a;
|
|
33
|
+
if (context.onClick) {
|
|
34
|
+
context.onClick(props.value);
|
|
35
|
+
(_a = props.onClick) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
36
|
+
}
|
|
37
|
+
} })));
|
|
38
|
+
}
|
|
39
|
+
var StyledSquareButton = styled(SquareButton, {
|
|
40
|
+
shouldForwardProp: function (prop) { return prop !== "isActive"; },
|
|
41
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n button {\n ", "\n }\n"], ["\n display: flex;\n justify-content: center;\n flex-grow: 1;\n button {\n ", "\n }\n"])), function (_a) {
|
|
42
|
+
var isActive = _a.isActive;
|
|
43
|
+
return isActive && "box-shadow: ".concat(shadows.shadow04, ";");
|
|
44
|
+
});
|
|
45
|
+
var templateObject_1;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type TableSize = "large" | "medium" | "small";
|
|
3
|
+
export interface TableProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
component?: React.ElementType;
|
|
6
|
+
/** Table의 내용입니다. 일반적으로 `TableHead`와 `TableBody`로 구성됩니다. */
|
|
7
|
+
children?: React.ReactNode;
|
|
8
|
+
/** Table Row 사이즈 */
|
|
9
|
+
size: TableSize;
|
|
10
|
+
/** fullWidth 여부 */
|
|
11
|
+
fullWidth?: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?type=design&node-id=181-91732&t=07ngLzGHuU3xxg4S-0)
|
|
15
|
+
*/
|
|
16
|
+
export default function Table(props: TableProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
17
|
+
/** @jsxImportSource @emotion/react */
|
|
18
|
+
import { css, useTheme } from "@emotion/react";
|
|
19
|
+
import { RESET_TABLE } from "../../utils/reset";
|
|
20
|
+
import TableSizeContext from "./TableSizeContext";
|
|
21
|
+
/**
|
|
22
|
+
* [피그마](https://www.figma.com/file/PnQp3tPxiCjgsPZfLUaUL1/Codle-PD-Kit---Patterns?type=design&node-id=181-91732&t=07ngLzGHuU3xxg4S-0)
|
|
23
|
+
*/
|
|
24
|
+
export default function Table(props) {
|
|
25
|
+
var className = props.className, _a = props.component, Component = _a === void 0 ? "table" : _a, children = props.children, size = props.size, fullWidth = props.fullWidth;
|
|
26
|
+
var theme = useTheme();
|
|
27
|
+
return (_jsx(Component, __assign({ className: className, css: [
|
|
28
|
+
RESET_TABLE,
|
|
29
|
+
css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border-collapse: separate;\n\n background: ", ";\n border: 1px solid ", ";\n color: ", ";\n border-radius: 4px;\n "], ["\n border-collapse: separate;\n\n background: ", ";\n border: 1px solid ", ";\n color: ", ";\n border-radius: 4px;\n "])), theme.color.background.neutralBase, theme.color.background.neutralAlt, theme.color.foreground.neutralBase),
|
|
30
|
+
fullWidth && css(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n width: 100%;\n "], ["\n width: 100%;\n "]))),
|
|
31
|
+
] }, { children: _jsx(TableSizeContext.Provider, __assign({ value: { size: size } }, { children: children })) })));
|
|
32
|
+
}
|
|
33
|
+
var templateObject_1, templateObject_2;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface TableBodyProps {
|
|
3
|
+
className?: string;
|
|
4
|
+
component?: React.ElementType;
|
|
5
|
+
/** Table의 내용입니다. 일반적으로 TableRow로 구성됩니다. */
|
|
6
|
+
children?: React.ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export default function TableBody(props: TableBodyProps): import("@emotion/react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import { jsx as _jsx } from "@emotion/react/jsx-runtime";
|
|
17
|
+
/** @jsxImportSource @emotion/react */
|
|
18
|
+
import { css } from "@emotion/react";
|
|
19
|
+
import TableVariantContext from "./TableVariantContext";
|
|
20
|
+
export default function TableBody(props) {
|
|
21
|
+
var className = props.className, _a = props.component, Component = _a === void 0 ? "tbody" : _a, children = props.children;
|
|
22
|
+
return (_jsx(Component, __assign({ className: className, css: [
|
|
23
|
+
css(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n display: table-row-group;\n "], ["\n display: table-row-group;\n "]))),
|
|
24
|
+
] }, { children: _jsx(TableVariantContext.Provider, __assign({ value: { variant: "body" } }, { children: children })) })));
|
|
25
|
+
}
|
|
26
|
+
var templateObject_1;
|