정보검색 기본계획보고서 탭 조회 UX 개선

This commit is contained in:
kiminchan
2026-06-30 13:09:07 +09:00
parent 31caee87db
commit c14d536133
12 changed files with 641 additions and 410 deletions
@@ -1,4 +1,4 @@
import * as SelectPrimitive from "@radix-ui/react-select"
import * as SelectPrimitive from "@radix-ui/react-select"
import { Check, ChevronDown, ChevronUp } from "lucide-react"
import * as React from "react"
@@ -17,7 +17,7 @@ const SelectTrigger = React.forwardRef<
<SelectPrimitive.Trigger
ref={ref}
className={cn(
"flex h-13 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-xl ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
"flex h-14 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-xl ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-inset focus:ring-ring focus:ring-offset-0 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
className
)}
{...props}
@@ -148,3 +148,5 @@ export {
Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue
}
@@ -1,8 +1,8 @@
@tailwind components;
@tailwind components;
@layer components {
.selectbox_root {
@apply flex items-center;
@apply flex items-center overflow-visible py-1;
}
.selectbox_label {
@@ -1,4 +1,4 @@
"use client";
"use client";
import {
Checkbox,
@@ -37,6 +37,7 @@ type UiTableProps<T extends object> = {
headButton?: React.ReactNode | undefined;
widthFixed?: boolean;
isHideCount?: boolean; // 총 건수 default false
clickableHeadIds?: string[];
};
type UiHeadProps = {
@@ -69,7 +70,8 @@ export function UiTable<T extends object = Record<string, unknown>>({
curPage = 1,
headButton = undefined,
widthFixed = false,
isHideCount = false, // 총 건수
isHideCount = false,
clickableHeadIds,
}: UiTableProps<T>) {
const [cur, setCur] = useState<number>(curPage);
const [idx, setIdx] = useState<number>(index);
@@ -97,32 +99,36 @@ export function UiTable<T extends object = Record<string, unknown>>({
useEffect(() => {
setIdx(index);
}, [index])
}, [index]);
useEffect(() => {
setCur(curPage);
}, [curPage])
}, [curPage]);
const handlePageChange = (page: number) => {
setCur(page);
onPageChange(page);
if (index == 0)
setIdx(0)
if (index == 0) setIdx(0);
};
const isHeadClickable = (headId: string) => {
if (!cellClick) return false;
if (!clickableHeadIds || clickableHeadIds.length === 0) return true;
return clickableHeadIds.includes(headId);
};
const handleCellClick = (index: number, headId: string) => {
if (cellClick) {
cellClick(index, headId);
setIdx(index);
}
if (!isHeadClickable(headId) || !cellClick) return;
cellClick(index, headId);
setIdx(index);
};
const getLeafCols = (list: UiHeadProps[]) => {
const maxRow = list?.reduce((max, head) => Math.max(max, head.row || 0), 0);
return list
.filter(h => h.visible !== false)
.filter(h => ((h.row ?? 0) + (h.rowSpan ?? 1) - 1) >= maxRow)
;
.filter((h) => h.visible !== false)
.filter((h) => ((h.row ?? 0) + (h.rowSpan ?? 1) - 1) >= maxRow);
};
const leafCols = getLeafCols(headlist);
@@ -153,12 +159,15 @@ export function UiTable<T extends object = Record<string, unknown>>({
)}
<div className={`card !p-0r !m-[1.2rem] ${className}`}>
<Table variant="secondary" className={widthFixed ? "table-fixed" : ""}>
{widthFixed ?
{widthFixed ? (
<colgroup>
{leafCols.map(col => (
{leafCols.map((col) => (
<col key={col.id} style={{ width: col.widthPercent ? `${col.widthPercent}%` : undefined }} />
))}
</colgroup> : ""}
</colgroup>
) : (
""
)}
<TableHeader ref={headerRef} className="font-bold">
{children ? children : <HeadMakeColSpan upHeadList={headlist} />}
</TableHeader>
@@ -174,9 +183,9 @@ export function UiTable<T extends object = Record<string, unknown>>({
head.id.length > 1 &&
(boldArray.includes(index) ? (
<TableCell
className={`${head.align === "right" ? "text-right" : head.align === "center" ? "text-center" : "text-center"} ${cellClick && idx === index
className={`${head.align === "right" ? "text-right" : head.align === "center" ? "text-center" : "text-center"} ${isHeadClickable(head.id) && idx === index
? "cursor-pointer !font-[1000]"
: cellClick
: isHeadClickable(head.id)
? "cursor-pointer"
: ""
} ${cellClassName ? cellClassName(el, head.id, index) : ""} sticky top-20 z-40 bg-secondary !font-bold whitespace-pre-line`}
@@ -190,55 +199,38 @@ export function UiTable<T extends object = Record<string, unknown>>({
? String(cellValue ?? "")
: String(cellValue).includes(".")
? String(cellValue)
.split(".")
.map((part, index) =>
index === 0
? part.replace(
/\B(?=(\d{3})+(?!\d))/g,
",",
)
: part,
)
.join(".")
: String(cellValue ?? "").replace(
/\B(?=(\d{3})+(?!\d))/g,
",",
);
.split(".")
.map((part, index) =>
index === 0
? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",")
: part,
)
.join(".")
: String(cellValue ?? "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
})()}
</TableCell>
) : (
<TableCell
className={`${head.align === "right" ? "text-right" : head.align === "center" ? "text-center" : "text-center"} ${cellClick && idx === index
className={`${head.align === "right" ? "text-right" : head.align === "center" ? "text-center" : "text-center"} ${isHeadClickable(head.id) && idx === index
? "cursor-pointer !font-[1000]"
: cellClick
: isHeadClickable(head.id)
? "cursor-pointer"
: ""
} ${cellClassName ? cellClassName(el, head.id, index) : ""} mt-[${boldArray.length * 40}px] whitespace-pre-line`}
onClick={() => handleCellClick(index, head.id)}
key={`cell-${head.id}-${index}`}
>
{
//체크박스 유형애서 readOnly가 필요한 경우를 위해서 ChkClass 를 사용해서 readOnly 처리함.
(() => {
const cellValue = (el as Record<string, unknown>)[head.id];
return typeof cellValue === "object" &&
cellValue !== null &&
"chk" in (cellValue as object) &&
"readonly" in (cellValue as object) ? (
{(() => {
const cellValue = (el as Record<string, unknown>)[head.id];
return typeof cellValue === "object" &&
cellValue !== null &&
"chk" in (cellValue as object) &&
"readonly" in (cellValue as object) ? (
<Checkbox
checked={
(cellValue as ChkClass)?.chk === true
}
checked={(cellValue as ChkClass)?.chk === true}
onCheckedChange={(checked) => {
{
console.log(cellValue);
}
if (
(cellValue as ChkClass).readonly == true
)
return;
(cellValue as ChkClass).chk =
Boolean(checked);
if ((cellValue as ChkClass).readonly == true) return;
(cellValue as ChkClass).chk = Boolean(checked);
}}
>
<Check className="h-6 w-6 text-primary" />
@@ -258,22 +250,13 @@ export function UiTable<T extends object = Record<string, unknown>>({
String(cellValue)
.split(".")
.map((part, index) =>
index === 0
? part.replace(
/\B(?=(\d{3})+(?!\d))/g,
",",
)
: part,
index === 0 ? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : part,
)
.join(".")
) : (
String(cellValue ?? "").replace(
/\B(?=(\d{3})+(?!\d))/g,
",",
)
String(cellValue ?? "").replace(/\B(?=(\d{3})+(?!\d))/g, ",")
);
})()
}
})()}
</TableCell>
)),
)}