dockview-core
Version:
Zero dependency layout manager supporting tabs, groups, grids and splitviews for vanilla TypeScript
86 lines (85 loc) • 3.74 kB
TypeScript
import { IDragSource } from '../../../dnd/backend';
import { IDisposable, IValueDisposable } from '../../../lifecycle';
import { DockviewComponent } from '../../dockviewComponent';
import { DockviewGroupPanel } from '../../dockviewGroupPanel';
import { DockviewHeaderDirection } from '../../options';
import { Tab } from '../tab/tab';
import { ITabGroup } from '../../tabGroup';
import { ITabGroupChipRenderer } from '../../framework';
import { Droptarget, DroptargetEvent } from '../../../dnd/droptarget';
export interface TabGroupManagerContext {
readonly group: DockviewGroupPanel;
readonly accessor: DockviewComponent;
readonly tabsList: HTMLElement;
getTabs(): IValueDisposable<Tab>[];
getTabMap(): Map<string, IValueDisposable<Tab>>;
getDirection(): DockviewHeaderDirection;
}
export interface TabGroupManagerCallbacks {
onChipContextMenu(tabGroup: ITabGroup, event: MouseEvent): void;
onChipDragStart(tabGroup: ITabGroup, chip: ITabGroupChipRenderer, event: DragEvent | PointerEvent): void;
/**
* HTML5 chip dragend only. Pointer dragend is handled centrally via
* `PointerDragController.onDragEnd` in `tabs.ts`.
*/
onChipDragEnd?(tabGroup: ITabGroup, chip: ITabGroupChipRenderer, event: DragEvent | PointerEvent): void;
onChipDrop(tabGroup: ITabGroup, event: DroptargetEvent): void;
}
interface ChipRendererEntry {
chip: ITabGroupChipRenderer;
/** Created by the manager so it can be toggled live on strategy changes. */
html5DragSource: IDragSource;
pointerDragSource: IDragSource;
disposable: IDisposable;
dropTarget: Droptarget;
}
export declare class TabGroupManager {
private readonly _ctx;
private readonly _callbacks;
private readonly _chipRenderers;
private _indicator;
private _skipNextCollapseAnimation;
private readonly _pendingTransitionCleanups;
get chipRenderers(): ReadonlyMap<string, ChipRendererEntry>;
get groupUnderlines(): ReadonlyMap<string, HTMLElement>;
get skipNextCollapseAnimation(): boolean;
set skipNextCollapseAnimation(value: boolean);
constructor(_ctx: TabGroupManagerContext, _callbacks: TabGroupManagerCallbacks);
/**
* Synchronize chip elements and CSS classes for all tab groups
* in the parent group model. Call after any tab group mutation.
*/
update(): void;
/**
* Re-read the active palette and re-apply colors to chips, tabs and
* the indicator. Called when `tabGroupColors` / `tabGroupAccent`
* options change at runtime.
*/
refreshAccents(): void;
positionAllChips(): void;
updateDirection(): void;
snapshotChipWidths(): Map<string, number>;
positionUnderlines(): void;
trackUnderlines(): void;
setGroupDragImage(event: DragEvent, tabGroup: ITabGroup, chipEl: HTMLElement): void;
cleanupTransition(panelId: string): void;
updateDragAndDropState(): void;
/**
* Synchronously dispose the chip drag sources for an in-flight chip
* drag. Called from `_commitGroupMove` so the transfer payload +
* iframe shield are released BEFORE the cross-group move detaches
* the chip (chip dispose is scheduled on a microtask via
* `_scheduleTabGroupUpdate`, which is too late for callers that read
* `getPanelData()` synchronously after the move). Idempotent — the
* subsequent `update()` will also dispose the sources.
*/
disposeChipDrag(tabGroupId: string): void;
/** Cloned chip rect used as the pointer follow-finger ghost. */
private _buildChipGhostElement;
disposeAll(): void;
private _ensureIndicator;
private _ensureChipForGroup;
private _positionChipForGroup;
private _updateTabGroupClasses;
}
export {};