UNPKG

@limetech/lime-elements

Version:
147 lines 4.85 kB
import { Languages } from '../date-picker/date.types'; /** * Displays a visual diff between two text values, modeled on * GitHub's code difference view. * * Supports unified and split (side-by-side) views with line numbers, * color-coded additions and removals, word-level inline highlighting, * and collapsible unchanged context sections. * * @beta * @exampleComponent limel-example-code-diff-basic * @exampleComponent limel-example-code-diff-headings * @exampleComponent limel-example-code-diff-json * @exampleComponent limel-example-code-diff-split * @exampleComponent limel-example-code-diff-line-wrap * @exampleComponent limel-example-code-diff-expand */ export declare class CodeDiff { /** * The "before" value to compare. * Can be a string or an object (which will be serialized to JSON). */ oldValue: string | object; /** * The "after" value to compare. * Can be a string or an object (which will be serialized to JSON). */ newValue: string | object; /** * Heading for the original (before) version, displayed in the diff header. * Defaults to `"Original"`, localized via `translationLanguage`. */ oldHeading?: string; /** * Heading for the modified (after) version, displayed in the diff header. * Defaults to `"Modified"`, localized via `translationLanguage`. */ newHeading?: string; /** * The layout of the diff view. * - `unified` — single column with interleaved additions and removals * - `split` — side-by-side comparison with old on left, new on right */ layout: 'unified' | 'split'; /** * Number of unchanged context lines to display around each change. */ contextLines: number; /** * When `true`, long lines are wrapped instead of causing * horizontal scrolling. Useful when comparing prose or * config files with long values. */ lineWrapping: boolean; /** * Language for syntax highlighting. * Currently supports `"json"`. When set, code tokens are * colorized (strings, numbers, keys, etc.) alongside the * diff highlighting. */ language?: string; /** * When `true`, JSON values are parsed, keys are sorted, * and indentation is normalized before diffing. * This eliminates noise from formatting or key-order differences. */ reformatJson: boolean; /** * Defines the language for translations. * Will translate all visible labels and announcements. */ translationLanguage: Languages; private readonly host; private diffResult; private liveAnnouncement; private copyState; private searchVisible; private searchTerm; private currentMatchIndex; private focusedRowIndex; private normalizedOldText; /** * Render-time counter that increments for each search match * found while rendering removed lines. Used to determine which * match is the "current" one for navigation highlighting. */ private searchMatchCounter; /** * Total search matches found during the last render pass. */ private totalSearchMatches; /** * Whether the current render is inside a removed line, * so search highlighting knows when to activate. */ private isRenderingRemovedLine; /** * Cached search regex for the current render pass. * Built once in render() and reused across all renderSearchableText calls. */ private activeSearchRegex; private searchInputEl; private prevSearchVisible; componentWillLoad(): void; componentDidRender(): void; render(): any; protected watchInputs(): void; private recomputeDiff; private formatSrSummary; private renderScreenReaderSummary; private handleKeyDown; private getDiffRows; private updateRowFocus; private announceLine; private renderHeader; private renderCopyButton; private copyToClipboard; private renderSearchToggle; private renderSearchBar; private toggleSearch; private onSearchInput; private onSearchKeyDown; private computeLineNumberWidth; private getSearchActions; private onSearchAction; private navigateSearch; private renderDiff; private renderHunks; private renderHunkLines; private renderChangeBlock; private renderLine; private renderSplitHunkRows; private renderSplitChangeBlock; private renderSplitRow; private renderBlockCopyButton; private renderContent; private renderSegment; private renderSyntaxTokens; private renderSyntaxToken; private renderSearchableText; private renderCollapsedRow; private renderCollapsedAfterRow; private expandHunk; private expandAfter; private getTranslation; } //# sourceMappingURL=code-diff.d.ts.map