diff --git a/es/DockData.d.ts b/es/DockData.d.ts index d5c69f32..89b1506d 100644 --- a/es/DockData.d.ts +++ b/es/DockData.d.ts @@ -243,6 +243,15 @@ export interface LayoutData extends LayoutBase { loadedFrom?: LayoutBase; } export declare type DropDirection = 'left' | 'right' | 'bottom' | 'top' | 'middle' | 'remove' | 'before-tab' | 'after-tab' | 'float' | 'front' | 'maximize' | 'new-window' | 'move' | 'active' | 'update'; +export interface FloatSize { + width: number; + height: number; +} +export interface FloatPosition extends FloatSize { + left: number; + top: number; +} +export declare type LayoutSize = FloatSize; export interface DockContext { /** @ignore */ getDockId(): any; @@ -254,10 +263,7 @@ export interface DockContext { clientY: number; }, panelSize?: [number, number]): void; /** @ignore */ - getLayoutSize(): { - width: number; - height: number; - }; + getLayoutSize(): LayoutSize; /** @ignore * When a state change happen to the layout that's handled locally, like inside DockPanel or DockBox. * It still need to tell the context there is a change so DockLayout can call onLayoutChange callback. @@ -276,12 +282,7 @@ export interface DockContext { * - when direction is 'float', target doesn't matter. If this is called directly from code without any user interaction, source must be PanelData with x,y,w,h properties * @param floatPosition position of float panel, used only when direction="float" */ - dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: { - left: number; - top: number; - width: number; - height: number; - }): void; + dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: FloatPosition): void; /** * Get the TabGroup defined in defaultLayout */ diff --git a/es/DockLayout.d.ts b/es/DockLayout.d.ts index c9a8e328..d951ae73 100644 --- a/es/DockLayout.d.ts +++ b/es/DockLayout.d.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import { BoxData, DockContext, DropDirection, LayoutBase, LayoutData, PanelBase, PanelData, TabBase, TabData, TabGroup, TabPaneCache } from "./DockData"; +import { BoxData, DockContext, DropDirection, FloatPosition, LayoutBase, LayoutData, LayoutSize, PanelBase, PanelData, TabBase, TabData, TabGroup, TabPaneCache } from "./DockData"; import * as Algorithm from "./Algorithm"; export interface LayoutProps { /** @@ -109,19 +109,11 @@ export declare class DockLayout extends DockPortalManager implements DockContext * @param direction @inheritDoc * @param floatPosition @inheritDoc */ - dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: { - left: number; - top: number; - width: number; - height: number; - }): void; + dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: FloatPosition): void; /** @inheritDoc */ find(id: string, filter?: Algorithm.Filter): PanelData | TabData | BoxData | undefined; /** @ignore */ - getLayoutSize(): { - width: number; - height: number; - }; + getLayoutSize(): LayoutSize; /** @inheritDoc */ updateTab(id: string, newTab: TabData | null, makeActive?: boolean): boolean; /** @inheritDoc */ diff --git a/lib/DockData.d.ts b/lib/DockData.d.ts index d5c69f32..89b1506d 100644 --- a/lib/DockData.d.ts +++ b/lib/DockData.d.ts @@ -243,6 +243,15 @@ export interface LayoutData extends LayoutBase { loadedFrom?: LayoutBase; } export declare type DropDirection = 'left' | 'right' | 'bottom' | 'top' | 'middle' | 'remove' | 'before-tab' | 'after-tab' | 'float' | 'front' | 'maximize' | 'new-window' | 'move' | 'active' | 'update'; +export interface FloatSize { + width: number; + height: number; +} +export interface FloatPosition extends FloatSize { + left: number; + top: number; +} +export declare type LayoutSize = FloatSize; export interface DockContext { /** @ignore */ getDockId(): any; @@ -254,10 +263,7 @@ export interface DockContext { clientY: number; }, panelSize?: [number, number]): void; /** @ignore */ - getLayoutSize(): { - width: number; - height: number; - }; + getLayoutSize(): LayoutSize; /** @ignore * When a state change happen to the layout that's handled locally, like inside DockPanel or DockBox. * It still need to tell the context there is a change so DockLayout can call onLayoutChange callback. @@ -276,12 +282,7 @@ export interface DockContext { * - when direction is 'float', target doesn't matter. If this is called directly from code without any user interaction, source must be PanelData with x,y,w,h properties * @param floatPosition position of float panel, used only when direction="float" */ - dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: { - left: number; - top: number; - width: number; - height: number; - }): void; + dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: FloatPosition): void; /** * Get the TabGroup defined in defaultLayout */ diff --git a/lib/DockLayout.d.ts b/lib/DockLayout.d.ts index c9a8e328..d951ae73 100644 --- a/lib/DockLayout.d.ts +++ b/lib/DockLayout.d.ts @@ -1,5 +1,5 @@ import * as React from "react"; -import { BoxData, DockContext, DropDirection, LayoutBase, LayoutData, PanelBase, PanelData, TabBase, TabData, TabGroup, TabPaneCache } from "./DockData"; +import { BoxData, DockContext, DropDirection, FloatPosition, LayoutBase, LayoutData, LayoutSize, PanelBase, PanelData, TabBase, TabData, TabGroup, TabPaneCache } from "./DockData"; import * as Algorithm from "./Algorithm"; export interface LayoutProps { /** @@ -109,19 +109,11 @@ export declare class DockLayout extends DockPortalManager implements DockContext * @param direction @inheritDoc * @param floatPosition @inheritDoc */ - dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: { - left: number; - top: number; - width: number; - height: number; - }): void; + dockMove(source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, floatPosition?: FloatPosition): void; /** @inheritDoc */ find(id: string, filter?: Algorithm.Filter): PanelData | TabData | BoxData | undefined; /** @ignore */ - getLayoutSize(): { - width: number; - height: number; - }; + getLayoutSize(): LayoutSize; /** @inheritDoc */ updateTab(id: string, newTab: TabData | null, makeActive?: boolean): boolean; /** @inheritDoc */ diff --git a/src/DockData.ts b/src/DockData.ts index 8bc0de71..b71c2015 100644 --- a/src/DockData.ts +++ b/src/DockData.ts @@ -310,6 +310,18 @@ export type DropDirection = | 'update' // tab updated with updateTab ; +export interface FloatSize { + width: number; + height: number; +} + +export interface FloatPosition extends FloatSize { + left: number; + top: number; +} + +export type LayoutSize = FloatSize; + export interface DockContext { /** @ignore */ getDockId(): any; @@ -321,7 +333,7 @@ export interface DockContext { setDropRect(element: HTMLElement, direction?: DropDirection, source?: any, event?: {clientX: number, clientY: number}, panelSize?: [number, number]): void; /** @ignore */ - getLayoutSize(): {width: number, height: number}; + getLayoutSize(): LayoutSize; /** @ignore * When a state change happen to the layout that's handled locally, like inside DockPanel or DockBox. @@ -346,7 +358,7 @@ export interface DockContext { source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, - floatPosition?: { left: number, top: number, width: number, height: number } + floatPosition?: FloatPosition ): void; /** @@ -389,7 +401,7 @@ export interface DockContext { } /** @ignore */ -export const DockContextType = React.createContext(null); +export const DockContextType = React.createContext(null!); /** @ignore */ export const DockContextProvider = DockContextType.Provider; /** @ignore */ diff --git a/src/DockLayout.tsx b/src/DockLayout.tsx index c6b7c6ef..fcaea363 100644 --- a/src/DockLayout.tsx +++ b/src/DockLayout.tsx @@ -7,8 +7,10 @@ import { DockContext, DockContextProvider, DropDirection, + FloatPosition, LayoutBase, LayoutData, + LayoutSize, PanelBase, PanelData, placeHolderGroup, @@ -215,7 +217,7 @@ export class DockLayout extends DockPortalManager implements DockContext { source: TabData | PanelData, target: string | TabData | PanelData | BoxData | null, direction: DropDirection, - floatPosition?: {left: number, top: number, width: number, height: number} + floatPosition?: FloatPosition ) { let layout = this.getLayout(); if (direction === 'maximize') { @@ -280,7 +282,7 @@ export class DockLayout extends DockPortalManager implements DockContext { } /** @ignore */ - getLayoutSize() { + getLayoutSize(): LayoutSize { if (this._ref) { return {width: this._ref.offsetWidth, height: this._ref.offsetHeight}; }