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, 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;
@ -774,7 +777,7 @@ export class DockviewComponent
addFloatingGroup( addFloatingGroup(
item: DockviewPanel | DockviewGroupPanel, item: DockviewPanel | DockviewGroupPanel,
options?: FloatingGroupOptions options?: FloatingGroupOptionsInternal
): void { ): void {
let group: DockviewGroupPanel; let group: DockviewGroupPanel;
@ -838,6 +841,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) {
@ -852,13 +856,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;
} }
@ -1446,14 +1450,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,

View File

@ -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;
}; };

View File

@ -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;