75 lines
1.9 KiB
TypeScript
75 lines
1.9 KiB
TypeScript
"use client";
|
|
|
|
import type React from "react";
|
|
import { TABLE_DIMENSIONS } from "@/components/lge-dashboard/chart/chart.config";
|
|
import { UNIT_TEXT } from "@/const/lg-common.const";
|
|
import type { DataColumn, SignStyle } from "../types";
|
|
import BaseDataTable from "../table/BaseDataTable";
|
|
|
|
type MergedChartCell<T> = {
|
|
key: keyof T;
|
|
startRowIndex?: number;
|
|
rowSpan?: number;
|
|
className?: string;
|
|
};
|
|
|
|
type Props<T extends Record<string, unknown>> = {
|
|
title?: string;
|
|
columns: DataColumn<T>[];
|
|
rows: T[];
|
|
chart: React.ReactNode;
|
|
chartCell: MergedChartCell<T>;
|
|
signStyle?: SignStyle<T>;
|
|
wrapperClassName?: string;
|
|
tableClassName?: string;
|
|
minWidthPx?: number;
|
|
minWidth?: number;
|
|
starUnder30Sample?: boolean;
|
|
unitText?: string;
|
|
getCellClassName?: (row: T, column: DataColumn<T>, rowIndex: number) => string | undefined;
|
|
};
|
|
|
|
export default function LeftChartTable<T extends Record<string, unknown>>({
|
|
title,
|
|
columns,
|
|
rows,
|
|
chart,
|
|
chartCell,
|
|
signStyle,
|
|
wrapperClassName,
|
|
tableClassName,
|
|
minWidthPx = TABLE_DIMENSIONS.MIN_WIDTH.COMPACT,
|
|
minWidth,
|
|
starUnder30Sample = true,
|
|
unitText = UNIT_TEXT,
|
|
getCellClassName,
|
|
}: Readonly<Props<T>>) {
|
|
return (
|
|
<BaseDataTable
|
|
columns={columns}
|
|
rows={rows}
|
|
title={title}
|
|
wrapperClassName={wrapperClassName}
|
|
tableClassName={tableClassName}
|
|
minWidth={minWidth ?? minWidthPx}
|
|
signStyle={signStyle}
|
|
signStyleFallback={{
|
|
positiveTextClassName: "lg-num-pos",
|
|
negativeTextClassName: "lg-num-neg",
|
|
zeroTextClassName: "",
|
|
arrowWithNumber: true,
|
|
}}
|
|
starUnder30Sample={starUnder30Sample}
|
|
unitText={unitText}
|
|
getCellClassName={getCellClassName}
|
|
mergedCell={{
|
|
key: chartCell.key,
|
|
content: chart,
|
|
startRowIndex: chartCell.startRowIndex,
|
|
rowSpan: chartCell.rowSpan,
|
|
className: chartCell.className,
|
|
}}
|
|
/>
|
|
);
|
|
}
|