mirror of
https://github.com/mathuo/dockview
synced 2025-03-10 16:02:04 +00:00
bug: fixup types
This commit is contained in:
parent
b326291f94
commit
bd28468bf5
@ -57,7 +57,7 @@ import {
|
|||||||
GroupDragEvent,
|
GroupDragEvent,
|
||||||
TabDragEvent,
|
TabDragEvent,
|
||||||
} from './components/titlebar/tabsContainer';
|
} from './components/titlebar/tabsContainer';
|
||||||
import { AnchoredBox, Box } from '../types';
|
import { AnchoredBox, AnchorPosition, Box } from '../types';
|
||||||
import {
|
import {
|
||||||
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
|
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
|
||||||
DEFAULT_FLOATING_GROUP_POSITION,
|
DEFAULT_FLOATING_GROUP_POSITION,
|
||||||
@ -175,7 +175,10 @@ export interface FloatingGroupOptions {
|
|||||||
y?: number;
|
y?: number;
|
||||||
height?: number;
|
height?: number;
|
||||||
width?: number;
|
width?: number;
|
||||||
position?: AnchoredBox;
|
position?: AnchorPosition;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FloatingGroupOptionsInternal extends FloatingGroupOptions {
|
||||||
skipRemoveGroup?: boolean;
|
skipRemoveGroup?: boolean;
|
||||||
inDragMode?: boolean;
|
inDragMode?: boolean;
|
||||||
skipActiveGroup?: boolean;
|
skipActiveGroup?: boolean;
|
||||||
@ -769,7 +772,7 @@ export class DockviewComponent
|
|||||||
|
|
||||||
addFloatingGroup(
|
addFloatingGroup(
|
||||||
item: DockviewPanel | DockviewGroupPanel,
|
item: DockviewPanel | DockviewGroupPanel,
|
||||||
options?: FloatingGroupOptions
|
options?: FloatingGroupOptionsInternal
|
||||||
): void {
|
): void {
|
||||||
let group: DockviewGroupPanel;
|
let group: DockviewGroupPanel;
|
||||||
|
|
||||||
@ -833,6 +836,7 @@ export class DockviewComponent
|
|||||||
function getAnchoredBox(): AnchoredBox {
|
function getAnchoredBox(): AnchoredBox {
|
||||||
if (options?.position) {
|
if (options?.position) {
|
||||||
const result: any = {};
|
const result: any = {};
|
||||||
|
|
||||||
if ('left' in options.position) {
|
if ('left' in options.position) {
|
||||||
result.left = Math.max(options.position.left, 0);
|
result.left = Math.max(options.position.left, 0);
|
||||||
} else if ('right' in options.position) {
|
} else if ('right' in options.position) {
|
||||||
@ -847,13 +851,13 @@ export class DockviewComponent
|
|||||||
} else {
|
} else {
|
||||||
result.top = DEFAULT_FLOATING_GROUP_POSITION.top;
|
result.top = DEFAULT_FLOATING_GROUP_POSITION.top;
|
||||||
}
|
}
|
||||||
if ('width' in options.position) {
|
if (typeof options.width === 'number') {
|
||||||
result.width = Math.max(options.position.width, 0);
|
result.width = Math.max(options.width, 0);
|
||||||
} else {
|
} else {
|
||||||
result.width = DEFAULT_FLOATING_GROUP_POSITION.width;
|
result.width = DEFAULT_FLOATING_GROUP_POSITION.width;
|
||||||
}
|
}
|
||||||
if ('height' in options.position) {
|
if (typeof options.height === 'number') {
|
||||||
result.height = Math.max(options.position.height, 0);
|
result.height = Math.max(options.height, 0);
|
||||||
} else {
|
} else {
|
||||||
result.height = DEFAULT_FLOATING_GROUP_POSITION.height;
|
result.height = DEFAULT_FLOATING_GROUP_POSITION.height;
|
||||||
}
|
}
|
||||||
@ -1437,14 +1441,14 @@ export class DockviewComponent
|
|||||||
const group = this.createGroup();
|
const group = this.createGroup();
|
||||||
this._onDidAddGroup.fire(group);
|
this._onDidAddGroup.fire(group);
|
||||||
|
|
||||||
const o =
|
const floatingGroupOptions =
|
||||||
typeof options.floating === 'object' &&
|
typeof options.floating === 'object' &&
|
||||||
options.floating !== null
|
options.floating !== null
|
||||||
? options.floating
|
? options.floating
|
||||||
: {};
|
: {};
|
||||||
|
|
||||||
this.addFloatingGroup(group, {
|
this.addFloatingGroup(group, {
|
||||||
...o,
|
...floatingGroupOptions,
|
||||||
inDragMode: false,
|
inDragMode: false,
|
||||||
skipRemoveGroup: true,
|
skipRemoveGroup: true,
|
||||||
skipActiveGroup: true,
|
skipActiveGroup: true,
|
||||||
|
@ -15,6 +15,7 @@ import { IDockviewPanel } from './dockviewPanel';
|
|||||||
import { DockviewPanelRenderer } from '../overlayRenderContainer';
|
import { DockviewPanelRenderer } from '../overlayRenderContainer';
|
||||||
import { IGroupHeaderProps } from './framework';
|
import { IGroupHeaderProps } from './framework';
|
||||||
import { AnchoredBox } from '../types';
|
import { AnchoredBox } from '../types';
|
||||||
|
import { FloatingGroupOptions } from './dockviewComponent';
|
||||||
|
|
||||||
export interface IHeaderActionsRenderer extends IDisposable {
|
export interface IHeaderActionsRenderer extends IDisposable {
|
||||||
readonly element: HTMLElement;
|
readonly element: HTMLElement;
|
||||||
@ -185,7 +186,7 @@ export function isPanelOptionsWithGroup(
|
|||||||
}
|
}
|
||||||
|
|
||||||
type AddPanelFloatingGroupUnion = {
|
type AddPanelFloatingGroupUnion = {
|
||||||
floating: Partial<AnchoredBox> | true;
|
floating: Partial<FloatingGroupOptions> | true;
|
||||||
position: never;
|
position: never;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ type TopRight = { top: number; right: number };
|
|||||||
type BottomLeft = { bottom: number; left: number };
|
type BottomLeft = { bottom: number; left: number };
|
||||||
type BottomRight = { bottom: number; right: number };
|
type BottomRight = { bottom: number; right: number };
|
||||||
|
|
||||||
type AnchorPosition = TopLeft | TopRight | BottomLeft | BottomRight;
|
export type AnchorPosition = TopLeft | TopRight | BottomLeft | BottomRight;
|
||||||
type Size = { width: number; height: number };
|
type Size = { width: number; height: number };
|
||||||
|
|
||||||
export type AnchoredBox = Size & AnchorPosition;
|
export type AnchoredBox = Size & AnchorPosition;
|
||||||
|
Loading…
Reference in New Issue
Block a user