diff --git a/packages/dockview-core/src/dnd/dataTransfer.ts b/packages/dockview-core/src/dnd/dataTransfer.ts index 2e756da5e..efb3d4347 100644 --- a/packages/dockview-core/src/dnd/dataTransfer.ts +++ b/packages/dockview-core/src/dnd/dataTransfer.ts @@ -1,8 +1,4 @@ -class TransferObject { - constructor() { - // - } -} +class TransferObject {} export class PanelTransfer extends TransferObject { constructor( diff --git a/packages/dockview-core/src/dnd/overlay.ts b/packages/dockview-core/src/dnd/overlay.ts index 236726f1b..05e1afb18 100644 --- a/packages/dockview-core/src/dnd/overlay.ts +++ b/packages/dockview-core/src/dnd/overlay.ts @@ -1,4 +1,3 @@ -import { toHaveDescription } from '@testing-library/jest-dom/matchers'; import { getElementsByTagName, quasiDefaultPrevented, diff --git a/packages/dockview-core/src/dockview/deserializer.ts b/packages/dockview-core/src/dockview/deserializer.ts index 3f3490b14..b8f308038 100644 --- a/packages/dockview-core/src/dockview/deserializer.ts +++ b/packages/dockview-core/src/dockview/deserializer.ts @@ -35,7 +35,7 @@ export class DefaultDockviewDeserialzier implements IPanelDeserializer { const contentComponent = viewData ? viewData.content.id - : panelData.contentComponent || 'unknown'; + : panelData.contentComponent ?? 'unknown'; const tabComponent = viewData ? viewData.tab?.id : panelData.tabComponent; @@ -56,8 +56,8 @@ export class DefaultDockviewDeserialzier implements IPanelDeserializer { ); panel.init({ - title: title || panelId, - params: params || {}, + title: title ?? panelId, + params: params ?? {}, }); return panel; diff --git a/packages/dockview-core/src/dockview/dockviewComponent.ts b/packages/dockview-core/src/dockview/dockviewComponent.ts index 98becc490..087ac13cd 100644 --- a/packages/dockview-core/src/dockview/dockviewComponent.ts +++ b/packages/dockview-core/src/dockview/dockviewComponent.ts @@ -55,7 +55,6 @@ import { GroupDragEvent, TabDragEvent, } from './components/titlebar/tabsContainer'; -import { DockviewGroupPanelApi } from '../api/dockviewGroupPanelApi'; const DEFAULT_FLOATING_GROUP_OVERFLOW_SIZE = 100; @@ -303,7 +302,7 @@ export class DockviewComponent constructor(options: DockviewComponentOptions) { super({ proportionalLayout: true, - orientation: options.orientation || Orientation.HORIZONTAL, + orientation: options.orientation ?? Orientation.HORIZONTAL, styles: options.styles, parentElement: options.parentElement, }); @@ -407,7 +406,7 @@ export class DockviewComponent this.moveGroupOrPanel( this.orthogonalize(event.position), data.groupId, - data.panelId || undefined, + data.panelId ?? undefined, 'center' ); } else { @@ -1214,7 +1213,7 @@ export class DockviewComponent if (!destinationTarget || destinationTarget === 'center') { const groupItem: IDockviewPanel | undefined = - sourceGroup?.model.removePanel(sourceItemId) || + sourceGroup?.model.removePanel(sourceItemId) ?? this.panels.find((panel) => panel.id === sourceItemId); if (!groupItem) { @@ -1278,7 +1277,7 @@ export class DockviewComponent this.doAddGroup(targetGroup, location); } else { const groupItem: IDockviewPanel | undefined = - sourceGroup?.model.removePanel(sourceItemId) || + sourceGroup?.model.removePanel(sourceItemId) ?? this.panels.find((panel) => panel.id === sourceItemId); if (!groupItem) { @@ -1431,7 +1430,7 @@ export class DockviewComponent ): DockviewPanel { const contentComponent = options.component; const tabComponent = - options.tabComponent || this.options.defaultTabComponent; + options.tabComponent ?? this.options.defaultTabComponent; const view = new DockviewPanelModel( this, @@ -1448,8 +1447,8 @@ export class DockviewComponent view ); panel.init({ - title: options.title || options.id, - params: options?.params || {}, + title: options.title ?? options.id, + params: options?.params ?? {}, }); return panel; diff --git a/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts b/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts index 0f3ec17ab..43ee03b01 100644 --- a/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts +++ b/packages/dockview-core/src/dockview/dockviewGroupPanelModel.ts @@ -322,7 +322,7 @@ export class DockviewGroupPanelModel ); this.header.hidden = !!options.hideHeader; - this.locked = options.locked || false; + this.locked = options.locked ?? false; this.addDisposables( this._onTabDragStart, diff --git a/packages/dockview-core/src/dockview/dockviewPanel.ts b/packages/dockview-core/src/dockview/dockviewPanel.ts index 8fef552c9..080abf1cf 100644 --- a/packages/dockview-core/src/dockview/dockviewPanel.ts +++ b/packages/dockview-core/src/dockview/dockviewPanel.ts @@ -117,7 +117,7 @@ export class DockviewPanel public update(event: PanelUpdateEvent): void { // merge the new parameters with the existing parameters this._params = { - ...(this._params || {}), + ...(this._params ?? {}), ...event.params, }; diff --git a/packages/dockview-core/src/dockview/dockviewPanelModel.ts b/packages/dockview-core/src/dockview/dockviewPanelModel.ts index 44461f6a2..b264ae663 100644 --- a/packages/dockview-core/src/dockview/dockviewPanelModel.ts +++ b/packages/dockview-core/src/dockview/dockviewPanelModel.ts @@ -97,7 +97,7 @@ export class DockviewPanelModel implements IDockviewPanelModel { return createComponent( id, componentName, - this.accessor.options.components || {}, + this.accessor.options.components ?? {}, this.accessor.options.frameworkComponents, this.accessor.options.frameworkComponentFactory?.content ); diff --git a/packages/dockview-core/src/gridview/baseComponentGridview.ts b/packages/dockview-core/src/gridview/baseComponentGridview.ts index f82db4870..640a57787 100644 --- a/packages/dockview-core/src/gridview/baseComponentGridview.ts +++ b/packages/dockview-core/src/gridview/baseComponentGridview.ts @@ -281,7 +281,7 @@ export abstract class BaseGrid public layout(width: number, height: number, forceResize?: boolean): void { const different = - forceResize || width !== this.width || height !== this.height; + forceResize ?? (width !== this.width || height !== this.height); if (!different) { return; diff --git a/packages/dockview-core/src/gridview/gridviewComponent.ts b/packages/dockview-core/src/gridview/gridviewComponent.ts index 0505cdc38..a61f49571 100644 --- a/packages/dockview-core/src/gridview/gridviewComponent.ts +++ b/packages/dockview-core/src/gridview/gridviewComponent.ts @@ -190,8 +190,8 @@ export class GridviewComponent const view = createComponent( data.id, data.component, - this.options.components || {}, - this.options.frameworkComponents || {}, + this.options.components ?? {}, + this.options.frameworkComponents ?? {}, this.options.frameworkComponentFactory ? { createComponent: @@ -308,7 +308,7 @@ export class GridviewComponent public addPanel( options: AddComponentOptions ): IGridviewPanel { - let relativeLocation: number[] = options.location || [0]; + let relativeLocation: number[] = options.location ?? [0]; if (options.position?.referencePanel) { const referenceGroup = this._groups.get( @@ -337,8 +337,8 @@ export class GridviewComponent const view = createComponent( options.id, options.component, - this.options.components || {}, - this.options.frameworkComponents || {}, + this.options.components ?? {}, + this.options.frameworkComponents ?? {}, this.options.frameworkComponentFactory ? { createComponent: @@ -349,7 +349,7 @@ export class GridviewComponent ); view.init({ - params: options.params || {}, + params: options.params ?? {}, minimumWidth: options.minimumWidth, maximumWidth: options.maximumWidth, minimumHeight: options.minimumHeight, diff --git a/packages/dockview-core/src/paneview/paneviewComponent.ts b/packages/dockview-core/src/paneview/paneviewComponent.ts index b1b3936af..31d083470 100644 --- a/packages/dockview-core/src/paneview/paneviewComponent.ts +++ b/packages/dockview-core/src/paneview/paneviewComponent.ts @@ -240,8 +240,8 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent { const body = createComponent( options.id, options.component, - this.options.components || {}, - this.options.frameworkComponents || {}, + this.options.components ?? {}, + this.options.frameworkComponents ?? {}, this.options.frameworkWrapper ? { createComponent: @@ -256,7 +256,7 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent { header = createComponent( options.id, options.headerComponent, - this.options.headerComponents || {}, + this.options.headerComponents ?? {}, this.options.headerframeworkComponents, this.options.frameworkWrapper ? { @@ -290,7 +290,7 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent { typeof options.index === 'number' ? options.index : undefined; view.init({ - params: options.params || {}, + params: options.params ?? {}, minimumBodySize: options.minimumBodySize, maximumBodySize: options.maximumBodySize, isExpanded: options.isExpanded, @@ -377,8 +377,8 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent { const body = createComponent( data.id, data.component, - this.options.components || {}, - this.options.frameworkComponents || {}, + this.options.components ?? {}, + this.options.frameworkComponents ?? {}, this.options.frameworkWrapper ? { createComponent: @@ -394,8 +394,8 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent { header = createComponent( data.id, data.headerComponent, - this.options.headerComponents || {}, - this.options.headerframeworkComponents || {}, + this.options.headerComponents ?? {}, + this.options.headerframeworkComponents ?? {}, this.options.frameworkWrapper ? { createComponent: @@ -424,7 +424,7 @@ export class PaneviewComponent extends Resizable implements IPaneviewComponent { queue.push(() => { panel.init({ - params: data.params || {}, + params: data.params ?? {}, minimumBodySize: view.minimumSize, maximumBodySize: view.maximumSize, title: data.title, diff --git a/packages/dockview-core/src/splitview/splitviewComponent.ts b/packages/dockview-core/src/splitview/splitviewComponent.ts index cd398d156..824cfa0a4 100644 --- a/packages/dockview-core/src/splitview/splitviewComponent.ts +++ b/packages/dockview-core/src/splitview/splitviewComponent.ts @@ -261,8 +261,8 @@ export class SplitviewComponent const view = createComponent( options.id, options.component, - this.options.components || {}, - this.options.frameworkComponents || {}, + this.options.components ?? {}, + this.options.frameworkComponents ?? {}, this.options.frameworkWrapper ? { createComponent: @@ -361,8 +361,8 @@ export class SplitviewComponent const panel = createComponent( data.id, data.component, - this.options.components || {}, - this.options.frameworkComponents || {}, + this.options.components ?? {}, + this.options.frameworkComponents ?? {}, this.options.frameworkWrapper ? { createComponent: @@ -374,7 +374,7 @@ export class SplitviewComponent queue.push(() => { panel.init({ - params: data.params || {}, + params: data.params ?? {}, minimumSize: data.minimumSize, maximumSize: data.maximumSize, snap: view.snap, diff --git a/packages/dockview-core/src/splitview/splitviewPanel.ts b/packages/dockview-core/src/splitview/splitviewPanel.ts index d0ac1c41c..4782e8c30 100644 --- a/packages/dockview-core/src/splitview/splitviewPanel.ts +++ b/packages/dockview-core/src/splitview/splitviewPanel.ts @@ -7,7 +7,6 @@ import { SplitviewPanelApiImpl } from '../api/splitviewPanelApi'; import { LayoutPriority, Orientation } from './splitview'; import { FunctionOrValue } from '../types'; import { Emitter, Event } from '../events'; -import { CompositeDisposable } from '../lifecycle'; export interface ISplitviewPanel extends BasePanelViewExported { diff --git a/packages/dockview/src/dockview/dockview.tsx b/packages/dockview/src/dockview/dockview.tsx index 2485e6d81..e736d0035 100644 --- a/packages/dockview/src/dockview/dockview.tsx +++ b/packages/dockview/src/dockview/dockview.tsx @@ -139,7 +139,7 @@ export const DockviewReact = React.forwardRef( }, }; - const frameworkTabComponents = props.tabComponents || {}; + const frameworkTabComponents = props.tabComponents ?? {}; if (props.defaultTabComponent) { frameworkTabComponents[DEFAULT_REACT_TAB] = @@ -267,7 +267,7 @@ export const DockviewReact = React.forwardRef( return; } - const frameworkTabComponents = props.tabComponents || {}; + const frameworkTabComponents = props.tabComponents ?? {}; if (props.defaultTabComponent) { frameworkTabComponents[DEFAULT_REACT_TAB] = diff --git a/packages/dockview/src/dockview/reactWatermarkPart.ts b/packages/dockview/src/dockview/reactWatermarkPart.ts index 587650568..2d9d0db85 100644 --- a/packages/dockview/src/dockview/reactWatermarkPart.ts +++ b/packages/dockview/src/dockview/reactWatermarkPart.ts @@ -60,7 +60,7 @@ export class ReactWatermarkPart implements IWatermarkRenderer { this.parameters.params = params.params; } - this.part?.update({ params: this.parameters?.params || {} }); + this.part?.update({ params: this.parameters?.params ?? {} }); } layout(_width: number, _height: number): void { diff --git a/packages/dockview/src/gridview/gridview.tsx b/packages/dockview/src/gridview/gridview.tsx index 1cb71f427..992565b03 100644 --- a/packages/dockview/src/gridview/gridview.tsx +++ b/packages/dockview/src/gridview/gridview.tsx @@ -51,7 +51,7 @@ export const GridviewReact = React.forwardRef( typeof props.proportionalLayout === 'boolean' ? props.proportionalLayout : true, - orientation: props.orientation || Orientation.HORIZONTAL, + orientation: props.orientation ?? Orientation.HORIZONTAL, frameworkComponents: props.components, frameworkComponentFactory: { createComponent: (id: string, componentId, component) => { diff --git a/packages/dockview/src/gridview/view.ts b/packages/dockview/src/gridview/view.ts index c941457e5..fce6f0690 100644 --- a/packages/dockview/src/gridview/view.ts +++ b/packages/dockview/src/gridview/view.ts @@ -23,7 +23,7 @@ export class ReactGridPanelView extends GridviewPanel { this.reactPortalStore, this.reactComponent, { - params: this._params?.params || {}, + params: this._params?.params ?? {}, api: this.api, containerApi: new GridviewApi( (this._params as GridviewInitParameters).accessor diff --git a/packages/dockview/src/splitview/splitview.tsx b/packages/dockview/src/splitview/splitview.tsx index c6536b256..d6fd90913 100644 --- a/packages/dockview/src/splitview/splitview.tsx +++ b/packages/dockview/src/splitview/splitview.tsx @@ -41,7 +41,7 @@ export const SplitviewReact = React.forwardRef( React.useEffect(() => { const splitview = new SplitviewComponent({ parentElement: domRef.current!, - orientation: props.orientation || Orientation.HORIZONTAL, + orientation: props.orientation ?? Orientation.HORIZONTAL, frameworkComponents: props.components, frameworkWrapper: { createComponent: ( diff --git a/packages/dockview/src/splitview/view.ts b/packages/dockview/src/splitview/view.ts index 926e3ed9f..e35cdd772 100644 --- a/packages/dockview/src/splitview/view.ts +++ b/packages/dockview/src/splitview/view.ts @@ -22,7 +22,7 @@ export class ReactPanelView extends SplitviewPanel { this.reactPortalStore, this.reactComponent, { - params: this._params?.params || {}, + params: this._params?.params ?? {}, api: this.api, containerApi: new SplitviewApi( (this._params as PanelViewInitParameters).accessor