import { type GestureResponderEvent } from "react-native"; import { type ColorTokens, type ViewStyle, type TextStyle, type TouchTargetSkin, type LayoutStyle } from "../../style/index.js"; import { type Variant } from "./code-block.styles.js"; export interface CodeBlockSkin extends TouchTargetSkin { /** Shared code type (size / line-height) used by code, gutter, and terminal text. */ codeType: TextStyle; /** The tightened compact ramp. */ codeTypeCompact: TextStyle; /** The card snippet's ramp (the `guide` density, 12 / 1.65). */ codeTypeGuide: TextStyle; /** Code foreground color (token-driven so it follows light/dark). */ codeText: (t: ColorTokens) => TextStyle; /** The muted, bordered, rounded code surface (plain + numbered base), per density. */ surface: (t: ColorTokens, density?: Density) => ViewStyle; /** Squares the top edge for `attached` blocks (flush under an adjoining bar). */ attachedTop: ViewStyle; /** Vertical padding of the rows column, per density. */ bodyPad: (density: Density) => ViewStyle; /** One code row: direction + horizontal insets, per density and gutter presence. */ rowPad: (density: Density, gutter: boolean) => ViewStyle; /** Header strip carrying the filename/language label or the tab strip, per density. */ headerBar: (t: ColorTokens, density?: Density) => 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: (density: Density) => ViewStyle; /** One gutter row (right-aligned number), per density. */ gutterRow: (density: Density) => ViewStyle; /** Dimmed line-number color. */ gutterText: (t: ColorTokens) => TextStyle; /** The expander bar under a collapsed block; its ripple clip follows the card's corner at each density. */ expanderBar: (t: ColorTokens) => ViewStyle; /** The expander's ripple clip: the surface's bottom corners, inside its border. */ expanderClip: (density?: Density) => 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: (density: Density) => 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 copyable inline pill (`inline copy`): its shape, fill and hairline, at rest or hovered. */ inlineCopyBox: (t: ColorTokens, hovered: boolean) => ViewStyle; /** The copyable inline pill's code type and ink, at rest or hovered. */ inlineCopyType: (t: ColorTokens, hovered: boolean) => TextStyle; /** The copyable inline pill's trailing glyph size. */ inlineCopyIcon: number; /** The copy chip shape/fill (`dark` picks the terminal chip; `floating` adds its shadow), per density. */ copyButton: (t: ColorTokens, dark: boolean, floating: boolean, density?: Density) => 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; /** Bare execution output: selectable, wrapped monochrome text with no card, header or expander. Takes precedence over terminal, numbered and inline; other display modifiers are ignored. */ transcript?: boolean; terminal?: boolean; numbered?: boolean; inline?: boolean; compact?: boolean; /** * The hand-off component page's JSX card (Component.dc.html lines 171 to 174, the * playground's output): the block at the card corner, its header a 40 px bar on the * card fill, 16 in and 8 out, with its Copy a 28 px hairline button, and the code 16 * above and below, 18 in, at the default 13 / 1.7 ramp. `compact` wins when both are passed. */ playground?: boolean; /** * The hand-off component page's own snippet (Component.dc.html line 283, the Usage * section's block under its paragraph): the code-card corner, with the code 16 above and * below and 18 in at the default 13 / 1.7 ramp. `compact` and `playground` win over it. */ snippet?: boolean; /** * The hand-off component page's card snippet (Component.dc.html line 288, the block in * a Usage guidance card): the card-snippet corner, with the code 12 above and below and * 14 in at 12 / 1.65. Every other density wins over it. */ guide?: boolean; /** * Show a copy affordance (header-hosted when a header/chrome exists, else pinned * top-right). On the `inline` variant the whole pill becomes the copy button: a raised * mono chip with a trailing copy glyph that turns to a check once copied (an import * line a reader takes away). */ copy?: boolean; /** Soft-wrap long lines instead of scrolling them horizontally. An overflowing unwrapped block is a keyboard tab stop; arrow keys use the platform's normal scrolling. */ 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; /** * Draw no header bar: `language` still drives the highlighting, but neither it nor a * `filename` labels the block, and `copy` floats over the code's top-right corner. For * a snippet whose context already names it (a docs page's usage block). Plain and * numbered variants; a `tabs` strip still needs its header, and the terminal keeps its * chrome. */ headerless?: boolean; /** * Keep the header bar but draw no trailing language badge beside the copy chip: * `language` still drives the highlighting, for a header whose `filename` already * names the language (the hand-off's playground bar, Component.dc.html lines 171 to * 174, is "JSX · " and a Copy button only). Nothing changes when there is * no `filename`, since the language is then the header's label, not a badge. */ unbadged?: 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; /** Composition within a parent only, never a restyle hook and never a width: the parent layout container provides the bounds. */ style?: LayoutStyle; } export declare function variantOf(p: CodeBlockProps): Variant; /** The block's density (pick one): the tightened ramp, the hand-off's playground card, its page snippet, its card snippet, or the default. */ export type Density = "compact" | "playground" | "snippet" | "guide" | "default"; export declare function densityOf(p: CodeBlockProps): Density; export declare function createCodeBlock(skin: CodeBlockSkin): (props: CodeBlockProps) => import("react").JSX.Element; //# sourceMappingURL=code-block.shared.d.ts.map