table update

This commit is contained in:
Nate Kelley 2025-04-10 14:56:11 -06:00
parent 861d9b7a7c
commit de99ea1742
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
2 changed files with 33 additions and 28 deletions

View File

@ -11,14 +11,11 @@ import { useMemoizedFn } from '@/hooks';
import { AppDataGrid } from '@/components/ui/table/AppDataGrid'; import { AppDataGrid } from '@/components/ui/table/AppDataGrid';
import './TableChart.css'; import './TableChart.css';
import { cn } from '@/lib/classMerge'; import { cn } from '@/lib/classMerge';
import { useUpdateMetricChart } from '@/context/Metrics';
export interface BusterTableChartProps extends BusterTableChartConfig, BusterChartPropsBase {} export interface BusterTableChartProps extends BusterTableChartConfig, BusterChartPropsBase {}
const BusterTableChartBase: React.FC< const BusterTableChartBase: React.FC<BusterTableChartProps> = ({
BusterTableChartProps & {
onChangeConfig?: (config: Partial<IBusterMetricChartConfig>) => void;
}
> = ({
className = '', className = '',
onMounted, onMounted,
data, data,
@ -27,13 +24,39 @@ const BusterTableChartBase: React.FC<
tableColumnWidths = DEFAULT_CHART_CONFIG.tableColumnWidths, tableColumnWidths = DEFAULT_CHART_CONFIG.tableColumnWidths,
readOnly = false, readOnly = false,
onInitialAnimationEnd, onInitialAnimationEnd,
onChangeConfig,
//TODO //TODO
tableHeaderBackgroundColor, tableHeaderBackgroundColor,
tableHeaderFontColor, tableHeaderFontColor,
animate, animate,
tableColumnFontColor tableColumnFontColor
}) => { }) => {
const { onUpdateMetricChartConfig } = useUpdateMetricChart();
const onChangeConfig = useMemoizedFn((config: Partial<IBusterMetricChartConfig>) => {
if (readOnly) return;
onUpdateMetricChartConfig({ chartConfig: config });
});
const onUpdateTableColumnOrder = useMemoizedFn((columns: string[]) => {
if (readOnly) return;
const config: Partial<IBusterMetricChartConfig> = {
tableColumnOrder: columns
};
onChangeConfig(config);
});
const onUpdateTableColumnSize = useMemoizedFn((columns: { key: string; size: number }[]) => {
if (readOnly) return;
const config: Partial<IBusterMetricChartConfig> = {
tableColumnWidths: columns.reduce<Record<string, number>>((acc, { key, size }) => {
acc[key] = Number(size.toFixed(1));
return acc;
}, {})
};
onChangeConfig(config);
});
//THIS MUST BE A USE CALLBACK //THIS MUST BE A USE CALLBACK
const onFormatHeader = useCallback( const onFormatHeader = useCallback(
(value: any, columnName: string) => { (value: any, columnName: string) => {
@ -49,28 +72,8 @@ const BusterTableChartBase: React.FC<
[columnLabelFormats] [columnLabelFormats]
); );
const onUpdateTableColumnOrder = useMemoizedFn((columns: string[]) => {
if (readOnly) return;
const config: Partial<IBusterMetricChartConfig> = {
tableColumnOrder: columns
};
onChangeConfig?.(config);
});
const onUpdateTableColumnSize = useMemoizedFn((columns: { key: string; size: number }[]) => {
if (readOnly) return;
const config: Partial<IBusterMetricChartConfig> = {
tableColumnWidths: columns.reduce<Record<string, number>>((acc, { key, size }) => {
acc[key] = size;
return acc;
}, {})
};
onChangeConfig?.(config);
});
const onReady = useMemoizedFn(() => { const onReady = useMemoizedFn(() => {
onMounted?.(); //I decided to remove this because it was causing a double render onMounted?.();
requestAnimationFrame(() => { requestAnimationFrame(() => {
onInitialAnimationEnd?.(); onInitialAnimationEnd?.();
}); });

View File

@ -16,7 +16,9 @@ export const PopupContainer: React.FC<{
animate={{ opacity: 1, y: 0 }} animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -3 }} exit={{ opacity: 0, y: -3 }}
transition={{ duration: 0.12 }}> transition={{ duration: 0.12 }}>
<div className="bg-background rounded px-2 py-1.5 shadow">{show && <>{children}</>}</div> <div className="bg-background rounded px-2 py-1.5 shadow-md">
{show && <>{children}</>}
</div>
</motion.div> </motion.div>
)} )}
</AnimatePresence> </AnimatePresence>