UNPKG

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