import { TileryDirection, TileryLayoutState, TileryPanelId, TileryReducerAction, TileryTabId } from 'tilery/internal'; /** * Identifies the kind of state transition that produced a lifecycle event, so * consumers can branch on how the change originated (a split, a tab move, a * removal, a whole-state replacement, and so on). */ export type TileryLifecycleSource = 'PANEL_SPLIT' | 'PANEL_REMOVE' | 'TAB_APPEND' | 'TAB_INSERT' | 'TAB_ID_CHANGE' | 'TAB_REMOVE' | 'TAB_MOVE' | 'TAB_FLOAT' | 'TAB_POPOUT' | 'TAB_ACTIVE_SET' | 'STATE_REPLACE'; /** Compact snapshot of a single tab involved in a lifecycle transition. */ export type TileryTabLifecycleChange = { /** Identifier of the affected tab. */ id: TileryTabId; /** Panel the tab belongs to at the snapshotted side of the transition. */ panelId: TileryPanelId; /** Caller-supplied data carried by the tab. */ data: TData; /** Whether the tab can be closed by the user. */ closable: boolean; /** Whether the tab can be dragged. */ draggable: boolean; }; /** Compact snapshot of a panel and its tab membership at a transition side. */ export type TileryPanelLifecycleChange = { /** Identifier of the affected panel. */ id: TileryPanelId; /** Ordered tab ids contained by the panel. */ tabIds: TileryTabId[]; /** Tab currently active in the panel, or null when it has none. */ activeTabId: TileryTabId | null; }; /** Describes one panel switching from one active tab to another. */ export type TileryActiveTabChange = { /** Panel whose active tab changed. */ panelId: TileryPanelId; /** Tab that was active before the change, or null. */ previousTabId: TileryTabId | null; /** Tab that is active after the change, or null. */ tabId: TileryTabId | null; }; /** Describes a tab relocating to a different panel or position. */ export type TileryTabMoveChange = { /** Identifier of the moved tab. */ id: TileryTabId; /** Panel the tab left. */ previousPanelId: TileryPanelId; /** Panel the tab moved into. */ panelId: TileryPanelId; /** Index the tab occupied in its previous panel. */ previousIndex: number; /** Index the tab occupies in its new panel. */ index: number; /** Caller-supplied data carried by the tab. */ data: TData; /** Whether the tab can be closed by the user. */ closable: boolean; /** Whether the tab can be dragged. */ draggable: boolean; }; /** Payload for `onActiveTabChange`: one or more panels changed active tab. */ export type TileryActiveTabChangeEvent = { /** Transition that produced the change. */ source: TileryLifecycleSource; /** Per-panel active-tab changes. */ changes: TileryActiveTabChange[]; /** Layout state before the transition. */ previousState: TileryLayoutState; /** Layout state after the transition. */ state: TileryLayoutState; }; /** Payload for `onTabsMove`: tabs moved between panels or to new indexes. */ export type TileryTabsMoveEvent = { /** Transition that produced the move. */ source: TileryLifecycleSource; /** The tabs that changed panel or position. */ tabs: TileryTabMoveChange[]; /** Layout state before the transition. */ previousState: TileryLayoutState; /** Layout state after the transition. */ state: TileryLayoutState; }; /** Payload for `onPanelsOpen`: one or more panels were created. */ export type TileryPanelsOpenEvent = { /** Transition that created the panels. */ source: TileryLifecycleSource; /** The panels that came into existence. */ panels: TileryPanelLifecycleChange[]; /** Tabs carried into the newly opened panels. */ tabs: TileryTabLifecycleChange[]; /** Layout state before the transition. */ previousState: TileryLayoutState; /** Layout state after the transition. */ state: TileryLayoutState; }; /** Payload for `onPanelSplit`: a panel was divided into two. */ export type TileryPanelSplitEvent = { /** Whether the split came from an explicit split or a tab move. */ source: 'PANEL_SPLIT' | 'TAB_MOVE'; /** Panel that was split (and remains). */ splitPanelId: TileryPanelId; /** Panel created alongside the split. */ createdPanelId: TileryPanelId; /** Side of the split panel the new panel was placed on. */ direction: TileryDirection; /** Size of the created panel as a percentage of the split region. */ size: number; /** Snapshot of the split panel after the operation. */ splitPanel: TileryPanelLifecycleChange; /** Snapshot of the newly created panel. */ createdPanel: TileryPanelLifecycleChange; /** Tabs that landed in the created panel. */ tabs: TileryTabLifecycleChange[]; /** Layout state before the transition. */ previousState: TileryLayoutState; /** Layout state after the transition. */ state: TileryLayoutState; }; /** Payload for `onTabsOpen`: one or more tabs were added. */ export type TileryTabsOpenEvent = { /** Transition that added the tabs. */ source: TileryLifecycleSource; /** The tabs that were added. */ tabs: TileryTabLifecycleChange[]; /** Layout state before the transition. */ previousState: TileryLayoutState; /** Layout state after the transition. */ state: TileryLayoutState; }; /** Payload for `onTabsClose`: one or more tabs were removed. */ export type TileryTabsCloseEvent = { /** Transition that removed the tabs. */ source: TileryLifecycleSource; /** The tabs that were removed. */ tabs: TileryTabLifecycleChange[]; /** Panels that closed as a result of the removal, if any. */ panels: TileryPanelLifecycleChange[]; /** Layout state before the transition. */ previousState: TileryLayoutState; /** Layout state after the transition. */ state: TileryLayoutState; }; /** Payload for `onPanelsClose`: one or more panels were removed. */ export type TileryPanelsCloseEvent = { /** Transition that removed the panels. */ source: TileryLifecycleSource; /** The panels that were removed. */ panels: TileryPanelLifecycleChange[]; /** Tabs the removed panels contained, including any moved out. */ tabs: TileryTabLifecycleChange[]; /** Layout state before the transition. */ previousState: TileryLayoutState; /** Layout state after the transition. */ state: TileryLayoutState; }; /** * Bundle of every lifecycle event that a single reducer action can fire; each * slot is non-null only when that kind of change actually occurred. */ export type TileryLifecycleEvents = { /** Active-tab change event, or null. */ activeTabChange: TileryActiveTabChangeEvent | null; /** Tab move event, or null. */ tabsMove: TileryTabsMoveEvent | null; /** Panels-open event, or null. */ panelsOpen: TileryPanelsOpenEvent | null; /** Panel-split event, or null. */ panelSplit: TileryPanelSplitEvent | null; /** Tabs-open event, or null. */ tabsOpen: TileryTabsOpenEvent | null; /** Tabs-close event, or null. */ tabsClose: TileryTabsCloseEvent | null; /** Panels-close event, or null. */ panelsClose: TileryPanelsCloseEvent | null; }; /** * Diffs the states surrounding a reducer action and returns the lifecycle * events that should fire for it. Actions classified with a null source never * change membership or the active tab, so they produce no events. */ export declare function makeLifecycleEvents(previousState: TileryLayoutState, state: TileryLayoutState, action: TileryReducerAction): TileryLifecycleEvents; //# sourceMappingURL=lifecycle.d.ts.map