diff options
Diffstat (limited to 'components')
| -rw-r--r-- | components/client-data-table/data-table.tsx | 11 | ||||
| -rw-r--r-- | components/data-table/data-table-detail.tsx | 13 | ||||
| -rw-r--r-- | components/data-table/data-table-resizer.tsx | 12 | ||||
| -rw-r--r-- | components/data-table/data-table.tsx | 18 | ||||
| -rw-r--r-- | components/data-table/expandable-data-table.tsx | 7 | ||||
| -rw-r--r-- | components/data-table/infinite-data-table.tsx | 7 |
6 files changed, 46 insertions, 22 deletions
diff --git a/components/client-data-table/data-table.tsx b/components/client-data-table/data-table.tsx index 9ea44775..44168bd2 100644 --- a/components/client-data-table/data-table.tsx +++ b/components/client-data-table/data-table.tsx @@ -203,7 +203,8 @@ export function ClientDataTable<TData, TValue>({ onScroll={handleScroll} // ๐ฏ ์คํฌ๋กค ์ด๋ฒคํธ ํธ๋ค๋ฌ ์ถ๊ฐ > <UiTable - className="[&>thead]:sticky [&>thead]:top-0 [&>thead]:z-10 table-fixed"> + className="[&>thead]:sticky [&>thead]:top-0 [&>thead]:z-10"> + {/* table-fixed ์ ๊ฑฐ: nested header์์ ๋์ width ๋ณ๊ฒฝ์ ์ํด ์ ์ฐํ ๋ ์ด์์ ์ฌ์ฉ */} <TableHeader> {table.getHeaderGroups().map((headerGroup) => ( <TableRow key={headerGroup.id} className={compactStyles.headerRow}> @@ -221,7 +222,9 @@ export function ClientDataTable<TData, TValue>({ className={compactStyles.header} style={{ ...getPinnedStyle(header.column, true), // ๐ฏ ํค๋์์ ๋ช
์ - width: header.getSize() // ๐ฏ width ๋ณ๋ ์ค์ + // ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ colSpan์ผ๋ก ๋๋น๊ฐ ๊ฒฐ์ ๋๋ฏ๋ก width ์ค์ ํ์ง ์์ + // ์์ ํค๋๋ง ๊ฐ๋ณ width ์ค์ + ...(!('columns' in header.column.columnDef) && { width: header.getSize() }), }} > <div style={{ position: "relative" }}> @@ -232,8 +235,8 @@ export function ClientDataTable<TData, TValue>({ header.getContext() )} - {/* ๋ฆฌ์ฌ์ด์ฆ ํธ๋ค - ํค๋์๋ง ์ถ๊ฐ */} - {header.column.getCanResize() && ( + {/* ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ ๋ฆฌ์ฌ์ด์ฆ ๋ถ๊ฐ, ์์ ํค๋๋ง ๋ฆฌ์ฌ์ด์ฆ ๊ฐ๋ฅ */} + {header.column.getCanResize() && !('columns' in header.column.columnDef) && ( <DataTableResizer header={header} /> )} </div> diff --git a/components/data-table/data-table-detail.tsx b/components/data-table/data-table-detail.tsx index c34f9e73..f3f09fe2 100644 --- a/components/data-table/data-table-detail.tsx +++ b/components/data-table/data-table-detail.tsx @@ -87,11 +87,13 @@ export function DataTableDetail<TData>({ data-column-id={header.column.id} className={compactStyles.header} style={{ - ...getCommonPinningStylesWithBorder({ - column: header.column, - isHeader: true + ...getCommonPinningStylesWithBorder({ + column: header.column, + isHeader: true }), - width: header.getSize(), + // ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ colSpan์ผ๋ก ๋๋น๊ฐ ๊ฒฐ์ ๋๋ฏ๋ก width ์ค์ ํ์ง ์์ + // ์์ ํค๋๋ง ๊ฐ๋ณ width ์ค์ + ...(!('columns' in header.column.columnDef) && { width: header.getSize() }), }} > <div style={{ position: "relative" }}> @@ -102,7 +104,8 @@ export function DataTableDetail<TData>({ header.getContext() )} - {header.column.getCanResize() && ( + {/* ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ ๋ฆฌ์ฌ์ด์ฆ ๋ถ๊ฐ, ์์ ํค๋๋ง ๋ฆฌ์ฌ์ด์ฆ ๊ฐ๋ฅ */} + {header.column.getCanResize() && !('columns' in header.column.columnDef) && ( <DataTableResizer header={header} /> )} </div> diff --git a/components/data-table/data-table-resizer.tsx b/components/data-table/data-table-resizer.tsx index 9723a0b4..8053606d 100644 --- a/components/data-table/data-table-resizer.tsx +++ b/components/data-table/data-table-resizer.tsx @@ -18,9 +18,10 @@ export function DataTableResizer<TData, TValue>({ // ๋๋ธํด๋ฆญ ์ ๋๋น ์๋ ์กฐ์ ํจ์ const handleDoubleClick = React.useCallback(() => { + // ํ
์ด๋ธ ์ธ์คํด์ค ๊ฐ์ ธ์ค๊ธฐ const table = header.getContext().table - + // 0. ๋ช ๊ฐ์ง ๊ธฐ๋ณธ ์ค์ const defaultMinWidth = 80 // ๊ธฐ๋ณธ ์ต์ ๋๋น const extraPadding = 24 // ์ฌ์ ๊ณต๊ฐ @@ -75,15 +76,20 @@ export function DataTableResizer<TData, TValue>({ table.setColumnSizing(updatedSizing) }, [header]) + const handleMouseDown = React.useCallback((e: React.MouseEvent) => { + // ๊ธฐ๋ณธ resize handler ์ฌ์ฉ + header.getResizeHandler()(e); + }, [header]); + return ( <> {/* ํค๋ ์ฝํ
์ธ ์ฐธ์กฐ๋ฅผ ์ํ ์์ */} <div ref={contentRef} className="absolute opacity-0 pointer-events-none" /> - + {/* ๋ฆฌ์ฌ์ด์ */} <div {...props} - onMouseDown={header.getResizeHandler()} + onMouseDown={handleMouseDown} onTouchStart={header.getResizeHandler()} onDoubleClick={handleDoubleClick} // ๋๋ธํด๋ฆญ ํธ๋ค๋ฌ ์ถ๊ฐ className={cn( diff --git a/components/data-table/data-table.tsx b/components/data-table/data-table.tsx index 07e4dcd2..2eb3e020 100644 --- a/components/data-table/data-table.tsx +++ b/components/data-table/data-table.tsx @@ -75,7 +75,8 @@ export function DataTable<TData>({ <div className={cn("w-full space-y-2.5 overflow-auto", className)} {...props}> {stableChildren} <div className="max-w-[100vw] overflow-auto" style={{ maxHeight: maxHeight || '35rem' }} > - <Table className="[&>thead]:sticky [&>thead]:top-0 [&>thead]:z-10 table-fixed"> + <Table className="[&>thead]:sticky [&>thead]:top-0 [&>thead]:z-10"> + {/* table-fixed ์ ๊ฑฐ: nested header์์ ๋์ width ๋ณ๊ฒฝ์ ์ํด ์ ์ฐํ ๋ ์ด์์ ์ฌ์ฉ */} {/* ํ
์ด๋ธ ํค๋ */} <TableHeader> {table.getHeaderGroups().map((headerGroup) => ( @@ -92,11 +93,15 @@ export function DataTable<TData>({ data-column-id={header.column.id} className={cn(compactStyles.header, "whitespace-normal break-words")} style={{ - ...getCommonPinningStylesWithBorder({ - column: header.column, - isHeader: true + ...getCommonPinningStylesWithBorder({ + column: header.column, + isHeader: true + }), + // ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ colSpan์ผ๋ก ๋๋น๊ฐ ๊ฒฐ์ ๋๋ฏ๋ก width ์ค์ ํ์ง ์์ + // ์์ ํค๋๋ง ๊ฐ๋ณ width ์ค์ + ...(!('columns' in header.column.columnDef) && { + width: header.getSize() }), - width: header.getSize(), }} > <div style={{ position: "relative" }}> @@ -107,7 +112,8 @@ export function DataTable<TData>({ header.getContext() )} - {header.column.getCanResize() && ( + {/* ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ ๋ฆฌ์ฌ์ด์ฆ ๋ถ๊ฐ, ์์ ํค๋๋ง ๋ฆฌ์ฌ์ด์ฆ ๊ฐ๋ฅ */} + {header.column.getCanResize() && !('columns' in header.column.columnDef) && ( <DataTableResizer header={header} /> )} </div> diff --git a/components/data-table/expandable-data-table.tsx b/components/data-table/expandable-data-table.tsx index 15c59540..d36f0251 100644 --- a/components/data-table/expandable-data-table.tsx +++ b/components/data-table/expandable-data-table.tsx @@ -532,7 +532,9 @@ export function ExpandableDataTable<TData>({ )} style={{ ...getPinnedStyle(header.column, true), - width: header.getSize() + // ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ colSpan์ผ๋ก ๋๋น๊ฐ ๊ฒฐ์ ๋๋ฏ๋ก width ์ค์ ํ์ง ์์ + // ์์ ํค๋๋ง ๊ฐ๋ณ width ์ค์ + ...(!('columns' in header.column.columnDef) && { width: header.getSize() }), }} > <div style={{ position: "relative" }}> @@ -543,7 +545,8 @@ export function ExpandableDataTable<TData>({ header.getContext() )} - {header.column.getCanResize() && ( + {/* ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ ๋ฆฌ์ฌ์ด์ฆ ๋ถ๊ฐ, ์์ ํค๋๋ง ๋ฆฌ์ฌ์ด์ฆ ๊ฐ๋ฅ */} + {header.column.getCanResize() && !('columns' in header.column.columnDef) && ( <DataTableResizer header={header} /> )} </div> diff --git a/components/data-table/infinite-data-table.tsx b/components/data-table/infinite-data-table.tsx index b8764d62..d766f35c 100644 --- a/components/data-table/infinite-data-table.tsx +++ b/components/data-table/infinite-data-table.tsx @@ -167,7 +167,9 @@ export function InfiniteDataTable<TData>({ className={compactStyles.header} style={{ ...getPinnedStyle(header.column, true), // ๐ฏ ํค๋์์ ๋ช
์ - width: header.getSize(), // ๐ฏ width ๋ณ๋ ์ค์ + // ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ colSpan์ผ๋ก ๋๋น๊ฐ ๊ฒฐ์ ๋๋ฏ๋ก width ์ค์ ํ์ง ์์ + // ์์ ํค๋๋ง ๊ฐ๋ณ width ์ค์ + ...(!('columns' in header.column.columnDef) && { width: header.getSize() }), }} > <div style={{ position: "relative" }}> @@ -178,7 +180,8 @@ export function InfiniteDataTable<TData>({ header.getContext() )} - {header.column.getCanResize() && ( + {/* ๋ถ๋ชจ ๊ทธ๋ฃน ํค๋๋ ๋ฆฌ์ฌ์ด์ฆ ๋ถ๊ฐ, ์์ ํค๋๋ง ๋ฆฌ์ฌ์ด์ฆ ๊ฐ๋ฅ */} + {header.column.getCanResize() && !('columns' in header.column.columnDef) && ( <DataTableResizer header={header} /> )} </div> |
