refactor: housekeeping

This commit is contained in:
mathuo 2021-03-24 17:43:22 +00:00
parent 09c639c28f
commit 2631765972
5 changed files with 26 additions and 26 deletions

View File

@ -1,8 +1,9 @@
const DOCKVIEW_SUPPRESS_WATERMARK = 'DOCKVIEW_WATERMARK_SUPPRESSED'; function runFootnote() {
const DOCKVIEW_SUPPRESS_WATERMARK = 'DOCKVIEW_WATERMARK_SUPPRESSED';
const isSuppressed = !!(window as any)[DOCKVIEW_SUPPRESS_WATERMARK]; const isSuppressed = !!(window as any)[DOCKVIEW_SUPPRESS_WATERMARK];
if (!isSuppressed) { if (!isSuppressed) {
console.log( console.log(
[ [
'dockview: https://github.com/mathuo/dockview for examples and documentation', 'dockview: https://github.com/mathuo/dockview for examples and documentation',
@ -11,4 +12,7 @@ if (!isSuppressed) {
'', '',
].join('\n') ].join('\n')
); );
}
} }
runFootnote();

View File

@ -1,6 +1,6 @@
import * as React from 'react'; import * as React from 'react';
import * as ReactDOM from 'react-dom'; import * as ReactDOM from 'react-dom';
import { ReactPartContext } from '../react'; import { isReactElement, ReactPartContext } from '../react';
import { ReactContentPartContext } from './reactContentPart'; import { ReactContentPartContext } from './reactContentPart';
interface WithChildren { interface WithChildren {
@ -18,13 +18,6 @@ const Action: React.FunctionComponent<WithChildren> = (props: WithChildren) => {
return <>{props.children}</>; return <>{props.children}</>;
}; };
// it does the job...
function isReactElement(
element: any | React.ReactElement
): element is React.ReactElement {
return !!(element as any)?.type;
}
function isValidComponent(element: React.ReactElement) { function isValidComponent(element: React.ReactElement) {
return [Body, Action, Tab].find((comp) => element.type === comp); return [Body, Action, Tab].find((comp) => element.type === comp);
} }

View File

@ -16,10 +16,6 @@ import { IDisposable } from '../../lifecycle';
import { watchElementResize } from '../../dom'; import { watchElementResize } from '../../dom';
import { IContentRenderer, ITabRenderer } from '../../groupview/types'; import { IContentRenderer, ITabRenderer } from '../../groupview/types';
export interface ActionsbarReference<P> extends IDisposable {
update(params: Partial<P>): void;
}
export interface IGroupPanelBaseProps { export interface IGroupPanelBaseProps {
api: IDockviewPanelApi; api: IDockviewPanelApi;
containerApi: DockviewApi; containerApi: DockviewApi;

View File

@ -5,9 +5,9 @@ import {
GroupPanelContentPartInitParameters, GroupPanelContentPartInitParameters,
} from '../../groupview/types'; } from '../../groupview/types';
import { ReactPart, ReactPortalStore } from '../react'; import { ReactPart, ReactPortalStore } from '../react';
import { ActionsbarReference, IDockviewPanelProps } from '../dockview/dockview'; import { IDockviewPanelProps } from '../dockview/dockview';
import { PanelUpdateEvent } from '../../panel/types'; import { PanelUpdateEvent } from '../../panel/types';
import { DockviewPanelApi, IDockviewPanelApi } from '../../api/groupPanelApi'; import { IDockviewPanelApi } from '../../api/groupPanelApi';
import { DockviewApi } from '../../api/component.api'; import { DockviewApi } from '../../api/component.api';
import { HostedContainer } from '../../hostedContainer'; import { HostedContainer } from '../../hostedContainer';
import { GroupviewPanel } from '../../groupview/v2/groupviewPanel'; import { GroupviewPanel } from '../../groupview/v2/groupviewPanel';

View File

@ -58,7 +58,7 @@ const ReactComponentBridge: React.ForwardRefRenderFunction<
return React.createElement(props.component, _props.current); return React.createElement(props.component, _props.current);
}; };
ReactComponentBridge.displayName = 'PanelWrapper'; ReactComponentBridge.displayName = 'DockviewReactJsBridge';
/** /**
* Since we are storing the React.Portal references in a rendered array they * Since we are storing the React.Portal references in a rendered array they
@ -181,3 +181,10 @@ export const usePortalsLifecycle: PortalLifecycleHook = () => {
return [portals, addPortal]; return [portals, addPortal];
}; };
// it does the job...
export function isReactElement(
element: any | React.ReactElement
): element is React.ReactElement {
return !!(element as any)?.type;
}