dockview 2.1.4 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dockview/dockview.d.ts +0 -1
- package/dist/cjs/dockview/dockview.js +3 -3
- package/dist/cjs/dockview/headerActionsRenderer.js +1 -1
- package/dist/cjs/dockview/reactContentPart.js +1 -1
- package/dist/cjs/dockview/reactHeaderPart.js +1 -1
- package/dist/cjs/dockview/reactWatermarkPart.js +1 -1
- package/dist/cjs/gridview/gridview.d.ts +2 -7
- package/dist/cjs/gridview/gridview.js +47 -20
- package/dist/cjs/paneview/paneview.d.ts +2 -6
- package/dist/cjs/paneview/paneview.js +54 -36
- package/dist/cjs/paneview/view.d.ts +2 -2
- package/dist/cjs/splitview/splitview.d.ts +2 -7
- package/dist/cjs/splitview/splitview.js +52 -20
- package/dist/dockview.amd.js +287 -238
- package/dist/dockview.amd.js.map +1 -1
- package/dist/dockview.amd.min.js +2 -2
- package/dist/dockview.amd.min.js.map +1 -1
- package/dist/dockview.amd.min.noStyle.js +2 -2
- package/dist/dockview.amd.min.noStyle.js.map +1 -1
- package/dist/dockview.amd.noStyle.js +287 -238
- package/dist/dockview.amd.noStyle.js.map +1 -1
- package/dist/dockview.cjs.js +287 -238
- package/dist/dockview.cjs.js.map +1 -1
- package/dist/dockview.esm.js +283 -238
- package/dist/dockview.esm.js.map +1 -1
- package/dist/dockview.esm.min.js +2 -2
- package/dist/dockview.esm.min.js.map +1 -1
- package/dist/dockview.js +287 -238
- package/dist/dockview.js.map +1 -1
- package/dist/dockview.min.js +2 -2
- package/dist/dockview.min.js.map +1 -1
- package/dist/dockview.min.noStyle.js +2 -2
- package/dist/dockview.min.noStyle.js.map +1 -1
- package/dist/dockview.noStyle.js +287 -238
- package/dist/dockview.noStyle.js.map +1 -1
- package/dist/esm/dockview/dockview.d.ts +0 -1
- package/dist/esm/dockview/dockview.js +4 -4
- package/dist/esm/dockview/headerActionsRenderer.js +1 -1
- package/dist/esm/dockview/reactContentPart.js +1 -1
- package/dist/esm/dockview/reactHeaderPart.js +1 -1
- package/dist/esm/dockview/reactWatermarkPart.js +1 -1
- package/dist/esm/gridview/gridview.d.ts +2 -7
- package/dist/esm/gridview/gridview.js +36 -20
- package/dist/esm/paneview/paneview.d.ts +2 -6
- package/dist/esm/paneview/paneview.js +53 -33
- package/dist/esm/paneview/view.d.ts +2 -2
- package/dist/esm/splitview/splitview.d.ts +2 -7
- package/dist/esm/splitview/splitview.js +41 -20
- package/package.json +2 -2
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { DockviewWillDropEvent, DockviewDidDropEvent, IWatermarkPanelProps, IDockviewHeaderActionsProps, IDockviewPanelHeaderProps, IDockviewPanelProps, DockviewOptions, DockviewReadyEvent } from 'dockview-core';
|
|
3
3
|
export interface IDockviewReactProps extends DockviewOptions {
|
|
4
|
-
className?: string;
|
|
5
4
|
tabComponents?: Record<string, React.FunctionComponent<IDockviewPanelHeaderProps>>;
|
|
6
5
|
components: Record<string, React.FunctionComponent<IDockviewPanelProps>>;
|
|
7
6
|
watermarkComponent?: React.FunctionComponent<IWatermarkPanelProps>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { PROPERTY_KEYS_DOCKVIEW, createDockview, } from 'dockview-core';
|
|
3
3
|
import { ReactPanelContentPart } from './reactContentPart';
|
|
4
4
|
import { ReactPanelHeaderPart } from './reactHeaderPart';
|
|
5
5
|
import { usePortalsLifecycle } from '../react';
|
|
@@ -14,7 +14,7 @@ function createGroupControlElement(component, store) {
|
|
|
14
14
|
}
|
|
15
15
|
const DEFAULT_REACT_TAB = 'props.defaultTabComponent';
|
|
16
16
|
function extractCoreOptions(props) {
|
|
17
|
-
const coreOptions =
|
|
17
|
+
const coreOptions = PROPERTY_KEYS_DOCKVIEW.reduce((obj, key) => {
|
|
18
18
|
if (key in props) {
|
|
19
19
|
obj[key] = props[key];
|
|
20
20
|
}
|
|
@@ -30,7 +30,7 @@ export const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
30
30
|
const prevProps = React.useRef({});
|
|
31
31
|
React.useEffect(() => {
|
|
32
32
|
const changes = {};
|
|
33
|
-
|
|
33
|
+
PROPERTY_KEYS_DOCKVIEW.forEach((propKey) => {
|
|
34
34
|
const key = propKey;
|
|
35
35
|
const propValue = props[key];
|
|
36
36
|
if (key in props && propValue !== prevProps.current[key]) {
|
|
@@ -44,7 +44,7 @@ export const DockviewReact = React.forwardRef((props, ref) => {
|
|
|
44
44
|
// not yet fully initialized
|
|
45
45
|
}
|
|
46
46
|
prevProps.current = props;
|
|
47
|
-
},
|
|
47
|
+
}, PROPERTY_KEYS_DOCKVIEW.map((key) => props[key]));
|
|
48
48
|
React.useEffect(() => {
|
|
49
49
|
var _a;
|
|
50
50
|
if (!domRef.current) {
|
|
@@ -13,7 +13,7 @@ export class ReactHeaderActionsRendererPart {
|
|
|
13
13
|
this._group = _group;
|
|
14
14
|
this.mutableDisposable = new DockviewMutableDisposable();
|
|
15
15
|
this._element = document.createElement('div');
|
|
16
|
-
this._element.className = '
|
|
16
|
+
this._element.className = 'dv-react-part';
|
|
17
17
|
this._element.style.height = '100%';
|
|
18
18
|
this._element.style.width = '100%';
|
|
19
19
|
}
|
|
@@ -13,7 +13,7 @@ export class ReactPanelContentPart {
|
|
|
13
13
|
this._onDidBlur = new DockviewEmitter();
|
|
14
14
|
this.onDidBlur = this._onDidBlur.event;
|
|
15
15
|
this._element = document.createElement('div');
|
|
16
|
-
this._element.className = '
|
|
16
|
+
this._element.className = 'dv-react-part';
|
|
17
17
|
this._element.style.height = '100%';
|
|
18
18
|
this._element.style.width = '100%';
|
|
19
19
|
}
|
|
@@ -8,7 +8,7 @@ export class ReactPanelHeaderPart {
|
|
|
8
8
|
this.component = component;
|
|
9
9
|
this.reactPortalStore = reactPortalStore;
|
|
10
10
|
this._element = document.createElement('div');
|
|
11
|
-
this._element.className = '
|
|
11
|
+
this._element.className = 'dv-react-part';
|
|
12
12
|
this._element.style.height = '100%';
|
|
13
13
|
this._element.style.width = '100%';
|
|
14
14
|
}
|
|
@@ -8,7 +8,7 @@ export class ReactWatermarkPart {
|
|
|
8
8
|
this.component = component;
|
|
9
9
|
this.reactPortalStore = reactPortalStore;
|
|
10
10
|
this._element = document.createElement('div');
|
|
11
|
-
this._element.className = '
|
|
11
|
+
this._element.className = 'dv-react-part';
|
|
12
12
|
this._element.style.height = '100%';
|
|
13
13
|
this._element.style.width = '100%';
|
|
14
14
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { GridviewPanelApi,
|
|
2
|
+
import { GridviewPanelApi, GridviewApi, GridviewOptions } from 'dockview-core';
|
|
3
3
|
import { PanelParameters } from '../types';
|
|
4
4
|
export interface GridviewReadyEvent {
|
|
5
5
|
api: GridviewApi;
|
|
@@ -10,13 +10,8 @@ export interface IGridviewPanelProps<T extends {
|
|
|
10
10
|
api: GridviewPanelApi;
|
|
11
11
|
containerApi: GridviewApi;
|
|
12
12
|
}
|
|
13
|
-
export interface IGridviewReactProps {
|
|
14
|
-
orientation?: Orientation;
|
|
13
|
+
export interface IGridviewReactProps extends GridviewOptions {
|
|
15
14
|
onReady: (event: GridviewReadyEvent) => void;
|
|
16
15
|
components: Record<string, React.FunctionComponent<IGridviewPanelProps>>;
|
|
17
|
-
hideBorders?: boolean;
|
|
18
|
-
className?: string;
|
|
19
|
-
proportionalLayout?: boolean;
|
|
20
|
-
disableAutoResizing?: boolean;
|
|
21
16
|
}
|
|
22
17
|
export declare const GridviewReact: React.ForwardRefExoticComponent<IGridviewReactProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { createGridview, PROPERTY_KEYS_GRIDVIEW, } from 'dockview-core';
|
|
3
3
|
import { ReactGridPanelView } from './view';
|
|
4
4
|
import { usePortalsLifecycle } from '../react';
|
|
5
|
+
function extractCoreOptions(props) {
|
|
6
|
+
const coreOptions = PROPERTY_KEYS_GRIDVIEW.reduce((obj, key) => {
|
|
7
|
+
if (key in props) {
|
|
8
|
+
obj[key] = props[key];
|
|
9
|
+
}
|
|
10
|
+
return obj;
|
|
11
|
+
}, {});
|
|
12
|
+
return coreOptions;
|
|
13
|
+
}
|
|
5
14
|
export const GridviewReact = React.forwardRef((props, ref) => {
|
|
6
15
|
const domRef = React.useRef(null);
|
|
7
16
|
const gridviewRef = React.useRef();
|
|
8
17
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
9
18
|
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
19
|
+
const prevProps = React.useRef({});
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
const changes = {};
|
|
22
|
+
PROPERTY_KEYS_GRIDVIEW.forEach((propKey) => {
|
|
23
|
+
const key = propKey;
|
|
24
|
+
const propValue = props[key];
|
|
25
|
+
if (key in props && propValue !== prevProps.current[key]) {
|
|
26
|
+
changes[key] = propValue;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
if (gridviewRef.current) {
|
|
30
|
+
gridviewRef.current.updateOptions(changes);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// not yet fully initialized
|
|
34
|
+
}
|
|
35
|
+
prevProps.current = props;
|
|
36
|
+
}, PROPERTY_KEYS_GRIDVIEW.map((key) => props[key]));
|
|
10
37
|
React.useEffect(() => {
|
|
11
|
-
var _a;
|
|
12
38
|
if (!domRef.current) {
|
|
13
39
|
return () => {
|
|
14
40
|
// noop
|
|
15
41
|
};
|
|
16
42
|
}
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
? props.proportionalLayout
|
|
21
|
-
: true,
|
|
22
|
-
orientation: (_a = props.orientation) !== null && _a !== void 0 ? _a : Orientation.HORIZONTAL,
|
|
23
|
-
frameworkComponents: props.components,
|
|
24
|
-
frameworkComponentFactory: {
|
|
25
|
-
createComponent: (id, componentId, component) => {
|
|
26
|
-
return new ReactGridPanelView(id, componentId, component, {
|
|
27
|
-
addPortal,
|
|
28
|
-
});
|
|
29
|
-
},
|
|
43
|
+
const frameworkOptions = {
|
|
44
|
+
createComponent: (options) => {
|
|
45
|
+
return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
30
46
|
},
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
: undefined,
|
|
34
|
-
});
|
|
47
|
+
};
|
|
48
|
+
const api = createGridview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
|
|
35
49
|
const { clientWidth, clientHeight } = domRef.current;
|
|
36
50
|
api.layout(clientWidth, clientHeight);
|
|
37
51
|
if (props.onReady) {
|
|
@@ -47,7 +61,9 @@ export const GridviewReact = React.forwardRef((props, ref) => {
|
|
|
47
61
|
return;
|
|
48
62
|
}
|
|
49
63
|
gridviewRef.current.updateOptions({
|
|
50
|
-
|
|
64
|
+
createComponent: (options) => {
|
|
65
|
+
return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
66
|
+
},
|
|
51
67
|
});
|
|
52
68
|
}, [props.components]);
|
|
53
69
|
return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PaneviewPanelApi,
|
|
2
|
+
import { PaneviewPanelApi, PaneviewApi, PaneviewDropEvent, PaneviewOptions } from 'dockview-core';
|
|
3
3
|
import { PanelParameters } from '../types';
|
|
4
4
|
export interface PaneviewReadyEvent {
|
|
5
5
|
api: PaneviewApi;
|
|
@@ -11,14 +11,10 @@ export interface IPaneviewPanelProps<T extends {
|
|
|
11
11
|
containerApi: PaneviewApi;
|
|
12
12
|
title: string;
|
|
13
13
|
}
|
|
14
|
-
export interface IPaneviewReactProps {
|
|
14
|
+
export interface IPaneviewReactProps extends PaneviewOptions {
|
|
15
15
|
onReady: (event: PaneviewReadyEvent) => void;
|
|
16
16
|
components: Record<string, React.FunctionComponent<IPaneviewPanelProps>>;
|
|
17
17
|
headerComponents?: Record<string, React.FunctionComponent<IPaneviewPanelProps>>;
|
|
18
|
-
className?: string;
|
|
19
|
-
disableAutoResizing?: boolean;
|
|
20
|
-
disableDnd?: boolean;
|
|
21
|
-
showDndOverlay?: (event: PaneviewDndOverlayEvent) => boolean;
|
|
22
18
|
onDidDrop?(event: PaneviewDropEvent): void;
|
|
23
19
|
}
|
|
24
20
|
export declare const PaneviewReact: React.ForwardRefExoticComponent<IPaneviewReactProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,33 +1,56 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { createPaneview, } from 'dockview-core';
|
|
2
|
+
import { createPaneview, PROPERTY_KEYS_PANEVIEW, } from 'dockview-core';
|
|
3
3
|
import { usePortalsLifecycle } from '../react';
|
|
4
4
|
import { PanePanelSection } from './view';
|
|
5
|
+
function extractCoreOptions(props) {
|
|
6
|
+
const coreOptions = PROPERTY_KEYS_PANEVIEW.reduce((obj, key) => {
|
|
7
|
+
if (key in props) {
|
|
8
|
+
obj[key] = props[key];
|
|
9
|
+
}
|
|
10
|
+
return obj;
|
|
11
|
+
}, {});
|
|
12
|
+
return coreOptions;
|
|
13
|
+
}
|
|
5
14
|
export const PaneviewReact = React.forwardRef((props, ref) => {
|
|
6
15
|
const domRef = React.useRef(null);
|
|
7
16
|
const paneviewRef = React.useRef();
|
|
8
17
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
9
18
|
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
19
|
+
const prevProps = React.useRef({});
|
|
10
20
|
React.useEffect(() => {
|
|
11
|
-
const
|
|
12
|
-
|
|
21
|
+
const changes = {};
|
|
22
|
+
PROPERTY_KEYS_PANEVIEW.forEach((propKey) => {
|
|
23
|
+
const key = propKey;
|
|
24
|
+
const propValue = props[key];
|
|
25
|
+
if (key in props && propValue !== prevProps.current[key]) {
|
|
26
|
+
changes[key] = propValue;
|
|
27
|
+
}
|
|
13
28
|
});
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
if (paneviewRef.current) {
|
|
30
|
+
paneviewRef.current.updateOptions(changes);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// not yet fully initialized
|
|
34
|
+
}
|
|
35
|
+
prevProps.current = props;
|
|
36
|
+
}, PROPERTY_KEYS_PANEVIEW.map((key) => props[key]));
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
var _a;
|
|
39
|
+
if (!domRef.current) {
|
|
40
|
+
return () => {
|
|
41
|
+
// noop
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
const headerComponents = (_a = props.headerComponents) !== null && _a !== void 0 ? _a : {};
|
|
45
|
+
const frameworkOptions = {
|
|
46
|
+
createComponent: (options) => {
|
|
47
|
+
return new PanePanelSection(options.id, props.components[options.name], { addPortal });
|
|
28
48
|
},
|
|
29
|
-
|
|
30
|
-
|
|
49
|
+
createHeaderComponent: (options) => {
|
|
50
|
+
return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const api = createPaneview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
|
|
31
54
|
const { clientWidth, clientHeight } = domRef.current;
|
|
32
55
|
api.layout(clientWidth, clientHeight);
|
|
33
56
|
if (props.onReady) {
|
|
@@ -43,41 +66,38 @@ export const PaneviewReact = React.forwardRef((props, ref) => {
|
|
|
43
66
|
return;
|
|
44
67
|
}
|
|
45
68
|
paneviewRef.current.updateOptions({
|
|
46
|
-
|
|
69
|
+
createComponent: (options) => {
|
|
70
|
+
return new PanePanelSection(options.id, props.components[options.name], { addPortal });
|
|
71
|
+
},
|
|
47
72
|
});
|
|
48
73
|
}, [props.components]);
|
|
49
74
|
React.useEffect(() => {
|
|
75
|
+
var _a;
|
|
50
76
|
if (!paneviewRef.current) {
|
|
51
77
|
return;
|
|
52
78
|
}
|
|
79
|
+
const headerComponents = (_a = props.headerComponents) !== null && _a !== void 0 ? _a : {};
|
|
53
80
|
paneviewRef.current.updateOptions({
|
|
54
|
-
|
|
81
|
+
createHeaderComponent: (options) => {
|
|
82
|
+
return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
|
|
83
|
+
},
|
|
55
84
|
});
|
|
56
85
|
}, [props.headerComponents]);
|
|
57
86
|
React.useEffect(() => {
|
|
58
87
|
if (!paneviewRef.current) {
|
|
59
88
|
return () => {
|
|
60
|
-
//
|
|
89
|
+
// noop
|
|
61
90
|
};
|
|
62
91
|
}
|
|
63
|
-
const
|
|
64
|
-
const disposable = api.onDidDrop((event) => {
|
|
92
|
+
const disposable = paneviewRef.current.onDidDrop((event) => {
|
|
65
93
|
if (props.onDidDrop) {
|
|
66
|
-
props.onDidDrop(
|
|
94
|
+
props.onDidDrop(event);
|
|
67
95
|
}
|
|
68
96
|
});
|
|
69
97
|
return () => {
|
|
70
98
|
disposable.dispose();
|
|
71
99
|
};
|
|
72
100
|
}, [props.onDidDrop]);
|
|
73
|
-
React.useEffect(() => {
|
|
74
|
-
if (!paneviewRef.current) {
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
paneviewRef.current.updateOptions({
|
|
78
|
-
showDndOverlay: props.showDndOverlay,
|
|
79
|
-
});
|
|
80
|
-
}, [props.showDndOverlay]);
|
|
81
101
|
return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
82
102
|
});
|
|
83
103
|
PaneviewReact.displayName = 'PaneviewComponent';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PanelUpdateEvent,
|
|
2
|
+
import { PanelUpdateEvent, IPanePart, PanePanelComponentInitParameter } from 'dockview-core';
|
|
3
3
|
import { ReactPortalStore } from '../react';
|
|
4
4
|
import { IPaneviewPanelProps } from './paneview';
|
|
5
|
-
export declare class PanePanelSection implements
|
|
5
|
+
export declare class PanePanelSection implements IPanePart {
|
|
6
6
|
readonly id: string;
|
|
7
7
|
private readonly component;
|
|
8
8
|
private readonly reactPortalStore;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SplitviewApi, SplitviewPanelApi,
|
|
2
|
+
import { SplitviewApi, SplitviewPanelApi, SplitviewOptions } from 'dockview-core';
|
|
3
3
|
import { PanelParameters } from '../types';
|
|
4
4
|
export interface SplitviewReadyEvent {
|
|
5
5
|
api: SplitviewApi;
|
|
@@ -10,13 +10,8 @@ export interface ISplitviewPanelProps<T extends {
|
|
|
10
10
|
api: SplitviewPanelApi;
|
|
11
11
|
containerApi: SplitviewApi;
|
|
12
12
|
}
|
|
13
|
-
export interface ISplitviewReactProps {
|
|
14
|
-
orientation?: Orientation;
|
|
13
|
+
export interface ISplitviewReactProps extends SplitviewOptions {
|
|
15
14
|
onReady: (event: SplitviewReadyEvent) => void;
|
|
16
15
|
components: Record<string, React.FunctionComponent<ISplitviewPanelProps>>;
|
|
17
|
-
proportionalLayout?: boolean;
|
|
18
|
-
hideBorders?: boolean;
|
|
19
|
-
className?: string;
|
|
20
|
-
disableAutoResizing?: boolean;
|
|
21
16
|
}
|
|
22
17
|
export declare const SplitviewReact: React.ForwardRefExoticComponent<ISplitviewReactProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -1,32 +1,51 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { createSplitview, PROPERTY_KEYS_SPLITVIEW, } from 'dockview-core';
|
|
3
3
|
import { usePortalsLifecycle } from '../react';
|
|
4
4
|
import { ReactPanelView } from './view';
|
|
5
|
+
function extractCoreOptions(props) {
|
|
6
|
+
const coreOptions = PROPERTY_KEYS_SPLITVIEW.reduce((obj, key) => {
|
|
7
|
+
if (key in props) {
|
|
8
|
+
obj[key] = props[key];
|
|
9
|
+
}
|
|
10
|
+
return obj;
|
|
11
|
+
}, {});
|
|
12
|
+
return coreOptions;
|
|
13
|
+
}
|
|
5
14
|
export const SplitviewReact = React.forwardRef((props, ref) => {
|
|
6
15
|
const domRef = React.useRef(null);
|
|
7
16
|
const splitviewRef = React.useRef();
|
|
8
17
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
9
18
|
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
19
|
+
const prevProps = React.useRef({});
|
|
10
20
|
React.useEffect(() => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return new ReactPanelView(id, componentId, component, {
|
|
19
|
-
addPortal,
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
proportionalLayout: typeof props.proportionalLayout === 'boolean'
|
|
24
|
-
? props.proportionalLayout
|
|
25
|
-
: true,
|
|
26
|
-
styles: props.hideBorders
|
|
27
|
-
? { separatorBorder: 'transparent' }
|
|
28
|
-
: undefined,
|
|
21
|
+
const changes = {};
|
|
22
|
+
PROPERTY_KEYS_SPLITVIEW.forEach((propKey) => {
|
|
23
|
+
const key = propKey;
|
|
24
|
+
const propValue = props[key];
|
|
25
|
+
if (key in props && propValue !== prevProps.current[key]) {
|
|
26
|
+
changes[key] = propValue;
|
|
27
|
+
}
|
|
29
28
|
});
|
|
29
|
+
if (splitviewRef.current) {
|
|
30
|
+
splitviewRef.current.updateOptions(changes);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// not yet fully initialized
|
|
34
|
+
}
|
|
35
|
+
prevProps.current = props;
|
|
36
|
+
}, PROPERTY_KEYS_SPLITVIEW.map((key) => props[key]));
|
|
37
|
+
React.useEffect(() => {
|
|
38
|
+
if (!domRef.current) {
|
|
39
|
+
return () => {
|
|
40
|
+
// noop
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
const frameworkOptions = {
|
|
44
|
+
createComponent: (options) => {
|
|
45
|
+
return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
const api = createSplitview(domRef.current, Object.assign(Object.assign({}, extractCoreOptions(props)), frameworkOptions));
|
|
30
49
|
const { clientWidth, clientHeight } = domRef.current;
|
|
31
50
|
api.layout(clientWidth, clientHeight);
|
|
32
51
|
if (props.onReady) {
|
|
@@ -42,7 +61,9 @@ export const SplitviewReact = React.forwardRef((props, ref) => {
|
|
|
42
61
|
return;
|
|
43
62
|
}
|
|
44
63
|
splitviewRef.current.updateOptions({
|
|
45
|
-
|
|
64
|
+
createComponent: (options) => {
|
|
65
|
+
return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
66
|
+
},
|
|
46
67
|
});
|
|
47
68
|
}, [props.components]);
|
|
48
69
|
return (React.createElement("div", { className: props.className, style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dockview",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Zero dependency layout manager supporting tabs, grids and splitviews",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"splitview",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"test:cov": "cross-env ../../node_modules/.bin/jest --selectProjects dockview --coverage"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"dockview-core": "^
|
|
57
|
+
"dockview-core": "^3.0.0"
|
|
58
58
|
},
|
|
59
59
|
"peerDependencies": {
|
|
60
60
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|