UNPKG

6.54 kBTypeScriptView Raw
1import { Title, Widget } from '@phosphor/widgets';
2import { Message } from '@phosphor/messaging';
3import { Emitter, Event, Disposable, DisposableCollection, MaybePromise } from '../../common';
4import { KeyCode, KeysOrKeyCodes } from '../keyboard/keys';
5import PerfectScrollbar from 'perfect-scrollbar';
6export * from '@phosphor/widgets';
7export * from '@phosphor/messaging';
8export declare const ACTION_ITEM = "action-label";
9export declare function codiconArray(name: string, actionItem?: boolean): string[];
10export declare function codicon(name: string, actionItem?: boolean): string;
11export declare const DISABLED_CLASS = "theia-mod-disabled";
12export declare const EXPANSION_TOGGLE_CLASS = "theia-ExpansionToggle";
13export declare const CODICON_TREE_ITEM_CLASSES: string[];
14export declare const COLLAPSED_CLASS = "theia-mod-collapsed";
15export declare const BUSY_CLASS = "theia-mod-busy";
16export declare const CODICON_LOADING_CLASSES: string[];
17export declare const SELECTED_CLASS = "theia-mod-selected";
18export declare const FOCUS_CLASS = "theia-mod-focus";
19export declare const PINNED_CLASS = "theia-mod-pinned";
20export declare const LOCKED_CLASS = "theia-mod-locked";
21export declare const DEFAULT_SCROLL_OPTIONS: PerfectScrollbar.Options;
22/**
23 * At a number of places in the code, we have effectively reimplemented Phosphor's Widget.attach and Widget.detach,
24 * but omitted the checks that Phosphor expects to be performed for those operations. That is a bad idea, because it
25 * means that we are telling widgets that they are attached or detached when not all the conditions that should apply
26 * do apply. We should explicitly mark those locations so that we know where we should go fix them later.
27 */
28export declare namespace UnsafeWidgetUtilities {
29 /**
30 * Ordinarily, the following checks should be performed before detaching a widget:
31 * It should not be the child of another widget
32 * It should be attached and it should be a child of document.body
33 */
34 function detach(widget: Widget): void;
35 /**
36 * @param ref The child of the host element to insert the widget before.
37 * Ordinarily the following checks should be performed:
38 * The widget should have no parent
39 * The widget should not be attached, and its node should not be a child of document.body
40 * The host should be a child of document.body
41 * We often violate the last condition.
42 */
43 function attach(widget: Widget, host: HTMLElement, ref?: HTMLElement | null): void;
44}
45export declare class BaseWidget extends Widget {
46 protected readonly onScrollYReachEndEmitter: Emitter<void>;
47 readonly onScrollYReachEnd: Event<void>;
48 protected readonly onScrollUpEmitter: Emitter<void>;
49 readonly onScrollUp: Event<void>;
50 protected readonly onDidChangeVisibilityEmitter: Emitter<boolean>;
51 readonly onDidChangeVisibility: Event<boolean>;
52 protected readonly onDidDisposeEmitter: Emitter<void>;
53 readonly onDidDispose: Event<void>;
54 protected readonly toDispose: DisposableCollection;
55 protected readonly toDisposeOnDetach: DisposableCollection;
56 protected scrollBar?: PerfectScrollbar;
57 protected scrollOptions?: PerfectScrollbar.Options;
58 dispose(): void;
59 protected onCloseRequest(msg: Message): void;
60 protected onBeforeAttach(msg: Message): void;
61 protected onAfterDetach(msg: Message): void;
62 protected onBeforeDetach(msg: Message): void;
63 protected onAfterAttach(msg: Message): void;
64 protected getScrollContainer(): MaybePromise<HTMLElement>;
65 protected disableScrollBarFocus(scrollContainer: HTMLElement): void;
66 protected onUpdateRequest(msg: Message): void;
67 protected addUpdateListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, useCapture?: boolean): void;
68 protected addEventListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject<K>, useCapture?: boolean): void;
69 protected addKeyListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, keysOrKeyCodes: KeyCode.Predicate | KeysOrKeyCodes, action: (event: KeyboardEvent) => boolean | void | Object, ...additionalEventTypes: K[]): void;
70 protected addClipboardListener<K extends 'cut' | 'copy' | 'paste'>(element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject<K>): void;
71 setFlag(flag: Widget.Flag): void;
72 clearFlag(flag: Widget.Flag): void;
73}
74export declare function setEnabled(element: HTMLElement, enabled: boolean): void;
75export declare function createIconButton(...classNames: string[]): HTMLSpanElement;
76export declare type EventListener<K extends keyof HTMLElementEventMap> = (this: HTMLElement, event: HTMLElementEventMap[K]) => any;
77export interface EventListenerObject<K extends keyof HTMLElementEventMap> {
78 handleEvent(evt: HTMLElementEventMap[K]): void;
79}
80export declare namespace EventListenerObject {
81 function is<K extends keyof HTMLElementEventMap>(listener: unknown): listener is EventListenerObject<K>;
82}
83export declare type EventListenerOrEventListenerObject<K extends keyof HTMLElementEventMap> = EventListener<K> | EventListenerObject<K>;
84export declare function addEventListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject<K>, useCapture?: boolean): Disposable;
85export declare function addKeyListener<K extends keyof HTMLElementEventMap>(element: HTMLElement, keysOrKeyCodes: KeyCode.Predicate | KeysOrKeyCodes, action: (event: KeyboardEvent) => boolean | void | Object, ...additionalEventTypes: K[]): Disposable;
86export declare function addClipboardListener<K extends 'cut' | 'copy' | 'paste'>(element: HTMLElement, type: K, listener: EventListenerOrEventListenerObject<K>): Disposable;
87/**
88 * Resolves when the given widget is detached and hidden.
89 */
90export declare function waitForClosed(widget: Widget): Promise<void>;
91/**
92 * Resolves when the given widget is attached and visible.
93 */
94export declare function waitForRevealed(widget: Widget): Promise<void>;
95/**
96 * Resolves when the given widget is hidden regardless of attachment.
97 */
98export declare function waitForHidden(widget: Widget): Promise<void>;
99export declare function isPinned(title: Title<Widget>): boolean;
100export declare function unpin(title: Title<Widget>): void;
101export declare function pin(title: Title<Widget>): void;
102export declare function lock(title: Title<Widget>): void;
103export declare function togglePinned(title?: Title<Widget>): void;
104//# sourceMappingURL=widget.d.ts.map
\No newline at end of file