flexlayout-react 0.6.3 → 0.6.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/README.md +1 -1
- package/declarations/model/Model.d.ts +1 -2
- package/declarations/model/RowNode.d.ts +0 -2
- package/dist/flexlayout.js +193 -319
- package/dist/flexlayout_min.js +1 -1
- package/lib/Attribute.js +1 -1
- package/lib/Attribute.js.map +1 -1
- package/lib/AttributeDefinitions.js +13 -9
- package/lib/AttributeDefinitions.js.map +1 -1
- package/lib/DockLocation.js +6 -6
- package/lib/DockLocation.js.map +1 -1
- package/lib/DragDrop.js +24 -22
- package/lib/DragDrop.js.map +1 -1
- package/lib/Orientation.js +1 -1
- package/lib/Orientation.js.map +1 -1
- package/lib/PopupMenu.js +6 -6
- package/lib/PopupMenu.js.map +1 -1
- package/lib/Rect.js +1 -1
- package/lib/Rect.js.map +1 -1
- package/lib/model/BorderNode.js +31 -31
- package/lib/model/BorderNode.js.map +1 -1
- package/lib/model/BorderSet.js +18 -14
- package/lib/model/BorderSet.js.map +1 -1
- package/lib/model/Model.js +40 -35
- package/lib/model/Model.js.map +1 -1
- package/lib/model/Node.js +29 -28
- package/lib/model/Node.js.map +1 -1
- package/lib/model/RowNode.js +53 -50
- package/lib/model/RowNode.js.map +1 -1
- package/lib/model/SplitterNode.js +11 -11
- package/lib/model/SplitterNode.js.map +1 -1
- package/lib/model/TabNode.js +17 -17
- package/lib/model/TabNode.js.map +1 -1
- package/lib/model/TabSetNode.js +52 -51
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/model/Utils.js +3 -3
- package/lib/model/Utils.js.map +1 -1
- package/lib/view/BorderButton.js +52 -12
- package/lib/view/BorderButton.js.map +1 -1
- package/lib/view/BorderTabSet.js +4 -4
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/ErrorBoundary.js +1 -1
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/FloatingWindow.js +27 -16
- package/lib/view/FloatingWindow.js.map +1 -1
- package/lib/view/FloatingWindowTab.js +1 -1
- package/lib/view/FloatingWindowTab.js.map +1 -1
- package/lib/view/Layout.js +80 -75
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/Splitter.js +1 -1
- package/lib/view/Splitter.js.map +1 -1
- package/lib/view/Tab.js +5 -5
- package/lib/view/Tab.js.map +1 -1
- package/lib/view/TabButton.js +10 -15
- package/lib/view/TabButton.js.map +1 -1
- package/lib/view/TabButtonStamp.js +2 -2
- package/lib/view/TabButtonStamp.js.map +1 -1
- package/lib/view/TabFloating.js +2 -2
- package/lib/view/TabFloating.js.map +1 -1
- package/lib/view/TabOverflowHook.js +1 -1
- package/lib/view/TabOverflowHook.js.map +1 -1
- package/lib/view/TabSet.js +16 -12
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js +3 -3
- package/lib/view/Utils.js.map +1 -1
- package/package.json +20 -14
- package/src/Attribute.ts +1 -1
- package/src/AttributeDefinitions.ts +9 -9
- package/src/DockLocation.ts +9 -9
- package/src/DragDrop.ts +42 -38
- package/src/Orientation.ts +2 -2
- package/src/PopupMenu.tsx +4 -4
- package/src/Rect.ts +1 -1
- package/src/model/BorderNode.ts +29 -28
- package/src/model/BorderSet.ts +16 -16
- package/src/model/IDraggable.ts +2 -2
- package/src/model/IDropTarget.ts +3 -3
- package/src/model/Model.ts +41 -41
- package/src/model/Node.ts +38 -38
- package/src/model/RowNode.ts +46 -44
- package/src/model/SplitterNode.ts +11 -11
- package/src/model/TabNode.ts +21 -21
- package/src/model/TabSetNode.ts +46 -44
- package/src/model/Utils.ts +3 -3
- package/src/view/BorderButton.tsx +82 -14
- package/src/view/BorderTabSet.tsx +2 -2
- package/src/view/ErrorBoundary.tsx +3 -3
- package/src/view/FloatingWindow.tsx +8 -6
- package/src/view/FloatingWindowTab.tsx +2 -2
- package/src/view/Layout.tsx +93 -93
- package/src/view/Splitter.tsx +2 -2
- package/src/view/Tab.tsx +3 -3
- package/src/view/TabButton.tsx +11 -15
- package/src/view/TabButtonStamp.tsx +2 -2
- package/src/view/TabFloating.tsx +2 -2
- package/src/view/TabOverflowHook.tsx +1 -1
- package/src/view/TabSet.tsx +2 -3
- package/src/view/Utils.tsx +3 -3
- package/style/_base.scss +1 -0
- package/style/dark.css +1 -0
- package/style/dark.css.map +1 -1
- package/style/gray.css +1 -0
- package/style/gray.css.map +1 -1
- package/style/light.css +1 -0
- package/style/light.css.map +1 -1
package/src/model/TabSetNode.ts
CHANGED
|
@@ -18,15 +18,15 @@ import { adjustSelectedIndex } from "./Utils";
|
|
|
18
18
|
export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
19
19
|
static readonly TYPE = "tabset";
|
|
20
20
|
|
|
21
|
-
/** @
|
|
21
|
+
/** @internal */
|
|
22
22
|
static _fromJson(json: any, model: Model) {
|
|
23
23
|
const newLayoutNode = new TabSetNode(model, json);
|
|
24
24
|
|
|
25
25
|
if (json.children != null) {
|
|
26
|
-
json.children
|
|
26
|
+
for (const jsonChild of json.children) {
|
|
27
27
|
const child = TabNode._fromJson(jsonChild, model);
|
|
28
28
|
newLayoutNode._addChild(child);
|
|
29
|
-
}
|
|
29
|
+
}
|
|
30
30
|
}
|
|
31
31
|
if (newLayoutNode._children.length === 0) {
|
|
32
32
|
newLayoutNode._setSelected(-1);
|
|
@@ -42,10 +42,10 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
42
42
|
|
|
43
43
|
return newLayoutNode;
|
|
44
44
|
}
|
|
45
|
-
/** @
|
|
45
|
+
/** @internal */
|
|
46
46
|
private static _attributeDefinitions: AttributeDefinitions = TabSetNode._createAttributeDefinitions();
|
|
47
47
|
|
|
48
|
-
/** @
|
|
48
|
+
/** @internal */
|
|
49
49
|
private static _createAttributeDefinitions(): AttributeDefinitions {
|
|
50
50
|
const attributeDefinitions = new AttributeDefinitions();
|
|
51
51
|
attributeDefinitions.add("type", TabSetNode.TYPE, true).setType(Attribute.STRING).setFixed();
|
|
@@ -79,23 +79,23 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
79
79
|
return attributeDefinitions;
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
/** @
|
|
82
|
+
/** @internal */
|
|
83
83
|
private _contentRect?: Rect;
|
|
84
|
-
/** @
|
|
84
|
+
/** @internal */
|
|
85
85
|
private _tabHeaderRect?: Rect;
|
|
86
|
-
/** @
|
|
87
|
-
private
|
|
88
|
-
/** @
|
|
89
|
-
private
|
|
86
|
+
/** @internal */
|
|
87
|
+
private _calculatedTabBarHeight: number;
|
|
88
|
+
/** @internal */
|
|
89
|
+
private _calculatedHeaderBarHeight: number;
|
|
90
90
|
|
|
91
|
-
/** @
|
|
91
|
+
/** @internal */
|
|
92
92
|
constructor(model: Model, json: any) {
|
|
93
93
|
super(model);
|
|
94
94
|
|
|
95
95
|
TabSetNode._attributeDefinitions.fromJson(json, this._attributes);
|
|
96
96
|
model._addNode(this);
|
|
97
|
-
this.
|
|
98
|
-
this.
|
|
97
|
+
this._calculatedTabBarHeight = 0;
|
|
98
|
+
this._calculatedHeaderBarHeight = 0;
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
getName() {
|
|
@@ -138,7 +138,7 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
138
138
|
return this._getAttr("minHeight") as number;
|
|
139
139
|
}
|
|
140
140
|
|
|
141
|
-
/** @
|
|
141
|
+
/** @internal */
|
|
142
142
|
getMinSize(orientation: Orientation) {
|
|
143
143
|
if (orientation === Orientation.HORZ) {
|
|
144
144
|
return this.getMinWidth();
|
|
@@ -221,51 +221,51 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
221
221
|
return this._getAttr("classNameHeader") as string | undefined;
|
|
222
222
|
}
|
|
223
223
|
|
|
224
|
-
/** @
|
|
224
|
+
/** @internal */
|
|
225
225
|
calculateHeaderBarHeight(metrics: ILayoutMetrics) {
|
|
226
226
|
const headerBarHeight = this._getAttr("headerHeight") as number;
|
|
227
227
|
if (headerBarHeight !== 0) {
|
|
228
228
|
// its defined
|
|
229
|
-
this.
|
|
229
|
+
this._calculatedHeaderBarHeight = headerBarHeight;
|
|
230
230
|
} else {
|
|
231
|
-
this.
|
|
231
|
+
this._calculatedHeaderBarHeight = metrics.headerBarSize;
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
|
|
235
|
-
/** @
|
|
235
|
+
/** @internal */
|
|
236
236
|
calculateTabBarHeight(metrics: ILayoutMetrics) {
|
|
237
237
|
const tabBarHeight = this._getAttr("tabStripHeight") as number;
|
|
238
238
|
if (tabBarHeight !== 0) {
|
|
239
239
|
// its defined
|
|
240
|
-
this.
|
|
240
|
+
this._calculatedTabBarHeight = tabBarHeight;
|
|
241
241
|
} else {
|
|
242
|
-
this.
|
|
242
|
+
this._calculatedTabBarHeight = metrics.tabBarSize;
|
|
243
243
|
}
|
|
244
244
|
}
|
|
245
245
|
|
|
246
246
|
getHeaderHeight() {
|
|
247
|
-
return this.
|
|
247
|
+
return this._calculatedHeaderBarHeight;
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
getTabStripHeight() {
|
|
251
|
-
return this.
|
|
251
|
+
return this._calculatedTabBarHeight;
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
getTabLocation() {
|
|
255
255
|
return this._getAttr("tabLocation") as string;
|
|
256
256
|
}
|
|
257
257
|
|
|
258
|
-
/** @
|
|
258
|
+
/** @internal */
|
|
259
259
|
_setWeight(weight: number) {
|
|
260
260
|
this._attributes.weight = weight;
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
/** @
|
|
263
|
+
/** @internal */
|
|
264
264
|
_setSelected(index: number) {
|
|
265
265
|
this._attributes.selected = index;
|
|
266
266
|
}
|
|
267
267
|
|
|
268
|
-
/** @
|
|
268
|
+
/** @internal */
|
|
269
269
|
canDrop(dragNode: Node & IDraggable, x: number, y: number): DropInfo | undefined {
|
|
270
270
|
let dropInfo;
|
|
271
271
|
|
|
@@ -320,7 +320,7 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
320
320
|
return dropInfo;
|
|
321
321
|
}
|
|
322
322
|
|
|
323
|
-
/** @
|
|
323
|
+
/** @internal */
|
|
324
324
|
_layout(rect: Rect, metrics: ILayoutMetrics) {
|
|
325
325
|
this.calculateHeaderBarHeight(metrics);
|
|
326
326
|
this.calculateTabBarHeight(metrics);
|
|
@@ -337,34 +337,35 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
337
337
|
let y = 0;
|
|
338
338
|
let h = 0;
|
|
339
339
|
if (showHeader) {
|
|
340
|
-
y += this.
|
|
341
|
-
h += this.
|
|
340
|
+
y += this._calculatedHeaderBarHeight;
|
|
341
|
+
h += this._calculatedHeaderBarHeight;
|
|
342
342
|
}
|
|
343
343
|
if (this.isEnableTabStrip()) {
|
|
344
344
|
if (this.getTabLocation() === "top") {
|
|
345
|
-
this._tabHeaderRect = new Rect(rect.x, rect.y + y, rect.width, this.
|
|
345
|
+
this._tabHeaderRect = new Rect(rect.x, rect.y + y, rect.width, this._calculatedTabBarHeight);
|
|
346
346
|
} else {
|
|
347
|
-
this._tabHeaderRect = new Rect(rect.x, rect.y + rect.height - this.
|
|
347
|
+
this._tabHeaderRect = new Rect(rect.x, rect.y + rect.height - this._calculatedTabBarHeight, rect.width, this._calculatedTabBarHeight);
|
|
348
348
|
}
|
|
349
|
-
h += this.
|
|
349
|
+
h += this._calculatedTabBarHeight;
|
|
350
350
|
if (this.getTabLocation() === "top") {
|
|
351
|
-
y += this.
|
|
351
|
+
y += this._calculatedTabBarHeight;
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
354
|
this._contentRect = new Rect(rect.x, rect.y + y, rect.width, rect.height - h);
|
|
355
355
|
|
|
356
|
-
this._children.
|
|
356
|
+
for (let i = 0; i < this._children.length; i++) {
|
|
357
|
+
const child = this._children[i];
|
|
357
358
|
child._layout(this._contentRect!, metrics);
|
|
358
359
|
child._setVisible(i === this.getSelected());
|
|
359
|
-
}
|
|
360
|
+
}
|
|
360
361
|
}
|
|
361
362
|
|
|
362
|
-
/** @
|
|
363
|
+
/** @internal */
|
|
363
364
|
_delete() {
|
|
364
365
|
(this._parent as RowNode)._removeChild(this);
|
|
365
366
|
}
|
|
366
367
|
|
|
367
|
-
/** @
|
|
368
|
+
/** @internal */
|
|
368
369
|
_remove(node: TabNode) {
|
|
369
370
|
const removedIndex = this._removeChild(node);
|
|
370
371
|
this._model._tidy();
|
|
@@ -372,7 +373,7 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
372
373
|
adjustSelectedIndex(this, removedIndex);
|
|
373
374
|
}
|
|
374
375
|
|
|
375
|
-
/** @
|
|
376
|
+
/** @internal */
|
|
376
377
|
drop(dragNode: Node & IDraggable, location: DockLocation, index: number, select?: boolean) {
|
|
377
378
|
const dockLocation = location;
|
|
378
379
|
|
|
@@ -407,11 +408,12 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
407
408
|
}
|
|
408
409
|
// console.log("added child at : " + insertPos);
|
|
409
410
|
} else {
|
|
410
|
-
dragNode.getChildren().
|
|
411
|
+
for (let i = 0; i < dragNode.getChildren().length; i++) {
|
|
412
|
+
const child = dragNode.getChildren()[i];
|
|
411
413
|
this._addChild(child, insertPos);
|
|
412
414
|
// console.log("added child at : " + insertPos);
|
|
413
415
|
insertPos++;
|
|
414
|
-
}
|
|
416
|
+
}
|
|
415
417
|
}
|
|
416
418
|
this._model._setActiveTabset(this);
|
|
417
419
|
} else {
|
|
@@ -471,17 +473,17 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
471
473
|
return json;
|
|
472
474
|
}
|
|
473
475
|
|
|
474
|
-
/** @
|
|
476
|
+
/** @internal */
|
|
475
477
|
_updateAttrs(json: any) {
|
|
476
478
|
TabSetNode._attributeDefinitions.update(json, this._attributes);
|
|
477
479
|
}
|
|
478
480
|
|
|
479
|
-
/** @
|
|
481
|
+
/** @internal */
|
|
480
482
|
_getAttributeDefinitions() {
|
|
481
483
|
return TabSetNode._attributeDefinitions;
|
|
482
484
|
}
|
|
483
485
|
|
|
484
|
-
/** @
|
|
486
|
+
/** @internal */
|
|
485
487
|
_getPrefSize(orientation: Orientation) {
|
|
486
488
|
let prefSize = this.getWidth();
|
|
487
489
|
if (orientation === Orientation.VERT) {
|
|
@@ -491,7 +493,7 @@ export class TabSetNode extends Node implements IDraggable, IDropTarget {
|
|
|
491
493
|
}
|
|
492
494
|
|
|
493
495
|
|
|
494
|
-
/** @
|
|
496
|
+
/** @internal */
|
|
495
497
|
static getAttributeDefinitions() {
|
|
496
498
|
return TabSetNode._attributeDefinitions;
|
|
497
499
|
}
|
package/src/model/Utils.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { BorderNode } from "./BorderNode";
|
|
|
3
3
|
import { RowNode } from "./RowNode";
|
|
4
4
|
import { TabNode } from "./TabNode";
|
|
5
5
|
|
|
6
|
-
/** @
|
|
6
|
+
/** @internal */
|
|
7
7
|
export function adjustSelectedIndexAfterFloat(node: TabNode) {
|
|
8
8
|
const parent = node.getParent();
|
|
9
9
|
if (parent !== null) {
|
|
@@ -29,7 +29,7 @@ export function adjustSelectedIndexAfterFloat(node: TabNode) {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
/** @
|
|
32
|
+
/** @internal */
|
|
33
33
|
export function adjustSelectedIndexAfterDock(node: TabNode) {
|
|
34
34
|
const parent = node.getParent();
|
|
35
35
|
if (parent !== null && (parent instanceof TabSetNode || parent instanceof BorderNode)) {
|
|
@@ -44,7 +44,7 @@ export function adjustSelectedIndexAfterDock(node: TabNode) {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
/** @
|
|
47
|
+
/** @internal */
|
|
48
48
|
export function adjustSelectedIndex(parent: TabSetNode | BorderNode | RowNode, removedIndex: number) {
|
|
49
49
|
// for the tabset/border being removed from set the selected index
|
|
50
50
|
if (parent !== undefined && (parent.getType() === TabSetNode.TYPE || parent.getType() === BorderNode.TYPE)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import { I18nLabel } from "
|
|
2
|
+
import { I18nLabel } from "../I18nLabel";
|
|
3
3
|
import { Actions } from "../model/Actions";
|
|
4
4
|
import { TabNode } from "../model/TabNode";
|
|
5
5
|
import { Rect } from "../Rect";
|
|
@@ -8,7 +8,7 @@ import { ICloseType } from "../model/ICloseType";
|
|
|
8
8
|
import { CLASSES } from "../Types";
|
|
9
9
|
import { getRenderStateEx, isAuxMouseEvent } from "./Utils";
|
|
10
10
|
|
|
11
|
-
/** @
|
|
11
|
+
/** @internal */
|
|
12
12
|
export interface IBorderButtonProps {
|
|
13
13
|
layout: ILayoutCallbacks;
|
|
14
14
|
node: TabNode;
|
|
@@ -16,18 +16,20 @@ export interface IBorderButtonProps {
|
|
|
16
16
|
border: string;
|
|
17
17
|
iconFactory?: (node: TabNode) => React.ReactNode | undefined;
|
|
18
18
|
titleFactory?: (node: TabNode) => React.ReactNode | undefined;
|
|
19
|
-
icons
|
|
19
|
+
icons: IIcons;
|
|
20
20
|
path: string;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
/** @
|
|
23
|
+
/** @internal */
|
|
24
24
|
export const BorderButton = (props: IBorderButtonProps) => {
|
|
25
25
|
const { layout, node, selected, border, iconFactory, titleFactory, icons, path } = props;
|
|
26
26
|
const selfRef = React.useRef<HTMLDivElement | null>(null);
|
|
27
|
+
const contentRef = React.useRef<HTMLInputElement | null>(null);
|
|
27
28
|
|
|
28
29
|
const onMouseDown = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | React.TouchEvent<HTMLDivElement>) => {
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
|
|
31
|
+
if (!isAuxMouseEvent(event) && !layout.getEditingTab()) {
|
|
32
|
+
layout.dragStart(event, undefined, node, node.isEnableDrag(), onClick, onDoubleClick);
|
|
31
33
|
}
|
|
32
34
|
};
|
|
33
35
|
|
|
@@ -45,6 +47,26 @@ export const BorderButton = (props: IBorderButtonProps) => {
|
|
|
45
47
|
layout.doAction(Actions.selectTab(node.getId()));
|
|
46
48
|
};
|
|
47
49
|
|
|
50
|
+
const onDoubleClick = (event: Event) => {
|
|
51
|
+
// if (node.isEnableRename()) {
|
|
52
|
+
// onRename();
|
|
53
|
+
// }
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// const onRename = () => {
|
|
57
|
+
// layout.setEditingTab(node);
|
|
58
|
+
// layout.getCurrentDocument()!.body.addEventListener("mousedown", onEndEdit);
|
|
59
|
+
// layout.getCurrentDocument()!.body.addEventListener("touchstart", onEndEdit);
|
|
60
|
+
// };
|
|
61
|
+
|
|
62
|
+
const onEndEdit = (event: Event) => {
|
|
63
|
+
if (event.target !== contentRef.current!) {
|
|
64
|
+
layout.getCurrentDocument()!.body.removeEventListener("mousedown", onEndEdit);
|
|
65
|
+
layout.getCurrentDocument()!.body.removeEventListener("touchstart", onEndEdit);
|
|
66
|
+
layout.setEditingTab(undefined);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
48
70
|
const isClosable = () => {
|
|
49
71
|
const closeType = node.getCloseType();
|
|
50
72
|
if (selected || closeType === ICloseType.Always) {
|
|
@@ -73,13 +95,33 @@ export const BorderButton = (props: IBorderButtonProps) => {
|
|
|
73
95
|
|
|
74
96
|
React.useLayoutEffect(() => {
|
|
75
97
|
updateRect();
|
|
98
|
+
if (layout.getEditingTab() === node) {
|
|
99
|
+
(contentRef.current! as HTMLInputElement).select();
|
|
100
|
+
}
|
|
76
101
|
});
|
|
77
102
|
|
|
78
103
|
const updateRect = () => {
|
|
79
|
-
// record position of tab in
|
|
80
|
-
const
|
|
104
|
+
// record position of tab in node
|
|
105
|
+
const layoutRect = layout.getDomRect();
|
|
81
106
|
const r = selfRef.current!.getBoundingClientRect();
|
|
82
|
-
node._setTabRect(new Rect(r.left -
|
|
107
|
+
node._setTabRect(new Rect(r.left - layoutRect.left, r.top - layoutRect.top, r.width, r.height));
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
const onTextBoxMouseDown = (event: React.MouseEvent<HTMLInputElement> | React.TouchEvent<HTMLInputElement>) => {
|
|
111
|
+
// console.log("onTextBoxMouseDown");
|
|
112
|
+
event.stopPropagation();
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const onTextBoxKeyPress = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
116
|
+
// console.log(event, event.keyCode);
|
|
117
|
+
if (event.keyCode === 27) {
|
|
118
|
+
// esc
|
|
119
|
+
layout.setEditingTab(undefined);
|
|
120
|
+
} else if (event.keyCode === 13) {
|
|
121
|
+
// enter
|
|
122
|
+
layout.setEditingTab(undefined);
|
|
123
|
+
layout.doAction(Actions.renameTab(node.getId(), (event.target as HTMLInputElement).value));
|
|
124
|
+
}
|
|
83
125
|
};
|
|
84
126
|
|
|
85
127
|
const cm = layout.getClassName;
|
|
@@ -97,8 +139,31 @@ export const BorderButton = (props: IBorderButtonProps) => {
|
|
|
97
139
|
|
|
98
140
|
const renderState = getRenderStateEx(layout, node, iconFactory, titleFactory);
|
|
99
141
|
|
|
100
|
-
|
|
101
|
-
|
|
142
|
+
let content = renderState.content ? (
|
|
143
|
+
<div className={cm(CLASSES.FLEXLAYOUT__BORDER_BUTTON_CONTENT)}>
|
|
144
|
+
{renderState.content}
|
|
145
|
+
</div>) : null;
|
|
146
|
+
|
|
147
|
+
const leading = renderState.leading ? (
|
|
148
|
+
<div className={cm(CLASSES.FLEXLAYOUT__BORDER_BUTTON_LEADING)}>
|
|
149
|
+
{renderState.leading}
|
|
150
|
+
</div>) : null;
|
|
151
|
+
|
|
152
|
+
if (layout.getEditingTab() === node) {
|
|
153
|
+
content = (
|
|
154
|
+
<input
|
|
155
|
+
ref={contentRef}
|
|
156
|
+
className={cm(CLASSES.FLEXLAYOUT__TAB_BUTTON_TEXTBOX)}
|
|
157
|
+
data-layout-path={path + "/textbox"}
|
|
158
|
+
type="text"
|
|
159
|
+
autoFocus={true}
|
|
160
|
+
defaultValue={node.getName()}
|
|
161
|
+
onKeyDown={onTextBoxKeyPress}
|
|
162
|
+
onMouseDown={onTextBoxMouseDown}
|
|
163
|
+
onTouchStart={onTextBoxMouseDown}
|
|
164
|
+
/>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
102
167
|
|
|
103
168
|
if (node.isEnableClose()) {
|
|
104
169
|
const closeTitle = layout.i18nName(I18nLabel.Close_Tab);
|
|
@@ -111,20 +176,23 @@ export const BorderButton = (props: IBorderButtonProps) => {
|
|
|
111
176
|
onMouseDown={onCloseMouseDown}
|
|
112
177
|
onClick={onClose}
|
|
113
178
|
onTouchStart={onCloseMouseDown}>
|
|
114
|
-
{icons
|
|
179
|
+
{(typeof icons.close === "function") ? icons.close(node) : icons.close}
|
|
115
180
|
</div>
|
|
116
181
|
);
|
|
117
182
|
}
|
|
118
183
|
|
|
119
184
|
return (
|
|
120
|
-
<div
|
|
185
|
+
<div
|
|
186
|
+
ref={selfRef}
|
|
121
187
|
data-layout-path={path}
|
|
188
|
+
className={classNames}
|
|
122
189
|
onMouseDown={onMouseDown}
|
|
123
190
|
onClick={onAuxMouseClick}
|
|
124
191
|
onAuxClick={onAuxMouseClick}
|
|
125
192
|
onContextMenu={onContextMenu}
|
|
126
193
|
onTouchStart={onMouseDown}
|
|
127
|
-
title={node.getHelpText()}
|
|
194
|
+
title={node.getHelpText()}
|
|
195
|
+
>
|
|
128
196
|
{leading}
|
|
129
197
|
{content}
|
|
130
198
|
{renderState.buttons}
|
|
@@ -12,7 +12,7 @@ import { Orientation } from "../Orientation";
|
|
|
12
12
|
import { CLASSES } from "../Types";
|
|
13
13
|
import { isAuxMouseEvent } from "./Utils";
|
|
14
14
|
|
|
15
|
-
/** @
|
|
15
|
+
/** @internal */
|
|
16
16
|
export interface IBorderTabSetProps {
|
|
17
17
|
border: BorderNode;
|
|
18
18
|
layout: ILayoutCallbacks;
|
|
@@ -22,7 +22,7 @@ export interface IBorderTabSetProps {
|
|
|
22
22
|
path: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/** @
|
|
25
|
+
/** @internal */
|
|
26
26
|
export const BorderTabSet = (props: IBorderTabSetProps) => {
|
|
27
27
|
const { border, layout, iconFactory, titleFactory, icons, path } = props;
|
|
28
28
|
|
|
@@ -2,16 +2,16 @@ import * as React from "react";
|
|
|
2
2
|
import { ErrorInfo } from "react";
|
|
3
3
|
import { CLASSES } from "../Types";
|
|
4
4
|
|
|
5
|
-
/** @
|
|
5
|
+
/** @internal */
|
|
6
6
|
export interface IErrorBoundaryProps {
|
|
7
7
|
message: string;
|
|
8
8
|
}
|
|
9
|
-
/** @
|
|
9
|
+
/** @internal */
|
|
10
10
|
export interface IErrorBoundaryState {
|
|
11
11
|
hasError: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/** @
|
|
14
|
+
/** @internal */
|
|
15
15
|
export class ErrorBoundary extends React.Component<IErrorBoundaryProps, IErrorBoundaryState> {
|
|
16
16
|
constructor(props: IErrorBoundaryProps) {
|
|
17
17
|
super(props);
|
|
@@ -3,7 +3,7 @@ import { createPortal } from "react-dom";
|
|
|
3
3
|
import { Rect } from "../Rect";
|
|
4
4
|
import { CLASSES } from "../Types";
|
|
5
5
|
|
|
6
|
-
/** @
|
|
6
|
+
/** @internal */
|
|
7
7
|
export interface IFloatingWindowProps {
|
|
8
8
|
title: string;
|
|
9
9
|
id: string;
|
|
@@ -19,7 +19,7 @@ interface IStyleSheet {
|
|
|
19
19
|
rules: string[] | null;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
/** @
|
|
22
|
+
/** @internal */
|
|
23
23
|
export const FloatingWindow = (props: React.PropsWithChildren<IFloatingWindowProps>) => {
|
|
24
24
|
const { title, id, url, rect, onCloseWindow, onSetWindow, children } = props;
|
|
25
25
|
const popoutWindow = React.useRef<Window | null>(null);
|
|
@@ -101,11 +101,11 @@ export const FloatingWindow = (props: React.PropsWithChildren<IFloatingWindowPro
|
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
103
|
|
|
104
|
-
/** @
|
|
104
|
+
/** @internal */
|
|
105
105
|
function copyStyles(doc: Document, styleSheets: IStyleSheet[]): Promise<boolean[]> {
|
|
106
106
|
const head = doc.head;
|
|
107
107
|
const promises: Promise<boolean>[] = [];
|
|
108
|
-
|
|
108
|
+
for (const styleSheet of styleSheets) {
|
|
109
109
|
if (styleSheet.href) {
|
|
110
110
|
// prefer links since they will keep paths to images etc
|
|
111
111
|
const styleElement = doc.createElement("link");
|
|
@@ -121,10 +121,12 @@ function copyStyles(doc: Document, styleSheets: IStyleSheet[]): Promise<boolean[
|
|
|
121
121
|
} else {
|
|
122
122
|
if (styleSheet.rules) {
|
|
123
123
|
const style = doc.createElement("style");
|
|
124
|
-
|
|
124
|
+
for (const rule of styleSheet.rules) {
|
|
125
|
+
style.appendChild(doc.createTextNode(rule));
|
|
126
|
+
}
|
|
125
127
|
head.appendChild(style);
|
|
126
128
|
}
|
|
127
129
|
}
|
|
128
|
-
}
|
|
130
|
+
}
|
|
129
131
|
return Promise.all(promises);
|
|
130
132
|
}
|
|
@@ -6,14 +6,14 @@ import { I18nLabel } from "../I18nLabel";
|
|
|
6
6
|
import { Fragment } from "react";
|
|
7
7
|
import { CLASSES } from "../Types";
|
|
8
8
|
|
|
9
|
-
/** @
|
|
9
|
+
/** @internal */
|
|
10
10
|
export interface IFloatingWindowTabProps {
|
|
11
11
|
layout: ILayoutCallbacks;
|
|
12
12
|
node: TabNode;
|
|
13
13
|
factory: (node: TabNode) => React.ReactNode;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
/** @
|
|
16
|
+
/** @internal */
|
|
17
17
|
export const FloatingWindowTab = (props: IFloatingWindowTabProps) => {
|
|
18
18
|
const { layout, node, factory } = props;
|
|
19
19
|
const cm = layout.getClassName;
|