21 lines
967 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.

import { Tooltip, Typography } from 'antd';
import { codeCellView } from './cellView';
import type { GridRow } from './statementGrid';
/** Ячейка кода (просмотр): код, у нераспознанного — серый сырой текст; подсказка — по `codeCellView`. */
export function CodeCell({ row, fontWeight }: { row: GridRow; fontWeight?: number }) {
const view = codeCellView(row);
const content = view.muted ? (
<Typography.Text type='secondary'>{view.text}</Typography.Text>
) : (
<span style={{ fontWeight }}>{view.text}</span>
);
if (!view.tip) return content;
return (
<Tooltip title={<span style={{ whiteSpace: 'pre-line' }}>{view.tip}</span>}>
{/* span с минимальной шириной: у расшифровки текст пуст, а подсказка должна открываться */}
<span style={{ display: 'inline-block', minWidth: 16 }}>{content}</span>
</Tooltip>
);
}