import type { CSSProperties, ReactElement } from 'react'; /** A styled part of the text, e.g. a variable inside a step name */ export interface HighlightTextPart { text: string; /** * Needs the same contrast as `color` on the row. Colour alone must not tell * kinds of parts apart (WCAG 1.4.1): a tooltip can say what the part is. */ color?: string; fontWeight?: CSSProperties['fontWeight']; /** * Shown on hover over this part only. Text or JSX, as for `tooltip` below. * A line break (`\n`) in text starts a new line, e.g. for an element's name * and type; prefer that over JSX in long lists, since JSX tooltips render a * hidden copy in every row. */ tooltip?: string | ReactElement; } /** Plain text, or a styled part */ export type HighlightTextSegment = string | HighlightTextPart; export interface HighlightTextProps { text?: string; /** * Use instead of `text` when parts need their own colour or tooltip. * Search highlighting runs on the joined text, so a match can span parts. */ segments?: HighlightTextSegment[]; highlight?: String; onlyExactMatch?: boolean; /** * Text colour: any CSS colour value or variable, e.g. `var(--brand-color)`. * WCAG 1.4.6 (AAA) needs 7:1 contrast with the background (4.5:1 for large * text), also against the search highlight. */ color?: string; fontWeight?: CSSProperties['fontWeight']; /** * Shown on hover or keyboard focus, through the global TooltipService. The * text takes focus for it, except inside another control (e.g. a button), * which should then carry the tooltip itself. Escape hides it. JSX is copied * into the tooltip as HTML, so it is static: event handlers inside it do not * run. */ tooltip?: string | ReactElement; /** * Keep to one line and end with an ellipsis when it does not fit. The full * text shows on hover or focus, only while it is cut off (unless `tooltip` * is set); the row takes focus only then. */ truncate?: boolean; }