Merge remote-tracking branch 'origin/iipbs/common/main' into iipbs/wr/dev
iipbs_wr / build (push) Has been cancelled
iipbs_wr / build (push) Has been cancelled
This commit is contained in:
@@ -1,9 +1,11 @@
|
||||
"use client"
|
||||
|
||||
import { Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components";
|
||||
import { Checkbox, Table, TableBody, TableCell, TableHeader, TableRow } from "@common/components";
|
||||
import { useEffect, useState } from "react";
|
||||
import { HeadMakeColSpan } from "./HeadMakeColSpan";
|
||||
import UiPageNations from "./uiPageNations";
|
||||
import { AlignVerticalDistributeCenterIcon, Check } from "lucide-react";
|
||||
import { boolean } from "zod";
|
||||
|
||||
type UiTableProps = {
|
||||
headName: React.ReactNode | undefined;
|
||||
@@ -29,6 +31,9 @@ type UiHeadProps = {
|
||||
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);
|
||||
const [isCheck, seIsCheck] = useState<boolean>(false);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if (resetPageNo) {
|
||||
setCur(1);
|
||||
@@ -47,6 +52,7 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
|
||||
setIdx(index);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -65,7 +71,9 @@ 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
|
||||
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' : ''
|
||||
@@ -78,7 +86,8 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
|
||||
index === 0 ? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : part
|
||||
).join('.')
|
||||
: String(el[head.id] ?? '').replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
|
||||
</TableCell>:
|
||||
</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' :
|
||||
@@ -87,11 +96,24 @@ export function UiTable({ tableData, headlist, pageSize, total, headName, childr
|
||||
onClick={() => handleCellClick(index, head.id)}
|
||||
key={`cell-${head.id}-${index}`}
|
||||
>
|
||||
{typeof el[head.id] !== 'number'?String(el[head.id] ?? ''): String(el[head.id]).includes('.')
|
||||
{typeof el[head.id] === 'boolean'
|
||||
?<Checkbox
|
||||
checked={el[head.id] === true}
|
||||
onCheckedChange={(checked) => {
|
||||
el[head.id]= checked;
|
||||
}}
|
||||
>
|
||||
<Check className="h-6 w-6 text-primary" />
|
||||
</Checkbox>
|
||||
:
|
||||
typeof el[head.id] !== 'number'?
|
||||
String(el[head.id] ?? ''):
|
||||
String(el[head.id]).includes('.')
|
||||
? String(el[head.id]).split('.').map((part, index) =>
|
||||
index === 0 ? part.replace(/\B(?=(\d{3})+(?!\d))/g, ",") : part
|
||||
).join('.')
|
||||
: String(el[head.id] ?? '').replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
|
||||
).join('.')
|
||||
:
|
||||
String(el[head.id] ?? '').replace(/\B(?=(\d{3})+(?!\d))/g, ",")}
|
||||
</TableCell>
|
||||
)
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user