테이블 boldArray property 추가 (역할 : 지정된 array의 글씨색 굵게 변경)

This commit is contained in:
YangJinSoo94
2025-05-09 16:55:09 +09:00
parent f04a463aeb
commit 1d4da4caf5
@@ -14,6 +14,7 @@ type UiTableProps = {
className?: string;
resetPageNo?: boolean;
children?: React.ReactNode | undefined;
boldArray?: number[];
}
type UiHeadProps = {
@@ -23,7 +24,7 @@ type UiHeadProps = {
visible?:boolean;
}
export function UiTable({ tableData, headlist, pageSize, total, headName, children, cellClick, onPageChange, className = '', resetPageNo = false }: UiTableProps) {
export function UiTable({ tableData, headlist, pageSize, total, headName, children, cellClick, onPageChange, className = '', resetPageNo = false, boldArray = [] }: UiTableProps) {
const [cur, setCur] = useState<number>(1);
const [idx, setIdx] = useState<number>(-1);
@@ -63,6 +64,16 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
.filter((item) => item.visible != false)
.map((head) => (
head.id && head.id.length > 1 && (
boldArray.includes(index) ? <TableCell
className={`${head.align === 'right' ? 'text-right' : head.align === 'center' ? 'text-center' : typeof el[head.id] === 'number' ? 'text-right' : 'text-center'} ${
cellClick && idx === index ? '!font-[1000] cursor-pointer' :
cellClick ? 'cursor-pointer' : ''
} !font-bold`}
onClick={() => handleCellClick(index, head.id)}
key={`cell-${head.id}-${index}`}
>
{typeof el[head.id] === 'number' ? String(el[head.id]).replace(/\B(?=(\d{3})+(?!\d))/g, ",") : String(el[head.id] ?? '')}
</TableCell>:
<TableCell
className={`${head.align === 'right' ? 'text-right' : head.align === 'center' ? 'text-center' : typeof el[head.id] === 'number' ? 'text-right' : 'text-center'} ${
cellClick && idx === index ? '!font-[1000] cursor-pointer' :