flexlayout-react 0.7.3 → 0.7.4
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/ChangeLog.txt +4 -0
- package/declarations/view/Icons.d.ts +1 -0
- package/dist/flexlayout.js +96 -184
- package/dist/flexlayout_min.js +1 -1
- package/lib/Attribute.js +12 -17
- package/lib/Attribute.js.map +1 -1
- package/lib/AttributeDefinitions.js +44 -53
- package/lib/AttributeDefinitions.js.map +1 -1
- package/lib/DockLocation.js +41 -46
- package/lib/DockLocation.js.map +1 -1
- package/lib/DragDrop.js +55 -60
- package/lib/DragDrop.js.map +1 -1
- package/lib/DropInfo.js +3 -8
- package/lib/DropInfo.js.map +1 -1
- package/lib/I18nLabel.js +2 -5
- package/lib/I18nLabel.js.map +1 -1
- package/lib/Orientation.js +11 -16
- package/lib/Orientation.js.map +1 -1
- package/lib/PopupMenu.js +24 -28
- package/lib/PopupMenu.js.map +1 -1
- package/lib/Rect.js +35 -41
- package/lib/Rect.js.map +1 -1
- package/lib/Types.js +2 -5
- package/lib/Types.js.map +1 -1
- package/lib/index.js +22 -38
- package/lib/index.js.map +1 -1
- package/lib/model/Action.js +3 -8
- package/lib/model/Action.js.map +1 -1
- package/lib/model/Actions.js +68 -75
- package/lib/model/Actions.js.map +1 -1
- package/lib/model/BorderNode.js +183 -206
- package/lib/model/BorderNode.js.map +1 -1
- package/lib/model/BorderSet.js +44 -55
- package/lib/model/BorderSet.js.map +1 -1
- package/lib/model/ICloseType.js +2 -5
- package/lib/model/ICloseType.js.map +1 -1
- package/lib/model/IDraggable.js +1 -2
- package/lib/model/IDropTarget.js +1 -2
- package/lib/model/IJsonModel.js +1 -2
- package/lib/model/Model.js +217 -232
- package/lib/model/Model.js.map +1 -1
- package/lib/model/Node.js +87 -94
- package/lib/model/Node.js.map +1 -1
- package/lib/model/RowNode.js +204 -250
- package/lib/model/RowNode.js.map +1 -1
- package/lib/model/SplitterNode.js +35 -57
- package/lib/model/SplitterNode.js.map +1 -1
- package/lib/model/TabNode.js +100 -124
- package/lib/model/TabNode.js.map +1 -1
- package/lib/model/TabSetNode.js +176 -199
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/model/Utils.js +20 -26
- package/lib/model/Utils.js.map +1 -1
- package/lib/view/BorderButton.js +45 -49
- package/lib/view/BorderButton.js.map +1 -1
- package/lib/view/BorderTabSet.js +57 -61
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/ErrorBoundary.js +15 -37
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/FloatingWindow.js +43 -56
- package/lib/view/FloatingWindow.js.map +1 -1
- package/lib/view/FloatingWindowTab.js +12 -16
- package/lib/view/FloatingWindowTab.js.map +1 -1
- package/lib/view/Icons.js +7 -15
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +392 -449
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/Splitter.js +53 -57
- package/lib/view/Splitter.js.map +1 -1
- package/lib/view/Tab.js +31 -35
- package/lib/view/Tab.js.map +1 -1
- package/lib/view/TabButton.js +46 -50
- package/lib/view/TabButton.js.map +1 -1
- package/lib/view/TabButtonStamp.js +11 -15
- package/lib/view/TabButtonStamp.js.map +1 -1
- package/lib/view/TabFloating.js +30 -34
- package/lib/view/TabFloating.js.map +1 -1
- package/lib/view/TabOverflowHook.js +46 -50
- package/lib/view/TabOverflowHook.js.map +1 -1
- package/lib/view/TabSet.js +93 -106
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js +11 -17
- package/lib/view/Utils.js.map +1 -1
- package/package.json +1 -1
- package/src/view/FloatingWindow.tsx +5 -1
- package/src/view/Layout.tsx +1 -5
package/lib/view/Layout.js
CHANGED
|
@@ -1,390 +1,348 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
30
|
-
if (ar || !(i in from)) {
|
|
31
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
32
|
-
ar[i] = from[i];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.Layout = void 0;
|
|
39
|
-
var React = require("react");
|
|
40
|
-
var react_dom_1 = require("react-dom");
|
|
41
|
-
var DockLocation_1 = require("../DockLocation");
|
|
42
|
-
var DragDrop_1 = require("../DragDrop");
|
|
43
|
-
var Actions_1 = require("../model/Actions");
|
|
44
|
-
var BorderNode_1 = require("../model/BorderNode");
|
|
45
|
-
var SplitterNode_1 = require("../model/SplitterNode");
|
|
46
|
-
var TabNode_1 = require("../model/TabNode");
|
|
47
|
-
var TabSetNode_1 = require("../model/TabSetNode");
|
|
48
|
-
var Rect_1 = require("../Rect");
|
|
49
|
-
var Types_1 = require("../Types");
|
|
50
|
-
var BorderTabSet_1 = require("./BorderTabSet");
|
|
51
|
-
var Splitter_1 = require("./Splitter");
|
|
52
|
-
var Tab_1 = require("./Tab");
|
|
53
|
-
var TabSet_1 = require("./TabSet");
|
|
54
|
-
var FloatingWindow_1 = require("./FloatingWindow");
|
|
55
|
-
var FloatingWindowTab_1 = require("./FloatingWindowTab");
|
|
56
|
-
var TabFloating_1 = require("./TabFloating");
|
|
57
|
-
var Orientation_1 = require("../Orientation");
|
|
58
|
-
var Icons_1 = require("./Icons");
|
|
59
|
-
var TabButtonStamp_1 = require("./TabButtonStamp");
|
|
60
|
-
var defaultIcons = {
|
|
61
|
-
close: React.createElement(Icons_1.CloseIcon, null),
|
|
62
|
-
closeTabset: React.createElement(Icons_1.CloseIcon, null),
|
|
63
|
-
popout: React.createElement(Icons_1.PopoutIcon, null),
|
|
64
|
-
maximize: React.createElement(Icons_1.MaximizeIcon, null),
|
|
65
|
-
restore: React.createElement(Icons_1.RestoreIcon, null),
|
|
66
|
-
more: React.createElement(Icons_1.OverflowIcon, null),
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import { DockLocation } from "../DockLocation";
|
|
4
|
+
import { DragDrop } from "../DragDrop";
|
|
5
|
+
import { Actions } from "../model/Actions";
|
|
6
|
+
import { BorderNode } from "../model/BorderNode";
|
|
7
|
+
import { SplitterNode } from "../model/SplitterNode";
|
|
8
|
+
import { TabNode } from "../model/TabNode";
|
|
9
|
+
import { TabSetNode } from "../model/TabSetNode";
|
|
10
|
+
import { Rect } from "../Rect";
|
|
11
|
+
import { CLASSES } from "../Types";
|
|
12
|
+
import { BorderTabSet } from "./BorderTabSet";
|
|
13
|
+
import { Splitter } from "./Splitter";
|
|
14
|
+
import { Tab } from "./Tab";
|
|
15
|
+
import { TabSet } from "./TabSet";
|
|
16
|
+
import { FloatingWindow } from "./FloatingWindow";
|
|
17
|
+
import { FloatingWindowTab } from "./FloatingWindowTab";
|
|
18
|
+
import { TabFloating } from "./TabFloating";
|
|
19
|
+
import { Orientation } from "../Orientation";
|
|
20
|
+
import { CloseIcon, MaximizeIcon, OverflowIcon, PopoutIcon, RestoreIcon } from "./Icons";
|
|
21
|
+
import { TabButtonStamp } from "./TabButtonStamp";
|
|
22
|
+
const defaultIcons = {
|
|
23
|
+
close: React.createElement(CloseIcon, null),
|
|
24
|
+
closeTabset: React.createElement(CloseIcon, null),
|
|
25
|
+
popout: React.createElement(PopoutIcon, null),
|
|
26
|
+
maximize: React.createElement(MaximizeIcon, null),
|
|
27
|
+
restore: React.createElement(RestoreIcon, null),
|
|
28
|
+
more: React.createElement(OverflowIcon, null),
|
|
67
29
|
};
|
|
68
30
|
// Popout windows work in latest browsers based on webkit (Chrome, Opera, Safari, latest Edge) and Firefox. They do
|
|
69
31
|
// not work on any version if IE or the original Edge browser
|
|
70
32
|
// Assume any recent desktop browser not IE or original Edge will work
|
|
71
33
|
/** @internal */
|
|
72
34
|
// @ts-ignore
|
|
73
|
-
|
|
35
|
+
const isIEorEdge = typeof window !== "undefined" && (window.document.documentMode || /Edge\//.test(window.navigator.userAgent));
|
|
74
36
|
/** @internal */
|
|
75
|
-
|
|
37
|
+
const isDesktop = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(hover: hover) and (pointer: fine)").matches;
|
|
76
38
|
/** @internal */
|
|
77
|
-
|
|
39
|
+
const defaultSupportsPopout = isDesktop && !isIEorEdge;
|
|
78
40
|
/**
|
|
79
41
|
* A React component that hosts a multi-tabbed layout
|
|
80
42
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
var _this = _super.call(this, props) || this;
|
|
43
|
+
export class Layout extends React.Component {
|
|
44
|
+
constructor(props) {
|
|
45
|
+
super(props);
|
|
85
46
|
/** @internal */
|
|
86
|
-
|
|
47
|
+
this.firstMove = false;
|
|
87
48
|
/** @internal */
|
|
88
|
-
|
|
49
|
+
this.dragRectRendered = true;
|
|
89
50
|
/** @internal */
|
|
90
|
-
|
|
51
|
+
this.dragDivText = undefined;
|
|
91
52
|
/** @internal */
|
|
92
|
-
|
|
53
|
+
this.edgeRectLength = 100;
|
|
93
54
|
/** @internal */
|
|
94
|
-
|
|
55
|
+
this.edgeRectWidth = 10;
|
|
95
56
|
/** @internal */
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
|
|
57
|
+
this.onModelChange = () => {
|
|
58
|
+
this.forceUpdate();
|
|
59
|
+
if (this.props.onModelChange) {
|
|
60
|
+
this.props.onModelChange(this.props.model);
|
|
100
61
|
}
|
|
101
62
|
};
|
|
102
63
|
/** @internal */
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
_this.setState({ rect: rect });
|
|
64
|
+
this.updateRect = (domRect = this.getDomRect()) => {
|
|
65
|
+
const rect = new Rect(0, 0, domRect.width, domRect.height);
|
|
66
|
+
if (!rect.equals(this.state.rect) && rect.width !== 0 && rect.height !== 0) {
|
|
67
|
+
this.setState({ rect });
|
|
108
68
|
}
|
|
109
69
|
};
|
|
110
70
|
/** @internal */
|
|
111
|
-
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
if (headerBarSize !==
|
|
115
|
-
|
|
71
|
+
this.updateLayoutMetrics = () => {
|
|
72
|
+
if (this.findHeaderBarSizeRef.current) {
|
|
73
|
+
const headerBarSize = this.findHeaderBarSizeRef.current.getBoundingClientRect().height;
|
|
74
|
+
if (headerBarSize !== this.state.calculatedHeaderBarSize) {
|
|
75
|
+
this.setState({ calculatedHeaderBarSize: headerBarSize });
|
|
116
76
|
}
|
|
117
77
|
}
|
|
118
|
-
if (
|
|
119
|
-
|
|
120
|
-
if (tabBarSize !==
|
|
121
|
-
|
|
78
|
+
if (this.findTabBarSizeRef.current) {
|
|
79
|
+
const tabBarSize = this.findTabBarSizeRef.current.getBoundingClientRect().height;
|
|
80
|
+
if (tabBarSize !== this.state.calculatedTabBarSize) {
|
|
81
|
+
this.setState({ calculatedTabBarSize: tabBarSize });
|
|
122
82
|
}
|
|
123
83
|
}
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
if (borderBarSize !==
|
|
127
|
-
|
|
84
|
+
if (this.findBorderBarSizeRef.current) {
|
|
85
|
+
const borderBarSize = this.findBorderBarSizeRef.current.getBoundingClientRect().height;
|
|
86
|
+
if (borderBarSize !== this.state.calculatedBorderBarSize) {
|
|
87
|
+
this.setState({ calculatedBorderBarSize: borderBarSize });
|
|
128
88
|
}
|
|
129
89
|
}
|
|
130
90
|
};
|
|
131
91
|
/** @internal */
|
|
132
|
-
|
|
133
|
-
if (
|
|
92
|
+
this.getClassName = (defaultClassName) => {
|
|
93
|
+
if (this.props.classNameMapper === undefined) {
|
|
134
94
|
return defaultClassName;
|
|
135
95
|
}
|
|
136
96
|
else {
|
|
137
|
-
return
|
|
97
|
+
return this.props.classNameMapper(defaultClassName);
|
|
138
98
|
}
|
|
139
99
|
};
|
|
140
100
|
/** @internal */
|
|
141
|
-
|
|
142
|
-
|
|
101
|
+
this.onCloseWindow = (id) => {
|
|
102
|
+
this.doAction(Actions.unFloatTab(id));
|
|
143
103
|
try {
|
|
144
|
-
|
|
104
|
+
this.props.model.getNodeById(id)._setWindow(undefined);
|
|
145
105
|
}
|
|
146
106
|
catch (e) {
|
|
147
107
|
// catch incase it was a model change
|
|
148
108
|
}
|
|
149
109
|
};
|
|
150
110
|
/** @internal */
|
|
151
|
-
|
|
152
|
-
|
|
111
|
+
this.onSetWindow = (id, window) => {
|
|
112
|
+
this.props.model.getNodeById(id)._setWindow(window);
|
|
153
113
|
};
|
|
154
114
|
/** @internal */
|
|
155
|
-
|
|
115
|
+
this.onCancelAdd = () => {
|
|
156
116
|
var _a, _b;
|
|
157
|
-
|
|
158
|
-
rootdiv.removeChild(
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
|
|
163
|
-
|
|
117
|
+
const rootdiv = this.selfRef.current;
|
|
118
|
+
rootdiv.removeChild(this.dragDiv);
|
|
119
|
+
this.dragDiv = undefined;
|
|
120
|
+
this.hidePortal();
|
|
121
|
+
if (this.fnNewNodeDropped != null) {
|
|
122
|
+
this.fnNewNodeDropped();
|
|
123
|
+
this.fnNewNodeDropped = undefined;
|
|
164
124
|
}
|
|
165
125
|
try {
|
|
166
|
-
(_b = (_a =
|
|
126
|
+
(_b = (_a = this.customDrop) === null || _a === void 0 ? void 0 : _a.invalidated) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
167
127
|
}
|
|
168
128
|
catch (e) {
|
|
169
129
|
console.error(e);
|
|
170
130
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
131
|
+
DragDrop.instance.hideGlass();
|
|
132
|
+
this.newTabJson = undefined;
|
|
133
|
+
this.customDrop = undefined;
|
|
174
134
|
};
|
|
175
135
|
/** @internal */
|
|
176
|
-
|
|
136
|
+
this.onCancelDrag = (wasDragging) => {
|
|
177
137
|
var _a, _b;
|
|
178
138
|
if (wasDragging) {
|
|
179
|
-
|
|
139
|
+
const rootdiv = this.selfRef.current;
|
|
180
140
|
try {
|
|
181
|
-
rootdiv.removeChild(
|
|
141
|
+
rootdiv.removeChild(this.outlineDiv);
|
|
182
142
|
}
|
|
183
143
|
catch (e) { }
|
|
184
144
|
try {
|
|
185
|
-
rootdiv.removeChild(
|
|
145
|
+
rootdiv.removeChild(this.dragDiv);
|
|
186
146
|
}
|
|
187
147
|
catch (e) { }
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
if (
|
|
192
|
-
|
|
193
|
-
|
|
148
|
+
this.dragDiv = undefined;
|
|
149
|
+
this.hidePortal();
|
|
150
|
+
this.setState({ showEdges: false });
|
|
151
|
+
if (this.fnNewNodeDropped != null) {
|
|
152
|
+
this.fnNewNodeDropped();
|
|
153
|
+
this.fnNewNodeDropped = undefined;
|
|
194
154
|
}
|
|
195
155
|
try {
|
|
196
|
-
(_b = (_a =
|
|
156
|
+
(_b = (_a = this.customDrop) === null || _a === void 0 ? void 0 : _a.invalidated) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
197
157
|
}
|
|
198
158
|
catch (e) {
|
|
199
159
|
console.error(e);
|
|
200
160
|
}
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
161
|
+
DragDrop.instance.hideGlass();
|
|
162
|
+
this.newTabJson = undefined;
|
|
163
|
+
this.customDrop = undefined;
|
|
204
164
|
}
|
|
205
|
-
|
|
165
|
+
this.setState({ showHiddenBorder: DockLocation.CENTER });
|
|
206
166
|
};
|
|
207
167
|
/** @internal */
|
|
208
|
-
|
|
168
|
+
this.onDragDivMouseDown = (event) => {
|
|
209
169
|
event.preventDefault();
|
|
210
|
-
|
|
170
|
+
this.dragStart(event, this.dragDivText, TabNode._fromJson(this.newTabJson, this.props.model, false), true, undefined, undefined);
|
|
211
171
|
};
|
|
212
172
|
/** @internal */
|
|
213
|
-
|
|
173
|
+
this.dragStart = (event, dragDivText, node, allowDrag, onClick, onDoubleClick) => {
|
|
214
174
|
if (!allowDrag) {
|
|
215
|
-
|
|
175
|
+
DragDrop.instance.startDrag(event, undefined, undefined, undefined, undefined, onClick, onDoubleClick, this.currentDocument, this.selfRef.current);
|
|
216
176
|
}
|
|
217
177
|
else {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
178
|
+
this.dragNode = node;
|
|
179
|
+
this.dragDivText = dragDivText;
|
|
180
|
+
DragDrop.instance.startDrag(event, this.onDragStart, this.onDragMove, this.onDragEnd, this.onCancelDrag, onClick, onDoubleClick, this.currentDocument, this.selfRef.current);
|
|
221
181
|
}
|
|
222
182
|
};
|
|
223
183
|
/** @internal */
|
|
224
|
-
|
|
225
|
-
|
|
184
|
+
this.dragRectRender = (text, node, json, onRendered) => {
|
|
185
|
+
let content;
|
|
226
186
|
if (text !== undefined) {
|
|
227
187
|
content = React.createElement("div", { style: { whiteSpace: "pre" } }, text.replace("<br>", "\n"));
|
|
228
188
|
}
|
|
229
189
|
else {
|
|
230
|
-
if (node && node instanceof
|
|
231
|
-
content = (React.createElement(
|
|
190
|
+
if (node && node instanceof TabNode) {
|
|
191
|
+
content = (React.createElement(TabButtonStamp, { node: node, layout: this, iconFactory: this.props.iconFactory, titleFactory: this.props.titleFactory }));
|
|
232
192
|
}
|
|
233
193
|
}
|
|
234
|
-
if (
|
|
235
|
-
|
|
194
|
+
if (this.props.onRenderDragRect !== undefined) {
|
|
195
|
+
const customContent = this.props.onRenderDragRect(content, node, json);
|
|
236
196
|
if (customContent !== undefined) {
|
|
237
197
|
content = customContent;
|
|
238
198
|
}
|
|
239
199
|
}
|
|
240
200
|
// hide div until the render is complete
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
201
|
+
this.dragDiv.style.visibility = "hidden";
|
|
202
|
+
this.dragRectRendered = false;
|
|
203
|
+
this.showPortal(React.createElement(DragRectRenderWrapper
|
|
244
204
|
// wait for it to be rendered
|
|
245
205
|
, {
|
|
246
206
|
// wait for it to be rendered
|
|
247
|
-
onRendered:
|
|
248
|
-
|
|
207
|
+
onRendered: () => {
|
|
208
|
+
this.dragRectRendered = true;
|
|
249
209
|
onRendered === null || onRendered === void 0 ? void 0 : onRendered();
|
|
250
|
-
} }, content),
|
|
210
|
+
} }, content), this.dragDiv);
|
|
251
211
|
};
|
|
252
212
|
/** @internal */
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
213
|
+
this.showPortal = (control, element) => {
|
|
214
|
+
const portal = createPortal(control, element);
|
|
215
|
+
this.setState({ portal });
|
|
256
216
|
};
|
|
257
217
|
/** @internal */
|
|
258
|
-
|
|
259
|
-
|
|
218
|
+
this.hidePortal = () => {
|
|
219
|
+
this.setState({ portal: undefined });
|
|
260
220
|
};
|
|
261
221
|
/** @internal */
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
rootdiv.appendChild(
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
rootdiv.appendChild(
|
|
222
|
+
this.onDragStart = () => {
|
|
223
|
+
this.dropInfo = undefined;
|
|
224
|
+
this.customDrop = undefined;
|
|
225
|
+
const rootdiv = this.selfRef.current;
|
|
226
|
+
this.outlineDiv = this.currentDocument.createElement("div");
|
|
227
|
+
this.outlineDiv.className = this.getClassName(CLASSES.FLEXLAYOUT__OUTLINE_RECT);
|
|
228
|
+
this.outlineDiv.style.visibility = "hidden";
|
|
229
|
+
rootdiv.appendChild(this.outlineDiv);
|
|
230
|
+
if (this.dragDiv == null) {
|
|
231
|
+
this.dragDiv = this.currentDocument.createElement("div");
|
|
232
|
+
this.dragDiv.className = this.getClassName(CLASSES.FLEXLAYOUT__DRAG_RECT);
|
|
233
|
+
this.dragDiv.setAttribute("data-layout-path", "/drag-rectangle");
|
|
234
|
+
this.dragRectRender(this.dragDivText, this.dragNode, this.newTabJson);
|
|
235
|
+
rootdiv.appendChild(this.dragDiv);
|
|
276
236
|
}
|
|
277
237
|
// add edge indicators
|
|
278
|
-
if (
|
|
279
|
-
|
|
238
|
+
if (this.props.model.getMaximizedTabset() === undefined) {
|
|
239
|
+
this.setState({ showEdges: true });
|
|
280
240
|
}
|
|
281
|
-
if (
|
|
282
|
-
|
|
241
|
+
if (this.dragNode !== undefined && this.dragNode instanceof TabNode && this.dragNode.getTabRect() !== undefined) {
|
|
242
|
+
this.dragNode.getTabRect().positionElement(this.outlineDiv);
|
|
283
243
|
}
|
|
284
|
-
|
|
244
|
+
this.firstMove = true;
|
|
285
245
|
return true;
|
|
286
246
|
};
|
|
287
247
|
/** @internal */
|
|
288
|
-
|
|
289
|
-
if (
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
248
|
+
this.onDragMove = (event) => {
|
|
249
|
+
if (this.firstMove === false) {
|
|
250
|
+
const speed = this.props.model._getAttribute("tabDragSpeed");
|
|
251
|
+
this.outlineDiv.style.transition = `top ${speed}s, left ${speed}s, width ${speed}s, height ${speed}s`;
|
|
252
|
+
}
|
|
253
|
+
this.firstMove = false;
|
|
254
|
+
const clientRect = this.selfRef.current.getBoundingClientRect();
|
|
255
|
+
const pos = {
|
|
296
256
|
x: event.clientX - clientRect.left,
|
|
297
257
|
y: event.clientY - clientRect.top,
|
|
298
258
|
};
|
|
299
|
-
|
|
259
|
+
this.checkForBorderToShow(pos.x, pos.y);
|
|
300
260
|
// keep it between left & right
|
|
301
|
-
|
|
302
|
-
|
|
261
|
+
const dragRect = this.dragDiv.getBoundingClientRect();
|
|
262
|
+
let newLeft = pos.x - dragRect.width / 2;
|
|
303
263
|
if (newLeft + dragRect.width > clientRect.width) {
|
|
304
264
|
newLeft = clientRect.width - dragRect.width;
|
|
305
265
|
}
|
|
306
266
|
newLeft = Math.max(0, newLeft);
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
if (
|
|
267
|
+
this.dragDiv.style.left = newLeft + "px";
|
|
268
|
+
this.dragDiv.style.top = pos.y + 5 + "px";
|
|
269
|
+
if (this.dragRectRendered && this.dragDiv.style.visibility === "hidden") {
|
|
310
270
|
// make visible once the drag rect has been rendered
|
|
311
|
-
|
|
271
|
+
this.dragDiv.style.visibility = "visible";
|
|
312
272
|
}
|
|
313
|
-
|
|
273
|
+
let dropInfo = this.props.model._findDropTargetNode(this.dragNode, pos.x, pos.y);
|
|
314
274
|
if (dropInfo) {
|
|
315
|
-
if (
|
|
316
|
-
|
|
275
|
+
if (this.props.onTabDrag) {
|
|
276
|
+
this.handleCustomTabDrag(dropInfo, pos, event);
|
|
317
277
|
}
|
|
318
278
|
else {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
dropInfo.rect.positionElement(
|
|
322
|
-
|
|
279
|
+
this.dropInfo = dropInfo;
|
|
280
|
+
this.outlineDiv.className = this.getClassName(dropInfo.className);
|
|
281
|
+
dropInfo.rect.positionElement(this.outlineDiv);
|
|
282
|
+
this.outlineDiv.style.visibility = "visible";
|
|
323
283
|
}
|
|
324
284
|
}
|
|
325
285
|
};
|
|
326
286
|
/** @internal */
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
rootdiv.removeChild(
|
|
330
|
-
rootdiv.removeChild(
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
if (
|
|
336
|
-
if (
|
|
337
|
-
|
|
287
|
+
this.onDragEnd = (event) => {
|
|
288
|
+
const rootdiv = this.selfRef.current;
|
|
289
|
+
rootdiv.removeChild(this.outlineDiv);
|
|
290
|
+
rootdiv.removeChild(this.dragDiv);
|
|
291
|
+
this.dragDiv = undefined;
|
|
292
|
+
this.hidePortal();
|
|
293
|
+
this.setState({ showEdges: false });
|
|
294
|
+
DragDrop.instance.hideGlass();
|
|
295
|
+
if (this.dropInfo) {
|
|
296
|
+
if (this.customDrop) {
|
|
297
|
+
this.newTabJson = undefined;
|
|
338
298
|
try {
|
|
339
|
-
|
|
340
|
-
callback(dragging, over, x, y,
|
|
341
|
-
if (
|
|
342
|
-
|
|
343
|
-
|
|
299
|
+
const { callback, dragging, over, x, y, location } = this.customDrop;
|
|
300
|
+
callback(dragging, over, x, y, location);
|
|
301
|
+
if (this.fnNewNodeDropped != null) {
|
|
302
|
+
this.fnNewNodeDropped();
|
|
303
|
+
this.fnNewNodeDropped = undefined;
|
|
344
304
|
}
|
|
345
305
|
}
|
|
346
306
|
catch (e) {
|
|
347
307
|
console.error(e);
|
|
348
308
|
}
|
|
349
309
|
}
|
|
350
|
-
else if (
|
|
351
|
-
|
|
352
|
-
if (
|
|
353
|
-
|
|
354
|
-
|
|
310
|
+
else if (this.newTabJson !== undefined) {
|
|
311
|
+
const newNode = this.doAction(Actions.addNode(this.newTabJson, this.dropInfo.node.getId(), this.dropInfo.location, this.dropInfo.index));
|
|
312
|
+
if (this.fnNewNodeDropped != null) {
|
|
313
|
+
this.fnNewNodeDropped(newNode, event);
|
|
314
|
+
this.fnNewNodeDropped = undefined;
|
|
355
315
|
}
|
|
356
|
-
|
|
316
|
+
this.newTabJson = undefined;
|
|
357
317
|
}
|
|
358
|
-
else if (
|
|
359
|
-
|
|
318
|
+
else if (this.dragNode !== undefined) {
|
|
319
|
+
this.doAction(Actions.moveNode(this.dragNode.getId(), this.dropInfo.node.getId(), this.dropInfo.location, this.dropInfo.index));
|
|
360
320
|
}
|
|
361
321
|
}
|
|
362
|
-
|
|
322
|
+
this.setState({ showHiddenBorder: DockLocation.CENTER });
|
|
363
323
|
};
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
rect: new Rect_1.Rect(0, 0, 0, 0),
|
|
324
|
+
this.props.model._setChangeListener(this.onModelChange);
|
|
325
|
+
this.tabIds = [];
|
|
326
|
+
this.selfRef = React.createRef();
|
|
327
|
+
this.findHeaderBarSizeRef = React.createRef();
|
|
328
|
+
this.findTabBarSizeRef = React.createRef();
|
|
329
|
+
this.findBorderBarSizeRef = React.createRef();
|
|
330
|
+
this.supportsPopout = props.supportsPopout !== undefined ? props.supportsPopout : defaultSupportsPopout;
|
|
331
|
+
this.popoutURL = props.popoutURL ? props.popoutURL : "popout.html";
|
|
332
|
+
this.icons = Object.assign(Object.assign({}, defaultIcons), props.icons);
|
|
333
|
+
this.state = {
|
|
334
|
+
rect: new Rect(0, 0, 0, 0),
|
|
376
335
|
calculatedHeaderBarSize: 25,
|
|
377
336
|
calculatedTabBarSize: 26,
|
|
378
337
|
calculatedBorderBarSize: 30,
|
|
379
338
|
editingTab: undefined,
|
|
380
|
-
showHiddenBorder:
|
|
339
|
+
showHiddenBorder: DockLocation.CENTER,
|
|
381
340
|
showEdges: false,
|
|
382
341
|
};
|
|
383
|
-
|
|
384
|
-
return _this;
|
|
342
|
+
this.onDragEnter = this.onDragEnter.bind(this);
|
|
385
343
|
}
|
|
386
344
|
/** @internal */
|
|
387
|
-
|
|
345
|
+
styleFont(style) {
|
|
388
346
|
if (this.props.font) {
|
|
389
347
|
if (this.selfRef.current) {
|
|
390
348
|
if (this.props.font.size) {
|
|
@@ -402,11 +360,11 @@ var Layout = /** @class */ (function (_super) {
|
|
|
402
360
|
}
|
|
403
361
|
}
|
|
404
362
|
return style;
|
|
405
|
-
}
|
|
363
|
+
}
|
|
406
364
|
/** @internal */
|
|
407
|
-
|
|
365
|
+
doAction(action) {
|
|
408
366
|
if (this.props.onAction !== undefined) {
|
|
409
|
-
|
|
367
|
+
const outcome = this.props.onAction(action);
|
|
410
368
|
if (outcome !== undefined) {
|
|
411
369
|
return this.props.model.doAction(outcome);
|
|
412
370
|
}
|
|
@@ -415,22 +373,21 @@ var Layout = /** @class */ (function (_super) {
|
|
|
415
373
|
else {
|
|
416
374
|
return this.props.model.doAction(action);
|
|
417
375
|
}
|
|
418
|
-
}
|
|
376
|
+
}
|
|
419
377
|
/** @internal */
|
|
420
|
-
|
|
421
|
-
var _this = this;
|
|
378
|
+
componentDidMount() {
|
|
422
379
|
this.updateRect();
|
|
423
380
|
this.updateLayoutMetrics();
|
|
424
381
|
// need to re-render if size changes
|
|
425
382
|
this.currentDocument = this.selfRef.current.ownerDocument;
|
|
426
383
|
this.currentWindow = this.currentDocument.defaultView;
|
|
427
|
-
this.resizeObserver = new ResizeObserver(
|
|
428
|
-
|
|
384
|
+
this.resizeObserver = new ResizeObserver(entries => {
|
|
385
|
+
this.updateRect(entries[0].contentRect);
|
|
429
386
|
});
|
|
430
387
|
this.resizeObserver.observe(this.selfRef.current);
|
|
431
|
-
}
|
|
388
|
+
}
|
|
432
389
|
/** @internal */
|
|
433
|
-
|
|
390
|
+
componentDidUpdate() {
|
|
434
391
|
this.updateLayoutMetrics();
|
|
435
392
|
if (this.props.model !== this.previousModel) {
|
|
436
393
|
if (this.previousModel !== undefined) {
|
|
@@ -440,69 +397,64 @@ var Layout = /** @class */ (function (_super) {
|
|
|
440
397
|
this.previousModel = this.props.model;
|
|
441
398
|
}
|
|
442
399
|
// console.log("Layout time: " + this.layoutTime + "ms Render time: " + (Date.now() - this.start) + "ms");
|
|
443
|
-
}
|
|
400
|
+
}
|
|
444
401
|
/** @internal */
|
|
445
|
-
|
|
402
|
+
getCurrentDocument() {
|
|
446
403
|
return this.currentDocument;
|
|
447
|
-
}
|
|
404
|
+
}
|
|
448
405
|
/** @internal */
|
|
449
|
-
|
|
406
|
+
getDomRect() {
|
|
450
407
|
return this.selfRef.current.getBoundingClientRect();
|
|
451
|
-
}
|
|
408
|
+
}
|
|
452
409
|
/** @internal */
|
|
453
|
-
|
|
410
|
+
getRootDiv() {
|
|
454
411
|
return this.selfRef.current;
|
|
455
|
-
}
|
|
412
|
+
}
|
|
456
413
|
/** @internal */
|
|
457
|
-
|
|
414
|
+
isSupportsPopout() {
|
|
458
415
|
return this.supportsPopout;
|
|
459
|
-
}
|
|
416
|
+
}
|
|
460
417
|
/** @internal */
|
|
461
|
-
|
|
418
|
+
isRealtimeResize() {
|
|
462
419
|
var _a;
|
|
463
420
|
return (_a = this.props.realtimeResize) !== null && _a !== void 0 ? _a : false;
|
|
464
|
-
}
|
|
421
|
+
}
|
|
465
422
|
/** @internal */
|
|
466
|
-
|
|
423
|
+
onTabDrag(...args) {
|
|
467
424
|
var _a, _b;
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
args[_i] = arguments[_i];
|
|
471
|
-
}
|
|
472
|
-
return (_b = (_a = this.props).onTabDrag) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([_a], args, false));
|
|
473
|
-
};
|
|
425
|
+
return (_b = (_a = this.props).onTabDrag) === null || _b === void 0 ? void 0 : _b.call(_a, ...args);
|
|
426
|
+
}
|
|
474
427
|
/** @internal */
|
|
475
|
-
|
|
428
|
+
getPopoutURL() {
|
|
476
429
|
return this.popoutURL;
|
|
477
|
-
}
|
|
430
|
+
}
|
|
478
431
|
/** @internal */
|
|
479
|
-
|
|
432
|
+
componentWillUnmount() {
|
|
480
433
|
var _a;
|
|
481
434
|
(_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.unobserve(this.selfRef.current);
|
|
482
|
-
}
|
|
435
|
+
}
|
|
483
436
|
/** @internal */
|
|
484
|
-
|
|
437
|
+
setEditingTab(tabNode) {
|
|
485
438
|
this.setState({ editingTab: tabNode });
|
|
486
|
-
}
|
|
439
|
+
}
|
|
487
440
|
/** @internal */
|
|
488
|
-
|
|
441
|
+
getEditingTab() {
|
|
489
442
|
return this.state.editingTab;
|
|
490
|
-
}
|
|
443
|
+
}
|
|
491
444
|
/** @internal */
|
|
492
|
-
|
|
445
|
+
render() {
|
|
493
446
|
// first render will be used to find the size (via selfRef)
|
|
494
|
-
if (this.
|
|
495
|
-
this.
|
|
496
|
-
return (React.createElement("div", { ref: this.selfRef, className: this.getClassName(Types_1.CLASSES.FLEXLAYOUT__LAYOUT) }, this.metricsElements()));
|
|
447
|
+
if (!this.selfRef.current) {
|
|
448
|
+
return (React.createElement("div", { ref: this.selfRef, className: this.getClassName(CLASSES.FLEXLAYOUT__LAYOUT) }, this.metricsElements()));
|
|
497
449
|
}
|
|
498
450
|
this.props.model._setPointerFine(window && window.matchMedia && window.matchMedia("(pointer: fine)").matches);
|
|
499
451
|
// this.start = Date.now();
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
452
|
+
const borderComponents = [];
|
|
453
|
+
const tabSetComponents = [];
|
|
454
|
+
const floatingWindows = [];
|
|
455
|
+
const tabComponents = {};
|
|
456
|
+
const splitterComponents = [];
|
|
457
|
+
const metrics = {
|
|
506
458
|
headerBarSize: this.state.calculatedHeaderBarSize,
|
|
507
459
|
tabBarSize: this.state.calculatedTabBarSize,
|
|
508
460
|
borderBarSize: this.state.calculatedBorderBarSize
|
|
@@ -511,11 +463,10 @@ var Layout = /** @class */ (function (_super) {
|
|
|
511
463
|
this.centerRect = this.props.model._layout(this.state.rect, metrics);
|
|
512
464
|
this.renderBorder(this.props.model.getBorderSet(), borderComponents, tabComponents, floatingWindows, splitterComponents);
|
|
513
465
|
this.renderChildren("", this.props.model.getRoot(), tabSetComponents, tabComponents, floatingWindows, splitterComponents);
|
|
514
|
-
|
|
515
|
-
|
|
466
|
+
const nextTopIds = [];
|
|
467
|
+
const nextTopIdsMap = {};
|
|
516
468
|
// Keep any previous tabs in the same DOM order as before, removing any that have been deleted
|
|
517
|
-
for (
|
|
518
|
-
var t = _a[_i];
|
|
469
|
+
for (const t of this.tabIds) {
|
|
519
470
|
if (tabComponents[t]) {
|
|
520
471
|
nextTopIds.push(t);
|
|
521
472
|
nextTopIdsMap[t] = t;
|
|
@@ -523,29 +474,28 @@ var Layout = /** @class */ (function (_super) {
|
|
|
523
474
|
}
|
|
524
475
|
this.tabIds = nextTopIds;
|
|
525
476
|
// Add tabs that have been added to the DOM
|
|
526
|
-
for (
|
|
527
|
-
var t = _c[_b];
|
|
477
|
+
for (const t of Object.keys(tabComponents)) {
|
|
528
478
|
if (!nextTopIdsMap[t]) {
|
|
529
479
|
this.tabIds.push(t);
|
|
530
480
|
}
|
|
531
481
|
}
|
|
532
|
-
|
|
482
|
+
const edges = [];
|
|
533
483
|
if (this.state.showEdges) {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
edges.push(React.createElement("div", { key: "North", style: { top: r.y, left: r.x + r.width / 2 - offset, width:
|
|
541
|
-
edges.push(React.createElement("div", { key: "West", style: { top: r.y + r.height / 2 - offset, left: r.x, width: width, height:
|
|
542
|
-
edges.push(React.createElement("div", { key: "South", style: { top: r.y + r.height - width, left: r.x + r.width / 2 - offset, width:
|
|
543
|
-
edges.push(React.createElement("div", { key: "East", style: { top: r.y + r.height / 2 - offset, left: r.x + r.width - width, width: width, height:
|
|
484
|
+
const r = this.centerRect;
|
|
485
|
+
const length = this.edgeRectLength;
|
|
486
|
+
const width = this.edgeRectWidth;
|
|
487
|
+
const offset = this.edgeRectLength / 2;
|
|
488
|
+
const className = this.getClassName(CLASSES.FLEXLAYOUT__EDGE_RECT);
|
|
489
|
+
const radius = 50;
|
|
490
|
+
edges.push(React.createElement("div", { key: "North", style: { top: r.y, left: r.x + r.width / 2 - offset, width: length, height: width, borderBottomLeftRadius: radius, borderBottomRightRadius: radius }, className: className }));
|
|
491
|
+
edges.push(React.createElement("div", { key: "West", style: { top: r.y + r.height / 2 - offset, left: r.x, width: width, height: length, borderTopRightRadius: radius, borderBottomRightRadius: radius }, className: className }));
|
|
492
|
+
edges.push(React.createElement("div", { key: "South", style: { top: r.y + r.height - width, left: r.x + r.width / 2 - offset, width: length, height: width, borderTopLeftRadius: radius, borderTopRightRadius: radius }, className: className }));
|
|
493
|
+
edges.push(React.createElement("div", { key: "East", style: { top: r.y + r.height / 2 - offset, left: r.x + r.width - width, width: width, height: length, borderTopLeftRadius: radius, borderBottomLeftRadius: radius }, className: className }));
|
|
544
494
|
}
|
|
545
495
|
// this.layoutTime = (Date.now() - this.start);
|
|
546
|
-
return (React.createElement("div", { ref: this.selfRef, className: this.getClassName(
|
|
496
|
+
return (React.createElement("div", { ref: this.selfRef, className: this.getClassName(CLASSES.FLEXLAYOUT__LAYOUT), onDragEnter: this.props.onExternalDrag ? this.onDragEnter : undefined },
|
|
547
497
|
tabSetComponents,
|
|
548
|
-
this.tabIds.map(
|
|
498
|
+
this.tabIds.map((t) => {
|
|
549
499
|
return tabComponents[t];
|
|
550
500
|
}),
|
|
551
501
|
borderComponents,
|
|
@@ -554,140 +504,137 @@ var Layout = /** @class */ (function (_super) {
|
|
|
554
504
|
floatingWindows,
|
|
555
505
|
this.metricsElements(),
|
|
556
506
|
this.state.portal));
|
|
557
|
-
}
|
|
507
|
+
}
|
|
558
508
|
/** @internal */
|
|
559
|
-
|
|
509
|
+
metricsElements() {
|
|
560
510
|
// used to measure the tab and border tab sizes
|
|
561
|
-
|
|
511
|
+
const fontStyle = this.styleFont({ visibility: "hidden" });
|
|
562
512
|
return (React.createElement(React.Fragment, null,
|
|
563
|
-
React.createElement("div", { key: "findHeaderBarSize", ref: this.findHeaderBarSizeRef, style: fontStyle, className: this.getClassName(
|
|
564
|
-
React.createElement("div", { key: "findTabBarSize", ref: this.findTabBarSizeRef, style: fontStyle, className: this.getClassName(
|
|
565
|
-
React.createElement("div", { key: "findBorderBarSize", ref: this.findBorderBarSizeRef, style: fontStyle, className: this.getClassName(
|
|
566
|
-
}
|
|
513
|
+
React.createElement("div", { key: "findHeaderBarSize", ref: this.findHeaderBarSizeRef, style: fontStyle, className: this.getClassName(CLASSES.FLEXLAYOUT__TABSET_HEADER_SIZER) }, "FindHeaderBarSize"),
|
|
514
|
+
React.createElement("div", { key: "findTabBarSize", ref: this.findTabBarSizeRef, style: fontStyle, className: this.getClassName(CLASSES.FLEXLAYOUT__TABSET_SIZER) }, "FindTabBarSize"),
|
|
515
|
+
React.createElement("div", { key: "findBorderBarSize", ref: this.findBorderBarSizeRef, style: fontStyle, className: this.getClassName(CLASSES.FLEXLAYOUT__BORDER_SIZER) }, "FindBorderBarSize")));
|
|
516
|
+
}
|
|
567
517
|
/** @internal */
|
|
568
|
-
|
|
569
|
-
for (
|
|
570
|
-
|
|
571
|
-
var borderPath = "/border/".concat(border.getLocation().getName());
|
|
518
|
+
renderBorder(borderSet, borderComponents, tabComponents, floatingWindows, splitterComponents) {
|
|
519
|
+
for (const border of borderSet.getBorders()) {
|
|
520
|
+
const borderPath = `/border/${border.getLocation().getName()}`;
|
|
572
521
|
if (border.isShowing()) {
|
|
573
|
-
borderComponents.push(React.createElement(
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
for (
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
splitterComponents.push(React.createElement(Splitter_1.Splitter, { key: child.getId(), layout: this, node: child, path: path }));
|
|
522
|
+
borderComponents.push(React.createElement(BorderTabSet, { key: `border_${border.getLocation().getName()}`, path: borderPath, border: border, layout: this, iconFactory: this.props.iconFactory, titleFactory: this.props.titleFactory, icons: this.icons }));
|
|
523
|
+
const drawChildren = border._getDrawChildren();
|
|
524
|
+
let i = 0;
|
|
525
|
+
let tabCount = 0;
|
|
526
|
+
for (const child of drawChildren) {
|
|
527
|
+
if (child instanceof SplitterNode) {
|
|
528
|
+
let path = borderPath + "/s";
|
|
529
|
+
splitterComponents.push(React.createElement(Splitter, { key: child.getId(), layout: this, node: child, path: path }));
|
|
582
530
|
}
|
|
583
|
-
else if (child instanceof
|
|
584
|
-
|
|
531
|
+
else if (child instanceof TabNode) {
|
|
532
|
+
let path = borderPath + "/t" + tabCount++;
|
|
585
533
|
if (this.supportsPopout && child.isFloating()) {
|
|
586
|
-
|
|
587
|
-
floatingWindows.push(React.createElement(
|
|
588
|
-
React.createElement(
|
|
589
|
-
tabComponents[child.getId()] = React.createElement(
|
|
534
|
+
const rect = this._getScreenRect(child);
|
|
535
|
+
floatingWindows.push(React.createElement(FloatingWindow, { key: child.getId(), url: this.popoutURL, rect: rect, title: child.getName(), id: child.getId(), onSetWindow: this.onSetWindow, onCloseWindow: this.onCloseWindow },
|
|
536
|
+
React.createElement(FloatingWindowTab, { layout: this, node: child, factory: this.props.factory })));
|
|
537
|
+
tabComponents[child.getId()] = React.createElement(TabFloating, { key: child.getId(), layout: this, path: path, node: child, selected: i === border.getSelected() });
|
|
590
538
|
}
|
|
591
539
|
else {
|
|
592
|
-
tabComponents[child.getId()] = React.createElement(
|
|
540
|
+
tabComponents[child.getId()] = React.createElement(Tab, { key: child.getId(), layout: this, path: path, node: child, selected: i === border.getSelected(), factory: this.props.factory });
|
|
593
541
|
}
|
|
594
542
|
}
|
|
595
543
|
i++;
|
|
596
544
|
}
|
|
597
545
|
}
|
|
598
546
|
}
|
|
599
|
-
}
|
|
547
|
+
}
|
|
600
548
|
/** @internal */
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
for (
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
tabSetComponents.push(React.createElement(TabSet_1.TabSet, { key: child.getId(), layout: this, path: newPath, node: child, iconFactory: this.props.iconFactory, titleFactory: this.props.titleFactory, icons: this.icons }));
|
|
549
|
+
renderChildren(path, node, tabSetComponents, tabComponents, floatingWindows, splitterComponents) {
|
|
550
|
+
const drawChildren = node._getDrawChildren();
|
|
551
|
+
let splitterCount = 0;
|
|
552
|
+
let tabCount = 0;
|
|
553
|
+
let rowCount = 0;
|
|
554
|
+
for (const child of drawChildren) {
|
|
555
|
+
if (child instanceof SplitterNode) {
|
|
556
|
+
const newPath = path + "/s" + (splitterCount++);
|
|
557
|
+
splitterComponents.push(React.createElement(Splitter, { key: child.getId(), layout: this, path: newPath, node: child }));
|
|
558
|
+
}
|
|
559
|
+
else if (child instanceof TabSetNode) {
|
|
560
|
+
const newPath = path + "/ts" + (rowCount++);
|
|
561
|
+
tabSetComponents.push(React.createElement(TabSet, { key: child.getId(), layout: this, path: newPath, node: child, iconFactory: this.props.iconFactory, titleFactory: this.props.titleFactory, icons: this.icons }));
|
|
615
562
|
this.renderChildren(newPath, child, tabSetComponents, tabComponents, floatingWindows, splitterComponents);
|
|
616
563
|
}
|
|
617
|
-
else if (child instanceof
|
|
618
|
-
|
|
619
|
-
|
|
564
|
+
else if (child instanceof TabNode) {
|
|
565
|
+
const newPath = path + "/t" + (tabCount++);
|
|
566
|
+
const selectedTab = child.getParent().getChildren()[child.getParent().getSelected()];
|
|
620
567
|
if (selectedTab === undefined) {
|
|
621
568
|
// this should not happen!
|
|
622
569
|
console.warn("undefined selectedTab should not happen");
|
|
623
570
|
}
|
|
624
571
|
if (this.supportsPopout && child.isFloating()) {
|
|
625
|
-
|
|
626
|
-
floatingWindows.push(React.createElement(
|
|
627
|
-
React.createElement(
|
|
628
|
-
tabComponents[child.getId()] = React.createElement(
|
|
572
|
+
const rect = this._getScreenRect(child);
|
|
573
|
+
floatingWindows.push(React.createElement(FloatingWindow, { key: child.getId(), url: this.popoutURL, rect: rect, title: child.getName(), id: child.getId(), onSetWindow: this.onSetWindow, onCloseWindow: this.onCloseWindow },
|
|
574
|
+
React.createElement(FloatingWindowTab, { layout: this, node: child, factory: this.props.factory })));
|
|
575
|
+
tabComponents[child.getId()] = React.createElement(TabFloating, { key: child.getId(), layout: this, path: newPath, node: child, selected: child === selectedTab });
|
|
629
576
|
}
|
|
630
577
|
else {
|
|
631
|
-
tabComponents[child.getId()] = React.createElement(
|
|
578
|
+
tabComponents[child.getId()] = React.createElement(Tab, { key: child.getId(), layout: this, path: newPath, node: child, selected: child === selectedTab, factory: this.props.factory });
|
|
632
579
|
}
|
|
633
580
|
}
|
|
634
581
|
else {
|
|
635
582
|
// is row
|
|
636
|
-
|
|
583
|
+
const newPath = path + ((child.getOrientation() === Orientation.HORZ) ? "/r" : "/c") + (rowCount++);
|
|
637
584
|
this.renderChildren(newPath, child, tabSetComponents, tabComponents, floatingWindows, splitterComponents);
|
|
638
585
|
}
|
|
639
586
|
}
|
|
640
|
-
}
|
|
587
|
+
}
|
|
641
588
|
/** @internal */
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
589
|
+
_getScreenRect(node) {
|
|
590
|
+
const rect = node.getRect().clone();
|
|
591
|
+
const bodyRect = this.selfRef.current.getBoundingClientRect();
|
|
592
|
+
const navHeight = Math.min(80, this.currentWindow.outerHeight - this.currentWindow.innerHeight);
|
|
593
|
+
const navWidth = Math.min(80, this.currentWindow.outerWidth - this.currentWindow.innerWidth);
|
|
647
594
|
rect.x = rect.x + bodyRect.x + this.currentWindow.screenX + navWidth;
|
|
648
595
|
rect.y = rect.y + bodyRect.y + this.currentWindow.screenY + navHeight;
|
|
649
596
|
return rect;
|
|
650
|
-
}
|
|
597
|
+
}
|
|
651
598
|
/**
|
|
652
599
|
* Adds a new tab to the given tabset
|
|
653
600
|
* @param tabsetId the id of the tabset where the new tab will be added
|
|
654
601
|
* @param json the json for the new tab node
|
|
655
602
|
*/
|
|
656
|
-
|
|
657
|
-
|
|
603
|
+
addTabToTabSet(tabsetId, json) {
|
|
604
|
+
const tabsetNode = this.props.model.getNodeById(tabsetId);
|
|
658
605
|
if (tabsetNode !== undefined) {
|
|
659
|
-
this.doAction(
|
|
606
|
+
this.doAction(Actions.addNode(json, tabsetId, DockLocation.CENTER, -1));
|
|
660
607
|
}
|
|
661
|
-
}
|
|
608
|
+
}
|
|
662
609
|
/**
|
|
663
610
|
* Adds a new tab to the active tabset (if there is one)
|
|
664
611
|
* @param json the json for the new tab node
|
|
665
612
|
*/
|
|
666
|
-
|
|
667
|
-
|
|
613
|
+
addTabToActiveTabSet(json) {
|
|
614
|
+
const tabsetNode = this.props.model.getActiveTabset();
|
|
668
615
|
if (tabsetNode !== undefined) {
|
|
669
|
-
this.doAction(
|
|
616
|
+
this.doAction(Actions.addNode(json, tabsetNode.getId(), DockLocation.CENTER, -1));
|
|
670
617
|
}
|
|
671
|
-
}
|
|
618
|
+
}
|
|
672
619
|
/**
|
|
673
620
|
* Adds a new tab by dragging a labeled panel to the drop location, dragging starts immediatelly
|
|
674
621
|
* @param dragText the text to show on the drag panel
|
|
675
622
|
* @param json the json for the new tab node
|
|
676
623
|
* @param onDrop a callback to call when the drag is complete (node and event will be undefined if the drag was cancelled)
|
|
677
624
|
*/
|
|
678
|
-
|
|
625
|
+
addTabWithDragAndDrop(dragText, json, onDrop) {
|
|
679
626
|
this.fnNewNodeDropped = onDrop;
|
|
680
627
|
this.newTabJson = json;
|
|
681
|
-
this.dragStart(undefined, dragText,
|
|
682
|
-
}
|
|
628
|
+
this.dragStart(undefined, dragText, TabNode._fromJson(json, this.props.model, false), true, undefined, undefined);
|
|
629
|
+
}
|
|
683
630
|
/**
|
|
684
631
|
* Move a tab/tabset using drag and drop
|
|
685
632
|
* @param node the tab or tabset to drag
|
|
686
633
|
* @param dragText the text to show on the drag panel
|
|
687
634
|
*/
|
|
688
|
-
|
|
635
|
+
moveTabWithDragAndDrop(node, dragText) {
|
|
689
636
|
this.dragStart(undefined, dragText, node, true, undefined, undefined);
|
|
690
|
-
}
|
|
637
|
+
}
|
|
691
638
|
/**
|
|
692
639
|
* Adds a new tab by dragging a labeled panel to the drop location, dragging starts when you
|
|
693
640
|
* mouse down on the panel
|
|
@@ -696,49 +643,47 @@ var Layout = /** @class */ (function (_super) {
|
|
|
696
643
|
* @param json the json for the new tab node
|
|
697
644
|
* @param onDrop a callback to call when the drag is complete (node and event will be undefined if the drag was cancelled)
|
|
698
645
|
*/
|
|
699
|
-
|
|
700
|
-
var _this = this;
|
|
646
|
+
addTabWithDragAndDropIndirect(dragText, json, onDrop) {
|
|
701
647
|
this.fnNewNodeDropped = onDrop;
|
|
702
648
|
this.newTabJson = json;
|
|
703
|
-
|
|
649
|
+
DragDrop.instance.addGlass(this.onCancelAdd);
|
|
704
650
|
this.dragDivText = dragText;
|
|
705
651
|
this.dragDiv = this.currentDocument.createElement("div");
|
|
706
|
-
this.dragDiv.className = this.getClassName(
|
|
652
|
+
this.dragDiv.className = this.getClassName(CLASSES.FLEXLAYOUT__DRAG_RECT);
|
|
707
653
|
this.dragDiv.addEventListener("mousedown", this.onDragDivMouseDown);
|
|
708
654
|
this.dragDiv.addEventListener("touchstart", this.onDragDivMouseDown, { passive: false });
|
|
709
|
-
this.dragRectRender(this.dragDivText, undefined, this.newTabJson,
|
|
710
|
-
if (
|
|
655
|
+
this.dragRectRender(this.dragDivText, undefined, this.newTabJson, () => {
|
|
656
|
+
if (this.dragDiv) {
|
|
711
657
|
// now it's been rendered into the dom it can be centered
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
r.centerInRect(
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
658
|
+
this.dragDiv.style.visibility = "visible";
|
|
659
|
+
const domRect = this.dragDiv.getBoundingClientRect();
|
|
660
|
+
const r = new Rect(0, 0, domRect === null || domRect === void 0 ? void 0 : domRect.width, domRect === null || domRect === void 0 ? void 0 : domRect.height);
|
|
661
|
+
r.centerInRect(this.state.rect);
|
|
662
|
+
this.dragDiv.setAttribute("data-layout-path", "/drag-rectangle");
|
|
663
|
+
this.dragDiv.style.left = r.x + "px";
|
|
664
|
+
this.dragDiv.style.top = r.y + "px";
|
|
719
665
|
}
|
|
720
666
|
});
|
|
721
|
-
|
|
667
|
+
const rootdiv = this.selfRef.current;
|
|
722
668
|
rootdiv.appendChild(this.dragDiv);
|
|
723
|
-
}
|
|
669
|
+
}
|
|
724
670
|
/** @internal */
|
|
725
|
-
|
|
726
|
-
var _this = this;
|
|
671
|
+
handleCustomTabDrag(dropInfo, pos, event) {
|
|
727
672
|
var _a, _b, _c;
|
|
728
|
-
|
|
729
|
-
|
|
673
|
+
let invalidated = (_a = this.customDrop) === null || _a === void 0 ? void 0 : _a.invalidated;
|
|
674
|
+
const currentCallback = (_b = this.customDrop) === null || _b === void 0 ? void 0 : _b.callback;
|
|
730
675
|
this.customDrop = undefined;
|
|
731
|
-
|
|
732
|
-
if (dragging && (dropInfo.node instanceof
|
|
733
|
-
|
|
734
|
-
|
|
676
|
+
const dragging = this.newTabJson || (this.dragNode instanceof TabNode ? this.dragNode : undefined);
|
|
677
|
+
if (dragging && (dropInfo.node instanceof TabSetNode || dropInfo.node instanceof BorderNode) && dropInfo.index === -1) {
|
|
678
|
+
const selected = dropInfo.node.getSelectedNode();
|
|
679
|
+
const tabRect = selected === null || selected === void 0 ? void 0 : selected.getRect();
|
|
735
680
|
if (selected && (tabRect === null || tabRect === void 0 ? void 0 : tabRect.contains(pos.x, pos.y))) {
|
|
736
|
-
|
|
681
|
+
let customDrop = undefined;
|
|
737
682
|
try {
|
|
738
|
-
|
|
683
|
+
const dest = this.onTabDrag(dragging, selected, pos.x - tabRect.x, pos.y - tabRect.y, dropInfo.location, () => this.onDragMove(event));
|
|
739
684
|
if (dest) {
|
|
740
685
|
customDrop = {
|
|
741
|
-
rect: new
|
|
686
|
+
rect: new Rect(dest.x + tabRect.x, dest.y + tabRect.y, dest.width, dest.height),
|
|
742
687
|
callback: dest.callback,
|
|
743
688
|
invalidated: dest.invalidated,
|
|
744
689
|
dragging: dragging,
|
|
@@ -760,14 +705,14 @@ var Layout = /** @class */ (function (_super) {
|
|
|
760
705
|
}
|
|
761
706
|
}
|
|
762
707
|
this.dropInfo = dropInfo;
|
|
763
|
-
this.outlineDiv.className = this.getClassName(this.customDrop ?
|
|
708
|
+
this.outlineDiv.className = this.getClassName(this.customDrop ? CLASSES.FLEXLAYOUT__OUTLINE_RECT : dropInfo.className);
|
|
764
709
|
if (this.customDrop) {
|
|
765
710
|
this.customDrop.rect.positionElement(this.outlineDiv);
|
|
766
711
|
}
|
|
767
712
|
else {
|
|
768
713
|
dropInfo.rect.positionElement(this.outlineDiv);
|
|
769
714
|
}
|
|
770
|
-
|
|
715
|
+
DragDrop.instance.setGlassCursorOverride((_c = this.customDrop) === null || _c === void 0 ? void 0 : _c.cursor);
|
|
771
716
|
this.outlineDiv.style.visibility = "visible";
|
|
772
717
|
try {
|
|
773
718
|
invalidated === null || invalidated === void 0 ? void 0 : invalidated();
|
|
@@ -775,72 +720,72 @@ var Layout = /** @class */ (function (_super) {
|
|
|
775
720
|
catch (e) {
|
|
776
721
|
console.error(e);
|
|
777
722
|
}
|
|
778
|
-
}
|
|
723
|
+
}
|
|
779
724
|
/** @internal */
|
|
780
|
-
|
|
725
|
+
onDragEnter(event) {
|
|
781
726
|
// DragDrop keeps track of number of dragenters minus the number of
|
|
782
727
|
// dragleaves. Only start a new drag if there isn't one already.
|
|
783
|
-
if (
|
|
728
|
+
if (DragDrop.instance.isDragging())
|
|
784
729
|
return;
|
|
785
|
-
|
|
730
|
+
const drag = this.props.onExternalDrag(event);
|
|
786
731
|
if (drag) {
|
|
787
732
|
// Mimic addTabWithDragAndDrop, but pass in DragEvent
|
|
788
733
|
this.fnNewNodeDropped = drag.onDrop;
|
|
789
734
|
this.newTabJson = drag.json;
|
|
790
|
-
this.dragStart(event, drag.dragText,
|
|
735
|
+
this.dragStart(event, drag.dragText, TabNode._fromJson(drag.json, this.props.model, false), true, undefined, undefined);
|
|
791
736
|
}
|
|
792
|
-
}
|
|
737
|
+
}
|
|
793
738
|
/** @internal */
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
if (this.props.model.isEnableEdgeDock() && this.state.showHiddenBorder ===
|
|
739
|
+
checkForBorderToShow(x, y) {
|
|
740
|
+
const r = this.props.model._getOuterInnerRects().outer;
|
|
741
|
+
const c = r.getCenter();
|
|
742
|
+
const margin = this.edgeRectWidth;
|
|
743
|
+
const offset = this.edgeRectLength / 2;
|
|
744
|
+
let overEdge = false;
|
|
745
|
+
if (this.props.model.isEnableEdgeDock() && this.state.showHiddenBorder === DockLocation.CENTER) {
|
|
801
746
|
if ((y > c.y - offset && y < c.y + offset) ||
|
|
802
747
|
(x > c.x - offset && x < c.x + offset)) {
|
|
803
748
|
overEdge = true;
|
|
804
749
|
}
|
|
805
750
|
}
|
|
806
|
-
|
|
751
|
+
let location = DockLocation.CENTER;
|
|
807
752
|
if (!overEdge) {
|
|
808
753
|
if (x <= r.x + margin) {
|
|
809
|
-
location =
|
|
754
|
+
location = DockLocation.LEFT;
|
|
810
755
|
}
|
|
811
756
|
else if (x >= r.getRight() - margin) {
|
|
812
|
-
location =
|
|
757
|
+
location = DockLocation.RIGHT;
|
|
813
758
|
}
|
|
814
759
|
else if (y <= r.y + margin) {
|
|
815
|
-
location =
|
|
760
|
+
location = DockLocation.TOP;
|
|
816
761
|
}
|
|
817
762
|
else if (y >= r.getBottom() - margin) {
|
|
818
|
-
location =
|
|
763
|
+
location = DockLocation.BOTTOM;
|
|
819
764
|
}
|
|
820
765
|
}
|
|
821
766
|
if (location !== this.state.showHiddenBorder) {
|
|
822
767
|
this.setState({ showHiddenBorder: location });
|
|
823
768
|
}
|
|
824
|
-
}
|
|
769
|
+
}
|
|
825
770
|
/** @internal */
|
|
826
|
-
|
|
827
|
-
this.doAction(
|
|
828
|
-
}
|
|
771
|
+
maximize(tabsetNode) {
|
|
772
|
+
this.doAction(Actions.maximizeToggle(tabsetNode.getId()));
|
|
773
|
+
}
|
|
829
774
|
/** @internal */
|
|
830
|
-
|
|
775
|
+
customizeTab(tabNode, renderValues) {
|
|
831
776
|
if (this.props.onRenderTab) {
|
|
832
777
|
this.props.onRenderTab(tabNode, renderValues);
|
|
833
778
|
}
|
|
834
|
-
}
|
|
779
|
+
}
|
|
835
780
|
/** @internal */
|
|
836
|
-
|
|
781
|
+
customizeTabSet(tabSetNode, renderValues) {
|
|
837
782
|
if (this.props.onRenderTabSet) {
|
|
838
783
|
this.props.onRenderTabSet(tabSetNode, renderValues);
|
|
839
784
|
}
|
|
840
|
-
}
|
|
785
|
+
}
|
|
841
786
|
/** @internal */
|
|
842
|
-
|
|
843
|
-
|
|
787
|
+
i18nName(id, param) {
|
|
788
|
+
let message;
|
|
844
789
|
if (this.props.i18nMapper) {
|
|
845
790
|
message = this.props.i18nMapper(id, param);
|
|
846
791
|
}
|
|
@@ -848,37 +793,35 @@ var Layout = /** @class */ (function (_super) {
|
|
|
848
793
|
message = id + (param === undefined ? "" : param);
|
|
849
794
|
}
|
|
850
795
|
return message;
|
|
851
|
-
}
|
|
796
|
+
}
|
|
852
797
|
/** @internal */
|
|
853
|
-
|
|
798
|
+
getOnRenderFloatingTabPlaceholder() {
|
|
854
799
|
return this.props.onRenderFloatingTabPlaceholder;
|
|
855
|
-
}
|
|
800
|
+
}
|
|
856
801
|
/** @internal */
|
|
857
|
-
|
|
802
|
+
getShowOverflowMenu() {
|
|
858
803
|
return this.props.onShowOverflowMenu;
|
|
859
|
-
}
|
|
804
|
+
}
|
|
860
805
|
/** @internal */
|
|
861
|
-
|
|
806
|
+
getTabSetPlaceHolderCallback() {
|
|
862
807
|
return this.props.onTabSetPlaceHolder;
|
|
863
|
-
}
|
|
808
|
+
}
|
|
864
809
|
/** @internal */
|
|
865
|
-
|
|
810
|
+
showContextMenu(node, event) {
|
|
866
811
|
if (this.props.onContextMenu) {
|
|
867
812
|
this.props.onContextMenu(node, event);
|
|
868
813
|
}
|
|
869
|
-
}
|
|
814
|
+
}
|
|
870
815
|
/** @internal */
|
|
871
|
-
|
|
816
|
+
auxMouseClick(node, event) {
|
|
872
817
|
if (this.props.onAuxMouseClick) {
|
|
873
818
|
this.props.onAuxMouseClick(node, event);
|
|
874
819
|
}
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
}(React.Component));
|
|
878
|
-
exports.Layout = Layout;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
879
822
|
/** @internal */
|
|
880
|
-
|
|
881
|
-
React.useEffect(
|
|
823
|
+
const DragRectRenderWrapper = (props) => {
|
|
824
|
+
React.useEffect(() => {
|
|
882
825
|
var _a;
|
|
883
826
|
(_a = props.onRendered) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
884
827
|
}, [props]);
|