import { CodeViewItem, CodeViewScrollTarget, DiffLineAnnotation, LineAnnotation } from "../types.js"; import { EditorChangeEvent, EditorType } from "../editor/types.js"; import { GetHoveredLineResult } from "../managers/InteractionManager.js"; import { Editor, EditorOptions } from "../editor/editor.js"; import { CodeView as CodeView$1, CodeViewItemEditCompleteHandler, CodeViewLineSelection, CodeViewOptions } from "../components/CodeView.js"; import "../edit/index.js"; import "../index.js"; import { CSSProperties, ReactNode, Ref } from "react"; //#region src/react/CodeView.d.ts type CodeViewGutterUtilityGetter = (() => GetHoveredLineResult<'file'> | undefined) | (() => GetHoveredLineResult<'diff'> | undefined); type CodeViewReactOptions = Omit, 'controlledSelection' | 'createEditor' | 'onSelectedLinesChange'>; interface CodeViewBaseProps { options?: CodeViewReactOptions; /** * Creation-time options passed to the nearest EditProvider factory. * CodeView supplies its item-specific change callback. */ editorOptions?: Omit, 'onChange'>; /** Resolve an in-memory retention key for an item's draft and undo history. */ getEditStateKey?(item: CodeViewItem): string | undefined; className?: string; style?: CSSProperties; /** * Ref to the scroll container element. A callback ref follows the React 18 * protocol: it is called with the element on mount and with `null` on * unmount. A cleanup function returned from the callback (the React 19 * form) is ignored, so release resources on the `null` call or use a ref * object. */ containerRef?: Ref; disableWorkerPool?: boolean; selectedLines?: CodeViewLineSelection | null; onSelectedLinesChange?(selection: CodeViewLineSelection | null): void; onScroll?(scrollTop: number, viewer: CodeView$1): void; /** Render a non-virtualized node at the very start of the scroll content, * before the first item. Always rendered; scrolls with the content. */ renderCodeViewHeader?(): ReactNode; /** Render a non-virtualized node at the very end of the scroll content, after * the last item. Always rendered; scrolls with the content. */ renderCodeViewFooter?(): ReactNode; /** * Called with the editor's `EditorChangeEvent` and the owning item on every * document change. Do not feed it directly back into the controlled item, * which can create update loops. */ onItemEditChange?(event: EditorChangeEvent, item: CodeViewItem): void; /** * Called once when an edit session ends: edit turned off, the item removed, * or the CodeView unmounted (where the result is not installed). Collapse * suspends the session instead of completing it. `nextItem` is the accepted * replacement CodeView built from `item`: the event's completed * `file`/`fileDiff` and annotations, `edit: false`, and a bumped `version`. * Return `'accept'` to install the edit — CodeView applies `nextItem` through * the item update path when the item still exists, and a controlled owner * puts the same `nextItem` into its state — or `'reject'` to revert. The event * is frozen; re-key the accepted value in place before accepting. */ onItemEditComplete?: CodeViewItemEditCompleteHandler; renderCustomHeader?(item: CodeViewItem): ReactNode; renderHeaderPrefix?(item: CodeViewItem): ReactNode; renderHeaderFilenameSuffix?(item: CodeViewItem): ReactNode; renderHeaderMetadata?(item: CodeViewItem): ReactNode; renderAnnotation?(annotation: LineAnnotation | DiffLineAnnotation, item: CodeViewItem): ReactNode; renderGutterUtility?(getHoveredLine: CodeViewGutterUtilityGetter, item: CodeViewItem): ReactNode; } interface ControlledCodeViewProps extends CodeViewBaseProps { items: readonly CodeViewItem[]; initialItems?: never; } interface UncontrolledCodeViewProps extends CodeViewBaseProps { initialItems?: readonly CodeViewItem[]; items?: never; } type CodeViewProps = ControlledCodeViewProps | UncontrolledCodeViewProps; interface CodeViewHandle { addItems(items: readonly CodeViewItem[]): void; getItem(id: string): CodeViewItem | undefined; removeItem(id: string): boolean; updateItem(item: CodeViewItem): boolean; updateItemId(oldId: string, newId: string): boolean; scrollTo(target: CodeViewScrollTarget): void; setSelectedLines(selection: CodeViewLineSelection | null): void; getSelectedLines(): CodeViewLineSelection | null; clearSelectedLines(): void; getEditor(id: string): Editor<'file', LAnnotation, Caret> | Editor<'file-diff', LAnnotation, Caret> | undefined; getInstance(): CodeView$1 | undefined; } type CodeViewComponent = (props: CodeViewProps & { ref?: React.Ref>; }) => React.JSX.Element; declare const CodeView: CodeViewComponent; //#endregion export { CodeView, CodeViewHandle, type CodeViewItemEditCompleteHandler, CodeViewProps, CodeViewReactOptions, ControlledCodeViewProps, UncontrolledCodeViewProps }; //# sourceMappingURL=CodeView.d.ts.map