dockview-react 7.0.4 → 8.1.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/LICENCE.md +21 -0
- package/README.md +21 -16
- package/dist/cjs/dockview/reactContextMenuItemPart.d.ts +10 -3
- package/dist/cjs/index.d.ts +2 -2
- package/dist/cjs/svg.d.ts +1 -0
- package/dist/dockview-react.js +19294 -21736
- package/dist/dockview-react.min.js +4142 -22
- package/dist/package/main.cjs.js +960 -986
- package/dist/package/main.cjs.min.js +6 -6
- package/dist/package/main.esm.min.mjs +6 -6
- package/dist/package/main.esm.mjs +926 -977
- package/dist/styles/dockview.css +3098 -2400
- package/package.json +91 -85
- package/dist/cjs/dockview/defaultTab.js +0 -99
- package/dist/cjs/dockview/dockview.js +0 -285
- package/dist/cjs/dockview/headerActionsRenderer.js +0 -86
- package/dist/cjs/dockview/reactContentPart.js +0 -52
- package/dist/cjs/dockview/reactContextMenuItemPart.js +0 -31
- package/dist/cjs/dockview/reactGroupDragGhostPart.js +0 -32
- package/dist/cjs/dockview/reactHeaderPart.js +0 -46
- package/dist/cjs/dockview/reactTabGroupChipPart.js +0 -36
- package/dist/cjs/dockview/reactWatermarkPart.js +0 -47
- package/dist/cjs/gridview/gridview.js +0 -105
- package/dist/cjs/gridview/view.js +0 -41
- package/dist/cjs/index.js +0 -24
- package/dist/cjs/paneview/paneview.js +0 -137
- package/dist/cjs/paneview/view.js +0 -44
- package/dist/cjs/react.js +0 -183
- package/dist/cjs/splitview/splitview.js +0 -105
- package/dist/cjs/splitview/view.js +0 -39
- package/dist/cjs/svg.js +0 -15
- package/dist/cjs/types.js +0 -2
- package/dist/dockview-react.min.js.map +0 -1
- package/dist/esm/dockview/defaultTab.d.ts +0 -7
- package/dist/esm/dockview/defaultTab.js +0 -65
- package/dist/esm/dockview/dockview.d.ts +0 -33
- package/dist/esm/dockview/dockview.js +0 -252
- package/dist/esm/dockview/headerActionsRenderer.d.ts +0 -24
- package/dist/esm/dockview/headerActionsRenderer.js +0 -72
- package/dist/esm/dockview/reactContentPart.d.ts +0 -21
- package/dist/esm/dockview/reactContentPart.js +0 -43
- package/dist/esm/dockview/reactContextMenuItemPart.d.ts +0 -14
- package/dist/esm/dockview/reactContextMenuItemPart.js +0 -22
- package/dist/esm/dockview/reactGroupDragGhostPart.d.ts +0 -20
- package/dist/esm/dockview/reactGroupDragGhostPart.js +0 -23
- package/dist/esm/dockview/reactHeaderPart.d.ts +0 -17
- package/dist/esm/dockview/reactHeaderPart.js +0 -37
- package/dist/esm/dockview/reactTabGroupChipPart.d.ts +0 -23
- package/dist/esm/dockview/reactTabGroupChipPart.js +0 -27
- package/dist/esm/dockview/reactWatermarkPart.d.ts +0 -18
- package/dist/esm/dockview/reactWatermarkPart.js +0 -38
- package/dist/esm/gridview/gridview.d.ts +0 -17
- package/dist/esm/gridview/gridview.js +0 -72
- package/dist/esm/gridview/view.d.ts +0 -9
- package/dist/esm/gridview/view.js +0 -19
- package/dist/esm/index.d.ts +0 -10
- package/dist/esm/index.js +0 -8
- package/dist/esm/paneview/paneview.d.ts +0 -20
- package/dist/esm/paneview/paneview.js +0 -104
- package/dist/esm/paneview/view.d.ts +0 -19
- package/dist/esm/paneview/view.js +0 -35
- package/dist/esm/react.d.ts +0 -35
- package/dist/esm/react.js +0 -134
- package/dist/esm/splitview/splitview.d.ts +0 -17
- package/dist/esm/splitview/splitview.js +0 -72
- package/dist/esm/splitview/view.d.ts +0 -9
- package/dist/esm/splitview/view.js +0 -17
- package/dist/esm/svg.d.ts +0 -3
- package/dist/esm/svg.js +0 -7
- package/dist/esm/types.d.ts +0 -4
- package/dist/esm/types.js +0 -1
|
@@ -1,1033 +1,982 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview-react
|
|
3
|
-
* @version
|
|
4
|
-
* @link https://github.com/
|
|
3
|
+
* @version 8.1.0
|
|
4
|
+
* @link https://github.com/dockview/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
7
|
-
import { DockviewDisposable, DockviewEmitter, DockviewMutableDisposable,
|
|
8
|
-
|
|
9
|
-
import
|
|
10
|
-
import ReactDOM from 'react-dom';
|
|
7
|
+
import { DockviewCompositeDisposable, DockviewDisposable, DockviewEmitter, DockviewMutableDisposable, GridviewApi, GridviewPanel, PROPERTY_KEYS_DOCKVIEW, PROPERTY_KEYS_GRIDVIEW, PROPERTY_KEYS_PANEVIEW, PROPERTY_KEYS_SPLITVIEW, SplitviewApi, SplitviewPanel, createDockview, createGridview, createPaneview, createSplitview } from "dockview";
|
|
8
|
+
import React from "react";
|
|
9
|
+
import ReactDOM from "react-dom";
|
|
11
10
|
|
|
11
|
+
export * from "dockview"
|
|
12
|
+
|
|
13
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
|
|
14
|
+
function _typeof(o) {
|
|
15
|
+
"@babel/helpers - typeof";
|
|
16
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
17
|
+
return typeof o;
|
|
18
|
+
} : function(o) {
|
|
19
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
20
|
+
}, _typeof(o);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
|
|
25
|
+
function toPrimitive(t, r) {
|
|
26
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
27
|
+
var e = t[Symbol.toPrimitive];
|
|
28
|
+
if (void 0 !== e) {
|
|
29
|
+
var i = e.call(t, r || "default");
|
|
30
|
+
if ("object" != _typeof(i)) return i;
|
|
31
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
32
|
+
}
|
|
33
|
+
return ("string" === r ? String : Number)(t);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
|
|
38
|
+
function toPropertyKey(t) {
|
|
39
|
+
var i = toPrimitive(t, "string");
|
|
40
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
|
|
45
|
+
function _defineProperty(e, r, t) {
|
|
46
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
47
|
+
value: t,
|
|
48
|
+
enumerable: !0,
|
|
49
|
+
configurable: !0,
|
|
50
|
+
writable: !0
|
|
51
|
+
}) : e[r] = t, e;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
//#endregion
|
|
55
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectSpread2.js
|
|
56
|
+
function ownKeys(e, r) {
|
|
57
|
+
var t = Object.keys(e);
|
|
58
|
+
if (Object.getOwnPropertySymbols) {
|
|
59
|
+
var o = Object.getOwnPropertySymbols(e);
|
|
60
|
+
r && (o = o.filter(function(r) {
|
|
61
|
+
return Object.getOwnPropertyDescriptor(e, r).enumerable;
|
|
62
|
+
})), t.push.apply(t, o);
|
|
63
|
+
}
|
|
64
|
+
return t;
|
|
65
|
+
}
|
|
66
|
+
function _objectSpread2(e) {
|
|
67
|
+
for (var r = 1; r < arguments.length; r++) {
|
|
68
|
+
var t = null != arguments[r] ? arguments[r] : {};
|
|
69
|
+
r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
|
|
70
|
+
_defineProperty(e, r, t[r]);
|
|
71
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
|
|
72
|
+
Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
return e;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/react.ts
|
|
12
80
|
/**
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
81
|
+
* This component is intended to interface between vanilla-js and React hence we need to be
|
|
82
|
+
* creative in how we update props.
|
|
83
|
+
* A ref of the component is exposed with an update method; which when called stores the props
|
|
84
|
+
* as a ref within this component and forcefully triggers a re-render of the component using
|
|
85
|
+
* the ref of props we just set on the renderered component as the props passed to the inner
|
|
86
|
+
* component
|
|
87
|
+
*/
|
|
20
88
|
const ReactComponentBridge = (props, ref) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}), []);
|
|
39
|
-
return React.createElement(props.component, _props.current);
|
|
89
|
+
const [, triggerRender] = React.useState(0);
|
|
90
|
+
const _props = React.useRef(props.componentProps);
|
|
91
|
+
React.useImperativeHandle(ref, () => ({ update: (componentProps) => {
|
|
92
|
+
_props.current = _objectSpread2(_objectSpread2({}, _props.current), componentProps);
|
|
93
|
+
/**
|
|
94
|
+
* setting a arbitrary piece of state within this component will
|
|
95
|
+
* trigger a re-render.
|
|
96
|
+
* we use this rather than updating through a prop since we can
|
|
97
|
+
* pass a ref into the vanilla-js world.
|
|
98
|
+
*
|
|
99
|
+
* Use a monotonic counter rather than `Date.now()` so two
|
|
100
|
+
* updates within the same millisecond still produce distinct
|
|
101
|
+
* state values and avoid React's bailout.
|
|
102
|
+
*/
|
|
103
|
+
triggerRender((n) => n + 1);
|
|
104
|
+
} }), []);
|
|
105
|
+
return React.createElement(props.component, _props.current);
|
|
40
106
|
};
|
|
41
|
-
ReactComponentBridge.displayName =
|
|
107
|
+
ReactComponentBridge.displayName = "DockviewReactJsBridge";
|
|
42
108
|
/**
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
109
|
+
* Since we are storing the React.Portal references in a rendered array they
|
|
110
|
+
* require a key property like any other React element rendered in an array
|
|
111
|
+
* to prevent excessive re-rendering
|
|
112
|
+
*/
|
|
47
113
|
const uniquePortalKeyGenerator = (() => {
|
|
48
|
-
|
|
49
|
-
|
|
114
|
+
let value = 1;
|
|
115
|
+
return { next: () => `dockview_react_portal_key_${(value++).toString()}` };
|
|
50
116
|
})();
|
|
51
117
|
const ReactPartContext = React.createContext({});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
: bridgeComponent;
|
|
102
|
-
const portal = ReactDOM.createPortal(node, this.parent, uniquePortalKeyGenerator.next());
|
|
103
|
-
this.ref = {
|
|
104
|
-
portal,
|
|
105
|
-
disposable: this.portalStore.addPortal(portal),
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
dispose() {
|
|
109
|
-
var _a;
|
|
110
|
-
(_a = this.ref) === null || _a === void 0 ? void 0 : _a.disposable.dispose();
|
|
111
|
-
this.disposed = true;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
118
|
+
var ReactPart = class {
|
|
119
|
+
constructor(parent, portalStore, component, parameters, context) {
|
|
120
|
+
this.parent = parent;
|
|
121
|
+
this.portalStore = portalStore;
|
|
122
|
+
this.component = component;
|
|
123
|
+
this.parameters = parameters;
|
|
124
|
+
this.context = context;
|
|
125
|
+
this._initialProps = {};
|
|
126
|
+
this.disposed = false;
|
|
127
|
+
this.createPortal();
|
|
128
|
+
}
|
|
129
|
+
update(props) {
|
|
130
|
+
if (this.disposed) throw new Error("invalid operation: resource is already disposed");
|
|
131
|
+
if (this.componentInstance) this.componentInstance.update(props);
|
|
132
|
+
else this._initialProps = _objectSpread2(_objectSpread2({}, this._initialProps), props);
|
|
133
|
+
}
|
|
134
|
+
createPortal() {
|
|
135
|
+
if (this.disposed) throw new Error("invalid operation: resource is already disposed");
|
|
136
|
+
if (!isReactComponent(this.component))
|
|
137
|
+
/**
|
|
138
|
+
* we know this isn't a React.FunctionComponent so throw an error here.
|
|
139
|
+
* if we do not intercept then React library will throw a very obsure error
|
|
140
|
+
* for the same reason... at least at this point we will emit a sensible stacktrace.
|
|
141
|
+
*/
|
|
142
|
+
throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");
|
|
143
|
+
const bridgeComponent = React.createElement(React.forwardRef(ReactComponentBridge), {
|
|
144
|
+
component: this.component,
|
|
145
|
+
componentProps: this.parameters,
|
|
146
|
+
ref: (element) => {
|
|
147
|
+
this.componentInstance = element;
|
|
148
|
+
if (Object.keys(this._initialProps).length > 0) {
|
|
149
|
+
this.componentInstance.update(this._initialProps);
|
|
150
|
+
this._initialProps = {};
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
const node = this.context ? React.createElement(ReactPartContext.Provider, { value: this.context }, bridgeComponent) : bridgeComponent;
|
|
155
|
+
const portal = ReactDOM.createPortal(node, this.parent, uniquePortalKeyGenerator.next());
|
|
156
|
+
this.ref = {
|
|
157
|
+
portal,
|
|
158
|
+
disposable: this.portalStore.addPortal(portal)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
dispose() {
|
|
162
|
+
var _this$ref;
|
|
163
|
+
(_this$ref = this.ref) === null || _this$ref === void 0 || _this$ref.disposable.dispose();
|
|
164
|
+
this.disposed = true;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
114
167
|
/**
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
168
|
+
* A React Hook that returns an array of portals to be rendered by the user of this hook
|
|
169
|
+
* and a disposable function to add a portal. Calling dispose removes this portal from the
|
|
170
|
+
* portal array
|
|
171
|
+
*/
|
|
119
172
|
const usePortalsLifecycle = () => {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
});
|
|
132
|
-
}, []);
|
|
133
|
-
return [portals, addPortal];
|
|
173
|
+
const [portals, setPortals] = React.useState([]);
|
|
174
|
+
React.useDebugValue(`Portal count: ${portals.length}`);
|
|
175
|
+
return [portals, React.useCallback((portal) => {
|
|
176
|
+
setPortals((existingPortals) => [...existingPortals, portal]);
|
|
177
|
+
let disposed = false;
|
|
178
|
+
return DockviewDisposable.from(() => {
|
|
179
|
+
if (disposed) throw new Error("invalid operation: resource already disposed");
|
|
180
|
+
disposed = true;
|
|
181
|
+
setPortals((existingPortals) => existingPortals.filter((p) => p !== portal));
|
|
182
|
+
});
|
|
183
|
+
}, [])];
|
|
134
184
|
};
|
|
135
185
|
function isReactComponent(component) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
!!(component === null || component === void 0 ? void 0 : component.$$typeof) /** React.memo(...) Components */);
|
|
186
|
+
/**
|
|
187
|
+
* Yes, we could use "react-is" but that would introduce an unwanted peer dependency
|
|
188
|
+
* so for now we will check in a rather crude fashion...
|
|
189
|
+
*/
|
|
190
|
+
return typeof component === "function" || !!(component === null || component === void 0 ? void 0 : component.$$typeof);
|
|
142
191
|
}
|
|
143
192
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}
|
|
184
|
-
}
|
|
193
|
+
//#endregion
|
|
194
|
+
//#region src/dockview/reactContentPart.ts
|
|
195
|
+
var ReactPanelContentPart = class {
|
|
196
|
+
get element() {
|
|
197
|
+
return this._element;
|
|
198
|
+
}
|
|
199
|
+
constructor(id, component, reactPortalStore) {
|
|
200
|
+
this.id = id;
|
|
201
|
+
this.component = component;
|
|
202
|
+
this.reactPortalStore = reactPortalStore;
|
|
203
|
+
this._onDidFocus = new DockviewEmitter();
|
|
204
|
+
this.onDidFocus = this._onDidFocus.event;
|
|
205
|
+
this._onDidBlur = new DockviewEmitter();
|
|
206
|
+
this.onDidBlur = this._onDidBlur.event;
|
|
207
|
+
this._element = document.createElement("div");
|
|
208
|
+
this._element.className = "dv-react-part";
|
|
209
|
+
this._element.style.height = "100%";
|
|
210
|
+
this._element.style.width = "100%";
|
|
211
|
+
}
|
|
212
|
+
focus() {}
|
|
213
|
+
init(parameters) {
|
|
214
|
+
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
215
|
+
params: parameters.params,
|
|
216
|
+
api: parameters.api,
|
|
217
|
+
containerApi: parameters.containerApi
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
update(event) {
|
|
221
|
+
var _this$part;
|
|
222
|
+
(_this$part = this.part) === null || _this$part === void 0 || _this$part.update({ params: event.params });
|
|
223
|
+
}
|
|
224
|
+
layout(_width, _height) {}
|
|
225
|
+
dispose() {
|
|
226
|
+
var _this$part2;
|
|
227
|
+
this._onDidFocus.dispose();
|
|
228
|
+
this._onDidBlur.dispose();
|
|
229
|
+
(_this$part2 = this.part) === null || _this$part2 === void 0 || _this$part2.dispose();
|
|
230
|
+
}
|
|
231
|
+
};
|
|
185
232
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
}
|
|
221
|
-
}
|
|
233
|
+
//#endregion
|
|
234
|
+
//#region src/dockview/reactHeaderPart.ts
|
|
235
|
+
var ReactPanelHeaderPart = class {
|
|
236
|
+
get element() {
|
|
237
|
+
return this._element;
|
|
238
|
+
}
|
|
239
|
+
constructor(id, component, reactPortalStore) {
|
|
240
|
+
this.id = id;
|
|
241
|
+
this.component = component;
|
|
242
|
+
this.reactPortalStore = reactPortalStore;
|
|
243
|
+
this._element = document.createElement("div");
|
|
244
|
+
this._element.className = "dv-react-part";
|
|
245
|
+
this._element.style.height = "100%";
|
|
246
|
+
this._element.style.width = "100%";
|
|
247
|
+
}
|
|
248
|
+
focus() {}
|
|
249
|
+
init(parameters) {
|
|
250
|
+
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
251
|
+
params: parameters.params,
|
|
252
|
+
api: parameters.api,
|
|
253
|
+
containerApi: parameters.containerApi,
|
|
254
|
+
tabLocation: parameters.tabLocation
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
update(event) {
|
|
258
|
+
var _this$part;
|
|
259
|
+
(_this$part = this.part) === null || _this$part === void 0 || _this$part.update({ params: event.params });
|
|
260
|
+
}
|
|
261
|
+
layout(_width, _height) {}
|
|
262
|
+
dispose() {
|
|
263
|
+
var _this$part2;
|
|
264
|
+
(_this$part2 = this.part) === null || _this$part2 === void 0 || _this$part2.dispose();
|
|
265
|
+
}
|
|
266
|
+
};
|
|
222
267
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
var _a;
|
|
257
|
-
(_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
|
|
258
|
-
}
|
|
259
|
-
}
|
|
268
|
+
//#endregion
|
|
269
|
+
//#region src/dockview/reactWatermarkPart.ts
|
|
270
|
+
var ReactWatermarkPart = class {
|
|
271
|
+
get element() {
|
|
272
|
+
return this._element;
|
|
273
|
+
}
|
|
274
|
+
constructor(id, component, reactPortalStore) {
|
|
275
|
+
this.id = id;
|
|
276
|
+
this.component = component;
|
|
277
|
+
this.reactPortalStore = reactPortalStore;
|
|
278
|
+
this._element = document.createElement("div");
|
|
279
|
+
this._element.className = "dv-react-part";
|
|
280
|
+
this._element.style.height = "100%";
|
|
281
|
+
this._element.style.width = "100%";
|
|
282
|
+
}
|
|
283
|
+
init(parameters) {
|
|
284
|
+
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
285
|
+
group: parameters.group,
|
|
286
|
+
containerApi: parameters.containerApi
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
focus() {}
|
|
290
|
+
update(params) {
|
|
291
|
+
var _this$part, _this$parameters$para, _this$parameters;
|
|
292
|
+
if (this.parameters) this.parameters.params = params.params;
|
|
293
|
+
(_this$part = this.part) === null || _this$part === void 0 || _this$part.update({ params: (_this$parameters$para = (_this$parameters = this.parameters) === null || _this$parameters === void 0 ? void 0 : _this$parameters.params) !== null && _this$parameters$para !== void 0 ? _this$parameters$para : {} });
|
|
294
|
+
}
|
|
295
|
+
layout(_width, _height) {}
|
|
296
|
+
dispose() {
|
|
297
|
+
var _this$part2;
|
|
298
|
+
(_this$part2 = this.part) === null || _this$part2 === void 0 || _this$part2.dispose();
|
|
299
|
+
}
|
|
300
|
+
};
|
|
260
301
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
});
|
|
326
|
-
}
|
|
327
|
-
updateLocation(location) {
|
|
328
|
-
this.update({ params: { location } });
|
|
329
|
-
}
|
|
330
|
-
}
|
|
302
|
+
//#endregion
|
|
303
|
+
//#region src/dockview/headerActionsRenderer.ts
|
|
304
|
+
var ReactHeaderActionsRendererPart = class {
|
|
305
|
+
get element() {
|
|
306
|
+
return this._element;
|
|
307
|
+
}
|
|
308
|
+
get part() {
|
|
309
|
+
return this._part;
|
|
310
|
+
}
|
|
311
|
+
constructor(component, reactPortalStore, _group) {
|
|
312
|
+
this.component = component;
|
|
313
|
+
this.reactPortalStore = reactPortalStore;
|
|
314
|
+
this._group = _group;
|
|
315
|
+
this.mutableDisposable = new DockviewMutableDisposable();
|
|
316
|
+
this._element = document.createElement("div");
|
|
317
|
+
this._element.className = "dv-react-part";
|
|
318
|
+
this._element.style.height = "100%";
|
|
319
|
+
this._element.style.width = "100%";
|
|
320
|
+
}
|
|
321
|
+
init(parameters) {
|
|
322
|
+
this.mutableDisposable.value = new DockviewCompositeDisposable(this._group.model.onDidAddPanel(() => {
|
|
323
|
+
this.updatePanels();
|
|
324
|
+
}), this._group.model.onDidRemovePanel(() => {
|
|
325
|
+
this.updatePanels();
|
|
326
|
+
}), this._group.model.onDidActivePanelChange(() => {
|
|
327
|
+
this.updateActivePanel();
|
|
328
|
+
}), parameters.api.onDidActiveChange(() => {
|
|
329
|
+
this.updateGroupActive();
|
|
330
|
+
}), parameters.api.onDidLocationChange((event) => {
|
|
331
|
+
this.updateLocation(event.location);
|
|
332
|
+
}));
|
|
333
|
+
this._part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
334
|
+
api: parameters.api,
|
|
335
|
+
containerApi: parameters.containerApi,
|
|
336
|
+
panels: this._group.model.panels,
|
|
337
|
+
activePanel: this._group.model.activePanel,
|
|
338
|
+
isGroupActive: this._group.api.isActive,
|
|
339
|
+
group: this._group,
|
|
340
|
+
headerPosition: this._group.model.headerPosition,
|
|
341
|
+
location: parameters.api.location
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
dispose() {
|
|
345
|
+
var _this$_part;
|
|
346
|
+
this.mutableDisposable.dispose();
|
|
347
|
+
(_this$_part = this._part) === null || _this$_part === void 0 || _this$_part.dispose();
|
|
348
|
+
}
|
|
349
|
+
update(event) {
|
|
350
|
+
var _this$_part2;
|
|
351
|
+
(_this$_part2 = this._part) === null || _this$_part2 === void 0 || _this$_part2.update(event.params);
|
|
352
|
+
}
|
|
353
|
+
updatePanels() {
|
|
354
|
+
this.update({ params: { panels: this._group.model.panels } });
|
|
355
|
+
}
|
|
356
|
+
updateActivePanel() {
|
|
357
|
+
this.update({ params: { activePanel: this._group.model.activePanel } });
|
|
358
|
+
}
|
|
359
|
+
updateGroupActive() {
|
|
360
|
+
this.update({ params: { isGroupActive: this._group.api.isActive } });
|
|
361
|
+
}
|
|
362
|
+
updateLocation(location) {
|
|
363
|
+
this.update({ params: { location } });
|
|
364
|
+
}
|
|
365
|
+
};
|
|
331
366
|
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/dockview/reactContextMenuItemPart.ts
|
|
369
|
+
var ReactContextMenuItemPart = class {
|
|
370
|
+
get element() {
|
|
371
|
+
return this._element;
|
|
372
|
+
}
|
|
373
|
+
constructor(id, component, reactPortalStore) {
|
|
374
|
+
this.id = id;
|
|
375
|
+
this.component = component;
|
|
376
|
+
this.reactPortalStore = reactPortalStore;
|
|
377
|
+
this._element = document.createElement("div");
|
|
378
|
+
this._element.className = "dv-react-part";
|
|
379
|
+
this._element.style.height = "100%";
|
|
380
|
+
this._element.style.width = "100%";
|
|
381
|
+
}
|
|
382
|
+
init(props) {
|
|
383
|
+
this.part = new ReactPart(this._element, this.reactPortalStore, this.component, props);
|
|
384
|
+
}
|
|
385
|
+
dispose() {
|
|
386
|
+
var _this$part;
|
|
387
|
+
(_this$part = this.part) === null || _this$part === void 0 || _this$part.dispose();
|
|
388
|
+
}
|
|
389
|
+
};
|
|
353
390
|
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/dockview/reactTabGroupChipPart.ts
|
|
393
|
+
var ReactTabGroupChipPart = class {
|
|
394
|
+
get element() {
|
|
395
|
+
return this._element;
|
|
396
|
+
}
|
|
397
|
+
constructor(component, reactPortalStore) {
|
|
398
|
+
this.component = component;
|
|
399
|
+
this.reactPortalStore = reactPortalStore;
|
|
400
|
+
this._element = document.createElement("div");
|
|
401
|
+
this._element.className = "dv-react-part";
|
|
402
|
+
this._element.style.display = "inline-flex";
|
|
403
|
+
}
|
|
404
|
+
init(params) {
|
|
405
|
+
this.part = new ReactPart(this._element, this.reactPortalStore, this.component, {
|
|
406
|
+
tabGroup: params.tabGroup,
|
|
407
|
+
api: params.api
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
update(params) {
|
|
411
|
+
var _this$part;
|
|
412
|
+
(_this$part = this.part) === null || _this$part === void 0 || _this$part.update({ tabGroup: params.tabGroup });
|
|
413
|
+
}
|
|
414
|
+
dispose() {
|
|
415
|
+
var _this$part2;
|
|
416
|
+
(_this$part2 = this.part) === null || _this$part2 === void 0 || _this$part2.dispose();
|
|
417
|
+
}
|
|
418
|
+
};
|
|
380
419
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/dockview/reactGroupDragGhostPart.ts
|
|
422
|
+
var ReactGroupDragGhostPart = class {
|
|
423
|
+
get element() {
|
|
424
|
+
return this._element;
|
|
425
|
+
}
|
|
426
|
+
constructor(component, reactPortalStore) {
|
|
427
|
+
this.component = component;
|
|
428
|
+
this.reactPortalStore = reactPortalStore;
|
|
429
|
+
this._element = document.createElement("div");
|
|
430
|
+
this._element.className = "dv-react-part";
|
|
431
|
+
this._element.style.display = "inline-flex";
|
|
432
|
+
}
|
|
433
|
+
init(params) {
|
|
434
|
+
this.part = new ReactPart(this._element, this.reactPortalStore, this.component, {
|
|
435
|
+
group: params.group,
|
|
436
|
+
api: params.api
|
|
437
|
+
});
|
|
438
|
+
}
|
|
439
|
+
dispose() {
|
|
440
|
+
var _this$part;
|
|
441
|
+
(_this$part = this.part) === null || _this$part === void 0 || _this$part.dispose();
|
|
442
|
+
}
|
|
443
|
+
};
|
|
403
444
|
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/dockview/dockview.tsx
|
|
404
447
|
function createGroupControlElement(component, store) {
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
}
|
|
409
|
-
: undefined;
|
|
448
|
+
return component ? (groupPanel) => {
|
|
449
|
+
return new ReactHeaderActionsRendererPart(component, store, groupPanel);
|
|
450
|
+
} : void 0;
|
|
410
451
|
}
|
|
411
|
-
const DEFAULT_REACT_TAB =
|
|
452
|
+
const DEFAULT_REACT_TAB = "props.defaultTabComponent";
|
|
412
453
|
function extractCoreOptions$3(props) {
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
return obj;
|
|
418
|
-
}, {});
|
|
419
|
-
return coreOptions;
|
|
454
|
+
return PROPERTY_KEYS_DOCKVIEW.reduce((obj, key) => {
|
|
455
|
+
if (key in props) obj[key] = props[key];
|
|
456
|
+
return obj;
|
|
457
|
+
}, {});
|
|
420
458
|
}
|
|
421
459
|
const DockviewReact = React.forwardRef((props, ref) => {
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
React.useEffect(() => {
|
|
556
|
-
if (!dockviewRef.current) {
|
|
557
|
-
return;
|
|
558
|
-
}
|
|
559
|
-
dockviewRef.current.updateOptions({
|
|
560
|
-
createGroupDragGhostComponent: props.groupDragGhostComponent
|
|
561
|
-
? () => {
|
|
562
|
-
return new ReactGroupDragGhostPart(props.groupDragGhostComponent, {
|
|
563
|
-
addPortal,
|
|
564
|
-
});
|
|
565
|
-
}
|
|
566
|
-
: undefined,
|
|
567
|
-
});
|
|
568
|
-
}, [props.groupDragGhostComponent]);
|
|
569
|
-
React.useEffect(() => {
|
|
570
|
-
if (!dockviewRef.current) {
|
|
571
|
-
return;
|
|
572
|
-
}
|
|
573
|
-
dockviewRef.current.updateOptions({
|
|
574
|
-
createComponent: (options) => {
|
|
575
|
-
return new ReactPanelContentPart(options.id, props.components[options.name], {
|
|
576
|
-
addPortal,
|
|
577
|
-
});
|
|
578
|
-
},
|
|
579
|
-
});
|
|
580
|
-
}, [props.components]);
|
|
581
|
-
React.useEffect(() => {
|
|
582
|
-
var _a;
|
|
583
|
-
if (!dockviewRef.current) {
|
|
584
|
-
return;
|
|
585
|
-
}
|
|
586
|
-
const frameworkTabComponents = (_a = props.tabComponents) !== null && _a !== void 0 ? _a : {};
|
|
587
|
-
if (props.defaultTabComponent) {
|
|
588
|
-
frameworkTabComponents[DEFAULT_REACT_TAB] =
|
|
589
|
-
props.defaultTabComponent;
|
|
590
|
-
}
|
|
591
|
-
dockviewRef.current.updateOptions({
|
|
592
|
-
defaultTabComponent: props.defaultTabComponent
|
|
593
|
-
? DEFAULT_REACT_TAB
|
|
594
|
-
: undefined,
|
|
595
|
-
createTabComponent(options) {
|
|
596
|
-
return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], {
|
|
597
|
-
addPortal,
|
|
598
|
-
});
|
|
599
|
-
},
|
|
600
|
-
});
|
|
601
|
-
}, [props.tabComponents, props.defaultTabComponent]);
|
|
602
|
-
React.useEffect(() => {
|
|
603
|
-
if (!dockviewRef.current) {
|
|
604
|
-
return;
|
|
605
|
-
}
|
|
606
|
-
dockviewRef.current.updateOptions({
|
|
607
|
-
createWatermarkComponent: props.watermarkComponent
|
|
608
|
-
? () => {
|
|
609
|
-
return new ReactWatermarkPart('watermark', props.watermarkComponent, {
|
|
610
|
-
addPortal,
|
|
611
|
-
});
|
|
612
|
-
}
|
|
613
|
-
: undefined,
|
|
614
|
-
});
|
|
615
|
-
}, [props.watermarkComponent]);
|
|
616
|
-
React.useEffect(() => {
|
|
617
|
-
if (!dockviewRef.current) {
|
|
618
|
-
return;
|
|
619
|
-
}
|
|
620
|
-
dockviewRef.current.updateOptions({
|
|
621
|
-
createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
622
|
-
});
|
|
623
|
-
}, [props.rightHeaderActionsComponent]);
|
|
624
|
-
React.useEffect(() => {
|
|
625
|
-
if (!dockviewRef.current) {
|
|
626
|
-
return;
|
|
627
|
-
}
|
|
628
|
-
dockviewRef.current.updateOptions({
|
|
629
|
-
createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
630
|
-
});
|
|
631
|
-
}, [props.leftHeaderActionsComponent]);
|
|
632
|
-
React.useEffect(() => {
|
|
633
|
-
if (!dockviewRef.current) {
|
|
634
|
-
return;
|
|
635
|
-
}
|
|
636
|
-
dockviewRef.current.updateOptions({
|
|
637
|
-
createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
|
|
638
|
-
});
|
|
639
|
-
}, [props.prefixHeaderActionsComponent]);
|
|
640
|
-
return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
460
|
+
const domRef = React.useRef(null);
|
|
461
|
+
const dockviewRef = React.useRef(void 0);
|
|
462
|
+
const [portals, addPortal] = usePortalsLifecycle();
|
|
463
|
+
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
464
|
+
const prevProps = React.useRef({});
|
|
465
|
+
React.useEffect(() => {
|
|
466
|
+
const changes = {};
|
|
467
|
+
PROPERTY_KEYS_DOCKVIEW.forEach((propKey) => {
|
|
468
|
+
const key = propKey;
|
|
469
|
+
const propValue = props[key];
|
|
470
|
+
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
471
|
+
});
|
|
472
|
+
if (dockviewRef.current) dockviewRef.current.updateOptions(changes);
|
|
473
|
+
prevProps.current = props;
|
|
474
|
+
}, PROPERTY_KEYS_DOCKVIEW.map((key) => props[key]));
|
|
475
|
+
React.useEffect(() => {
|
|
476
|
+
if (!domRef.current) return;
|
|
477
|
+
const frameworkTabComponents = _objectSpread2({}, props.tabComponents);
|
|
478
|
+
if (props.defaultTabComponent) frameworkTabComponents[DEFAULT_REACT_TAB] = props.defaultTabComponent;
|
|
479
|
+
const frameworkOptions = {
|
|
480
|
+
createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }),
|
|
481
|
+
createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }),
|
|
482
|
+
createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }),
|
|
483
|
+
createComponent: (options) => {
|
|
484
|
+
return new ReactPanelContentPart(options.id, props.components[options.name], { addPortal });
|
|
485
|
+
},
|
|
486
|
+
createTabComponent(options) {
|
|
487
|
+
return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], { addPortal });
|
|
488
|
+
},
|
|
489
|
+
createWatermarkComponent: props.watermarkComponent ? () => {
|
|
490
|
+
return new ReactWatermarkPart("watermark", props.watermarkComponent, { addPortal });
|
|
491
|
+
} : void 0,
|
|
492
|
+
defaultTabComponent: props.defaultTabComponent ? DEFAULT_REACT_TAB : void 0,
|
|
493
|
+
createContextMenuItemComponent: (options) => {
|
|
494
|
+
if (!options.component) return;
|
|
495
|
+
return new ReactContextMenuItemPart(options.id, options.component, { addPortal });
|
|
496
|
+
}
|
|
497
|
+
};
|
|
498
|
+
const coreOptions = extractCoreOptions$3(props);
|
|
499
|
+
if (props.tabGroupChipComponent) {
|
|
500
|
+
const chipComponent = props.tabGroupChipComponent;
|
|
501
|
+
coreOptions.createTabGroupChipComponent = () => {
|
|
502
|
+
return new ReactTabGroupChipPart(chipComponent, { addPortal });
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
if (props.groupDragGhostComponent) {
|
|
506
|
+
const ghostComponent = props.groupDragGhostComponent;
|
|
507
|
+
coreOptions.createGroupDragGhostComponent = () => {
|
|
508
|
+
return new ReactGroupDragGhostPart(ghostComponent, { addPortal });
|
|
509
|
+
};
|
|
510
|
+
}
|
|
511
|
+
const api = createDockview(domRef.current, _objectSpread2(_objectSpread2({}, coreOptions), frameworkOptions));
|
|
512
|
+
const { clientWidth, clientHeight } = domRef.current;
|
|
513
|
+
api.layout(clientWidth, clientHeight);
|
|
514
|
+
if (props.onReady) props.onReady({ api });
|
|
515
|
+
dockviewRef.current = api;
|
|
516
|
+
return () => {
|
|
517
|
+
dockviewRef.current = void 0;
|
|
518
|
+
api.dispose();
|
|
519
|
+
};
|
|
520
|
+
}, []);
|
|
521
|
+
React.useEffect(() => {
|
|
522
|
+
if (!dockviewRef.current) return () => {};
|
|
523
|
+
const disposable = dockviewRef.current.onDidDrop((event) => {
|
|
524
|
+
if (props.onDidDrop) props.onDidDrop(event);
|
|
525
|
+
});
|
|
526
|
+
return () => {
|
|
527
|
+
disposable.dispose();
|
|
528
|
+
};
|
|
529
|
+
}, [props.onDidDrop]);
|
|
530
|
+
React.useEffect(() => {
|
|
531
|
+
if (!dockviewRef.current) return () => {};
|
|
532
|
+
const disposable = dockviewRef.current.onWillDrop((event) => {
|
|
533
|
+
if (props.onWillDrop) props.onWillDrop(event);
|
|
534
|
+
});
|
|
535
|
+
return () => {
|
|
536
|
+
disposable.dispose();
|
|
537
|
+
};
|
|
538
|
+
}, [props.onWillDrop]);
|
|
539
|
+
React.useEffect(() => {
|
|
540
|
+
if (!dockviewRef.current) return;
|
|
541
|
+
dockviewRef.current.updateOptions({ createTabGroupChipComponent: props.tabGroupChipComponent ? () => {
|
|
542
|
+
return new ReactTabGroupChipPart(props.tabGroupChipComponent, { addPortal });
|
|
543
|
+
} : void 0 });
|
|
544
|
+
}, [props.tabGroupChipComponent]);
|
|
545
|
+
React.useEffect(() => {
|
|
546
|
+
if (!dockviewRef.current) return;
|
|
547
|
+
dockviewRef.current.updateOptions({ createGroupDragGhostComponent: props.groupDragGhostComponent ? () => {
|
|
548
|
+
return new ReactGroupDragGhostPart(props.groupDragGhostComponent, { addPortal });
|
|
549
|
+
} : void 0 });
|
|
550
|
+
}, [props.groupDragGhostComponent]);
|
|
551
|
+
React.useEffect(() => {
|
|
552
|
+
if (!dockviewRef.current) return;
|
|
553
|
+
dockviewRef.current.updateOptions({ createComponent: (options) => {
|
|
554
|
+
return new ReactPanelContentPart(options.id, props.components[options.name], { addPortal });
|
|
555
|
+
} });
|
|
556
|
+
}, [props.components]);
|
|
557
|
+
React.useEffect(() => {
|
|
558
|
+
if (!dockviewRef.current) return;
|
|
559
|
+
const frameworkTabComponents = _objectSpread2({}, props.tabComponents);
|
|
560
|
+
if (props.defaultTabComponent) frameworkTabComponents[DEFAULT_REACT_TAB] = props.defaultTabComponent;
|
|
561
|
+
dockviewRef.current.updateOptions({
|
|
562
|
+
defaultTabComponent: props.defaultTabComponent ? DEFAULT_REACT_TAB : void 0,
|
|
563
|
+
createTabComponent(options) {
|
|
564
|
+
return new ReactPanelHeaderPart(options.id, frameworkTabComponents[options.name], { addPortal });
|
|
565
|
+
}
|
|
566
|
+
});
|
|
567
|
+
}, [props.tabComponents, props.defaultTabComponent]);
|
|
568
|
+
React.useEffect(() => {
|
|
569
|
+
if (!dockviewRef.current) return;
|
|
570
|
+
dockviewRef.current.updateOptions({ createWatermarkComponent: props.watermarkComponent ? () => {
|
|
571
|
+
return new ReactWatermarkPart("watermark", props.watermarkComponent, { addPortal });
|
|
572
|
+
} : void 0 });
|
|
573
|
+
}, [props.watermarkComponent]);
|
|
574
|
+
React.useEffect(() => {
|
|
575
|
+
if (!dockviewRef.current) return;
|
|
576
|
+
dockviewRef.current.updateOptions({ createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }) });
|
|
577
|
+
}, [props.rightHeaderActionsComponent]);
|
|
578
|
+
React.useEffect(() => {
|
|
579
|
+
if (!dockviewRef.current) return;
|
|
580
|
+
dockviewRef.current.updateOptions({ createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }) });
|
|
581
|
+
}, [props.leftHeaderActionsComponent]);
|
|
582
|
+
React.useEffect(() => {
|
|
583
|
+
if (!dockviewRef.current) return;
|
|
584
|
+
dockviewRef.current.updateOptions({ createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }) });
|
|
585
|
+
}, [props.prefixHeaderActionsComponent]);
|
|
586
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
587
|
+
style: {
|
|
588
|
+
height: "100%",
|
|
589
|
+
width: "100%"
|
|
590
|
+
},
|
|
591
|
+
ref: domRef
|
|
592
|
+
}, portals);
|
|
641
593
|
});
|
|
642
|
-
DockviewReact.displayName =
|
|
594
|
+
DockviewReact.displayName = "DockviewComponent";
|
|
643
595
|
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
var t = {};
|
|
663
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
664
|
-
t[p] = s[p];
|
|
665
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
666
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
667
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
668
|
-
t[p[i]] = s[p[i]];
|
|
669
|
-
}
|
|
670
|
-
return t;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
674
|
-
var e = new Error(message);
|
|
675
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
676
|
-
};
|
|
596
|
+
//#endregion
|
|
597
|
+
//#region src/svg.tsx
|
|
598
|
+
const CloseButton = () => /* @__PURE__ */ React.createElement("svg", {
|
|
599
|
+
height: "11",
|
|
600
|
+
width: "11",
|
|
601
|
+
viewBox: "0 0 28 28",
|
|
602
|
+
"aria-hidden": "false",
|
|
603
|
+
focusable: false,
|
|
604
|
+
className: "dv-svg"
|
|
605
|
+
}, /* @__PURE__ */ React.createElement("path", { d: "M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z" }));
|
|
606
|
+
const PinButton = () => /* @__PURE__ */ React.createElement("svg", {
|
|
607
|
+
height: "11",
|
|
608
|
+
width: "11",
|
|
609
|
+
viewBox: "0 0 24 24",
|
|
610
|
+
"aria-hidden": "false",
|
|
611
|
+
focusable: false,
|
|
612
|
+
className: "dv-svg"
|
|
613
|
+
}, /* @__PURE__ */ React.createElement("path", { d: "M16 9V4h1c.55 0 1-.45 1-1s-.45-1-1-1H6c-.55 0-1 .45-1 1s.45 1 1 1h1v5c0 1.66-1.34 3-3 3v2h5.97v7l1 1 1-1v-7H19v-2c-1.66 0-3-1.34-3-3z" }));
|
|
677
614
|
|
|
678
|
-
|
|
679
|
-
|
|
615
|
+
//#endregion
|
|
616
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectWithoutPropertiesLoose.js
|
|
617
|
+
function _objectWithoutPropertiesLoose(r, e) {
|
|
618
|
+
if (null == r) return {};
|
|
619
|
+
var t = {};
|
|
620
|
+
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
621
|
+
if (e.includes(n)) continue;
|
|
622
|
+
t[n] = r[n];
|
|
623
|
+
}
|
|
624
|
+
return t;
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
//#endregion
|
|
628
|
+
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/objectWithoutProperties.js
|
|
629
|
+
function _objectWithoutProperties(e, t) {
|
|
630
|
+
if (null == e) return {};
|
|
631
|
+
var o, r, i = _objectWithoutPropertiesLoose(e, t);
|
|
632
|
+
if (Object.getOwnPropertySymbols) {
|
|
633
|
+
var s = Object.getOwnPropertySymbols(e);
|
|
634
|
+
for (r = 0; r < s.length; r++) o = s[r], t.includes(o) || {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
635
|
+
}
|
|
636
|
+
return i;
|
|
637
|
+
}
|
|
680
638
|
|
|
639
|
+
//#endregion
|
|
640
|
+
//#region src/dockview/defaultTab.tsx
|
|
641
|
+
const _excluded = [
|
|
642
|
+
"api",
|
|
643
|
+
"containerApi",
|
|
644
|
+
"params",
|
|
645
|
+
"hideClose",
|
|
646
|
+
"closeActionOverride",
|
|
647
|
+
"onPointerDown",
|
|
648
|
+
"onPointerUp",
|
|
649
|
+
"onPointerLeave",
|
|
650
|
+
"tabLocation"
|
|
651
|
+
];
|
|
681
652
|
function useTitle(api) {
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
};
|
|
694
|
-
}, [api]);
|
|
695
|
-
return title;
|
|
653
|
+
const [title, setTitle] = React.useState(api.title);
|
|
654
|
+
React.useEffect(() => {
|
|
655
|
+
const disposable = api.onDidTitleChange((event) => {
|
|
656
|
+
setTitle(event.title);
|
|
657
|
+
});
|
|
658
|
+
if (title !== api.title) setTitle(api.title);
|
|
659
|
+
return () => {
|
|
660
|
+
disposable.dispose();
|
|
661
|
+
};
|
|
662
|
+
}, [api]);
|
|
663
|
+
return title;
|
|
696
664
|
}
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
665
|
+
function useIsPinned(api) {
|
|
666
|
+
const [isPinned, setIsPinned] = React.useState(api.isPinned);
|
|
667
|
+
React.useEffect(() => {
|
|
668
|
+
const disposable = api.onDidChangePinned((event) => {
|
|
669
|
+
setIsPinned(event.isPinned);
|
|
670
|
+
});
|
|
671
|
+
if (isPinned !== api.isPinned) setIsPinned(api.isPinned);
|
|
672
|
+
return () => {
|
|
673
|
+
disposable.dispose();
|
|
674
|
+
};
|
|
675
|
+
}, [api]);
|
|
676
|
+
return isPinned;
|
|
677
|
+
}
|
|
678
|
+
const DockviewDefaultTab = (_ref) => {
|
|
679
|
+
let { api, containerApi: _containerApi, params: _params, hideClose, closeActionOverride, onPointerDown, onPointerUp, onPointerLeave, tabLocation } = _ref, rest = _objectWithoutProperties(_ref, _excluded);
|
|
680
|
+
const title = useTitle(api);
|
|
681
|
+
const isPinned = useIsPinned(api);
|
|
682
|
+
const isMiddleMouseButton = React.useRef(false);
|
|
683
|
+
const onClose = React.useCallback((event) => {
|
|
684
|
+
event.preventDefault();
|
|
685
|
+
if (closeActionOverride) closeActionOverride();
|
|
686
|
+
else api.close();
|
|
687
|
+
}, [api, closeActionOverride]);
|
|
688
|
+
const onBtnPointerDown = React.useCallback((event) => {
|
|
689
|
+
event.preventDefault();
|
|
690
|
+
}, []);
|
|
691
|
+
const _onPointerDown = React.useCallback((event) => {
|
|
692
|
+
isMiddleMouseButton.current = event.button === 1;
|
|
693
|
+
onPointerDown === null || onPointerDown === void 0 || onPointerDown(event);
|
|
694
|
+
}, [onPointerDown]);
|
|
695
|
+
const _onPointerUp = React.useCallback((event) => {
|
|
696
|
+
if (isMiddleMouseButton.current && event.button === 1 && !hideClose) {
|
|
697
|
+
isMiddleMouseButton.current = false;
|
|
698
|
+
onClose(event);
|
|
699
|
+
}
|
|
700
|
+
onPointerUp === null || onPointerUp === void 0 || onPointerUp(event);
|
|
701
|
+
}, [
|
|
702
|
+
onPointerUp,
|
|
703
|
+
onClose,
|
|
704
|
+
hideClose
|
|
705
|
+
]);
|
|
706
|
+
const _onPointerLeave = React.useCallback((event) => {
|
|
707
|
+
isMiddleMouseButton.current = false;
|
|
708
|
+
onPointerLeave === null || onPointerLeave === void 0 || onPointerLeave(event);
|
|
709
|
+
}, [onPointerLeave]);
|
|
710
|
+
return /* @__PURE__ */ React.createElement("div", _objectSpread2(_objectSpread2({ "data-testid": "dockview-dv-default-tab" }, rest), {}, {
|
|
711
|
+
onPointerDown: _onPointerDown,
|
|
712
|
+
onPointerUp: _onPointerUp,
|
|
713
|
+
onPointerLeave: _onPointerLeave,
|
|
714
|
+
className: "dv-default-tab"
|
|
715
|
+
}), isPinned && /* @__PURE__ */ React.createElement("div", { className: "dv-tab-pin" }, /* @__PURE__ */ React.createElement(PinButton, null)), /* @__PURE__ */ React.createElement("span", { className: "dv-default-tab-content" }, title), !hideClose && /* @__PURE__ */ React.createElement("button", {
|
|
716
|
+
type: "button",
|
|
717
|
+
className: "dv-default-tab-action",
|
|
718
|
+
"aria-label": "Close tab",
|
|
719
|
+
onPointerDown: onBtnPointerDown,
|
|
720
|
+
onClick: onClose
|
|
721
|
+
}, /* @__PURE__ */ React.createElement(CloseButton, null)));
|
|
732
722
|
};
|
|
733
723
|
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
}
|
|
724
|
+
//#endregion
|
|
725
|
+
//#region src/splitview/view.ts
|
|
726
|
+
var ReactPanelView = class extends SplitviewPanel {
|
|
727
|
+
constructor(id, component, reactComponent, reactPortalStore) {
|
|
728
|
+
super(id, component);
|
|
729
|
+
this.reactComponent = reactComponent;
|
|
730
|
+
this.reactPortalStore = reactPortalStore;
|
|
731
|
+
}
|
|
732
|
+
getComponent() {
|
|
733
|
+
var _this$_params$params, _this$_params;
|
|
734
|
+
return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
|
|
735
|
+
params: (_this$_params$params = (_this$_params = this._params) === null || _this$_params === void 0 ? void 0 : _this$_params.params) !== null && _this$_params$params !== void 0 ? _this$_params$params : {},
|
|
736
|
+
api: this.api,
|
|
737
|
+
containerApi: new SplitviewApi(this._params.accessor)
|
|
738
|
+
});
|
|
739
|
+
}
|
|
740
|
+
};
|
|
749
741
|
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region src/splitview/splitview.tsx
|
|
750
744
|
function extractCoreOptions$2(props) {
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
return obj;
|
|
756
|
-
}, {});
|
|
757
|
-
return coreOptions;
|
|
745
|
+
return PROPERTY_KEYS_SPLITVIEW.reduce((obj, key) => {
|
|
746
|
+
if (key in props) obj[key] = props[key];
|
|
747
|
+
return obj;
|
|
748
|
+
}, {});
|
|
758
749
|
}
|
|
759
750
|
const SplitviewReact = React.forwardRef((props, ref) => {
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
React.useEffect(() => {
|
|
803
|
-
if (!splitviewRef.current) {
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
806
|
-
splitviewRef.current.updateOptions({
|
|
807
|
-
createComponent: (options) => {
|
|
808
|
-
return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
809
|
-
},
|
|
810
|
-
});
|
|
811
|
-
}, [props.components]);
|
|
812
|
-
return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
751
|
+
const domRef = React.useRef(null);
|
|
752
|
+
const splitviewRef = React.useRef(void 0);
|
|
753
|
+
const [portals, addPortal] = usePortalsLifecycle();
|
|
754
|
+
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
755
|
+
const prevProps = React.useRef({});
|
|
756
|
+
React.useEffect(() => {
|
|
757
|
+
const changes = {};
|
|
758
|
+
PROPERTY_KEYS_SPLITVIEW.forEach((propKey) => {
|
|
759
|
+
const key = propKey;
|
|
760
|
+
const propValue = props[key];
|
|
761
|
+
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
762
|
+
});
|
|
763
|
+
if (splitviewRef.current) splitviewRef.current.updateOptions(changes);
|
|
764
|
+
prevProps.current = props;
|
|
765
|
+
}, PROPERTY_KEYS_SPLITVIEW.map((key) => props[key]));
|
|
766
|
+
React.useEffect(() => {
|
|
767
|
+
if (!domRef.current) return () => {};
|
|
768
|
+
const api = createSplitview(domRef.current, _objectSpread2(_objectSpread2({}, extractCoreOptions$2(props)), { createComponent: (options) => {
|
|
769
|
+
return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
770
|
+
} }));
|
|
771
|
+
const { clientWidth, clientHeight } = domRef.current;
|
|
772
|
+
api.layout(clientWidth, clientHeight);
|
|
773
|
+
if (props.onReady) props.onReady({ api });
|
|
774
|
+
splitviewRef.current = api;
|
|
775
|
+
return () => {
|
|
776
|
+
splitviewRef.current = void 0;
|
|
777
|
+
api.dispose();
|
|
778
|
+
};
|
|
779
|
+
}, []);
|
|
780
|
+
React.useEffect(() => {
|
|
781
|
+
if (!splitviewRef.current) return;
|
|
782
|
+
splitviewRef.current.updateOptions({ createComponent: (options) => {
|
|
783
|
+
return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
784
|
+
} });
|
|
785
|
+
}, [props.components]);
|
|
786
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
787
|
+
style: {
|
|
788
|
+
height: "100%",
|
|
789
|
+
width: "100%"
|
|
790
|
+
},
|
|
791
|
+
ref: domRef
|
|
792
|
+
}, portals);
|
|
813
793
|
});
|
|
814
|
-
SplitviewReact.displayName =
|
|
794
|
+
SplitviewReact.displayName = "SplitviewComponent";
|
|
815
795
|
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
}
|
|
796
|
+
//#endregion
|
|
797
|
+
//#region src/gridview/view.ts
|
|
798
|
+
var ReactGridPanelView = class extends GridviewPanel {
|
|
799
|
+
constructor(id, component, reactComponent, reactPortalStore) {
|
|
800
|
+
super(id, component);
|
|
801
|
+
this.reactComponent = reactComponent;
|
|
802
|
+
this.reactPortalStore = reactPortalStore;
|
|
803
|
+
}
|
|
804
|
+
getComponent() {
|
|
805
|
+
var _this$_params$params, _this$_params;
|
|
806
|
+
return new ReactPart(this.element, this.reactPortalStore, this.reactComponent, {
|
|
807
|
+
params: (_this$_params$params = (_this$_params = this._params) === null || _this$_params === void 0 ? void 0 : _this$_params.params) !== null && _this$_params$params !== void 0 ? _this$_params$params : {},
|
|
808
|
+
api: this.api,
|
|
809
|
+
containerApi: new GridviewApi(this._params.accessor)
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
};
|
|
833
813
|
|
|
814
|
+
//#endregion
|
|
815
|
+
//#region src/gridview/gridview.tsx
|
|
834
816
|
function extractCoreOptions$1(props) {
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
return obj;
|
|
840
|
-
}, {});
|
|
841
|
-
return coreOptions;
|
|
817
|
+
return PROPERTY_KEYS_GRIDVIEW.reduce((obj, key) => {
|
|
818
|
+
if (key in props) obj[key] = props[key];
|
|
819
|
+
return obj;
|
|
820
|
+
}, {});
|
|
842
821
|
}
|
|
843
822
|
const GridviewReact = React.forwardRef((props, ref) => {
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
React.useEffect(() => {
|
|
887
|
-
if (!gridviewRef.current) {
|
|
888
|
-
return;
|
|
889
|
-
}
|
|
890
|
-
gridviewRef.current.updateOptions({
|
|
891
|
-
createComponent: (options) => {
|
|
892
|
-
return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
893
|
-
},
|
|
894
|
-
});
|
|
895
|
-
}, [props.components]);
|
|
896
|
-
return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
823
|
+
const domRef = React.useRef(null);
|
|
824
|
+
const gridviewRef = React.useRef(void 0);
|
|
825
|
+
const [portals, addPortal] = usePortalsLifecycle();
|
|
826
|
+
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
827
|
+
const prevProps = React.useRef({});
|
|
828
|
+
React.useEffect(() => {
|
|
829
|
+
const changes = {};
|
|
830
|
+
PROPERTY_KEYS_GRIDVIEW.forEach((propKey) => {
|
|
831
|
+
const key = propKey;
|
|
832
|
+
const propValue = props[key];
|
|
833
|
+
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
834
|
+
});
|
|
835
|
+
if (gridviewRef.current) gridviewRef.current.updateOptions(changes);
|
|
836
|
+
prevProps.current = props;
|
|
837
|
+
}, PROPERTY_KEYS_GRIDVIEW.map((key) => props[key]));
|
|
838
|
+
React.useEffect(() => {
|
|
839
|
+
if (!domRef.current) return () => {};
|
|
840
|
+
const api = createGridview(domRef.current, _objectSpread2(_objectSpread2({}, extractCoreOptions$1(props)), { createComponent: (options) => {
|
|
841
|
+
return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
842
|
+
} }));
|
|
843
|
+
const { clientWidth, clientHeight } = domRef.current;
|
|
844
|
+
api.layout(clientWidth, clientHeight);
|
|
845
|
+
if (props.onReady) props.onReady({ api });
|
|
846
|
+
gridviewRef.current = api;
|
|
847
|
+
return () => {
|
|
848
|
+
gridviewRef.current = void 0;
|
|
849
|
+
api.dispose();
|
|
850
|
+
};
|
|
851
|
+
}, []);
|
|
852
|
+
React.useEffect(() => {
|
|
853
|
+
if (!gridviewRef.current) return;
|
|
854
|
+
gridviewRef.current.updateOptions({ createComponent: (options) => {
|
|
855
|
+
return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
856
|
+
} });
|
|
857
|
+
}, [props.components]);
|
|
858
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
859
|
+
style: {
|
|
860
|
+
height: "100%",
|
|
861
|
+
width: "100%"
|
|
862
|
+
},
|
|
863
|
+
ref: domRef
|
|
864
|
+
}, portals);
|
|
897
865
|
});
|
|
898
|
-
GridviewReact.displayName =
|
|
866
|
+
GridviewReact.displayName = "GridviewComponent";
|
|
899
867
|
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
}
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region src/paneview/view.ts
|
|
870
|
+
var PanePanelSection = class {
|
|
871
|
+
get element() {
|
|
872
|
+
return this._element;
|
|
873
|
+
}
|
|
874
|
+
constructor(id, component, reactPortalStore) {
|
|
875
|
+
this.id = id;
|
|
876
|
+
this.component = component;
|
|
877
|
+
this.reactPortalStore = reactPortalStore;
|
|
878
|
+
this._element = document.createElement("div");
|
|
879
|
+
this._element.style.height = "100%";
|
|
880
|
+
this._element.style.width = "100%";
|
|
881
|
+
}
|
|
882
|
+
init(parameters) {
|
|
883
|
+
this.part = new ReactPart(this.element, this.reactPortalStore, this.component, {
|
|
884
|
+
params: parameters.params,
|
|
885
|
+
api: parameters.api,
|
|
886
|
+
title: parameters.title,
|
|
887
|
+
containerApi: parameters.containerApi
|
|
888
|
+
});
|
|
889
|
+
}
|
|
890
|
+
toJSON() {
|
|
891
|
+
return { id: this.id };
|
|
892
|
+
}
|
|
893
|
+
update(params) {
|
|
894
|
+
var _this$part;
|
|
895
|
+
(_this$part = this.part) === null || _this$part === void 0 || _this$part.update(params.params);
|
|
896
|
+
}
|
|
897
|
+
dispose() {
|
|
898
|
+
var _this$part2;
|
|
899
|
+
(_this$part2 = this.part) === null || _this$part2 === void 0 || _this$part2.dispose();
|
|
900
|
+
}
|
|
901
|
+
};
|
|
934
902
|
|
|
903
|
+
//#endregion
|
|
904
|
+
//#region src/paneview/paneview.tsx
|
|
935
905
|
function extractCoreOptions(props) {
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
return obj;
|
|
941
|
-
}, {});
|
|
942
|
-
return coreOptions;
|
|
906
|
+
return PROPERTY_KEYS_PANEVIEW.reduce((obj, key) => {
|
|
907
|
+
if (key in props) obj[key] = props[key];
|
|
908
|
+
return obj;
|
|
909
|
+
}, {});
|
|
943
910
|
}
|
|
944
911
|
const PaneviewReact = React.forwardRef((props, ref) => {
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
},
|
|
1012
|
-
});
|
|
1013
|
-
}, [props.headerComponents]);
|
|
1014
|
-
React.useEffect(() => {
|
|
1015
|
-
if (!paneviewRef.current) {
|
|
1016
|
-
return () => {
|
|
1017
|
-
// noop
|
|
1018
|
-
};
|
|
1019
|
-
}
|
|
1020
|
-
const disposable = paneviewRef.current.onDidDrop((event) => {
|
|
1021
|
-
if (props.onDidDrop) {
|
|
1022
|
-
props.onDidDrop(event);
|
|
1023
|
-
}
|
|
1024
|
-
});
|
|
1025
|
-
return () => {
|
|
1026
|
-
disposable.dispose();
|
|
1027
|
-
};
|
|
1028
|
-
}, [props.onDidDrop]);
|
|
1029
|
-
return (React.createElement("div", { style: { height: '100%', width: '100%' }, ref: domRef }, portals));
|
|
912
|
+
const domRef = React.useRef(null);
|
|
913
|
+
const paneviewRef = React.useRef(void 0);
|
|
914
|
+
const [portals, addPortal] = usePortalsLifecycle();
|
|
915
|
+
React.useImperativeHandle(ref, () => domRef.current, []);
|
|
916
|
+
const prevProps = React.useRef({});
|
|
917
|
+
React.useEffect(() => {
|
|
918
|
+
const changes = {};
|
|
919
|
+
PROPERTY_KEYS_PANEVIEW.forEach((propKey) => {
|
|
920
|
+
const key = propKey;
|
|
921
|
+
const propValue = props[key];
|
|
922
|
+
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
923
|
+
});
|
|
924
|
+
if (paneviewRef.current) paneviewRef.current.updateOptions(changes);
|
|
925
|
+
prevProps.current = props;
|
|
926
|
+
}, PROPERTY_KEYS_PANEVIEW.map((key) => props[key]));
|
|
927
|
+
React.useEffect(() => {
|
|
928
|
+
var _props$headerComponen;
|
|
929
|
+
if (!domRef.current) return () => {};
|
|
930
|
+
const headerComponents = (_props$headerComponen = props.headerComponents) !== null && _props$headerComponen !== void 0 ? _props$headerComponen : {};
|
|
931
|
+
const api = createPaneview(domRef.current, _objectSpread2(_objectSpread2({}, extractCoreOptions(props)), {
|
|
932
|
+
createComponent: (options) => {
|
|
933
|
+
return new PanePanelSection(options.id, props.components[options.name], { addPortal });
|
|
934
|
+
},
|
|
935
|
+
createHeaderComponent: (options) => {
|
|
936
|
+
return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
|
|
937
|
+
}
|
|
938
|
+
}));
|
|
939
|
+
const { clientWidth, clientHeight } = domRef.current;
|
|
940
|
+
api.layout(clientWidth, clientHeight);
|
|
941
|
+
if (props.onReady) props.onReady({ api });
|
|
942
|
+
paneviewRef.current = api;
|
|
943
|
+
return () => {
|
|
944
|
+
paneviewRef.current = void 0;
|
|
945
|
+
api.dispose();
|
|
946
|
+
};
|
|
947
|
+
}, []);
|
|
948
|
+
React.useEffect(() => {
|
|
949
|
+
if (!paneviewRef.current) return;
|
|
950
|
+
paneviewRef.current.updateOptions({ createComponent: (options) => {
|
|
951
|
+
return new PanePanelSection(options.id, props.components[options.name], { addPortal });
|
|
952
|
+
} });
|
|
953
|
+
}, [props.components]);
|
|
954
|
+
React.useEffect(() => {
|
|
955
|
+
var _props$headerComponen2;
|
|
956
|
+
if (!paneviewRef.current) return;
|
|
957
|
+
const headerComponents = (_props$headerComponen2 = props.headerComponents) !== null && _props$headerComponen2 !== void 0 ? _props$headerComponen2 : {};
|
|
958
|
+
paneviewRef.current.updateOptions({ createHeaderComponent: (options) => {
|
|
959
|
+
return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
|
|
960
|
+
} });
|
|
961
|
+
}, [props.headerComponents]);
|
|
962
|
+
React.useEffect(() => {
|
|
963
|
+
if (!paneviewRef.current) return () => {};
|
|
964
|
+
const disposable = paneviewRef.current.onDidDrop((event) => {
|
|
965
|
+
if (props.onDidDrop) props.onDidDrop(event);
|
|
966
|
+
});
|
|
967
|
+
return () => {
|
|
968
|
+
disposable.dispose();
|
|
969
|
+
};
|
|
970
|
+
}, [props.onDidDrop]);
|
|
971
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
972
|
+
style: {
|
|
973
|
+
height: "100%",
|
|
974
|
+
width: "100%"
|
|
975
|
+
},
|
|
976
|
+
ref: domRef
|
|
977
|
+
}, portals);
|
|
1030
978
|
});
|
|
1031
|
-
PaneviewReact.displayName =
|
|
979
|
+
PaneviewReact.displayName = "PaneviewComponent";
|
|
1032
980
|
|
|
1033
|
-
|
|
981
|
+
//#endregion
|
|
982
|
+
export { DockviewDefaultTab, DockviewReact, GridviewReact, PaneviewReact, ReactPart, ReactPartContext, SplitviewReact, isReactComponent, usePortalsLifecycle };
|