sussudio
Version:
An unofficial VS Code Internal API
149 lines (148 loc) • 5.38 kB
text/typescript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { IHistoryNavigationWidget } from "../../history.mjs";
import { IContextViewProvider } from "../contextview/contextview.mjs";
import { Widget } from "../widget.mjs";
import { IAction } from "../../../common/actions.mjs";
import { Event } from "../../../common/event.mjs";
import "../../../../css!./inputBox.mjs";
export interface IInputOptions {
readonly placeholder?: string;
readonly showPlaceholderOnFocus?: boolean;
readonly tooltip?: string;
readonly ariaLabel?: string;
readonly type?: string;
readonly validationOptions?: IInputValidationOptions;
readonly flexibleHeight?: boolean;
readonly flexibleWidth?: boolean;
readonly flexibleMaxHeight?: number;
readonly actions?: ReadonlyArray<IAction>;
readonly inputBoxStyles: IInputBoxStyles;
}
export interface IInputBoxStyles {
readonly inputBackground: string | undefined;
readonly inputForeground: string | undefined;
readonly inputBorder: string | undefined;
readonly inputValidationInfoBorder: string | undefined;
readonly inputValidationInfoBackground: string | undefined;
readonly inputValidationInfoForeground: string | undefined;
readonly inputValidationWarningBorder: string | undefined;
readonly inputValidationWarningBackground: string | undefined;
readonly inputValidationWarningForeground: string | undefined;
readonly inputValidationErrorBorder: string | undefined;
readonly inputValidationErrorBackground: string | undefined;
readonly inputValidationErrorForeground: string | undefined;
}
export interface IInputValidator {
(value: string): IMessage | null;
}
export interface IMessage {
readonly content?: string;
readonly formatContent?: boolean;
readonly type?: MessageType;
}
export interface IInputValidationOptions {
validation?: IInputValidator;
}
export declare const enum MessageType {
INFO = 1,
WARNING = 2,
ERROR = 3
}
export interface IRange {
start: number;
end: number;
}
export declare const unthemedInboxStyles: IInputBoxStyles;
export declare class InputBox extends Widget {
private contextViewProvider?;
element: HTMLElement;
protected input: HTMLInputElement;
private actionbar?;
private readonly options;
private message;
protected placeholder: string;
private tooltip;
private ariaLabel;
private validation?;
private state;
private mirror;
private cachedHeight;
private cachedContentHeight;
private maxHeight;
private scrollableElement;
private _onDidChange;
readonly onDidChange: Event<string>;
private _onDidHeightChange;
readonly onDidHeightChange: Event<number>;
constructor(container: HTMLElement, contextViewProvider: IContextViewProvider | undefined, options: IInputOptions);
protected onBlur(): void;
protected onFocus(): void;
setPlaceHolder(placeHolder: string): void;
setTooltip(tooltip: string): void;
setAriaLabel(label: string): void;
getAriaLabel(): string;
get mirrorElement(): HTMLElement | undefined;
get inputElement(): HTMLInputElement;
get value(): string;
set value(newValue: string);
get step(): string;
set step(newValue: string);
get height(): number;
focus(): void;
blur(): void;
hasFocus(): boolean;
select(range?: IRange | null): void;
isSelectionAtEnd(): boolean;
enable(): void;
disable(): void;
setEnabled(enabled: boolean): void;
get width(): number;
set width(width: number);
set paddingRight(paddingRight: number);
private updateScrollDimensions;
showMessage(message: IMessage, force?: boolean): void;
hideMessage(): void;
isInputValid(): boolean;
validate(): MessageType | undefined;
stylesForType(type: MessageType | undefined): {
border: string | undefined;
background: string | undefined;
foreground: string | undefined;
};
private classForType;
private _showMessage;
private _hideMessage;
private onValueChange;
private updateMirror;
protected applyStyles(): void;
layout(): void;
insertAtCursor(text: string): void;
dispose(): void;
}
export interface IHistoryInputOptions extends IInputOptions {
history: string[];
readonly showHistoryHint?: () => boolean;
}
export declare class HistoryInputBox extends InputBox implements IHistoryNavigationWidget {
private readonly history;
private observer;
private readonly _onDidFocus;
readonly onDidFocus: Event<void>;
private readonly _onDidBlur;
readonly onDidBlur: Event<void>;
constructor(container: HTMLElement, contextViewProvider: IContextViewProvider | undefined, options: IHistoryInputOptions);
dispose(): void;
addToHistory(): void;
getHistory(): string[];
showNextValue(): void;
showPreviousValue(): void;
clearHistory(): void;
protected onBlur(): void;
protected onFocus(): void;
private getCurrentValue;
private getPreviousValue;
private getNextValue;
}