22 lines
915 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Что нужно включить, чтобы строку с ключом key можно было показать на экране (переход «Показать»).
import type { GridRow } from './statementGrid';
export interface FocusSwitches {
details: boolean;
emptySublines: boolean;
}
/** Какие переключатели нужно включить для строки key; уже включённые и неизвестный ключ — false. */
export function switchesFor(
key: string,
rows: GridRow[],
state: { showDetails: boolean; showEmptySublines: boolean; emptySublines: ReadonlySet<string> },
): FocusSwitches {
const row = rows.find((r) => r.key === key);
if (!row) return { details: false, emptySublines: false };
return {
details: row.lineStatus === 'detail' && !state.showDetails,
emptySublines: state.emptySublines.has(key) && !state.showEmptySublines,
};
}