@team-monolith/cds 0.1.8 → 0.2.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.
Files changed (93) hide show
  1. package/dist/components/AlertDialog/AlertDialogContent.js +2 -2
  2. package/dist/components/Button.d.ts +10 -3
  3. package/dist/components/Button.js +3 -3
  4. package/dist/icons/arrows.d.ts +12 -0
  5. package/dist/icons/arrows.js +4 -0
  6. package/dist/icons/system.d.ts +3 -0
  7. package/dist/icons/system.js +1 -0
  8. package/dist/index.d.ts +0 -2
  9. package/dist/index.js +0 -2
  10. package/dist/patterns/Card/Card.d.ts +39 -0
  11. package/dist/patterns/Card/Card.js +68 -0
  12. package/dist/patterns/Card/index.d.ts +2 -0
  13. package/dist/patterns/Card/index.js +2 -0
  14. package/dist/patterns/Dialog/Dialog.d.ts +12 -0
  15. package/dist/patterns/Dialog/Dialog.js +26 -0
  16. package/dist/patterns/Dialog/DialogContent.d.ts +8 -0
  17. package/dist/patterns/Dialog/DialogContent.js +23 -0
  18. package/dist/patterns/Dialog/DialogNavigation.d.ts +12 -0
  19. package/dist/patterns/Dialog/DialogNavigation.js +25 -0
  20. package/dist/patterns/Dialog/DialogNavigationContext.d.ts +5 -0
  21. package/dist/patterns/Dialog/DialogNavigationContext.js +5 -0
  22. package/dist/patterns/Dialog/DialogNavigationItem.d.ts +10 -0
  23. package/dist/patterns/Dialog/DialogNavigationItem.js +25 -0
  24. package/dist/patterns/Dialog/DialogPanel.d.ts +10 -0
  25. package/dist/patterns/Dialog/DialogPanel.js +31 -0
  26. package/dist/patterns/Dialog/DialogPanels.d.ts +13 -0
  27. package/dist/patterns/Dialog/DialogPanels.js +17 -0
  28. package/dist/patterns/Dialog/DialogPanelsContext.d.ts +5 -0
  29. package/dist/patterns/Dialog/DialogPanelsContext.js +5 -0
  30. package/dist/patterns/Dialog/DialogTitle.d.ts +13 -0
  31. package/dist/patterns/Dialog/DialogTitle.js +26 -0
  32. package/dist/patterns/Dialog/index.d.ts +7 -0
  33. package/dist/patterns/Dialog/index.js +7 -0
  34. package/dist/patterns/Navigation/NavigationContext.d.ts +5 -0
  35. package/dist/patterns/Navigation/NavigationContext.js +5 -0
  36. package/dist/patterns/Navigation/NavigationHorizontal.d.ts +11 -0
  37. package/dist/patterns/Navigation/NavigationHorizontal.js +27 -0
  38. package/dist/patterns/Navigation/NavigationItem.d.ts +9 -0
  39. package/dist/patterns/Navigation/NavigationItem.js +33 -0
  40. package/dist/patterns/Navigation/NavigationVertical.d.ts +14 -0
  41. package/dist/patterns/Navigation/NavigationVertical.js +27 -0
  42. package/dist/patterns/Navigation/index.d.ts +3 -0
  43. package/dist/patterns/Navigation/index.js +3 -0
  44. package/dist/patterns/Table/Table.d.ts +2 -0
  45. package/dist/patterns/Table/Table.js +3 -3
  46. package/dist/patterns/Table/TableCell.js +5 -5
  47. package/dist/patterns/Table/TablePropsContext.d.ts +7 -0
  48. package/dist/patterns/Table/TablePropsContext.js +3 -0
  49. package/dist/patterns/Table/TableRow.d.ts +2 -0
  50. package/dist/patterns/Table/TableRow.js +9 -4
  51. package/package.json +1 -1
  52. package/src/cds/components/AlertDialog/AlertDialogContent.tsx +14 -16
  53. package/src/cds/components/Button.tsx +98 -77
  54. package/src/cds/icons/arrows.tsx +55 -0
  55. package/src/cds/icons/system.tsx +15 -0
  56. package/src/cds/patterns/Card/Card.tsx +294 -0
  57. package/src/cds/patterns/Card/class-icon.svg +28 -0
  58. package/src/cds/patterns/Card/index.tsx +2 -0
  59. package/src/cds/patterns/Card/material-icon.svg +25 -0
  60. package/src/cds/patterns/Card/problem-icon.svg +25 -0
  61. package/src/cds/patterns/Card/thumbnail/sample.png +0 -0
  62. package/src/cds/patterns/Dialog/Dialog.tsx +57 -0
  63. package/src/cds/patterns/Dialog/DialogContent.tsx +28 -0
  64. package/src/cds/patterns/Dialog/DialogNavigation.tsx +29 -0
  65. package/src/cds/patterns/Dialog/DialogNavigationContext.tsx +9 -0
  66. package/src/cds/patterns/Dialog/DialogNavigationItem.tsx +42 -0
  67. package/src/cds/patterns/Dialog/DialogPanel.tsx +40 -0
  68. package/src/cds/patterns/Dialog/DialogPanels.tsx +24 -0
  69. package/src/cds/patterns/Dialog/DialogPanelsContext.tsx +9 -0
  70. package/src/cds/patterns/Dialog/DialogTitle.tsx +55 -0
  71. package/src/cds/patterns/Dialog/index.tsx +7 -0
  72. package/src/cds/patterns/Navigation/NavigationContext.tsx +9 -0
  73. package/src/cds/patterns/Navigation/NavigationHorizontal.tsx +32 -0
  74. package/src/cds/patterns/Navigation/NavigationItem.tsx +36 -0
  75. package/src/cds/patterns/Navigation/NavigationVertical.tsx +39 -0
  76. package/src/cds/patterns/Navigation/index.tsx +3 -0
  77. package/src/cds/patterns/Table/Table.tsx +8 -2
  78. package/src/cds/patterns/Table/TableCell.tsx +14 -3
  79. package/src/cds/patterns/Table/TablePropsContext.tsx +9 -0
  80. package/src/cds/patterns/Table/TableRow.tsx +23 -7
  81. package/dist/patterns/EmptyState/empty-state-icon.svg +0 -36
  82. package/dist/patterns/Grid/EnhancedTableCell.d.ts +0 -9
  83. package/dist/patterns/Grid/EnhancedTableCell.js +0 -122
  84. package/dist/patterns/Grid/Grid.d.ts +0 -51
  85. package/dist/patterns/Grid/Grid.js +0 -140
  86. package/dist/patterns/Grid/index.d.ts +0 -3
  87. package/dist/patterns/Grid/index.js +0 -2
  88. package/dist/patterns/Table/TableSizeContext.d.ts +0 -7
  89. package/dist/patterns/Table/TableSizeContext.js +0 -3
  90. package/src/cds/patterns/Grid/EnhancedTableCell.tsx +0 -180
  91. package/src/cds/patterns/Grid/Grid.tsx +0 -360
  92. package/src/cds/patterns/Grid/index.tsx +0 -4
  93. package/src/cds/patterns/Table/TableSizeContext.tsx +0 -10
@@ -1,140 +0,0 @@
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;
@@ -1,3 +0,0 @@
1
- import Grid from "./Grid";
2
- export type { GridProps, GridApi, CellClickedEvent } from "./Grid";
3
- export default Grid;
@@ -1,2 +0,0 @@
1
- import Grid from "./Grid";
2
- export default Grid;
@@ -1,7 +0,0 @@
1
- import * as React from "react";
2
- import { TableSize } from "./Table";
3
- interface TableSizeContextProps {
4
- size?: TableSize;
5
- }
6
- declare const TableSizeContext: React.Context<TableSizeContextProps>;
7
- export default TableSizeContext;
@@ -1,3 +0,0 @@
1
- import * as React from "react";
2
- var TableSizeContext = React.createContext({});
3
- export default TableSizeContext;
@@ -1,180 +0,0 @@
1
- /** @jsxImportSource @emotion/react */
2
- import {
3
- Header,
4
- RowData,
5
- Table as TableType,
6
- flexRender,
7
- } from "@tanstack/react-table";
8
- import { ReactNode, useRef, useState } from "react";
9
- import { css } from "@emotion/react";
10
- import { DropdownItemProps } from "../Dropdown/DropdownItem";
11
- import DropdownMenu from "../Dropdown/DropdownMenu";
12
- import { TableCell } from "../Table";
13
- import styled from "@emotion/styled";
14
-
15
- // 두 Set의 합집합을 구하는 함수
16
- function union(setA: Set<any>, setB: Set<any>) {
17
- const _union = new Set(setA);
18
- setB.forEach((elem) => {
19
- _union.add(elem);
20
- });
21
- return _union;
22
- }
23
-
24
- /**
25
- * Sort, Filter, Resize 등의 기능이 추가된 Cell입니다.
26
- */
27
- export default function EnhancedTableCell<TData extends RowData>(props: {
28
- table: TableType<TData>;
29
- header: Header<TData, unknown>;
30
- }) {
31
- const { table, header } = props;
32
- const [open, setOpen] = useState(false);
33
- const menuRef = useRef<HTMLButtonElement | null>(null);
34
-
35
- let filterDropdownMenu: ReactNode = null;
36
- if (header.column.getCanFilter()) {
37
- // 필터 내의 드롭다운 메뉴 아이템 정렬에서 사용할 firstValue 값
38
- // 이 값이 number 타입인지, string 타입인지에 따라 아이템 정렬 함수를 다르게 설정합니다.
39
- const firstValue = table
40
- .getPreFilteredRowModel()
41
- .flatRows[0]?.getValue(header.column.id);
42
-
43
- // 한 열에서 중복값이 제거된 고유값들을 받아옵니다.
44
- const uniqueValues = header.column.getFacetedUniqueValues().keys();
45
-
46
- const currentFilterValue = header.column.getFilterValue() as
47
- | Set<any>
48
- | undefined;
49
-
50
- // 열의 고유값의 배열과 현재 필터가 걸려있는 값의 배열들을 합집합시킵니다.
51
- const filterMenuValues = Array.from(
52
- union(new Set(uniqueValues), currentFilterValue ?? new Set())
53
- );
54
-
55
- // 타입에 따라서 필터 메뉴를 오름차순 정렬합니다.
56
- const sortedFilterMenuValues =
57
- typeof firstValue === "number"
58
- ? filterMenuValues.sort((a, b) => Number(a) - Number(b))
59
- : filterMenuValues.sort();
60
-
61
- /**
62
- * val 값에 해당하는 필터를 토글하는 함수
63
- * 모든 값이 해제되었을때, 빈 배열이 아닌 undefined 값을 필터 값으로 설정하여야
64
- * 필터가 정상적으로 해제됩니다.
65
- */
66
- const toggleFilterValue = (val: string) => {
67
- if (currentFilterValue?.has(val)) {
68
- header.column.setFilterValue((old: Set<any> | undefined) => {
69
- if (!old) {
70
- return;
71
- }
72
- const newFilterValue = new Set(old);
73
- newFilterValue.delete(val);
74
- if (newFilterValue.size === 0) {
75
- return undefined;
76
- } else {
77
- return newFilterValue;
78
- }
79
- });
80
- } else {
81
- header.column.setFilterValue((old: Set<any> | undefined) => {
82
- if (!old) {
83
- return new Set().add(val);
84
- }
85
- return new Set(old).add(val);
86
- });
87
- }
88
- };
89
-
90
- filterDropdownMenu = (
91
- <DropdownMenu
92
- itemsProps={sortedFilterMenuValues.map(
93
- (val): DropdownItemProps => ({
94
- label: val,
95
- checkbox: true,
96
- checkboxProps: {
97
- checked: currentFilterValue?.has(val) ?? false,
98
- onChange: (event) => toggleFilterValue(val),
99
- },
100
- onClick: () => toggleFilterValue(val),
101
- })
102
- )}
103
- open={open}
104
- anchorEl={menuRef.current}
105
- anchorOrigin={{ vertical: "bottom", horizontal: "right" }}
106
- transformOrigin={{ vertical: "top", horizontal: "right" }}
107
- onClose={() => setOpen(false)}
108
- />
109
- );
110
- }
111
-
112
- // 정렬 옵션, 현재 정렬 상태에 따라 TableCell에 전달할 sort 인자를 계산합니다.
113
- const sort =
114
- header.column.getIsSorted() ||
115
- (header.column.getCanSort() ? "none" : undefined);
116
-
117
- // 필터 옵션, 현재 필터 상태에 따라 TableCell에 전달할 filter 인자를 계산합니다.
118
- const isFilterActive =
119
- header.column.getIsFiltered() ||
120
- (header.column.getCanFilter() ? false : undefined);
121
-
122
- return (
123
- <TableCell
124
- colSpan={header.colSpan}
125
- sort={sort}
126
- onSortClick={header.column.getToggleSortingHandler()}
127
- isFilterActive={isFilterActive}
128
- onFilterClick={() => setOpen(true)}
129
- filterButttonRef={menuRef}
130
- css={[
131
- css`
132
- width: ${header.getSize()}px;
133
- `,
134
- // Resize 관련 속성
135
- header.column.getCanResize() &&
136
- css`
137
- position: relative;
138
- `,
139
- ]}
140
- >
141
- {header.isPlaceholder
142
- ? null
143
- : flexRender(header.column.columnDef.header, header.getContext())}
144
- {header.column.getCanResize() && (
145
- <Resizer
146
- onMouseDown={header.getResizeHandler()}
147
- onTouchStart={header.getResizeHandler()}
148
- />
149
- )}
150
- {filterDropdownMenu}
151
- </TableCell>
152
- );
153
- }
154
-
155
- /**
156
- * Resize 핸들이 2px일때는 너무 얇아서 클릭이 어렵습니다.
157
- * 따라서 4px인 클릭 영역을 먼저 만들고
158
- * &::after 가상선택자를 이용하여 2px인 핸들을 그립니다.
159
- */
160
- const Resizer = styled.div(
161
- ({ theme }) => css`
162
- position: absolute;
163
- right: 0;
164
- top: calc(50% - 8px);
165
- height: 16px;
166
- width: 4px;
167
-
168
- cursor: col-resize;
169
- user-select: none;
170
- touch-action: none;
171
- &::after {
172
- position: absolute;
173
- background: ${theme.color.background.neutralAltActive};
174
- content: "";
175
- width: 2px;
176
- height: 100%;
177
- left: calc(50% - 2px);
178
- }
179
- `
180
- );