import { type GestureResponderEvent } from "react-native"; import { type ColorTokens, type StyleProp, type ViewStyle, type TextStyle } from "../../style/index.js"; export interface CodeBlockSkin { /** Shared code type (size / line-height) used by code, gutter, and terminal text. */ codeType: TextStyle; /** The tightened compact ramp. */ codeTypeCompact: TextStyle; /** Code foreground color (token-driven so it follows light/dark). */ codeText: (t: ColorTokens) => TextStyle; /** The muted, bordered, rounded code surface (plain + numbered base). */ surface: (t: ColorTokens) => ViewStyle; /** Squares the top edge for `attached` blocks (flush under an adjoining bar). */ attachedTop: ViewStyle; /** Vertical padding of the rows column, per density. */ bodyPad: (compact: boolean) => ViewStyle; /** One code row: direction + horizontal insets, per density and gutter presence. */ rowPad: (compact: boolean, gutter: boolean) => ViewStyle; /** Header strip carrying the filename/language label or the tab strip. */ headerBar: (t: ColorTokens) => ViewStyle; /** Header adjustments when it hosts the tab strip. */ headerBarWithTabs: ViewStyle; /** Header label type (the file/language name). */ headerLabel: (t: ColorTokens) => TextStyle; /** The trailing language badge (shown when both filename and language are set). */ headerBadge: (t: ColorTokens) => TextStyle; /** Squares off the surface's top corners when a header bar sits above it. */ surfaceUnderHeader: ViewStyle; /** The tab row hosted by the header bar / terminal chrome. */ tabStrip: ViewStyle; /** One tab (underline when active; `dark` styles the terminal incarnation). */ tabItem: (t: ColorTokens, active: boolean, dark: boolean) => ViewStyle; /** One tab's label type. */ tabLabel: (t: ColorTokens, active: boolean, dark: boolean) => TextStyle; /** The soft primary wash behind a `highlightLines` row. */ highlightRow: (t: ColorTokens, dark: boolean) => ViewStyle; /** The green/red wash behind an added/removed diff row. */ diffRow: (kind: "add" | "del", dark: boolean) => ViewStyle; /** The +/- marker glyph type (non-selectable). */ diffMarker: (kind: "add" | "del" | "ctx", t: ColorTokens, dark: boolean) => TextStyle; /** The pinned line-number column, per density. */ gutterCol: (compact: boolean) => ViewStyle; /** One gutter row (right-aligned number), per density. */ gutterRow: (compact: boolean) => ViewStyle; /** Dimmed line-number color. */ gutterText: (t: ColorTokens) => TextStyle; /** The expander bar under a collapsed block. */ expanderBar: (t: ColorTokens) => ViewStyle; /** The expander label type. */ expanderLabel: (t: ColorTokens) => TextStyle; /** Terminal outer window: shape, border, shadow/elevation, clipping. */ terminalOuter: (t: ColorTokens) => ViewStyle; /** Terminal chrome bar (dots + label / tabs / copy chip). */ terminalChrome: ViewStyle; /** Chrome adjustments when it hosts the tab strip. */ terminalChromeWithTabs: ViewStyle; /** A single traffic-light dot, keyed by hue. */ trafficDot: (hue: "red" | "amber" | "green") => ViewStyle; /** Terminal chrome label type. */ terminalLabel: TextStyle; /** Terminal body container (dark fill + vertical padding), per density. */ terminalBody: (compact: boolean) => ViewStyle; /** The non-selectable prompt glyph. */ terminalPrompt: TextStyle; /** The command line text. */ terminalLine: TextStyle; /** A dimmed transcript output line. */ terminalOutput: TextStyle; /** The inline pill (short mid-sentence token). */ inlineBox: (t: ColorTokens) => ViewStyle; /** Inline label type (its own smaller size). */ inlineType: TextStyle; /** The copy chip shape/fill (`dark` picks the terminal chip; `floating` adds its shadow). */ copyButton: (t: ColorTokens, dark: boolean, floating: boolean) => ViewStyle; /** The copy chip label. */ copyText: (t: ColorTokens, dark: boolean) => TextStyle; /** Press dim opacity for pressable chrome (iOS/web feedback). */ copyPressedOpacity: number; } /** One snippet in a `tabs` group: a labeled code alternative (npm / yarn / bun…). */ export interface CodeBlockTab { /** The tab's visible label. */ label: string; /** The code this tab shows. */ code: string; /** Per-tab grammar; falls back to the block-level `language`. */ language?: string; /** Per-tab filename; falls back to the block-level `filename`. */ filename?: string; } export interface CodeBlockProps { /** The code to render. Newlines are preserved (RN Text honors "\n"). */ code?: string; /** * Optional filename label shown in a header bar above the surface. Honored by * the plain and numbered variants (and the terminal chrome label); the inline * pill has no header. When both are set, `filename` takes the header label and * `language` renders as a trailing badge. */ filename?: string; /** * The snippet's language. Drives syntax highlighting (ts/tsx/js/jsx, json, * bash/sh, css, html, python — anything else renders monochrome) and the * header/terminal label when no `filename` is given. */ language?: string; terminal?: boolean; numbered?: boolean; inline?: boolean; compact?: boolean; /** Show a copy affordance (header-hosted when a header/chrome exists, else pinned top-right). */ copy?: boolean; /** Soft-wrap long lines instead of scrolling them horizontally. */ wrap?: boolean; /** * Render the code as a unified diff: the first column of every line is the * marker ("+" added, "-" removed, anything else context). Added/removed rows * tint green/red, markers stay out of the selection, and the copy chip yields * the post-change code (context + added lines, markers stripped). */ diff?: boolean; /** Square the top edge (no top radius/border) to sit flush under an adjoining bar. */ attached?: boolean; /** * Emphasize lines: entries are 1-based line numbers or "start-end" ranges * (e.g. `[2, "5-7"]`). Numbers refer to the displayed numbering, so they * respect `startLine`. Plain and numbered variants only. */ highlightLines?: ReadonlyArray; /** First displayed line number for the numbered variant (default 1). */ startLine?: number; /** Fold long blocks behind a "Show all" expander (plain + numbered variants). */ collapsible?: boolean; /** How many lines a collapsed block shows (default 8). */ collapsedLines?: number; /** Controlled expanded state for `collapsible`. */ expanded?: boolean; /** Uncontrolled initial expanded state (default false). */ defaultExpanded?: boolean; /** Called when the expander toggles (fires in both modes). */ onExpandedChange?: (expanded: boolean) => void; /** * Labeled code alternatives rendered as a tab strip in the header (or the * terminal chrome) — the classic npm/yarn/bun switcher. Each tab supplies its * own code and optional language/filename. */ tabs?: ReadonlyArray; /** Controlled active tab index. */ active?: number; /** Uncontrolled initial tab index (default 0). */ defaultActive?: number; /** Called with the next tab index when a tab is selected (fires in both modes). */ onTabChange?: (index: number) => void; /** The terminal prompt marker (default "$"). Lines starting with it render as commands. */ prompt?: string; /** * Called when the copy affordance is pressed, with the copied text. The chip * also writes the clipboard itself (navigator.clipboard on web, the optional * expo-clipboard peer on native), so this is for side effects, not plumbing. */ onCopy?: (code: string, event: GestureResponderEvent) => void; /** E2E hook forwarded to the root element. */ testID?: string; /** Outer layout composition only (width/flex within a parent), never a restyle hook. */ style?: StyleProp; } export declare function createCodeBlock(skin: CodeBlockSkin): (props: CodeBlockProps) => import("react").JSX.Element; //# sourceMappingURL=code-block.shared.d.ts.map