UNPKG

dockview-core

Version:

Zero dependency layout manager supporting tabs, groups, grids and splitviews for vanilla TypeScript

156 lines (155 loc) 6.42 kB
import { Event } from '../../../events'; import { CompositeDisposable } from '../../../lifecycle'; import { DockviewComponent } from '../../dockviewComponent'; import { DockviewGroupPanel } from '../../dockviewGroupPanel'; import { DockviewWillShowOverlayLocationEvent } from '../../events'; import { IDockviewPanel } from '../../dockviewPanel'; import { DockviewHeaderDirection } from '../../options'; import { Tab } from '../tab/tab'; import { TabDragEvent, TabDropIndexEvent } from './tabsContainer'; export declare class Tabs extends CompositeDisposable { private readonly group; private readonly accessor; private readonly _element; private readonly _tabsList; private readonly _observerDisposable; private readonly _scrollbar; private _tabs; private readonly _tabMap; private selectedIndex; private _showTabsOverflowControl; private _direction; private _animState; private readonly _pendingMarginCleanups; private _pendingCollapse; private _flipTransitionCleanup; private _voidContainer; private _voidContainerListeners; private _extendedDropZone; private _pointerInsideTabsList; private readonly _tabGroupManager; private readonly _onTabDragStart; readonly onTabDragStart: Event<TabDragEvent>; private readonly _onDrop; readonly onDrop: Event<TabDropIndexEvent>; private readonly _onWillShowOverlay; readonly onWillShowOverlay: Event<DockviewWillShowOverlayLocationEvent>; private readonly _onOverflowTabsChange; readonly onOverflowTabsChange: Event<{ tabs: string[]; tabGroups: string[]; reset: boolean; }>; get showTabsOverflowControl(): boolean; set showTabsOverflowControl(value: boolean); get element(): HTMLElement; set voidContainer(el: HTMLElement | null); /** * Handle a drop that occurred on the void container (empty header * space to the right of the tabs). Returns `true` if the drop was * consumed by an active group drag, `false` otherwise. */ handleVoidDrop(): boolean; get panels(): string[]; get size(): number; get tabs(): Tab[]; get direction(): DockviewHeaderDirection; set direction(value: DockviewHeaderDirection); constructor(group: DockviewGroupPanel, accessor: DockviewComponent, options: { showTabsOverflowControl: boolean; }); indexOf(id: string): number; isActive(tab: Tab): boolean; setActivePanel(panel: IDockviewPanel): void; openPanel(panel: IDockviewPanel, index?: number): void; delete(id: string): void; private addTab; private toggleDropdown; updateDragAndDropState(): void; /** * Synchronize chip elements and CSS classes for all tab groups * in the parent group model. Call after any tab group mutation. */ updateTabGroups(): void; refreshTabGroupAccent(): void; /** * Tabs-list-specific side effects of a chip drag start. The chip's * drag sources (constructed by `TabGroupManager`) own the transfer * payload, iframe shielding, dataTransfer setup, and the HTML5 drag * image. This method just sets up the smooth-reorder anim state and * collapses the source-group tabs in the tabs list. */ private _handleChipDragStart; /** * A drop on a tab group chip means "insert before this group". Resolve to * the index of the group's first tab, adjusting for same-group removal * (when the source tab is currently to the left of the target slot, its * removal shifts the insertion index down by one). Always clears * `targetTabGroupId` so the dropped tab lands outside the group. */ private _handleChipDrop; /** * Sets the broader container that is part of the same logical drop surface * as this tab list (e.g. the full header element). When a dragleave from * the tabs list lands inside this container, `_animState` is preserved so * that external dragover listeners can continue the animation. */ setExtendedDropZone(el: HTMLElement): void; /** * Allows external elements (e.g. void container, left actions) to push an * insertion index into the animation while the cursor is outside the tabs * list itself. Pass `null` to clear the indicator. */ setExternalInsertionIndex(index: number | null): void; /** * Called when the drag cursor leaves the entire header area (not just the * tabs list). Clears animation state for cross-group drags, which never * receive a `dragend` event on this tab list. */ clearExternalAnimState(): void; private snapshotTabPositions; private getAverageTabWidth; /** * Pointer-event entry point. The HTML5 path enters via the per-element * `dragover` listener; this one hit-tests the global pointer-drag * position against the tabs list and routes through the same shared * `_processDragOver` / `_processDragLeave` helpers. */ private _handlePointerDragMove; /** * Shared body of the dragover entry point. Refreshes stale anim state * for a changed drag identity, initializes anim state for incoming * cross-group drags, and dispatches to the gap-following math in * `handleDragOver`. Returns true when this tabs list has taken * ownership of the drag — HTML5 callers use this to gate * `event.preventDefault()`. */ private _processDragOver; /** * Shared body of the dragleave entry point. Preserves anim state when * the drag moves between tabs-list children, into the extended drop * zone, or into the void container; tears it down otherwise. */ private _processDragLeave; private handleDragOver; /** * Batch-remove a CSS class from multiple elements instantly, * forcing only a single reflow for the entire batch. */ private _removeClassInstantlyBatch; /** * Remove `dv-tab--dragging` from the source tab instantly so it * regains its real width before FLIP snapshots. */ private _uncollapsSourceTab; private applyDragOverTransforms; private resetTabTransforms; /** * Commit a group-drag drop: clear drag classes, move the group * in the model, and run a FLIP animation. */ private _commitGroupMove; private _clearGroupDragClasses; private resetDragAnimation; private runFlipAnimation; }