Merge pull request #648 from mathuo/647-115-removed-types-that-are-still-valid

bug: fixup types
This commit is contained in:
mathuo 2024-07-16 20:22:38 +01:00 committed by GitHub
commit aa39b55563
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 11 deletions

View File

@ -57,7 +57,7 @@ import {
GroupDragEvent,
TabDragEvent,
} from './components/titlebar/tabsContainer';
import { AnchoredBox, Box } from '../types';
import { AnchoredBox, AnchorPosition, Box } from '../types';
import {
DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE,
DEFAULT_FLOATING_GROUP_POSITION,
@ -175,7 +175,10 @@ export interface FloatingGroupOptions {
y?: number;
height?: number;
width?: number;
position?: AnchoredBox;
position?: AnchorPosition;
}
export interface FloatingGroupOptionsInternal extends FloatingGroupOptions {
skipRemoveGroup?: boolean;
inDragMode?: boolean;
skipActiveGroup?: boolean;
@ -774,7 +777,7 @@ export class DockviewComponent
addFloatingGroup(
item: DockviewPanel | DockviewGroupPanel,
options?: FloatingGroupOptions
options?: FloatingGroupOptionsInternal
): void {
let group: DockviewGroupPanel;
@ -838,6 +841,7 @@ export class DockviewComponent
function getAnchoredBox(): AnchoredBox {
if (options?.position) {
const result: any = {};
if ('left' in options.position) {
result.left = Math.max(options.position.left, 0);
} else if ('right' in options.position) {
@ -852,13 +856,13 @@ export class DockviewComponent
} else {
result.top = DEFAULT_FLOATING_GROUP_POSITION.top;
}
if ('width' in options.position) {
result.width = Math.max(options.position.width, 0);
if (typeof options.width === 'number') {
result.width = Math.max(options.width, 0);
} else {
result.width = DEFAULT_FLOATING_GROUP_POSITION.width;
}
if ('height' in options.position) {
result.height = Math.max(options.position.height, 0);
if (typeof options.height === 'number') {
result.height = Math.max(options.height, 0);
} else {
result.height = DEFAULT_FLOATING_GROUP_POSITION.height;
}
@ -1446,14 +1450,14 @@ export class DockviewComponent
const group = this.createGroup();
this._onDidAddGroup.fire(group);
const o =
const floatingGroupOptions =
typeof options.floating === 'object' &&
options.floating !== null
? options.floating
: {};
this.addFloatingGroup(group, {
...o,
...floatingGroupOptions,
inDragMode: false,
skipRemoveGroup: true,
skipActiveGroup: true,

View File

@ -15,6 +15,7 @@ import { IDockviewPanel } from './dockviewPanel';
import { DockviewPanelRenderer } from '../overlayRenderContainer';
import { IGroupHeaderProps } from './framework';
import { AnchoredBox } from '../types';
import { FloatingGroupOptions } from './dockviewComponent';
export interface IHeaderActionsRenderer extends IDisposable {
readonly element: HTMLElement;
@ -185,7 +186,7 @@ export function isPanelOptionsWithGroup(
}
type AddPanelFloatingGroupUnion = {
floating: Partial<AnchoredBox> | true;
floating: Partial<FloatingGroupOptions> | true;
position: never;
};

View File

@ -14,7 +14,7 @@ type TopRight = { top: number; right: number };
type BottomLeft = { bottom: number; left: 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 };
export type AnchoredBox = Size & AnchorPosition;