dockview-react 6.6.1 → 7.0.2
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/defaultTab.d.ts +7 -0
- package/dist/cjs/dockview/defaultTab.js +99 -0
- package/dist/cjs/dockview/dockview.d.ts +33 -0
- package/dist/cjs/dockview/dockview.js +285 -0
- package/dist/cjs/dockview/headerActionsRenderer.d.ts +24 -0
- package/dist/cjs/dockview/headerActionsRenderer.js +86 -0
- package/dist/cjs/dockview/reactContentPart.d.ts +21 -0
- package/dist/cjs/dockview/reactContentPart.js +52 -0
- package/dist/cjs/dockview/reactContextMenuItemPart.d.ts +14 -0
- package/dist/cjs/dockview/reactContextMenuItemPart.js +31 -0
- package/dist/cjs/dockview/reactGroupDragGhostPart.d.ts +20 -0
- package/dist/cjs/dockview/reactGroupDragGhostPart.js +32 -0
- package/dist/cjs/dockview/reactHeaderPart.d.ts +17 -0
- package/dist/cjs/dockview/reactHeaderPart.js +46 -0
- package/dist/cjs/dockview/reactTabGroupChipPart.d.ts +23 -0
- package/dist/cjs/dockview/reactTabGroupChipPart.js +36 -0
- package/dist/cjs/dockview/reactWatermarkPart.d.ts +18 -0
- package/dist/cjs/dockview/reactWatermarkPart.js +47 -0
- package/dist/cjs/gridview/gridview.d.ts +17 -0
- package/dist/cjs/gridview/gridview.js +105 -0
- package/dist/cjs/gridview/view.d.ts +9 -0
- package/dist/cjs/gridview/view.js +41 -0
- package/dist/cjs/index.d.ts +9 -0
- package/dist/cjs/index.js +7 -0
- package/dist/cjs/paneview/paneview.d.ts +20 -0
- package/dist/cjs/paneview/paneview.js +137 -0
- package/dist/cjs/paneview/view.d.ts +19 -0
- package/dist/cjs/paneview/view.js +44 -0
- package/dist/cjs/react.d.ts +35 -0
- package/dist/cjs/react.js +183 -0
- package/dist/cjs/splitview/splitview.d.ts +17 -0
- package/dist/cjs/splitview/splitview.js +105 -0
- package/dist/cjs/splitview/view.d.ts +9 -0
- package/dist/cjs/splitview/view.js +39 -0
- package/dist/cjs/svg.d.ts +3 -0
- package/dist/cjs/svg.js +15 -0
- package/dist/cjs/types.d.ts +4 -0
- package/dist/cjs/types.js +2 -0
- package/dist/dockview-react.js +21650 -11
- package/dist/dockview-react.min.js +21 -2
- package/dist/dockview-react.min.js.map +1 -1
- package/dist/esm/dockview/defaultTab.d.ts +7 -0
- package/dist/esm/dockview/defaultTab.js +65 -0
- package/dist/esm/dockview/dockview.d.ts +33 -0
- package/dist/esm/dockview/dockview.js +252 -0
- package/dist/esm/dockview/headerActionsRenderer.d.ts +24 -0
- package/dist/esm/dockview/headerActionsRenderer.js +72 -0
- package/dist/esm/dockview/reactContentPart.d.ts +21 -0
- package/dist/esm/dockview/reactContentPart.js +43 -0
- package/dist/esm/dockview/reactContextMenuItemPart.d.ts +14 -0
- package/dist/esm/dockview/reactContextMenuItemPart.js +22 -0
- package/dist/esm/dockview/reactGroupDragGhostPart.d.ts +20 -0
- package/dist/esm/dockview/reactGroupDragGhostPart.js +23 -0
- package/dist/esm/dockview/reactHeaderPart.d.ts +17 -0
- package/dist/esm/dockview/reactHeaderPart.js +37 -0
- package/dist/esm/dockview/reactTabGroupChipPart.d.ts +23 -0
- package/dist/esm/dockview/reactTabGroupChipPart.js +27 -0
- package/dist/esm/dockview/reactWatermarkPart.d.ts +18 -0
- package/dist/esm/dockview/reactWatermarkPart.js +38 -0
- package/dist/esm/gridview/gridview.d.ts +17 -0
- package/dist/esm/gridview/gridview.js +72 -0
- package/dist/esm/gridview/view.d.ts +9 -0
- package/dist/esm/gridview/view.js +19 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/paneview/paneview.d.ts +20 -0
- package/dist/esm/paneview/paneview.js +104 -0
- package/dist/esm/paneview/view.d.ts +19 -0
- package/dist/esm/paneview/view.js +35 -0
- package/dist/esm/react.d.ts +35 -0
- package/dist/esm/react.js +134 -0
- package/dist/esm/splitview/splitview.d.ts +17 -0
- package/dist/esm/splitview/splitview.js +72 -0
- package/dist/esm/splitview/view.d.ts +9 -0
- package/dist/esm/splitview/view.js +17 -0
- package/dist/esm/svg.d.ts +3 -0
- package/dist/esm/svg.js +7 -0
- package/dist/esm/types.d.ts +4 -0
- package/dist/esm/types.js +1 -0
- package/dist/package/main.cjs.js +1037 -5
- package/dist/package/main.cjs.min.js +2 -2
- package/dist/package/main.esm.min.mjs +2 -8
- package/dist/package/main.esm.mjs +1027 -1
- package/dist/styles/dockview.css +275 -13
- package/package.json +15 -2
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IDockviewPanelHeaderProps } from 'dockview';
|
|
3
|
+
export type IDockviewDefaultTabProps = IDockviewPanelHeaderProps & React.HtmlHTMLAttributes<HTMLDivElement> & {
|
|
4
|
+
hideClose?: boolean;
|
|
5
|
+
closeActionOverride?: () => void;
|
|
6
|
+
};
|
|
7
|
+
export declare const DockviewDefaultTab: React.FunctionComponent<IDockviewDefaultTabProps>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { CloseButton } from '../svg';
|
|
14
|
+
function useTitle(api) {
|
|
15
|
+
const [title, setTitle] = React.useState(api.title);
|
|
16
|
+
React.useEffect(() => {
|
|
17
|
+
const disposable = api.onDidTitleChange((event) => {
|
|
18
|
+
setTitle(event.title);
|
|
19
|
+
});
|
|
20
|
+
// Depending on the order in which React effects are run, the title may already be out of sync (cf. issue #1003).
|
|
21
|
+
if (title !== api.title) {
|
|
22
|
+
setTitle(api.title);
|
|
23
|
+
}
|
|
24
|
+
return () => {
|
|
25
|
+
disposable.dispose();
|
|
26
|
+
};
|
|
27
|
+
}, [api]);
|
|
28
|
+
return title;
|
|
29
|
+
}
|
|
30
|
+
export const DockviewDefaultTab = (_a) => {
|
|
31
|
+
var { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride, onPointerDown, onPointerUp, onPointerLeave, tabLocation } = _a, rest = __rest(_a, ["api", "containerApi", "params", "hideClose", "closeActionOverride", "onPointerDown", "onPointerUp", "onPointerLeave", "tabLocation"]);
|
|
32
|
+
const title = useTitle(api);
|
|
33
|
+
const isMiddleMouseButton = React.useRef(false);
|
|
34
|
+
const onClose = React.useCallback((event) => {
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
if (closeActionOverride) {
|
|
37
|
+
closeActionOverride();
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
api.close();
|
|
41
|
+
}
|
|
42
|
+
}, [api, closeActionOverride]);
|
|
43
|
+
const onBtnPointerDown = React.useCallback((event) => {
|
|
44
|
+
event.preventDefault();
|
|
45
|
+
}, []);
|
|
46
|
+
const _onPointerDown = React.useCallback((event) => {
|
|
47
|
+
isMiddleMouseButton.current = event.button === 1;
|
|
48
|
+
onPointerDown === null || onPointerDown === void 0 ? void 0 : onPointerDown(event);
|
|
49
|
+
}, [onPointerDown]);
|
|
50
|
+
const _onPointerUp = React.useCallback((event) => {
|
|
51
|
+
if (isMiddleMouseButton && event.button === 1 && !hideClose) {
|
|
52
|
+
isMiddleMouseButton.current = false;
|
|
53
|
+
onClose(event);
|
|
54
|
+
}
|
|
55
|
+
onPointerUp === null || onPointerUp === void 0 ? void 0 : onPointerUp(event);
|
|
56
|
+
}, [onPointerUp, onClose, hideClose]);
|
|
57
|
+
const _onPointerLeave = React.useCallback((event) => {
|
|
58
|
+
isMiddleMouseButton.current = false;
|
|
59
|
+
onPointerLeave === null || onPointerLeave === void 0 ? void 0 : onPointerLeave(event);
|
|
60
|
+
}, [onPointerLeave]);
|
|
61
|
+
return (React.createElement("div", Object.assign({ "data-testid": "dockview-dv-default-tab" }, rest, { onPointerDown: _onPointerDown, onPointerUp: _onPointerUp, onPointerLeave: _onPointerLeave, className: "dv-default-tab" }),
|
|
62
|
+
React.createElement("span", { className: "dv-default-tab-content" }, title),
|
|
63
|
+
!hideClose && (React.createElement("div", { className: "dv-default-tab-action", onPointerDown: onBtnPointerDown, onClick: onClose },
|
|
64
|
+
React.createElement(CloseButton, null)))));
|
|
65
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { DockviewWillDropEvent, DockviewDidDropEvent, IWatermarkPanelProps, IDockviewHeaderActionsProps, IDockviewPanelHeaderProps, IDockviewPanelProps, DockviewOptions, DockviewReadyEvent, BuiltInContextMenuItem, BuiltInChipContextMenuItem, ContextMenuItemConfig, GetTabContextMenuItemsParams, GetTabGroupChipContextMenuItemsParams, IContextMenuItemComponentProps } from 'dockview';
|
|
3
|
+
import { IDockviewTabGroupChipProps } from './reactTabGroupChipPart';
|
|
4
|
+
import { IDockviewGroupDragGhostProps } from './reactGroupDragGhostPart';
|
|
5
|
+
export interface ReactContextMenuItemConfig extends Omit<ContextMenuItemConfig, 'component'> {
|
|
6
|
+
component?: React.FunctionComponent<IContextMenuItemComponentProps>;
|
|
7
|
+
}
|
|
8
|
+
export interface IDockviewReactProps extends DockviewOptions {
|
|
9
|
+
tabComponents?: Record<string, React.FunctionComponent<IDockviewPanelHeaderProps>>;
|
|
10
|
+
components: Record<string, React.FunctionComponent<IDockviewPanelProps>>;
|
|
11
|
+
watermarkComponent?: React.FunctionComponent<IWatermarkPanelProps>;
|
|
12
|
+
defaultTabComponent?: React.FunctionComponent<IDockviewPanelHeaderProps>;
|
|
13
|
+
rightHeaderActionsComponent?: React.FunctionComponent<IDockviewHeaderActionsProps>;
|
|
14
|
+
leftHeaderActionsComponent?: React.FunctionComponent<IDockviewHeaderActionsProps>;
|
|
15
|
+
prefixHeaderActionsComponent?: React.FunctionComponent<IDockviewHeaderActionsProps>;
|
|
16
|
+
getTabContextMenuItems?: (params: GetTabContextMenuItemsParams) => (BuiltInContextMenuItem | ReactContextMenuItemConfig)[];
|
|
17
|
+
getTabGroupChipContextMenuItems?: (params: GetTabGroupChipContextMenuItemsParams) => (BuiltInChipContextMenuItem | ReactContextMenuItemConfig)[];
|
|
18
|
+
tabGroupChipComponent?: React.FunctionComponent<IDockviewTabGroupChipProps>;
|
|
19
|
+
/**
|
|
20
|
+
* Component rendered as the drag ghost (the small floating chip) while
|
|
21
|
+
* a group of panels is being dragged. If omitted, the default
|
|
22
|
+
* `"Multiple Panels (N)"` ghost is used.
|
|
23
|
+
*
|
|
24
|
+
* Note: the ghost is captured by the browser at drag start, so the
|
|
25
|
+
* component must render fast / synchronously enough to be visible
|
|
26
|
+
* before the browser snapshots it.
|
|
27
|
+
*/
|
|
28
|
+
groupDragGhostComponent?: React.FunctionComponent<IDockviewGroupDragGhostProps>;
|
|
29
|
+
onReady: (event: DockviewReadyEvent) => void;
|
|
30
|
+
onDidDrop?: (event: DockviewDidDropEvent) => void;
|
|
31
|
+
onWillDrop?: (event: DockviewWillDropEvent) => void;
|
|
32
|
+
}
|
|
33
|
+
export declare const DockviewReact: React.ForwardRefExoticComponent<IDockviewReactProps & React.RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { PROPERTY_KEYS_DOCKVIEW, createDockview, } from 'dockview';
|
|
3
|
+
import { ReactPanelContentPart } from './reactContentPart';
|
|
4
|
+
import { ReactPanelHeaderPart } from './reactHeaderPart';
|
|
5
|
+
import { usePortalsLifecycle } from '../react';
|
|
6
|
+
import { ReactWatermarkPart } from './reactWatermarkPart';
|
|
7
|
+
import { ReactHeaderActionsRendererPart } from './headerActionsRenderer';
|
|
8
|
+
import { ReactContextMenuItemPart } from './reactContextMenuItemPart';
|
|
9
|
+
import { ReactTabGroupChipPart, } from './reactTabGroupChipPart';
|
|
10
|
+
import { ReactGroupDragGhostPart, } from './reactGroupDragGhostPart';
|
|
11
|
+
function createGroupControlElement(component, store) {
|
|
12
|
+
return component
|
|
13
|
+
? (groupPanel) => {
|
|
14
|
+
return new ReactHeaderActionsRendererPart(component, store, groupPanel);
|
|
15
|
+
}
|
|
16
|
+
: undefined;
|
|
17
|
+
}
|
|
18
|
+
const DEFAULT_REACT_TAB = 'props.defaultTabComponent';
|
|
19
|
+
function extractCoreOptions(props) {
|
|
20
|
+
const coreOptions = PROPERTY_KEYS_DOCKVIEW.reduce((obj, key) => {
|
|
21
|
+
if (key in props) {
|
|
22
|
+
obj[key] = props[key];
|
|
23
|
+
}
|
|
24
|
+
return obj;
|
|
25
|
+
}, {});
|
|
26
|
+
return coreOptions;
|
|
27
|
+
}
|
|
28
|
+
export const DockviewReact = React.forwardRef((props, ref) => {
|
|
29
|
+
const domRef = React.useRef(null);
|
|
30
|
+
const dockviewRef = React.useRef(undefined);
|
|
31
|
+
const [portals, addPortal] = usePortalsLifecycle();
|
|
32
|
+
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
33
|
+
const prevProps = React.useRef({});
|
|
34
|
+
React.useEffect(() => {
|
|
35
|
+
const changes = {};
|
|
36
|
+
PROPERTY_KEYS_DOCKVIEW.forEach((propKey) => {
|
|
37
|
+
const key = propKey;
|
|
38
|
+
const propValue = props[key];
|
|
39
|
+
if (key in props && propValue !== prevProps.current[key]) {
|
|
40
|
+
changes[key] = propValue;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
if (dockviewRef.current) {
|
|
44
|
+
dockviewRef.current.updateOptions(changes);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
// not yet fully initialized
|
|
48
|
+
}
|
|
49
|
+
prevProps.current = props;
|
|
50
|
+
}, PROPERTY_KEYS_DOCKVIEW.map((key) => props[key]));
|
|
51
|
+
React.useEffect(() => {
|
|
52
|
+
var _a;
|
|
53
|
+
if (!domRef.current) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const frameworkTabComponents = (_a = props.tabComponents) !== null && _a !== void 0 ? _a : {};
|
|
57
|
+
if (props.defaultTabComponent) {
|
|
58
|
+
frameworkTabComponents[DEFAULT_REACT_TAB] =
|
|
59
|
+
props.defaultTabComponent;
|
|
60
|
+
}
|
|
61
|
+
const frameworkOptions = {
|
|
62
|
+
createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
63
|
+
createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
64
|
+
createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
|
|
65
|
+
createComponent: (options) => {
|
|
66
|
+
return new ReactPanelContentPart(options.id, props.components[options.name], {
|
|
67
|
+
addPortal,
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
createTabComponent(options) {
|
|
71
|
+
return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
|
|
72
|
+
addPortal,
|
|
73
|
+
});
|
|
74
|
+
},
|
|
75
|
+
createWatermarkComponent: props.watermarkComponent
|
|
76
|
+
? () => {
|
|
77
|
+
return new ReactWatermarkPart('watermark', props.watermarkComponent, {
|
|
78
|
+
addPortal,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
: undefined,
|
|
82
|
+
defaultTabComponent: props.defaultTabComponent
|
|
83
|
+
? DEFAULT_REACT_TAB
|
|
84
|
+
: undefined,
|
|
85
|
+
createContextMenuItemComponent: (options) => {
|
|
86
|
+
if (!options.component) {
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
return new ReactContextMenuItemPart(options.id, options.component, { addPortal });
|
|
90
|
+
},
|
|
91
|
+
};
|
|
92
|
+
const coreOptions = extractCoreOptions(props);
|
|
93
|
+
if (props.tabGroupChipComponent) {
|
|
94
|
+
const chipComponent = props.tabGroupChipComponent;
|
|
95
|
+
coreOptions.createTabGroupChipComponent = () => {
|
|
96
|
+
return new ReactTabGroupChipPart(chipComponent, {
|
|
97
|
+
addPortal,
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (props.groupDragGhostComponent) {
|
|
102
|
+
const ghostComponent = props.groupDragGhostComponent;
|
|
103
|
+
coreOptions.createGroupDragGhostComponent = () => {
|
|
104
|
+
return new ReactGroupDragGhostPart(ghostComponent, {
|
|
105
|
+
addPortal,
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
const api = createDockview(domRef.current, Object.assign(Object.assign({}, coreOptions), frameworkOptions));
|
|
110
|
+
const { clientWidth, clientHeight } = domRef.current;
|
|
111
|
+
api.layout(clientWidth, clientHeight);
|
|
112
|
+
if (props.onReady) {
|
|
113
|
+
props.onReady({ api });
|
|
114
|
+
}
|
|
115
|
+
dockviewRef.current = api;
|
|
116
|
+
return () => {
|
|
117
|
+
dockviewRef.current = undefined;
|
|
118
|
+
api.dispose();
|
|
119
|
+
};
|
|
120
|
+
}, []);
|
|
121
|
+
React.useEffect(() => {
|
|
122
|
+
if (!dockviewRef.current) {
|
|
123
|
+
return () => {
|
|
124
|
+
// noop
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const disposable = dockviewRef.current.onDidDrop((event) => {
|
|
128
|
+
if (props.onDidDrop) {
|
|
129
|
+
props.onDidDrop(event);
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
return () => {
|
|
133
|
+
disposable.dispose();
|
|
134
|
+
};
|
|
135
|
+
}, [props.onDidDrop]);
|
|
136
|
+
React.useEffect(() => {
|
|
137
|
+
if (!dockviewRef.current) {
|
|
138
|
+
return () => {
|
|
139
|
+
// noop
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
const disposable = dockviewRef.current.onWillDrop((event) => {
|
|
143
|
+
if (props.onWillDrop) {
|
|
144
|
+
props.onWillDrop(event);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
return () => {
|
|
148
|
+
disposable.dispose();
|
|
149
|
+
};
|
|
150
|
+
}, [props.onWillDrop]);
|
|
151
|
+
React.useEffect(() => {
|
|
152
|
+
if (!dockviewRef.current) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
dockviewRef.current.updateOptions({
|
|
156
|
+
createTabGroupChipComponent: props.tabGroupChipComponent
|
|
157
|
+
? () => {
|
|
158
|
+
return new ReactTabGroupChipPart(props.tabGroupChipComponent, {
|
|
159
|
+
addPortal,
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
: undefined,
|
|
163
|
+
});
|
|
164
|
+
}, [props.tabGroupChipComponent]);
|
|
165
|
+
React.useEffect(() => {
|
|
166
|
+
if (!dockviewRef.current) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
dockviewRef.current.updateOptions({
|
|
170
|
+
createGroupDragGhostComponent: props.groupDragGhostComponent
|
|
171
|
+
? () => {
|
|
172
|
+
return new ReactGroupDragGhostPart(props.groupDragGhostComponent, {
|
|
173
|
+
addPortal,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
: undefined,
|
|
177
|
+
});
|
|
178
|
+
}, [props.groupDragGhostComponent]);
|
|
179
|
+
React.useEffect(() => {
|
|
180
|
+
if (!dockviewRef.current) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
dockviewRef.current.updateOptions({
|
|
184
|
+
createComponent: (options) => {
|
|
185
|
+
return new ReactPanelContentPart(options.id, props.components[options.name], {
|
|
186
|
+
addPortal,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}, [props.components]);
|
|
191
|
+
React.useEffect(() => {
|
|
192
|
+
var _a;
|
|
193
|
+
if (!dockviewRef.current) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
const frameworkTabComponents = (_a = props.tabComponents) !== null && _a !== void 0 ? _a : {};
|
|
197
|
+
if (props.defaultTabComponent) {
|
|
198
|
+
frameworkTabComponents[DEFAULT_REACT_TAB] =
|
|
199
|
+
props.defaultTabComponent;
|
|
200
|
+
}
|
|
201
|
+
dockviewRef.current.updateOptions({
|
|
202
|
+
defaultTabComponent: props.defaultTabComponent
|
|
203
|
+
? DEFAULT_REACT_TAB
|
|
204
|
+
: undefined,
|
|
205
|
+
createTabComponent(options) {
|
|
206
|
+
return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
|
|
207
|
+
addPortal,
|
|
208
|
+
});
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}, [props.tabComponents, props.defaultTabComponent]);
|
|
212
|
+
React.useEffect(() => {
|
|
213
|
+
if (!dockviewRef.current) {
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
dockviewRef.current.updateOptions({
|
|
217
|
+
createWatermarkComponent: props.watermarkComponent
|
|
218
|
+
? () => {
|
|
219
|
+
return new ReactWatermarkPart('watermark', props.watermarkComponent, {
|
|
220
|
+
addPortal,
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
: undefined,
|
|
224
|
+
});
|
|
225
|
+
}, [props.watermarkComponent]);
|
|
226
|
+
React.useEffect(() => {
|
|
227
|
+
if (!dockviewRef.current) {
|
|
228
|
+
return;
|
|
229
|
+
}
|
|
230
|
+
dockviewRef.current.updateOptions({
|
|
231
|
+
createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
232
|
+
});
|
|
233
|
+
}, [props.rightHeaderActionsComponent]);
|
|
234
|
+
React.useEffect(() => {
|
|
235
|
+
if (!dockviewRef.current) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
dockviewRef.current.updateOptions({
|
|
239
|
+
createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
240
|
+
});
|
|
241
|
+
}, [props.leftHeaderActionsComponent]);
|
|
242
|
+
React.useEffect(() => {
|
|
243
|
+
if (!dockviewRef.current) {
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
dockviewRef.current.updateOptions({
|
|
247
|
+
createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
|
|
248
|
+
});
|
|
249
|
+
}, [props.prefixHeaderActionsComponent]);
|
|
250
|
+
return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
251
|
+
});
|
|
252
|
+
DockviewReact.displayName = 'DockviewComponent';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactPart, ReactPortalStore } from '../react';
|
|
3
|
+
import { DockviewApi, DockviewGroupPanel, DockviewGroupPanelApi, PanelUpdateEvent, IHeaderActionsRenderer, IDockviewHeaderActionsProps } from 'dockview';
|
|
4
|
+
export declare class ReactHeaderActionsRendererPart implements IHeaderActionsRenderer {
|
|
5
|
+
private readonly component;
|
|
6
|
+
private readonly reactPortalStore;
|
|
7
|
+
private readonly _group;
|
|
8
|
+
private readonly mutableDisposable;
|
|
9
|
+
private readonly _element;
|
|
10
|
+
private _part?;
|
|
11
|
+
get element(): HTMLElement;
|
|
12
|
+
get part(): ReactPart<IDockviewHeaderActionsProps> | undefined;
|
|
13
|
+
constructor(component: React.FunctionComponent<IDockviewHeaderActionsProps>, reactPortalStore: ReactPortalStore, _group: DockviewGroupPanel);
|
|
14
|
+
init(parameters: {
|
|
15
|
+
containerApi: DockviewApi;
|
|
16
|
+
api: DockviewGroupPanelApi;
|
|
17
|
+
}): void;
|
|
18
|
+
dispose(): void;
|
|
19
|
+
update(event: PanelUpdateEvent): void;
|
|
20
|
+
private updatePanels;
|
|
21
|
+
private updateActivePanel;
|
|
22
|
+
private updateGroupActive;
|
|
23
|
+
private updateLocation;
|
|
24
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { ReactPart } from '../react';
|
|
2
|
+
import { DockviewCompositeDisposable, DockviewMutableDisposable, } from 'dockview';
|
|
3
|
+
export class ReactHeaderActionsRendererPart {
|
|
4
|
+
get element() {
|
|
5
|
+
return this._element;
|
|
6
|
+
}
|
|
7
|
+
get part() {
|
|
8
|
+
return this._part;
|
|
9
|
+
}
|
|
10
|
+
constructor(component, reactPortalStore, _group) {
|
|
11
|
+
this.component = component;
|
|
12
|
+
this.reactPortalStore = reactPortalStore;
|
|
13
|
+
this._group = _group;
|
|
14
|
+
this.mutableDisposable = new DockviewMutableDisposable();
|
|
15
|
+
this._element = document.createElement('div');
|
|
16
|
+
this._element.className = 'dv-react-part';
|
|
17
|
+
this._element.style.height = '100%';
|
|
18
|
+
this._element.style.width = '100%';
|
|
19
|
+
}
|
|
20
|
+
init(parameters) {
|
|
21
|
+
this.mutableDisposable.value = new DockviewCompositeDisposable(this._group.model.onDidAddPanel(() => {
|
|
22
|
+
this.updatePanels();
|
|
23
|
+
}), this._group.model.onDidRemovePanel(() => {
|
|
24
|
+
this.updatePanels();
|
|
25
|
+
}), this._group.model.onDidActivePanelChange(() => {
|
|
26
|
+
this.updateActivePanel();
|
|
27
|
+
}), parameters.api.onDidActiveChange(() => {
|
|
28
|
+
this.updateGroupActive();
|
|
29
|
+
}), parameters.api.onDidLocationChange((event) => {
|
|
30
|
+
this.updateLocation(event.location);
|
|
31
|
+
}));
|
|
32
|
+
this._part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
33
|
+
api: parameters.api,
|
|
34
|
+
containerApi: parameters.containerApi,
|
|
35
|
+
panels: this._group.model.panels,
|
|
36
|
+
activePanel: this._group.model.activePanel,
|
|
37
|
+
isGroupActive: this._group.api.isActive,
|
|
38
|
+
group: this._group,
|
|
39
|
+
headerPosition: this._group.model.headerPosition,
|
|
40
|
+
location: parameters.api.location,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
dispose() {
|
|
44
|
+
var _a;
|
|
45
|
+
this.mutableDisposable.dispose();
|
|
46
|
+
(_a = this._part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
47
|
+
}
|
|
48
|
+
update(event) {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = this._part) === null || _a === void 0 ? void 0 : _a.update(event.params);
|
|
51
|
+
}
|
|
52
|
+
updatePanels() {
|
|
53
|
+
this.update({ params: { panels: this._group.model.panels } });
|
|
54
|
+
}
|
|
55
|
+
updateActivePanel() {
|
|
56
|
+
this.update({
|
|
57
|
+
params: {
|
|
58
|
+
activePanel: this._group.model.activePanel,
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
updateGroupActive() {
|
|
63
|
+
this.update({
|
|
64
|
+
params: {
|
|
65
|
+
isGroupActive: this._group.api.isActive,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
updateLocation(location) {
|
|
70
|
+
this.update({ params: { location } });
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactPortalStore } from '../react';
|
|
3
|
+
import { DockviewEvent, PanelUpdateEvent, IContentRenderer, GroupPanelPartInitParameters, IDockviewPanelProps } from 'dockview';
|
|
4
|
+
export declare class ReactPanelContentPart implements IContentRenderer {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
private readonly component;
|
|
7
|
+
private readonly reactPortalStore;
|
|
8
|
+
private readonly _element;
|
|
9
|
+
private part?;
|
|
10
|
+
private readonly _onDidFocus;
|
|
11
|
+
readonly onDidFocus: DockviewEvent<void>;
|
|
12
|
+
private readonly _onDidBlur;
|
|
13
|
+
readonly onDidBlur: DockviewEvent<void>;
|
|
14
|
+
get element(): HTMLElement;
|
|
15
|
+
constructor(id: string, component: React.FunctionComponent<IDockviewPanelProps>, reactPortalStore: ReactPortalStore);
|
|
16
|
+
focus(): void;
|
|
17
|
+
init(parameters: GroupPanelPartInitParameters): void;
|
|
18
|
+
update(event: PanelUpdateEvent): void;
|
|
19
|
+
layout(_width: number, _height: number): void;
|
|
20
|
+
dispose(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ReactPart } from '../react';
|
|
2
|
+
import { DockviewEmitter, } from 'dockview';
|
|
3
|
+
export class ReactPanelContentPart {
|
|
4
|
+
get element() {
|
|
5
|
+
return this._element;
|
|
6
|
+
}
|
|
7
|
+
constructor(id, component, reactPortalStore) {
|
|
8
|
+
this.id = id;
|
|
9
|
+
this.component = component;
|
|
10
|
+
this.reactPortalStore = reactPortalStore;
|
|
11
|
+
this._onDidFocus = new DockviewEmitter();
|
|
12
|
+
this.onDidFocus = this._onDidFocus.event;
|
|
13
|
+
this._onDidBlur = new DockviewEmitter();
|
|
14
|
+
this.onDidBlur = this._onDidBlur.event;
|
|
15
|
+
this._element = document.createElement('div');
|
|
16
|
+
this._element.className = 'dv-react-part';
|
|
17
|
+
this._element.style.height = '100%';
|
|
18
|
+
this._element.style.width = '100%';
|
|
19
|
+
}
|
|
20
|
+
focus() {
|
|
21
|
+
// TODO
|
|
22
|
+
}
|
|
23
|
+
init(parameters) {
|
|
24
|
+
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
25
|
+
params: parameters.params,
|
|
26
|
+
api: parameters.api,
|
|
27
|
+
containerApi: parameters.containerApi,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
update(event) {
|
|
31
|
+
var _a;
|
|
32
|
+
(_a = this.part) === null || _a === void 0 ? void 0 : _a.update({ params: event.params });
|
|
33
|
+
}
|
|
34
|
+
layout(_width, _height) {
|
|
35
|
+
// noop
|
|
36
|
+
}
|
|
37
|
+
dispose() {
|
|
38
|
+
var _a;
|
|
39
|
+
this._onDidFocus.dispose();
|
|
40
|
+
this._onDidBlur.dispose();
|
|
41
|
+
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactPortalStore } from '../react';
|
|
3
|
+
import { IContextMenuItemRenderer, IContextMenuItemComponentProps } from 'dockview';
|
|
4
|
+
export declare class ReactContextMenuItemPart implements IContextMenuItemRenderer {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
private readonly component;
|
|
7
|
+
private readonly reactPortalStore;
|
|
8
|
+
private readonly _element;
|
|
9
|
+
private part?;
|
|
10
|
+
get element(): HTMLElement;
|
|
11
|
+
constructor(id: string, component: React.FunctionComponent<IContextMenuItemComponentProps>, reactPortalStore: ReactPortalStore);
|
|
12
|
+
init(props: IContextMenuItemComponentProps): void;
|
|
13
|
+
dispose(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ReactPart } from '../react';
|
|
2
|
+
export class ReactContextMenuItemPart {
|
|
3
|
+
get element() {
|
|
4
|
+
return this._element;
|
|
5
|
+
}
|
|
6
|
+
constructor(id, component, reactPortalStore) {
|
|
7
|
+
this.id = id;
|
|
8
|
+
this.component = component;
|
|
9
|
+
this.reactPortalStore = reactPortalStore;
|
|
10
|
+
this._element = document.createElement('div');
|
|
11
|
+
this._element.className = 'dv-react-part';
|
|
12
|
+
this._element.style.height = '100%';
|
|
13
|
+
this._element.style.width = '100%';
|
|
14
|
+
}
|
|
15
|
+
init(props) {
|
|
16
|
+
this.part = new ReactPart(this._element, this.reactPortalStore, this.component, props);
|
|
17
|
+
}
|
|
18
|
+
dispose() {
|
|
19
|
+
var _a;
|
|
20
|
+
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactPortalStore } from '../react';
|
|
3
|
+
import { IDockviewGroupPanel, IGroupDragGhostRenderer, DockviewApi } from 'dockview';
|
|
4
|
+
export interface IDockviewGroupDragGhostProps {
|
|
5
|
+
group: IDockviewGroupPanel;
|
|
6
|
+
api: DockviewApi;
|
|
7
|
+
}
|
|
8
|
+
export declare class ReactGroupDragGhostPart implements IGroupDragGhostRenderer {
|
|
9
|
+
private readonly component;
|
|
10
|
+
private readonly reactPortalStore;
|
|
11
|
+
private readonly _element;
|
|
12
|
+
private part?;
|
|
13
|
+
get element(): HTMLElement;
|
|
14
|
+
constructor(component: React.FunctionComponent<IDockviewGroupDragGhostProps>, reactPortalStore: ReactPortalStore);
|
|
15
|
+
init(params: {
|
|
16
|
+
group: IDockviewGroupPanel;
|
|
17
|
+
api: DockviewApi;
|
|
18
|
+
}): void;
|
|
19
|
+
dispose(): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ReactPart } from '../react';
|
|
2
|
+
export class ReactGroupDragGhostPart {
|
|
3
|
+
get element() {
|
|
4
|
+
return this._element;
|
|
5
|
+
}
|
|
6
|
+
constructor(component, reactPortalStore) {
|
|
7
|
+
this.component = component;
|
|
8
|
+
this.reactPortalStore = reactPortalStore;
|
|
9
|
+
this._element = document.createElement('div');
|
|
10
|
+
this._element.className = 'dv-react-part';
|
|
11
|
+
this._element.style.display = 'inline-flex';
|
|
12
|
+
}
|
|
13
|
+
init(params) {
|
|
14
|
+
this.part = new ReactPart(this._element, this.reactPortalStore, this.component, {
|
|
15
|
+
group: params.group,
|
|
16
|
+
api: params.api,
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
dispose() {
|
|
20
|
+
var _a;
|
|
21
|
+
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ReactPortalStore } from '../react';
|
|
3
|
+
import { PanelUpdateEvent, ITabRenderer, TabPartInitParameters, IDockviewPanelHeaderProps } from 'dockview';
|
|
4
|
+
export declare class ReactPanelHeaderPart implements ITabRenderer {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
private readonly component;
|
|
7
|
+
private readonly reactPortalStore;
|
|
8
|
+
private readonly _element;
|
|
9
|
+
private part?;
|
|
10
|
+
get element(): HTMLElement;
|
|
11
|
+
constructor(id: string, component: React.FunctionComponent<IDockviewPanelHeaderProps>, reactPortalStore: ReactPortalStore);
|
|
12
|
+
focus(): void;
|
|
13
|
+
init(parameters: TabPartInitParameters): void;
|
|
14
|
+
update(event: PanelUpdateEvent): void;
|
|
15
|
+
layout(_width: number, _height: number): void;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { ReactPart } from '../react';
|
|
2
|
+
export class ReactPanelHeaderPart {
|
|
3
|
+
get element() {
|
|
4
|
+
return this._element;
|
|
5
|
+
}
|
|
6
|
+
constructor(id, component, reactPortalStore) {
|
|
7
|
+
this.id = id;
|
|
8
|
+
this.component = component;
|
|
9
|
+
this.reactPortalStore = reactPortalStore;
|
|
10
|
+
this._element = document.createElement('div');
|
|
11
|
+
this._element.className = 'dv-react-part';
|
|
12
|
+
this._element.style.height = '100%';
|
|
13
|
+
this._element.style.width = '100%';
|
|
14
|
+
}
|
|
15
|
+
focus() {
|
|
16
|
+
//noop
|
|
17
|
+
}
|
|
18
|
+
init(parameters) {
|
|
19
|
+
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
20
|
+
params: parameters.params,
|
|
21
|
+
api: parameters.api,
|
|
22
|
+
containerApi: parameters.containerApi,
|
|
23
|
+
tabLocation: parameters.tabLocation,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
update(event) {
|
|
27
|
+
var _a;
|
|
28
|
+
(_a = this.part) === null || _a === void 0 ? void 0 : _a.update({ params: event.params });
|
|
29
|
+
}
|
|
30
|
+
layout(_width, _height) {
|
|
31
|
+
// noop - retrieval from api
|
|
32
|
+
}
|
|
33
|
+
dispose() {
|
|
34
|
+
var _a;
|
|
35
|
+
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
36
|
+
}
|
|
37
|
+
}
|