golden-layout
Version:
A multi-screen javascript Layout manager
1,394 lines (1,363 loc) • 133 kB
TypeScript
/** @public */
export declare class ApiError extends ExternalError {
/** @internal */
constructor(message: string);
}
/** @internal */
export declare interface AreaLinkedRect {
x1: number;
x2: number;
y1: number;
y2: number;
}
/** @public */
export declare class BindError extends ExternalError {
/** @internal */
constructor(message: string);
}
/**
* Pops a content item out into a new browser window.
* This is achieved by
*
* - Creating a new configuration with the content item as root element
* - Serializing and minifying the configuration
* - Opening the current window's URL with the configuration as a GET parameter
* - GoldenLayout when opened in the new window will look for the GET parameter
* and use it instead of the provided configuration
* @public
*/
export declare class BrowserPopout extends EventEmitter {
/** @internal */
private _config;
/** @internal */
private _initialWindowSize;
/** @internal */
private _layoutManager;
/** @internal */
private _popoutWindow;
/** @internal */
private _isInitialised;
/** @internal */
private _checkReadyInterval;
/**
* @param _config - GoldenLayout item config
* @param _initialWindowSize - A map with width, height, top and left
* @internal
*/
constructor(
/** @internal */
_config: ResolvedPopoutLayoutConfig,
/** @internal */
_initialWindowSize: Rect,
/** @internal */
_layoutManager: LayoutManager);
toConfig(): ResolvedPopoutLayoutConfig;
getGlInstance(): LayoutManager;
/**
* Retrieves the native BrowserWindow backing this popout.
* Might throw an UnexpectedNullError exception when the window is not initialized yet.
* @public
*/
getWindow(): Window;
close(): void;
/**
* Returns the popped out item to its original position. If the original
* parent isn't available anymore it falls back to the layout's topmost element
*/
popIn(): void;
/**
* Creates the URL and window parameter
* and opens a new window
* @internal
*/
private createWindow;
/** @internal */
private checkReady;
/**
* Serialises a map of key:values to a window options string
*
* @param windowOptions -
*
* @returns serialised window options
* @internal
*/
private serializeWindowFeatures;
/**
* Creates the URL for the new window, including the
* config GET parameter
*
* @returns URL
* @internal
*/
private createUrl;
/**
* Move the newly created window roughly to
* where the component used to be.
* @internal
*/
private positionWindow;
/**
* Callback when the new window is opened and the GoldenLayout instance
* within it is initialised
* @internal
*/
private onInitialised;
/**
* Invoked 50ms after the window unload event
* @internal
*/
private _onClose;
}
/** @public */
export declare class ComponentContainer extends EventEmitter {
/** @internal */
private readonly _config;
/** @internal */
private readonly _parent;
/** @internal */
private readonly _layoutManager;
/** @internal */
private readonly _element;
/** @internal */
private readonly _updateItemConfigEvent;
/** @internal */
private readonly _showEvent;
/** @internal */
private readonly _hideEvent;
/** @internal */
private readonly _focusEvent;
/** @internal */
private readonly _blurEvent;
/** @internal */
private _componentType;
/** @internal */
private _boundComponent;
/** @internal */
private _width;
/** @internal */
private _height;
/** @internal */
private _isClosable;
/** @internal */
private _initialState;
/** @internal */
private _state;
/** @internal */
private _visible;
/** @internal */
private _isShownWithZeroDimensions;
/** @internal */
private _tab;
/** @internal */
private _stackMaximised;
/** @internal */
private _logicalZIndex;
stateRequestEvent: ComponentContainer.StateRequestEventHandler | undefined;
virtualRectingRequiredEvent: ComponentContainer.VirtualRectingRequiredEvent | undefined;
virtualVisibilityChangeRequiredEvent: ComponentContainer.VirtualVisibilityChangeRequiredEvent | undefined;
virtualZIndexChangeRequiredEvent: ComponentContainer.VirtualZIndexChangeRequiredEvent | undefined;
get width(): number;
get height(): number;
get parent(): ComponentItem;
/** @internal @deprecated use {@link (ComponentContainer:class).componentType} */
get componentName(): JsonValue;
get componentType(): JsonValue;
get virtual(): boolean;
get component(): ComponentContainer.Component;
get tab(): Tab;
get title(): string;
get layoutManager(): LayoutManager;
get isHidden(): boolean;
get visible(): boolean;
get state(): JsonValue | undefined;
/** Return the initial component state */
get initialState(): JsonValue | undefined;
/** The inner DOM element where the container's content is intended to live in */
get element(): HTMLElement;
/** @internal */
constructor(
/** @internal */
_config: ResolvedComponentItemConfig,
/** @internal */
_parent: ComponentItem,
/** @internal */
_layoutManager: LayoutManager,
/** @internal */
_element: HTMLElement,
/** @internal */
_updateItemConfigEvent: ComponentContainer.UpdateItemConfigEventHandler,
/** @internal */
_showEvent: ComponentContainer.ShowEventHandler,
/** @internal */
_hideEvent: ComponentContainer.HideEventHandler,
/** @internal */
_focusEvent: ComponentContainer.FocusEventHandler,
/** @internal */
_blurEvent: ComponentContainer.BlurEventHandler);
/** @internal */
destroy(): void;
/** @deprecated use {@link (ComponentContainer:class).element } */
getElement(): HTMLElement;
/**
* Hides the container's component item (and hence, the container) if not already hidden.
* Emits hide event prior to hiding the container.
*/
hide(): void;
/**
* Shows the container's component item (and hence, the container) if not visible.
* Emits show event prior to hiding the container.
*/
show(): void;
/**
* Focus this component in Layout.
*/
focus(suppressEvent?: boolean): void;
/**
* Remove focus from this component in Layout.
*/
blur(suppressEvent?: boolean): void;
/**
* Set the size from within the container. Traverses up
* the item tree until it finds a row or column element
* and resizes its items accordingly.
*
* If this container isn't a descendant of a row or column
* it returns false
* @param width - The new width in pixel
* @param height - The new height in pixel
*
* @returns resizeSuccesful
*
* @internal
*/
setSize(width: number, height: number): boolean;
/**
* Closes the container if it is closable. Can be called by
* both the component within at as well as the contentItem containing
* it. Emits a close event before the container itself is closed.
*/
close(): void;
/** Replaces component without affecting layout */
replaceComponent(itemConfig: ComponentItemConfig): void;
/**
* Returns the initial component state or the latest passed in setState()
* @returns state
* @deprecated Use {@link (ComponentContainer:class).initialState}
*/
getState(): JsonValue | undefined;
/**
* Merges the provided state into the current one
* @deprecated Use {@link (ComponentContainer:class).stateRequestEvent}
*/
extendState(state: Record<string, unknown>): void;
/**
* Sets the component state
* @deprecated Use {@link (ComponentContainer:class).stateRequestEvent}
*/
setState(state: JsonValue): void;
/**
* Set's the components title
*/
setTitle(title: string): void;
/** @internal */
setTab(tab: Tab): void;
/** @internal */
setVisibility(value: boolean): void;
setBaseLogicalZIndex(): void;
setLogicalZIndex(logicalZIndex: LogicalZIndex): void;
/**
* Set the container's size, but considered temporary (for dragging)
* so don't emit any events.
* @internal
*/
enterDragMode(width: number, height: number): void;
/** @internal */
exitDragMode(): void;
/** @internal */
enterStackMaximised(): void;
/** @internal */
exitStackMaximised(): void;
/** @internal */
drag(): void;
/**
* Sets the container's size. Called by the container's component item.
* To instead set the size programmatically from within the component itself,
* use the public setSize method
* @param width - in px
* @param height - in px
* @param force - set even if no change
* @internal
*/
setSizeToNodeSize(width: number, height: number, force: boolean): void;
/** @internal */
notifyVirtualRectingRequired(): void;
/** @internal */
private notifyVirtualZIndexChangeRequired;
/** @internal */
private updateElementPositionPropertyFromBoundComponent;
/** @internal */
private addVirtualSizedContainerToLayoutManager;
/** @internal */
private checkShownFromZeroDimensions;
/** @internal */
private emitShow;
/** @internal */
private emitHide;
/** @internal */
private releaseComponent;
}
/** @public */
export declare namespace ComponentContainer {
export type Component = unknown;
export interface BindableComponent {
component: Component;
virtual: boolean;
}
export type StateRequestEventHandler = (this: void) => JsonValue | undefined;
export type VirtualRectingRequiredEvent = (this: void, container: ComponentContainer, width: number, height: number) => void;
export type VirtualVisibilityChangeRequiredEvent = (this: void, container: ComponentContainer, visible: boolean) => void;
export type VirtualZIndexChangeRequiredEvent = (this: void, container: ComponentContainer, logicalZIndex: LogicalZIndex, defaultZIndex: string) => void;
/** @internal */
export type ShowEventHandler = (this: void) => void;
/** @internal */
export type HideEventHandler = (this: void) => void;
/** @internal */
export type FocusEventHandler = (this: void, suppressEvent: boolean) => void;
/** @internal */
export type BlurEventHandler = (this: void, suppressEvent: boolean) => void;
/** @internal */
export type UpdateItemConfigEventHandler = (itemConfig: ResolvedComponentItemConfig) => void;
}
/** @public */
export declare class ComponentItem extends ContentItem {
/** @internal */
private _parentItem;
/** @internal */
private _reorderEnabled;
/** @internal */
private _headerConfig;
/** @internal */
private _title;
/** @internal */
private readonly _initialWantMaximise;
/** @internal */
private _container;
/** @internal */
private _tab;
/** @internal */
private _focused;
/** @internal @deprecated use {@link (ComponentItem:class).componentType} */
get componentName(): JsonValue;
get componentType(): JsonValue;
get reorderEnabled(): boolean;
/** @internal */
get initialWantMaximise(): boolean;
get component(): ComponentContainer.Component | undefined;
get container(): ComponentContainer;
get parentItem(): ComponentParentableItem;
get headerConfig(): ResolvedHeaderedItemConfig.Header | undefined;
get title(): string;
get tab(): Tab;
get focused(): boolean;
/** @internal */
constructor(layoutManager: LayoutManager, config: ResolvedComponentItemConfig,
/** @internal */
_parentItem: ComponentParentableItem);
/** @internal */
destroy(): void;
applyUpdatableConfig(config: ResolvedComponentItemConfig): void;
toConfig(): ResolvedComponentItemConfig;
close(): void;
/** @internal */
enterDragMode(width: number, height: number): void;
/** @internal */
exitDragMode(): void;
/** @internal */
enterStackMaximised(): void;
/** @internal */
exitStackMaximised(): void;
/** @internal */
drag(): void;
/** @internal */
updateSize(force: boolean): void;
/** @internal */
init(): void;
/**
* Set this component's title
*
* @public
* @param title -
*/
setTitle(title: string): void;
setTab(tab: Tab): void;
/** @internal */
hide(): void;
/** @internal */
show(): void;
/**
* Focuses the item if it is not already focused
*/
focus(suppressEvent?: boolean): void;
/** @internal */
setFocused(suppressEvent: boolean): void;
/**
* Blurs (defocuses) the item if it is focused
*/
blur(suppressEvent?: boolean): void;
/** @internal */
setBlurred(suppressEvent: boolean): void;
/** @internal */
protected setParent(parent: ContentItem): void;
/** @internal */
private handleUpdateItemConfigEvent;
/** @internal */
private updateNodeSize;
}
/** @public */
export declare namespace ComponentItem {
export type Component = ComponentContainer.Component;
}
/** @public */
export declare interface ComponentItemConfig extends HeaderedItemConfig {
type: 'component';
readonly content?: [];
/**
* The title of the item as displayed on its tab and on popout windows
* Default: componentType.toString() or ''
*/
title?: string;
/**
* The type of the component.
* @deprecated use {@link (ComponentItemConfig:interface).componentType} instead
*/
componentName?: string;
/**
* The type of the component.
* `componentType` must be of type `string` if it is registered with any of the following functions:
* * {@link (GoldenLayout:class).registerComponent} (deprecated)
* * {@link (GoldenLayout:class).registerComponentConstructor}
* * {@link (GoldenLayout:class).registerComponentFactoryFunction}
*/
componentType: JsonValue;
/**
* The state information with which a component will be initialised with.
* Will be passed to the component constructor function and will be the value returned by
* container.initialState.
*/
componentState?: JsonValue;
/**
* Default: true
*/
reorderEnabled?: boolean;
}
/** @public */
export declare namespace ComponentItemConfig {
/** @internal */
export function resolve(itemConfig: ComponentItemConfig, rowAndColumnChildLegacySizeDefault: boolean): ResolvedComponentItemConfig;
/** @internal */
export function fromResolved(resolvedConfig: ResolvedComponentItemConfig): ComponentItemConfig;
export function componentTypeToTitle(componentType: JsonValue): string;
}
declare abstract class ComponentParentableItem extends ContentItem {
/** @internal */
private _focused;
get focused(): boolean;
/** @internal */
setFocusedValue(value: boolean): void;
abstract setActiveComponentItem(item: ComponentItem, focus: boolean, suppressFocusEvent: boolean): void;
}
/** @public @deprecated - use {@link (LayoutConfig:interface)} */
export declare type Config = LayoutConfig;
/** @public */
export declare class ConfigurationError extends ExternalError {
readonly node?: string | undefined;
/** @internal */
constructor(message: string, node?: string | undefined);
}
/**
* This is the baseclass that all content items inherit from.
* Most methods provide a subset of what the sub-classes do.
*
* It also provides a number of functions for tree traversal
* @public
*/
export declare abstract class ContentItem extends EventEmitter {
readonly layoutManager: LayoutManager;
/** @internal */
private _parent;
/** @internal */
private readonly _element;
/** @internal */
private _type;
/** @internal */
private _id;
/** @internal */
private _popInParentIds;
/** @internal */
private _contentItems;
/** @internal */
private _isClosable;
/** @internal */
private _pendingEventPropagations;
/** @internal */
private _throttledEvents;
/** @internal */
private _isInitialised;
/** @internal */
size: number;
/** @internal */
sizeUnit: SizeUnitEnum;
/** @internal */
minSize: number | undefined;
/** @internal */
minSizeUnit: SizeUnitEnum;
isGround: boolean;
isRow: boolean;
isColumn: boolean;
isStack: boolean;
isComponent: boolean;
get type(): ItemType;
get id(): string;
set id(value: string);
/** @internal */
get popInParentIds(): string[];
get parent(): ContentItem | null;
get contentItems(): ContentItem[];
get isClosable(): boolean;
get element(): HTMLElement;
get isInitialised(): boolean;
static isStack(item: ContentItem): item is Stack;
static isComponentItem(item: ContentItem): item is ComponentItem;
static isComponentParentableItem(item: ContentItem): item is ComponentParentableItem;
/** @internal */
constructor(layoutManager: LayoutManager, config: ResolvedItemConfig,
/** @internal */
_parent: ContentItem | null,
/** @internal */
_element: HTMLElement);
/**
* Updaters the size of the component and its children, called recursively
* @param force - In some cases the size is not updated if it has not changed. In this case, events
* (such as ComponentContainer.virtualRectingRequiredEvent) are not fired. Setting force to true, ensures the size is updated regardless, and
* the respective events are fired. This is sometimes necessary when a component's size has not changed but it has become visible, and the
* relevant events need to be fired.
* @internal
*/
abstract updateSize(force: boolean): void;
/**
* Removes a child node (and its children) from the tree
* @param contentItem - The child item to remove
* @param keepChild - Whether to destroy the removed item
*/
removeChild(contentItem: ContentItem, keepChild?: boolean): void;
/**
* Sets up the tree structure for the newly added child
* The responsibility for the actual DOM manipulations lies
* with the concrete item
*
* @param contentItem -
* @param index - If omitted item will be appended
* @param suspendResize - Used by descendent implementations
*/
addChild(contentItem: ContentItem, index?: number | null, suspendResize?: boolean): number;
/**
* Replaces oldChild with newChild
* @param oldChild -
* @param newChild -
* @internal
*/
replaceChild(oldChild: ContentItem, newChild: ContentItem, destroyOldChild?: boolean): void;
/**
* Convenience method.
* Shorthand for this.parent.removeChild( this )
*/
remove(): void;
/**
* Removes the component from the layout and creates a new
* browser window with the component and its children inside
*/
popout(): BrowserPopout;
abstract toConfig(): ResolvedItemConfig;
/** @internal */
calculateConfigContent(): ResolvedItemConfig[];
/** @internal */
highlightDropZone(x: number, y: number, area: AreaLinkedRect): void;
/** @internal */
onDrop(contentItem: ContentItem, area: ContentItem.Area): void;
/** @internal */
show(): void;
/**
* Destroys this item ands its children
* @internal
*/
destroy(): void;
/**
* Returns the area the component currently occupies
* @internal
*/
getElementArea(element?: HTMLElement): ContentItem.Area | null;
/**
* The tree of content items is created in two steps: First all content items are instantiated,
* then init is called recursively from top to bottem. This is the basic init function,
* it can be used, extended or overwritten by the content items
*
* Its behaviour depends on the content item
* @internal
*/
init(): void;
/** @internal */
protected setParent(parent: ContentItem): void;
/** @internal */
addPopInParentId(id: string): void;
/** @internal */
protected initContentItems(): void;
/** @internal */
protected hide(): void;
/** @internal */
protected updateContentItemsSize(force: boolean): void;
/**
* creates all content items for this node at initialisation time
* PLEASE NOTE, please see addChild for adding contentItems at runtime
* @internal
*/
private createContentItems;
/**
* Called for every event on the item tree. Decides whether the event is a bubbling
* event and propagates it to its parent
*
* @param name - The name of the event
* @param event -
* @internal
*/
private propagateEvent;
tryBubbleEvent(name: string, args: unknown[]): void;
/**
* All raw events bubble up to the Ground element. Some events that
* are propagated to - and emitted by - the layoutManager however are
* only string-based, batched and sanitized to make them more usable
*
* @param name - The name of the event
* @internal
*/
private scheduleEventPropagationToLayoutManager;
/**
* Callback for events scheduled by _scheduleEventPropagationToLayoutManager
*
* @param name - The name of the event
* @internal
*/
private propagateEventToLayoutManager;
}
/** @public */
export declare namespace ContentItem {
/** @internal */
export interface Area extends AreaLinkedRect {
surface: number;
contentItem: ContentItem;
}
}
/** @internal */
declare class DragListener extends EventEmitter {
private _eElement;
private _timeout;
private _allowableTargets;
private _oDocument;
private _eBody;
private _nDelay;
private _nDistance;
private _nX;
private _nY;
private _nOriginalX;
private _nOriginalY;
private _dragging;
private _pointerTracking;
private _pointerDownEventListener;
private _pointerMoveEventListener;
private _pointerUpEventListener;
constructor(_eElement: HTMLElement, extraAllowableChildTargets: HTMLElement[]);
destroy(): void;
cancelDrag(): void;
private onPointerDown;
private processPointerDown;
private onPointerMove;
private processDragMove;
private onPointerUp;
private processDragStop;
private checkRemovePointerTrackingEventListeners;
private startDrag;
private getPointerCoordinates;
}
/** @internal */
declare namespace DragListener {
interface PointerCoordinates {
x: number;
y: number;
}
}
/**
* Allows for any DOM item to create a component on drag
* start to be dragged into the Layout
* @public
*/
export declare class DragSource {
/** @internal */
private _layoutManager;
/** @internal */
private readonly _element;
/** @internal */
private readonly _extraAllowableChildTargets;
/** @internal @deprecated replace with componentItemConfigOrFtn in version 3 */
private _componentTypeOrFtn;
/** @internal @deprecated remove in version 3 */
private _componentState;
/** @internal @deprecated remove in version 3 */
private _title;
/** @internal @deprecated remove in version 3 */
private _id;
/** @internal */
private _dragListener;
/** @internal */
private _dummyGroundContainer;
/** @internal */
private _dummyGroundContentItem;
/** @internal */
constructor(
/** @internal */
_layoutManager: LayoutManager,
/** @internal */
_element: HTMLElement,
/** @internal */
_extraAllowableChildTargets: HTMLElement[],
/** @internal @deprecated replace with componentItemConfigOrFtn in version 3 */
_componentTypeOrFtn: JsonValue | (() => (DragSource.ComponentItemConfig | ComponentItemConfig)),
/** @internal @deprecated remove in version 3 */
_componentState: JsonValue | undefined,
/** @internal @deprecated remove in version 3 */
_title: string | undefined,
/** @internal @deprecated remove in version 3 */
_id: string | undefined);
/**
* Disposes of the drag listeners so the drag source is not usable any more.
* @internal
*/
destroy(): void;
/**
* Called initially and after every drag
* @internal
*/
private createDragListener;
/**
* Callback for the DragListener's dragStart event
*
* @param x - The x position of the mouse on dragStart
* @param y - The x position of the mouse on dragStart
* @internal
*/
private onDragStart;
/** @internal */
private onDragStop;
/**
* Called after every drag and when the drag source is being disposed of.
* @internal
*/
private removeDragListener;
}
/** @public */
export declare namespace DragSource {
/** @deprecated use Config {@link (ComponentItemConfig:interface)} */
export interface ComponentItemConfig {
type: JsonValue;
state?: JsonValue;
title?: string;
}
/** @deprecated remove in version 3 */
export function isDragSourceComponentItemConfig(config: DragSource.ComponentItemConfig | ComponentItemConfig): config is DragSource.ComponentItemConfig;
}
/** @internal */
declare class DropTargetIndicator {
private _element;
constructor();
destroy(): void;
highlightArea(area: AreaLinkedRect, margin: number): void;
hide(): void;
}
/**
* A generic and very fast EventEmitter implementation. On top of emitting the actual event it emits an
* {@link (EventEmitter:namespace).ALL_EVENT} event for every event triggered. This allows to hook into it and proxy events forwards
* @public
*/
export declare class EventEmitter {
/** @internal */
private _allEventSubscriptions;
/** @internal */
private _subscriptionsMap;
tryBubbleEvent(name: string, args: unknown[]): void;
/**
* Emit an event and notify listeners
*
* @param eventName - The name of the event
* @param args - Additional arguments that will be passed to the listener
*/
emit<K extends keyof EventEmitter.EventParamsMap>(eventName: K, ...args: EventEmitter.EventParamsMap[K]): void;
/** @internal */
emitUnknown(eventName: string, ...args: EventEmitter.UnknownParams): void;
emitBaseBubblingEvent<K extends keyof EventEmitter.EventParamsMap>(eventName: K): void;
/** @internal */
emitUnknownBubblingEvent(eventName: string): void;
/**
* Removes a listener for an event.
* @param eventName - The name of the event
* @param callback - The previously registered callback method (optional)
*/
removeEventListener<K extends keyof EventEmitter.EventParamsMap>(eventName: K, callback: EventEmitter.Callback<K>): void;
off<K extends keyof EventEmitter.EventParamsMap>(eventName: K, callback: EventEmitter.Callback<K>): void;
/**
* Alias for off
*/
unbind: <K extends keyof EventEmitter.EventParamsMap>(eventName: K, callback: EventEmitter.Callback<K>) => void;
/**
* Alias for emit
*/
trigger: <K extends keyof EventEmitter.EventParamsMap>(eventName: K, ...args: EventEmitter.EventParamsMap[K]) => void;
/**
* Listen for events
*
* @param eventName - The name of the event to listen to
* @param callback - The callback to execute when the event occurs
*/
addEventListener<K extends keyof EventEmitter.EventParamsMap>(eventName: K, callback: EventEmitter.Callback<K>): void;
on<K extends keyof EventEmitter.EventParamsMap>(eventName: K, callback: EventEmitter.Callback<K>): void;
/** @internal */
private addUnknownEventListener;
/** @internal */
private removeUnknownEventListener;
/** @internal */
private removeSubscription;
/** @internal */
private emitAllEvent;
}
/** @public */
export declare namespace EventEmitter {
/**
* The name of the event that's triggered for every event
*/
const ALL_EVENT = "__all";
const headerClickEventName = "stackHeaderClick";
const headerTouchStartEventName = "stackHeaderTouchStart";
/** @internal */
export type UnknownCallback = (this: void, ...args: UnknownParams) => void;
export type Callback<K extends keyof EventEmitter.EventParamsMap> = (this: void, ...args: EventParamsMap[K]) => void;
export interface EventParamsMap {
"__all": UnknownParams;
"activeContentItemChanged": ComponentItemParam;
"close": NoParams;
"closed": NoParams;
"destroy": NoParams;
"drag": DragParams;
"dragStart": DragStartParams;
"dragStop": DragStopParams;
"hide": NoParams;
"initialised": NoParams;
"itemDropped": ComponentItemParam;
"maximised": NoParams;
"minimised": NoParams;
"open": NoParams;
"popIn": NoParams;
"resize": NoParams;
"show": NoParams;
/** @deprecated - use show instead */
"shown": NoParams;
"stateChanged": NoParams;
"tab": TabParam;
"tabCreated": TabParam;
"titleChanged": StringParam;
"windowClosed": PopoutParam;
"windowOpened": PopoutParam;
"beforeComponentRelease": BeforeComponentReleaseParams;
"beforeItemDestroyed": BubblingEventParam;
"itemCreated": BubblingEventParam;
"itemDestroyed": BubblingEventParam;
"focus": BubblingEventParam;
"blur": BubblingEventParam;
"stackHeaderClick": ClickBubblingEventParam;
"stackHeaderTouchStart": TouchStartBubblingEventParam;
"userBroadcast": UnknownParams;
}
export type UnknownParams = unknown[];
export type NoParams = [];
export type UnknownParam = [unknown];
export type PopoutParam = [BrowserPopout];
export type ComponentItemParam = [ComponentItem];
export type TabParam = [Tab];
export type BubblingEventParam = [EventEmitter.BubblingEvent];
export type StringParam = [string];
export type DragStartParams = [originalX: number, originalY: number];
export type DragStopParams = [event: PointerEvent | undefined];
export type DragParams = [offsetX: number, offsetY: number, event: PointerEvent];
export type BeforeComponentReleaseParams = [component: unknown];
export type ClickBubblingEventParam = [ClickBubblingEvent];
export type TouchStartBubblingEventParam = [TouchStartBubblingEvent];
export class BubblingEvent {
/** @internal */
private readonly _name;
/** @internal */
private readonly _target;
/** @internal */
private _isPropagationStopped;
get name(): string;
get target(): EventEmitter;
/** @deprecated Use {@link (EventEmitter:namespace).(BubblingEvent:class).target} instead */
get origin(): EventEmitter;
get isPropagationStopped(): boolean;
/** @internal */
constructor(
/** @internal */
_name: string,
/** @internal */
_target: EventEmitter);
stopPropagation(): void;
}
export class ClickBubblingEvent extends BubblingEvent {
/** @internal */
private readonly _mouseEvent;
get mouseEvent(): MouseEvent;
/** @internal */
constructor(name: string, target: EventEmitter,
/** @internal */
_mouseEvent: MouseEvent);
}
export class TouchStartBubblingEvent extends BubblingEvent {
/** @internal */
private readonly _touchEvent;
get touchEvent(): TouchEvent;
/** @internal */
constructor(name: string, target: EventEmitter,
/** @internal */
_touchEvent: TouchEvent);
}
}
/**
* An EventEmitter singleton that propagates events
* across multiple windows. This is a little bit trickier since
* windows are allowed to open childWindows in their own right.
*
* This means that we deal with a tree of windows. Therefore, we do the event propagation in two phases:
*
* - Propagate events from this layout to the parent layout
* - Repeat until the event arrived at the root layout
* - Propagate events to this layout and to all children
* - Repeat until all layouts got the event
*
* **WARNING**: Only userBroadcast events are propagated between windows.
* This means the you have to take care of propagating state changes between windows yourself.
*
* @public
*/
export declare class EventHub extends EventEmitter {
/** @internal */
private _layoutManager;
/** @internal */
private _childEventListener;
/**
* Creates a new EventHub instance
* @param _layoutManager - the layout manager to synchronize between the windows
* @internal
*/
constructor(
/** @internal */
_layoutManager: LayoutManager);
/**
* Emit an event and notify listeners
*
* @param eventName - The name of the event
* @param args - Additional arguments that will be passed to the listener
* @public
*/
emit<K extends keyof EventEmitter.EventParamsMap>(eventName: K, ...args: EventEmitter.EventParamsMap[K]): void;
/**
* Broadcasts a message to all other currently opened windows.
* @public
*/
emitUserBroadcast(...args: EventEmitter.UnknownParams): void;
/**
* Destroys the EventHub
* @internal
*/
destroy(): void;
/**
* Internal processor to process local events.
* @internal
*/
private handleUserBroadcastEvent;
/**
* Callback for child events raised on the window
* @internal
*/
private onEventFromChild;
/**
* Propagates the event to the parent by emitting
* it on the parent's DOM window
* @internal
*/
private propagateToParent;
/**
* Propagate events to the whole subtree under this event hub.
* @internal
*/
private propagateToThisAndSubtree;
}
/** @public */
export declare namespace EventHub {
/** @internal */
const ChildEventName = "gl_child_event";
/** @internal */
export type ChildEventDetail = {
layoutManager: LayoutManager;
eventName: string;
args: unknown[];
};
/** @internal */
export type ChildEventInit = CustomEventInit<ChildEventDetail>;
}
/** @public */
export declare abstract class ExternalError extends Error {
readonly type: string;
/** @internal */
constructor(type: string, message: string);
}
/** @internal */
export declare function formatSize(size: number, sizeUnit: SizeUnitEnum): string;
/** @internal */
export declare function formatUndefinableSize(size: number | undefined, sizeUnit: SizeUnitEnum): string | undefined;
/** @public */
export declare class GoldenLayout extends VirtualLayout {
/** @internal */
private _componentTypesMap;
/** @internal */
private _getComponentConstructorFtn;
/** @internal */
private _registeredComponentMap;
/** @internal */
private _virtuableComponentMap;
/** @internal */
private _goldenLayoutBoundingClientRect;
/** @internal */
private _containerVirtualRectingRequiredEventListener;
/** @internal */
private _containerVirtualVisibilityChangeRequiredEventListener;
/** @internal */
private _containerVirtualZIndexChangeRequiredEventListener;
/**
* @param container - A Dom HTML element. Defaults to body
* @param bindComponentEventHandler - Event handler to bind components
* @param bindComponentEventHandler - Event handler to unbind components
* If bindComponentEventHandler is defined, then constructor will be determinate. It will always call the init()
* function and the init() function will always complete. This means that the bindComponentEventHandler will be called
* if constructor is for a popout window. Make sure bindComponentEventHandler is ready for events.
*/
constructor(container?: HTMLElement, bindComponentEventHandler?: VirtualLayout.BindComponentEventHandler, unbindComponentEventHandler?: VirtualLayout.UnbindComponentEventHandler);
/** @deprecated specify layoutConfig in {@link (LayoutManager:class).loadLayout} */
constructor(config: LayoutConfig, container?: HTMLElement);
/**
* Register a new component type with the layout manager.
*
* @deprecated See {@link https://stackoverflow.com/questions/40922531/how-to-check-if-a-javascript-function-is-a-constructor}
* instead use {@link (GoldenLayout:class).registerComponentConstructor}
* or {@link (GoldenLayout:class).registerComponentFactoryFunction}
*/
registerComponent(name: string, componentConstructorOrFactoryFtn: GoldenLayout.ComponentConstructor | GoldenLayout.ComponentFactoryFunction, virtual?: boolean): void;
/**
* Register a new component type with the layout manager.
*/
registerComponentConstructor(typeName: string, componentConstructor: GoldenLayout.ComponentConstructor, virtual?: boolean): void;
/**
* Register a new component with the layout manager.
*/
registerComponentFactoryFunction(typeName: string, componentFactoryFunction: GoldenLayout.ComponentFactoryFunction, virtual?: boolean): void;
/**
* Register a component function with the layout manager. This function should
* return a constructor for a component based on a config.
* This function will be called if a component type with the required name is not already registered.
* It is recommended that applications use the {@link (VirtualLayout:class).getComponentEvent} and
* {@link (VirtualLayout:class).releaseComponentEvent} instead of registering a constructor callback
* @deprecated use {@link (GoldenLayout:class).registerGetComponentConstructorCallback}
*/
registerComponentFunction(callback: GoldenLayout.GetComponentConstructorCallback): void;
/**
* Register a callback closure with the layout manager which supplies a Component Constructor.
* This callback should return a constructor for a component based on a config.
* This function will be called if a component type with the required name is not already registered.
* It is recommended that applications use the {@link (VirtualLayout:class).getComponentEvent} and
* {@link (VirtualLayout:class).releaseComponentEvent} instead of registering a constructor callback
*/
registerGetComponentConstructorCallback(callback: GoldenLayout.GetComponentConstructorCallback): void;
getRegisteredComponentTypeNames(): string[];
/**
* Returns a previously registered component instantiator. Attempts to utilize registered
* component type by first, then falls back to the component constructor callback function (if registered).
* If neither gets an instantiator, then returns `undefined`.
* Note that `undefined` will return if config.componentType is not a string
*
* @param config - The item config
* @public
*/
getComponentInstantiator(config: ResolvedComponentItemConfig): GoldenLayout.ComponentInstantiator | undefined;
/** @internal */
bindComponent(container: ComponentContainer, itemConfig: ResolvedComponentItemConfig): ComponentContainer.BindableComponent;
/** @internal */
unbindComponent(container: ComponentContainer, virtual: boolean, component: ComponentContainer.Component | undefined): void;
fireBeforeVirtualRectingEvent(count: number): void;
/** @internal */
private handleContainerVirtualRectingRequiredEvent;
/** @internal */
private handleContainerVirtualVisibilityChangeRequiredEvent;
/** @internal */
private handleContainerVirtualZIndexChangeRequiredEvent;
}
/** @public */
export declare namespace GoldenLayout {
export interface VirtuableComponent {
rootHtmlElement: HTMLElement;
}
export type ComponentConstructor = new (container: ComponentContainer, state: JsonValue | undefined, virtual: boolean) => ComponentContainer.Component;
export type ComponentFactoryFunction = (container: ComponentContainer, state: JsonValue | undefined, virtual: boolean) => ComponentContainer.Component | undefined;
export type GetComponentConstructorCallback = (this: void, config: ResolvedComponentItemConfig) => ComponentConstructor;
export interface ComponentInstantiator {
constructor: ComponentConstructor | undefined;
factoryFunction: ComponentFactoryFunction | undefined;
virtual: boolean;
}
}
/**
* GroundItem is the ContentItem whose one child is the root ContentItem (Root is planted in Ground).
* (Previously it was called root however this was incorrect as its child is the root item)
* There is only one instance of GroundItem and it is automatically created by the Layout Manager
* @internal
*/
declare class GroundItem extends ComponentParentableItem {
private readonly _childElementContainer;
private readonly _containerElement;
constructor(layoutManager: LayoutManager, rootItemConfig: ResolvedRootItemConfig | undefined, containerElement: HTMLElement);
init(): void;
/**
* Loads a new Layout
* Internal only. To load a new layout with API, use {@link (LayoutManager:class).loadLayout}
*/
loadRoot(rootItemConfig: ResolvedRootItemConfig | undefined): void;
clearRoot(): void;
/**
* Adds a ContentItem child to root ContentItem.
* Internal only. To load a add with API, use {@link (LayoutManager:class).addItem}
* @returns -1 if added as root otherwise index in root ContentItem's content
*/
addItem(itemConfig: RowOrColumnItemConfig | StackItemConfig | ComponentItemConfig, index?: number): number;
loadComponentAsRoot(itemConfig: ComponentItemConfig): void;
/**
* Adds a Root ContentItem.
* Internal only. To replace Root ContentItem with API, use {@link (LayoutManager:class).loadLayout}
*/
addChild(contentItem: ContentItem, index?: number): number;
/** @internal */
calculateConfigContent(): ResolvedRootItemConfig[];
/** @internal */
setSize(width: number, height: number): void;
/**
* Adds a Root ContentItem.
* Internal only. To replace Root ContentItem with API, use {@link (LayoutManager:class).updateRootSize}
*/
updateSize(force: boolean): void;
createSideAreas(): GroundItem.Area[];
highlightDropZone(x: number, y: number, area: AreaLinkedRect): void;
onDrop(contentItem: ContentItem, area: GroundItem.Area): void;
dock(): void;
validateDocking(): void;
getAllContentItems(): ContentItem[];
getConfigMaximisedItems(): ContentItem[];
getItemsByPopInParentId(popInParentId: string): ContentItem[];
toConfig(): ResolvedItemConfig;
setActiveComponentItem(item: ComponentItem, focus: boolean, suppressFocusEvent: boolean): void;
private updateNodeSize;
private deepGetAllContentItems;
private deepFilterContentItems;
}
/** @internal */
declare namespace GroundItem {
interface Area extends ContentItem.Area {
side: keyof typeof Area.Side;
}
namespace Area {
const enum Side {
y2 = 0,
x2 = 1,
y1 = 2,
x1 = 3
}
type Sides = {
[side in keyof typeof Side]: keyof typeof Side;
};
const oppositeSides: Sides;
}
function createElement(document: Document): HTMLDivElement;
}
/**
* This class represents a header above a Stack ContentItem.
* @public
*/
export declare class Header extends EventEmitter {
/** @internal */
private _layoutManager;
/** @internal */
private _parent;
/** @internal */
private readonly _configClosable;
/** @internal */
private _getActiveComponentItemEvent;
/** @internal */
private _popoutEvent;
/** @internal */
private _maximiseToggleEvent;
/** @internal */
private _clickEvent;
/** @internal */
private _touchStartEvent;
/** @internal */
private _componentRemoveEvent;
/** @internal */
private _componentFocusEvent;
/** @internal */
private _componentDragStartEvent;
/** @internal */
private readonly _tabsContainer;
/** @internal */
private readonly _element;
/** @internal */
private readonly _controlsContainerElement;
/** @internal */
private readonly _show;
/** @internal */
private readonly _popoutEnabled;
/** @internal */
private readonly _popoutLabel;
/** @internal */
private readonly _maximiseEnabled;
/** @internal */
private readonly _maximiseLabel;
/** @internal */
private readonly _minimiseEnabled;
/** @internal */
private readonly _minimiseLabel;
/** @internal */
private readonly _closeEnabled;
/** @internal */
private readonly _closeLabel;
/** @internal */
private readonly _tabDropdownEnabled;
/** @internal */
private readonly _tabDropdownLabel;
/** @internal */
private readonly _tabControlOffset;
/** @internal */
private readonly _clickListener;
/** @internal */
private readonly _touchStartListener;
/** @internal */
private readonly _documentMouseUpListener;
/** @internal */
private _rowColumnClosable;
/** @internal */
private _canRemoveComponent;
/** @internal */
private _side;
/** @internal */
private _leftRightSided;
/** @internal */
private readonly _closeButton;
/** @internal */
private readonly _popoutButton;
/** @internal */
private readonly _tabDropdownButton;
/** @internal */
private readonly _maximiseButton;
get show(): boolean;
get side(): Side;
get leftRightSided(): boolean;
get layoutManager(): LayoutManager;
get parent(): Stack;
get tabs(): Tab[];
get lastVisibleTabIndex(): number;
get element(): HTMLElement;
get tabsContainerElement(): HTMLElement;
get controlsContainerElement(): HTMLElement;
/** @internal */
constructor(
/** @internal */
_layoutManager: LayoutManager,
/** @internal */
_parent: Stack, settings: Header.Settings,
/** @internal */
_configClosable: boolean,
/** @internal */
_getActiveComponentItemEvent: Header.GetActiveComponentItemEvent, closeEvent: Header.CloseEvent,
/** @internal */
_popoutEvent: Header.PopoutEvent | undefined,
/** @internal */
_maximiseToggleEvent: Header.MaximiseToggleEvent | undefined,
/** @internal */
_clickEvent: Header.ClickEvent | undefined,
/** @internal */
_touchStartEvent: Header.TouchStartEvent | undefined,
/** @internal */
_componentRemoveEvent: Header.ComponentRemoveEvent | undefined,
/** @internal */
_componentFocusEvent: Header.ComponentFocusEvent | undefined,
/** @internal */
_componentDragStartEvent: Header.ComponentDragStartEvent | undefined);
/**
* Destroys the entire header
* @internal
*/
destroy(): void;
/**
* Creates a new tab and associates it with a contentItem
* @param index - The position of the tab
* @internal
*/
createTab(componentItem: ComponentItem, index: number): void;
/**
* Finds a tab based on the contentItem its associated with and removes it.
* Cannot remove tab if it has the active ComponentItem
* @internal
*/
removeTab(componentItem: ComponentItem): void;
/** @internal */
processActiveComponentChanged(newActiveComponentItem: ComponentItem): void;
/** @internal */
setSide(value: Side): void;
/**
* Programmatically set closability.
* @param value - Whether to enable/disable closability.
* @returns Whether the action was successful
* @internal
*/
setRowColumnClosable(value: boolean): void;
/**
* Updates the header's closability. If a stack/header is able
* to close, but has a non closable component added to it, the stack is no
* longer closable until all components are closable.
* @internal
*/
updateClosability(): void;
/** @internal */
applyFocusedValue(value: boolean): void;
/** @internal */
processMaximised(): void;
/** @internal */
processMinimised(): void;
/**
* Pushes the tabs to the tab dropdown if the available space is not sufficient
* @internal
*/
updateTabSizes(): void;
/** @internal */
private handleTabInitiatedComponentRemoveEvent;
/*