flexlayout-react 0.7.14 → 0.8.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/ChangeLog.txt +26 -0
- package/README.md +157 -330
- package/Screenshot_light.png +0 -0
- package/Screenshot_rounded.png +0 -0
- package/declarations/Attribute.d.ts +1 -1
- package/declarations/AttributeDefinitions.d.ts +1 -1
- package/declarations/DockLocation.d.ts +12 -12
- package/declarations/DropInfo.d.ts +12 -12
- package/declarations/I18nLabel.d.ts +12 -14
- package/declarations/Orientation.d.ts +7 -7
- package/declarations/PopupMenu.d.ts +1 -1
- package/declarations/Rect.d.ts +41 -28
- package/declarations/Types.d.ts +95 -79
- package/declarations/examples/demo/Utils.d.ts +4 -0
- package/declarations/index.d.ts +21 -22
- package/declarations/model/Action.d.ts +5 -5
- package/declarations/model/Actions.d.ts +127 -110
- package/declarations/model/BorderNode.d.ts +30 -34
- package/declarations/model/BorderSet.d.ts +3 -4
- package/declarations/model/ICloseType.d.ts +5 -5
- package/declarations/model/IDraggable.d.ts +2 -2
- package/declarations/model/IDropTarget.d.ts +2 -2
- package/declarations/model/IJsonModel.d.ts +811 -149
- package/declarations/model/LayoutWindow.d.ts +28 -0
- package/declarations/model/Model.d.ts +91 -86
- package/declarations/model/Node.d.ts +17 -17
- package/declarations/model/RowNode.d.ts +10 -11
- package/declarations/model/TabNode.d.ts +44 -37
- package/declarations/model/TabSetNode.d.ts +44 -41
- package/declarations/model/Utils.d.ts +1 -1
- package/declarations/model/WindowLayout.d.ts +24 -0
- package/declarations/src/Attribute.d.ts +1 -0
- package/declarations/src/AttributeDefinitions.d.ts +1 -0
- package/declarations/src/DockLocation.d.ts +12 -0
- package/declarations/src/DropInfo.d.ts +12 -0
- package/declarations/src/I18nLabel.d.ts +10 -0
- package/declarations/src/Orientation.d.ts +7 -0
- package/declarations/src/PopupMenu.d.ts +1 -0
- package/declarations/src/Rect.d.ts +31 -0
- package/declarations/src/Types.d.ts +92 -0
- package/declarations/src/index.d.ts +20 -0
- package/declarations/src/model/Action.d.ts +5 -0
- package/declarations/src/model/Actions.d.ts +110 -0
- package/declarations/src/model/BorderNode.d.ts +28 -0
- package/declarations/src/model/BorderSet.d.ts +3 -0
- package/declarations/src/model/ICloseType.d.ts +5 -0
- package/declarations/src/model/IDraggable.d.ts +2 -0
- package/declarations/src/model/IDropTarget.d.ts +2 -0
- package/declarations/src/model/IJsonModel.d.ts +153 -0
- package/declarations/src/model/Model.d.ts +98 -0
- package/declarations/src/model/Node.d.ts +16 -0
- package/declarations/src/model/RowNode.d.ts +11 -0
- package/declarations/src/model/TabNode.d.ts +36 -0
- package/declarations/src/model/TabSetNode.d.ts +37 -0
- package/declarations/src/model/Utils.d.ts +1 -0
- package/declarations/src/view/BorderButton.d.ts +1 -0
- package/declarations/src/view/BorderTab.d.ts +2 -0
- package/declarations/src/view/BorderTabSet.d.ts +1 -0
- package/declarations/src/view/DragContainer.d.ts +1 -0
- package/declarations/src/view/ErrorBoundary.d.ts +1 -0
- package/declarations/src/view/FloatingWindow.d.ts +1 -0
- package/declarations/src/view/Icons.d.ts +7 -0
- package/declarations/src/view/Layout.d.ts +113 -0
- package/declarations/src/view/Overlay.d.ts +1 -0
- package/declarations/src/view/PopupMenu.d.ts +1 -0
- package/declarations/src/view/Row.d.ts +1 -0
- package/declarations/src/view/Splitter.d.ts +1 -0
- package/declarations/src/view/Tab.d.ts +1 -0
- package/declarations/src/view/TabButton.d.ts +1 -0
- package/declarations/src/view/TabButtonStamp.d.ts +1 -0
- package/declarations/src/view/TabOverflowHook.d.ts +1 -0
- package/declarations/src/view/TabSet.d.ts +1 -0
- package/declarations/src/view/Utils.d.ts +4 -0
- package/declarations/view/BorderButton.d.ts +1 -1
- package/declarations/view/BorderTab.d.ts +2 -0
- package/declarations/view/BorderTabSet.d.ts +1 -1
- package/declarations/view/DragContainer.d.ts +1 -0
- package/declarations/view/ErrorBoundary.d.ts +1 -1
- package/declarations/view/ExtendedResizeObserver.d.ts +23 -0
- package/declarations/view/FloatingWindow.d.ts +1 -1
- package/declarations/view/Icons.d.ts +8 -6
- package/declarations/view/Layout.d.ts +139 -160
- package/declarations/view/Overlay.d.ts +1 -0
- package/declarations/view/PopoutWindow.d.ts +1 -0
- package/declarations/view/PopupMenu.d.ts +1 -0
- package/declarations/view/Row.d.ts +1 -0
- package/declarations/view/SizeTracker.d.ts +10 -0
- package/declarations/view/Splitter.d.ts +1 -1
- package/declarations/view/Tab.d.ts +1 -1
- package/declarations/view/TabButton.d.ts +1 -1
- package/declarations/view/TabButtonStamp.d.ts +1 -1
- package/declarations/view/TabOverflowHook.d.ts +1 -1
- package/declarations/view/TabSet.d.ts +1 -1
- package/declarations/view/Utils.d.ts +11 -1
- package/dist/bundles/demo.js +232052 -0
- package/dist/bundles/demo.js.map +1 -0
- package/dist/flexlayout.js +122 -92
- package/dist/flexlayout_min.js +1 -1
- package/lib/Attribute.js +42 -31
- package/lib/Attribute.js.map +1 -1
- package/lib/AttributeDefinitions.js +131 -108
- package/lib/AttributeDefinitions.js.map +1 -1
- package/lib/DockLocation.js +120 -124
- package/lib/DockLocation.js.map +1 -1
- package/lib/DropInfo.js +9 -13
- package/lib/DropInfo.js.map +1 -1
- package/lib/I18nLabel.js +13 -18
- package/lib/I18nLabel.js.map +1 -1
- package/lib/Orientation.js +22 -26
- package/lib/Orientation.js.map +1 -1
- package/lib/Rect.js +104 -72
- package/lib/Rect.js.map +1 -1
- package/lib/Types.js +96 -83
- package/lib/Types.js.map +1 -1
- package/lib/index.js +21 -38
- package/lib/index.js.map +1 -1
- package/lib/model/Action.js +6 -10
- package/lib/model/Action.js.map +1 -1
- package/lib/model/Actions.js +169 -155
- package/lib/model/Actions.js.map +1 -1
- package/lib/model/BorderNode.js +385 -406
- package/lib/model/BorderNode.js.map +1 -1
- package/lib/model/BorderSet.js +66 -121
- package/lib/model/BorderSet.js.map +1 -1
- package/lib/model/ICloseType.js +6 -9
- 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/LayoutWindow.js +83 -0
- package/lib/model/LayoutWindow.js.map +1 -0
- package/lib/model/Model.js +614 -496
- package/lib/model/Model.js.map +1 -1
- package/lib/model/Node.js +217 -228
- package/lib/model/Node.js.map +1 -1
- package/lib/model/RowNode.js +491 -504
- package/lib/model/RowNode.js.map +1 -1
- package/lib/model/TabNode.js +289 -184
- package/lib/model/TabNode.js.map +1 -1
- package/lib/model/TabSetNode.js +457 -446
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/model/Utils.js +47 -82
- package/lib/model/Utils.js.map +1 -1
- package/lib/view/BorderButton.js +124 -138
- package/lib/view/BorderButton.js.map +1 -1
- package/lib/view/BorderTab.js +47 -0
- package/lib/view/BorderTab.js.map +1 -0
- package/lib/view/BorderTabSet.js +134 -128
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/DragContainer.js +16 -0
- package/lib/view/DragContainer.js.map +1 -0
- package/lib/view/ErrorBoundary.js +23 -27
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/Icons.js +40 -40
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +918 -901
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/Overlay.js +9 -0
- package/lib/view/Overlay.js.map +1 -0
- package/lib/view/PopoutWindow.js +129 -0
- package/lib/view/PopoutWindow.js.map +1 -0
- package/lib/view/PopupMenu.js +71 -0
- package/lib/view/PopupMenu.js.map +1 -0
- package/lib/view/Row.js +45 -0
- package/lib/view/Row.js.map +1 -0
- package/lib/view/SizeTracker.js +11 -0
- package/lib/view/SizeTracker.js.map +1 -0
- package/lib/view/Splitter.js +191 -147
- package/lib/view/Splitter.js.map +1 -1
- package/lib/view/Tab.js +86 -60
- package/lib/view/Tab.js.map +1 -1
- package/lib/view/TabButton.js +122 -135
- package/lib/view/TabButton.js.map +1 -1
- package/lib/view/TabButtonStamp.js +16 -21
- package/lib/view/TabButtonStamp.js.map +1 -1
- package/lib/view/TabOverflowHook.js +150 -149
- package/lib/view/TabOverflowHook.js.map +1 -1
- package/lib/view/TabSet.js +267 -234
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js +126 -68
- package/lib/view/Utils.js.map +1 -1
- package/package.json +36 -30
- package/src/Attribute.ts +23 -0
- package/src/AttributeDefinitions.ts +38 -15
- package/src/DockLocation.ts +13 -13
- package/src/I18nLabel.ts +7 -9
- package/src/Rect.ts +53 -1
- package/src/Types.ts +16 -0
- package/src/index.ts +1 -2
- package/src/model/Actions.ts +49 -29
- package/src/model/BorderNode.ts +208 -214
- package/src/model/BorderSet.ts +42 -91
- package/src/model/IJsonModel.ts +883 -103
- package/src/model/LayoutWindow.ts +121 -0
- package/src/model/Model.ts +488 -366
- package/src/model/Node.ts +98 -111
- package/src/model/RowNode.ts +323 -319
- package/src/model/TabNode.ts +294 -110
- package/src/model/TabSetNode.ts +300 -242
- package/src/model/Utils.ts +6 -32
- package/src/view/BorderButton.tsx +32 -52
- package/src/view/BorderTab.tsx +70 -0
- package/src/view/BorderTabSet.tsx +64 -52
- package/src/view/DragContainer.tsx +32 -0
- package/src/view/Icons.tsx +13 -0
- package/src/view/Layout.tsx +1071 -1047
- package/src/view/Overlay.tsx +22 -0
- package/src/view/PopoutWindow.tsx +152 -0
- package/src/{PopupMenu.tsx → view/PopupMenu.tsx} +36 -31
- package/src/view/Row.tsx +68 -0
- package/src/view/SizeTracker.tsx +20 -0
- package/src/view/Splitter.tsx +167 -112
- package/src/view/Tab.tsx +76 -42
- package/src/view/TabButton.tsx +36 -55
- package/src/view/TabButtonStamp.tsx +5 -9
- package/src/view/TabOverflowHook.tsx +14 -9
- package/src/view/TabSet.tsx +217 -176
- package/src/view/Utils.tsx +119 -39
- package/style/_base.scss +143 -35
- package/style/dark.css +685 -577
- package/style/dark.css.map +1 -1
- package/style/dark.scss +4 -1
- package/style/gray.css +668 -560
- package/style/gray.css.map +1 -1
- package/style/gray.scss +4 -1
- package/style/light.css +669 -561
- package/style/light.css.map +1 -1
- package/style/light.scss +6 -3
- package/style/rounded.css +697 -0
- package/style/rounded.css.map +1 -0
- package/style/rounded.scss +194 -0
- package/style/underline.css +690 -582
- package/style/underline.css.map +1 -1
- package/style/underline.scss +4 -1
- package/cypress.config.ts +0 -16
- package/lib/DragDrop.js +0 -316
- package/lib/DragDrop.js.map +0 -1
- package/lib/PopupMenu.js +0 -68
- package/lib/PopupMenu.js.map +0 -1
- package/lib/model/SplitterNode.js +0 -72
- package/lib/model/SplitterNode.js.map +0 -1
- package/lib/view/FloatingWindow.js +0 -123
- package/lib/view/FloatingWindow.js.map +0 -1
- package/lib/view/FloatingWindowTab.js +0 -19
- package/lib/view/FloatingWindowTab.js.map +0 -1
- package/lib/view/TabFloating.js +0 -66
- package/lib/view/TabFloating.js.map +0 -1
- package/src/DragDrop.ts +0 -392
- package/src/model/SplitterNode.ts +0 -78
- package/src/view/FloatingWindow.tsx +0 -140
- package/src/view/FloatingWindowTab.tsx +0 -29
- package/src/view/TabFloating.tsx +0 -101
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { AttributeDefinitions } from "../AttributeDefinitions";
|
|
2
|
-
import { Orientation } from "../Orientation";
|
|
3
|
-
import { Model } from "./Model";
|
|
4
|
-
import { Node } from "./Node";
|
|
5
|
-
|
|
6
|
-
export class SplitterNode extends Node {
|
|
7
|
-
static readonly TYPE: string = "splitter";
|
|
8
|
-
|
|
9
|
-
/** @internal */
|
|
10
|
-
constructor(model: Model) {
|
|
11
|
-
super(model);
|
|
12
|
-
this._fixed = true;
|
|
13
|
-
this._attributes.type = SplitterNode.TYPE;
|
|
14
|
-
model._addNode(this);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @internal */
|
|
18
|
-
getWidth() {
|
|
19
|
-
return this._model.getSplitterSize();
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** @internal */
|
|
23
|
-
getMinWidth() {
|
|
24
|
-
if (this.getOrientation() === Orientation.VERT) {
|
|
25
|
-
return this._model.getSplitterSize();
|
|
26
|
-
} else {
|
|
27
|
-
return 0;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/** @internal */
|
|
32
|
-
getHeight() {
|
|
33
|
-
return this._model.getSplitterSize();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** @internal */
|
|
37
|
-
getMinHeight() {
|
|
38
|
-
if (this.getOrientation() === Orientation.HORZ) {
|
|
39
|
-
return this._model.getSplitterSize();
|
|
40
|
-
} else {
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** @internal */
|
|
46
|
-
getMinSize(orientation: Orientation) {
|
|
47
|
-
if (orientation === Orientation.HORZ) {
|
|
48
|
-
return this.getMinWidth();
|
|
49
|
-
} else {
|
|
50
|
-
return this.getMinHeight();
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/** @internal */
|
|
55
|
-
getWeight(): number {
|
|
56
|
-
return 0;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/** @internal */
|
|
60
|
-
_setWeight(value: number): void { }
|
|
61
|
-
|
|
62
|
-
/** @internal */
|
|
63
|
-
_getPrefSize(orientation: Orientation): number {
|
|
64
|
-
return this._model.getSplitterSize();
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/** @internal */
|
|
68
|
-
_updateAttrs(json: any): void { }
|
|
69
|
-
|
|
70
|
-
/** @internal */
|
|
71
|
-
_getAttributeDefinitions(): AttributeDefinitions {
|
|
72
|
-
return new AttributeDefinitions();
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
toJson(): undefined {
|
|
76
|
-
return undefined;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
import { Rect } from "../Rect";
|
|
4
|
-
import { CLASSES } from "../Types";
|
|
5
|
-
|
|
6
|
-
/** @internal */
|
|
7
|
-
export interface IFloatingWindowProps {
|
|
8
|
-
title: string;
|
|
9
|
-
id: string;
|
|
10
|
-
url: string;
|
|
11
|
-
rect: Rect | null;
|
|
12
|
-
onCloseWindow: (id: string) => void;
|
|
13
|
-
onSetWindow: (id: string, window: Window) => void;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface IStyleSheet {
|
|
17
|
-
href: string | null;
|
|
18
|
-
type: string;
|
|
19
|
-
rules: string[] | null;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/** @internal */
|
|
23
|
-
export const FloatingWindow = (props: React.PropsWithChildren<IFloatingWindowProps>) => {
|
|
24
|
-
const { title, id, url, rect, onCloseWindow, onSetWindow, children } = props;
|
|
25
|
-
const popoutWindow = React.useRef<Window | null>(null);
|
|
26
|
-
const timerId = React.useRef<any>(null);
|
|
27
|
-
const [content, setContent] = React.useState<HTMLElement | undefined>(undefined);
|
|
28
|
-
|
|
29
|
-
React.useLayoutEffect(() => {
|
|
30
|
-
if (timerId.current) {
|
|
31
|
-
clearTimeout(timerId.current);
|
|
32
|
-
}
|
|
33
|
-
let isMounted = true;
|
|
34
|
-
const r = rect || new Rect(0, 0, 100, 100);
|
|
35
|
-
// Make a local copy of the styles from the current window which will be passed into
|
|
36
|
-
// the floating window. window.document.styleSheets is mutable and we can't guarantee
|
|
37
|
-
// the styles will exist when 'popoutWindow.load' is called below.
|
|
38
|
-
const styles = Array.from(window.document.styleSheets).reduce((result, styleSheet) => {
|
|
39
|
-
let rules: CSSRuleList | undefined = undefined;
|
|
40
|
-
try {
|
|
41
|
-
rules = styleSheet.cssRules;
|
|
42
|
-
} catch (e) {
|
|
43
|
-
// styleSheet.cssRules can throw security exception
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
return [
|
|
48
|
-
...result,
|
|
49
|
-
{
|
|
50
|
-
href: styleSheet.href,
|
|
51
|
-
type: styleSheet.type,
|
|
52
|
-
rules: rules ? Array.from(rules).map(rule => rule.cssText) : null,
|
|
53
|
-
}
|
|
54
|
-
];
|
|
55
|
-
} catch (e) {
|
|
56
|
-
return result;
|
|
57
|
-
}
|
|
58
|
-
}, [] as IStyleSheet[]);
|
|
59
|
-
popoutWindow.current = window.open(url, id, `left=${r.x},top=${r.y},width=${r.width},height=${r.height}`);
|
|
60
|
-
if (popoutWindow.current !== null) {
|
|
61
|
-
onSetWindow(id, popoutWindow.current);
|
|
62
|
-
|
|
63
|
-
// listen for parent unloading to remove all popouts
|
|
64
|
-
window.addEventListener("beforeunload", () => {
|
|
65
|
-
if (popoutWindow.current) {
|
|
66
|
-
popoutWindow.current.close();
|
|
67
|
-
popoutWindow.current = null;
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
popoutWindow.current.addEventListener("load", () => {
|
|
72
|
-
if (isMounted) {
|
|
73
|
-
const popoutDocument = popoutWindow.current!.document;
|
|
74
|
-
popoutDocument.title = title;
|
|
75
|
-
const popoutContent = popoutDocument.createElement("div");
|
|
76
|
-
popoutContent.className = CLASSES.FLEXLAYOUT__FLOATING_WINDOW_CONTENT;
|
|
77
|
-
popoutDocument.body.appendChild(popoutContent);
|
|
78
|
-
copyStyles(popoutDocument, styles).then(() => {
|
|
79
|
-
setContent(popoutContent);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
// listen for popout unloading (needs to be after load for safari)
|
|
83
|
-
popoutWindow.current!.addEventListener("beforeunload", () => {
|
|
84
|
-
onCloseWindow(id);
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
} else {
|
|
89
|
-
console.warn(`Unable to open window ${url}`);
|
|
90
|
-
onCloseWindow(id);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return () => {
|
|
94
|
-
isMounted = false;
|
|
95
|
-
// delay so refresh will close window
|
|
96
|
-
timerId.current = setTimeout(() => {
|
|
97
|
-
if (popoutWindow.current) {
|
|
98
|
-
popoutWindow.current.close();
|
|
99
|
-
popoutWindow.current = null;
|
|
100
|
-
}
|
|
101
|
-
}, 0);
|
|
102
|
-
};
|
|
103
|
-
}, []);
|
|
104
|
-
|
|
105
|
-
if (content !== undefined) {
|
|
106
|
-
return createPortal(children, content!);
|
|
107
|
-
} else {
|
|
108
|
-
return null;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
/** @internal */
|
|
113
|
-
function copyStyles(doc: Document, styleSheets: IStyleSheet[]): Promise<boolean[]> {
|
|
114
|
-
const head = doc.head;
|
|
115
|
-
const promises: Promise<boolean>[] = [];
|
|
116
|
-
for (const styleSheet of styleSheets) {
|
|
117
|
-
if (styleSheet.href) {
|
|
118
|
-
// prefer links since they will keep paths to images etc
|
|
119
|
-
const styleElement = doc.createElement("link");
|
|
120
|
-
styleElement.type = styleSheet.type;
|
|
121
|
-
styleElement.rel = "stylesheet";
|
|
122
|
-
styleElement.href = styleSheet.href!;
|
|
123
|
-
head.appendChild(styleElement);
|
|
124
|
-
promises.push(
|
|
125
|
-
new Promise((resolve) => {
|
|
126
|
-
styleElement.onload = () => resolve(true);
|
|
127
|
-
})
|
|
128
|
-
);
|
|
129
|
-
} else {
|
|
130
|
-
if (styleSheet.rules) {
|
|
131
|
-
const style = doc.createElement("style");
|
|
132
|
-
for (const rule of styleSheet.rules) {
|
|
133
|
-
style.appendChild(doc.createTextNode(rule));
|
|
134
|
-
}
|
|
135
|
-
head.appendChild(style);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return Promise.all(promises);
|
|
140
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { TabNode } from "../model/TabNode";
|
|
3
|
-
import { ILayoutCallbacks } from "./Layout";
|
|
4
|
-
import { ErrorBoundary } from "./ErrorBoundary";
|
|
5
|
-
import { I18nLabel } from "../I18nLabel";
|
|
6
|
-
import { Fragment } from "react";
|
|
7
|
-
import { CLASSES } from "../Types";
|
|
8
|
-
|
|
9
|
-
/** @internal */
|
|
10
|
-
export interface IFloatingWindowTabProps {
|
|
11
|
-
layout: ILayoutCallbacks;
|
|
12
|
-
node: TabNode;
|
|
13
|
-
factory: (node: TabNode) => React.ReactNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export const FloatingWindowTab = (props: IFloatingWindowTabProps) => {
|
|
18
|
-
const { layout, node, factory } = props;
|
|
19
|
-
const cm = layout.getClassName;
|
|
20
|
-
const child = factory(node);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className={cm(CLASSES.FLEXLAYOUT__FLOATING_WINDOW_TAB)}>
|
|
24
|
-
<ErrorBoundary message={props.layout.i18nName(I18nLabel.Error_rendering_component)}>
|
|
25
|
-
<Fragment>{child}</Fragment>
|
|
26
|
-
</ErrorBoundary>
|
|
27
|
-
</div>
|
|
28
|
-
);
|
|
29
|
-
};
|
package/src/view/TabFloating.tsx
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Actions } from "../model/Actions";
|
|
3
|
-
import { TabNode } from "../model/TabNode";
|
|
4
|
-
import { TabSetNode } from "../model/TabSetNode";
|
|
5
|
-
import { CLASSES } from "../Types";
|
|
6
|
-
import { ILayoutCallbacks } from "./Layout";
|
|
7
|
-
import { I18nLabel } from "../I18nLabel";
|
|
8
|
-
import { hideElement } from "./Utils";
|
|
9
|
-
import { BorderNode } from "../model/BorderNode";
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export interface ITabFloatingProps {
|
|
13
|
-
layout: ILayoutCallbacks;
|
|
14
|
-
selected: boolean;
|
|
15
|
-
node: TabNode;
|
|
16
|
-
path: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** @internal */
|
|
20
|
-
export const TabFloating = (props: ITabFloatingProps) => {
|
|
21
|
-
const { layout, selected, node, path } = props;
|
|
22
|
-
|
|
23
|
-
const showPopout = () => {
|
|
24
|
-
if (node.getWindow()) {
|
|
25
|
-
node.getWindow()!.focus();
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const dockPopout = () => {
|
|
30
|
-
layout.doAction(Actions.unFloatTab(node.getId()));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const onMouseDown = () => {
|
|
34
|
-
const parent = node.getParent() as TabSetNode;
|
|
35
|
-
if (parent.getType() === TabSetNode.TYPE) {
|
|
36
|
-
if (!parent.isActive()) {
|
|
37
|
-
layout.doAction(Actions.setActiveTabset(parent.getId()));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const onClickFocus = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
|
43
|
-
event.preventDefault();
|
|
44
|
-
showPopout();
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const onClickDock = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
dockPopout();
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const cm = layout.getClassName;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const parentNode = node.getParent() as TabSetNode | BorderNode;
|
|
56
|
-
const style: Record<string, any> = node._styleWithPosition();
|
|
57
|
-
if (!selected) {
|
|
58
|
-
hideElement(style, node.getModel().isUseVisibility());
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (parentNode instanceof TabSetNode) {
|
|
62
|
-
if (node.getModel().getMaximizedTabset() !== undefined && !parentNode.isMaximized()) {
|
|
63
|
-
hideElement(style, node.getModel().isUseVisibility());
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const message = layout.i18nName(I18nLabel.Floating_Window_Message);
|
|
68
|
-
const showMessage = layout.i18nName(I18nLabel.Floating_Window_Show_Window);
|
|
69
|
-
const dockMessage = layout.i18nName(I18nLabel.Floating_Window_Dock_Window);
|
|
70
|
-
|
|
71
|
-
const customRenderCallback = layout.getOnRenderFloatingTabPlaceholder();
|
|
72
|
-
if (customRenderCallback) {
|
|
73
|
-
return (
|
|
74
|
-
<div className={cm(CLASSES.FLEXLAYOUT__TAB_FLOATING)} onMouseDown={onMouseDown} onTouchStart={onMouseDown} style={style}>
|
|
75
|
-
{customRenderCallback(dockPopout, showPopout)}
|
|
76
|
-
</div>
|
|
77
|
-
);
|
|
78
|
-
} else {
|
|
79
|
-
return (
|
|
80
|
-
<div className={cm(CLASSES.FLEXLAYOUT__TAB_FLOATING)}
|
|
81
|
-
data-layout-path={path}
|
|
82
|
-
onMouseDown={onMouseDown}
|
|
83
|
-
onTouchStart={onMouseDown}
|
|
84
|
-
style={style}>
|
|
85
|
-
<div className={cm(CLASSES.FLEXLAYOUT__TAB_FLOATING_INNER)}>
|
|
86
|
-
<div>{message}</div>
|
|
87
|
-
<div>
|
|
88
|
-
<a href="#" onClick={onClickFocus}>
|
|
89
|
-
{showMessage}
|
|
90
|
-
</a>
|
|
91
|
-
</div>
|
|
92
|
-
<div>
|
|
93
|
-
<a href="#" onClick={onClickDock}>
|
|
94
|
-
{dockMessage}
|
|
95
|
-
</a>
|
|
96
|
-
</div>
|
|
97
|
-
</div>
|
|
98
|
-
</div>
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
};
|