All files / src/pages/flowsheet-page/economics/results-panel/tables resultRowState.ts

100% Statements 4/4
87.5% Branches 7/8
100% Functions 0/0
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                        18x 4x                         22x                
import type { EconomicsResultLineRead } from "@/api/apiStore.gen";
import { cn } from "@/lib/utils";
import {
  RESULT_HIGHLIGHTABLE_ROW_CLASS,
  RESULT_SELECTED_ROW_CLASS,
} from "./resultStyles";
 
export function resultLineRowRef(
  rowRefs: Map<number, HTMLElement>,
  lineId: number,
) {
  return (node: HTMLElement | null) => {
    if (node) rowRefs.set(lineId, node);
    else rowRefs.delete(lineId);
  };
}
 
export function resultLineRowClassName({
  line,
  selectedSourceRowId,
  className,
}: {
  line?: EconomicsResultLineRead;
  selectedSourceRowId?: number;
  className?: string;
}) {
  return cn(
    line ? RESULT_HIGHLIGHTABLE_ROW_CLASS : undefined,
    line && selectedSourceRowId === line.id
      ? RESULT_SELECTED_ROW_CLASS
      : undefined,
    className,
  );
}