flexlayout-react 0.8.12 → 0.8.14
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/README.md +16 -5
- package/declarations/Attribute.d.ts +25 -1
- package/declarations/AttributeDefinitions.d.ts +18 -1
- package/declarations/DockLocation.d.ts +22 -0
- package/declarations/I18nLabel.d.ts +2 -1
- package/declarations/Orientation.d.ts +4 -0
- package/declarations/Rect.d.ts +3 -0
- package/declarations/index.d.ts +1 -0
- package/declarations/model/BorderNode.d.ts +53 -0
- package/declarations/model/BorderSet.d.ts +28 -0
- package/declarations/model/IDraggable.d.ts +4 -0
- package/declarations/model/IDropTarget.d.ts +10 -0
- package/declarations/model/LayoutWindow.d.ts +16 -0
- package/declarations/model/Model.d.ts +55 -0
- package/declarations/model/Node.d.ts +61 -0
- package/declarations/model/RowNode.d.ts +67 -0
- package/declarations/model/TabNode.d.ts +79 -0
- package/declarations/model/TabSetNode.d.ts +60 -0
- package/declarations/model/Utils.d.ts +8 -0
- package/declarations/view/BorderButton.d.ts +13 -1
- package/declarations/view/BorderTab.d.ts +8 -0
- package/declarations/view/BorderTabSet.d.ts +10 -1
- package/declarations/view/DragContainer.d.ts +9 -1
- package/declarations/view/ErrorBoundary.d.ts +22 -1
- package/declarations/view/Icons.d.ts +1 -0
- package/declarations/view/Layout.d.ts +143 -1
- package/declarations/view/Overlay.d.ts +8 -1
- package/declarations/view/PopoutWindow.d.ts +14 -1
- package/declarations/view/PopupMenu.d.ts +12 -1
- package/declarations/view/Row.d.ts +9 -1
- package/declarations/view/Splitter.d.ts +14 -1
- package/declarations/view/Tab.d.ts +11 -1
- package/declarations/view/TabButton.d.ts +11 -1
- package/declarations/view/TabButtonStamp.d.ts +9 -1
- package/declarations/view/TabOverflowHook.d.ts +16 -1
- package/declarations/view/TabSet.d.ts +9 -1
- package/declarations/view/Utils.d.ts +13 -0
- package/lib/index.js +6410 -22
- package/package.json +35 -26
- package/ChangeLog.txt +0 -372
- package/declarations/DragDrop.d.ts +0 -15
- package/declarations/PopupMenu.d.ts +0 -1
- package/declarations/model/SplitterNode.d.ts +0 -5
- package/declarations/model/WindowLayout.d.ts +0 -24
- package/declarations/src/Attribute.d.ts +0 -1
- package/declarations/src/AttributeDefinitions.d.ts +0 -1
- package/declarations/src/DockLocation.d.ts +0 -12
- package/declarations/src/DropInfo.d.ts +0 -12
- package/declarations/src/I18nLabel.d.ts +0 -10
- package/declarations/src/Orientation.d.ts +0 -7
- package/declarations/src/PopupMenu.d.ts +0 -1
- package/declarations/src/Rect.d.ts +0 -31
- package/declarations/src/Types.d.ts +0 -92
- package/declarations/src/index.d.ts +0 -20
- package/declarations/src/model/Action.d.ts +0 -5
- package/declarations/src/model/Actions.d.ts +0 -110
- package/declarations/src/model/BorderNode.d.ts +0 -28
- package/declarations/src/model/BorderSet.d.ts +0 -3
- package/declarations/src/model/ICloseType.d.ts +0 -5
- package/declarations/src/model/IDraggable.d.ts +0 -2
- package/declarations/src/model/IDropTarget.d.ts +0 -2
- package/declarations/src/model/IJsonModel.d.ts +0 -153
- package/declarations/src/model/Model.d.ts +0 -98
- package/declarations/src/model/Node.d.ts +0 -16
- package/declarations/src/model/RowNode.d.ts +0 -11
- package/declarations/src/model/TabNode.d.ts +0 -36
- package/declarations/src/model/TabSetNode.d.ts +0 -37
- package/declarations/src/model/Utils.d.ts +0 -1
- package/declarations/src/view/BorderButton.d.ts +0 -1
- package/declarations/src/view/BorderTab.d.ts +0 -2
- package/declarations/src/view/BorderTabSet.d.ts +0 -1
- package/declarations/src/view/DragContainer.d.ts +0 -1
- package/declarations/src/view/ErrorBoundary.d.ts +0 -1
- package/declarations/src/view/FloatingWindow.d.ts +0 -1
- package/declarations/src/view/Icons.d.ts +0 -7
- package/declarations/src/view/Layout.d.ts +0 -113
- package/declarations/src/view/Overlay.d.ts +0 -1
- package/declarations/src/view/PopupMenu.d.ts +0 -1
- package/declarations/src/view/Row.d.ts +0 -1
- package/declarations/src/view/Splitter.d.ts +0 -1
- package/declarations/src/view/Tab.d.ts +0 -1
- package/declarations/src/view/TabButton.d.ts +0 -1
- package/declarations/src/view/TabButtonStamp.d.ts +0 -1
- package/declarations/src/view/TabOverflowHook.d.ts +0 -1
- package/declarations/src/view/TabSet.d.ts +0 -1
- package/declarations/src/view/Utils.d.ts +0 -4
- package/declarations/view/ExtendedResizeObserver.d.ts +0 -23
- package/declarations/view/FloatingWindow.d.ts +0 -1
- package/declarations/view/FloatingWindowTab.d.ts +0 -1
- package/declarations/view/TabFloating.d.ts +0 -1
- package/dist/flexlayout.js +0 -610
- package/dist/flexlayout_min.js +0 -2
- package/dist/flexlayout_min.js.LICENSE.txt +0 -29
- package/dist/src/Attribute.js +0 -43
- package/dist/src/Attribute.js.map +0 -1
- package/dist/src/AttributeDefinitions.js +0 -132
- package/dist/src/AttributeDefinitions.js.map +0 -1
- package/dist/src/DockLocation.js +0 -121
- package/dist/src/DockLocation.js.map +0 -1
- package/dist/src/DropInfo.js +0 -10
- package/dist/src/DropInfo.js.map +0 -1
- package/dist/src/I18nLabel.js +0 -14
- package/dist/src/I18nLabel.js.map +0 -1
- package/dist/src/Orientation.js +0 -23
- package/dist/src/Orientation.js.map +0 -1
- package/dist/src/Rect.js +0 -111
- package/dist/src/Rect.js.map +0 -1
- package/dist/src/Types.js +0 -95
- package/dist/src/Types.js.map +0 -1
- package/dist/src/index.js +0 -22
- package/dist/src/index.js.map +0 -1
- package/dist/src/model/Action.js +0 -7
- package/dist/src/model/Action.js.map +0 -1
- package/dist/src/model/Actions.js +0 -170
- package/dist/src/model/Actions.js.map +0 -1
- package/dist/src/model/BorderNode.js +0 -390
- package/dist/src/model/BorderNode.js.map +0 -1
- package/dist/src/model/BorderSet.js +0 -67
- package/dist/src/model/BorderSet.js.map +0 -1
- package/dist/src/model/ICloseType.js +0 -7
- package/dist/src/model/ICloseType.js.map +0 -1
- package/dist/src/model/IDraggable.js +0 -2
- package/dist/src/model/IDraggable.js.map +0 -1
- package/dist/src/model/IDropTarget.js +0 -2
- package/dist/src/model/IDropTarget.js.map +0 -1
- package/dist/src/model/IJsonModel.js +0 -2
- package/dist/src/model/IJsonModel.js.map +0 -1
- package/dist/src/model/LayoutWindow.js +0 -81
- package/dist/src/model/LayoutWindow.js.map +0 -1
- package/dist/src/model/Model.js +0 -608
- package/dist/src/model/Model.js.map +0 -1
- package/dist/src/model/Node.js +0 -218
- package/dist/src/model/Node.js.map +0 -1
- package/dist/src/model/RowNode.js +0 -492
- package/dist/src/model/RowNode.js.map +0 -1
- package/dist/src/model/TabNode.js +0 -293
- package/dist/src/model/TabNode.js.map +0 -1
- package/dist/src/model/TabSetNode.js +0 -469
- package/dist/src/model/TabSetNode.js.map +0 -1
- package/dist/src/model/Utils.js +0 -48
- package/dist/src/model/Utils.js.map +0 -1
- package/dist/src/view/BorderButton.js +0 -126
- package/dist/src/view/BorderButton.js.map +0 -1
- package/dist/src/view/BorderTab.js +0 -44
- package/dist/src/view/BorderTab.js.map +0 -1
- package/dist/src/view/BorderTabSet.js +0 -138
- package/dist/src/view/BorderTabSet.js.map +0 -1
- package/dist/src/view/DragContainer.js +0 -16
- package/dist/src/view/DragContainer.js.map +0 -1
- package/dist/src/view/ErrorBoundary.js +0 -24
- package/dist/src/view/ErrorBoundary.js.map +0 -1
- package/dist/src/view/Icons.js +0 -29
- package/dist/src/view/Icons.js.map +0 -1
- package/dist/src/view/Layout.js +0 -881
- package/dist/src/view/Layout.js.map +0 -1
- package/dist/src/view/Overlay.js +0 -9
- package/dist/src/view/Overlay.js.map +0 -1
- package/dist/src/view/PopoutWindow.js +0 -129
- package/dist/src/view/PopoutWindow.js.map +0 -1
- package/dist/src/view/PopupMenu.js +0 -89
- package/dist/src/view/PopupMenu.js.map +0 -1
- package/dist/src/view/Row.js +0 -46
- package/dist/src/view/Row.js.map +0 -1
- package/dist/src/view/SizeTracker.js +0 -12
- package/dist/src/view/SizeTracker.js.map +0 -1
- package/dist/src/view/Splitter.js +0 -192
- package/dist/src/view/Splitter.js.map +0 -1
- package/dist/src/view/Tab.js +0 -91
- package/dist/src/view/Tab.js.map +0 -1
- package/dist/src/view/TabButton.js +0 -124
- package/dist/src/view/TabButton.js.map +0 -1
- package/dist/src/view/TabButtonStamp.js +0 -15
- package/dist/src/view/TabButtonStamp.js.map +0 -1
- package/dist/src/view/TabOverflowHook.js +0 -266
- package/dist/src/view/TabOverflowHook.js.map +0 -1
- package/dist/src/view/TabSet.js +0 -256
- package/dist/src/view/TabSet.js.map +0 -1
- package/dist/src/view/Utils.js +0 -110
- package/dist/src/view/Utils.js.map +0 -1
- package/lib/Attribute.js +0 -43
- package/lib/Attribute.js.map +0 -1
- package/lib/AttributeDefinitions.js +0 -132
- package/lib/AttributeDefinitions.js.map +0 -1
- package/lib/DockLocation.js +0 -121
- package/lib/DockLocation.js.map +0 -1
- package/lib/DropInfo.js +0 -10
- package/lib/DropInfo.js.map +0 -1
- package/lib/I18nLabel.js +0 -14
- package/lib/I18nLabel.js.map +0 -1
- package/lib/Orientation.js +0 -23
- package/lib/Orientation.js.map +0 -1
- package/lib/Rect.js +0 -111
- package/lib/Rect.js.map +0 -1
- package/lib/Types.js +0 -95
- package/lib/Types.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/model/Action.js +0 -7
- package/lib/model/Action.js.map +0 -1
- package/lib/model/Actions.js +0 -170
- package/lib/model/Actions.js.map +0 -1
- package/lib/model/BorderNode.js +0 -390
- package/lib/model/BorderNode.js.map +0 -1
- package/lib/model/BorderSet.js +0 -67
- package/lib/model/BorderSet.js.map +0 -1
- package/lib/model/ICloseType.js +0 -7
- package/lib/model/ICloseType.js.map +0 -1
- package/lib/model/IDraggable.js +0 -2
- package/lib/model/IDraggable.js.map +0 -1
- package/lib/model/IDropTarget.js +0 -2
- package/lib/model/IDropTarget.js.map +0 -1
- package/lib/model/IJsonModel.js +0 -2
- package/lib/model/IJsonModel.js.map +0 -1
- package/lib/model/LayoutWindow.js +0 -81
- package/lib/model/LayoutWindow.js.map +0 -1
- package/lib/model/Model.js +0 -608
- package/lib/model/Model.js.map +0 -1
- package/lib/model/Node.js +0 -218
- package/lib/model/Node.js.map +0 -1
- package/lib/model/RowNode.js +0 -492
- package/lib/model/RowNode.js.map +0 -1
- package/lib/model/TabNode.js +0 -293
- package/lib/model/TabNode.js.map +0 -1
- package/lib/model/TabSetNode.js +0 -469
- package/lib/model/TabSetNode.js.map +0 -1
- package/lib/model/Utils.js +0 -48
- package/lib/model/Utils.js.map +0 -1
- package/lib/view/BorderButton.js +0 -126
- package/lib/view/BorderButton.js.map +0 -1
- package/lib/view/BorderTab.js +0 -56
- package/lib/view/BorderTab.js.map +0 -1
- package/lib/view/BorderTabSet.js +0 -138
- package/lib/view/BorderTabSet.js.map +0 -1
- package/lib/view/DragContainer.js +0 -16
- package/lib/view/DragContainer.js.map +0 -1
- package/lib/view/ErrorBoundary.js +0 -24
- package/lib/view/ErrorBoundary.js.map +0 -1
- package/lib/view/Icons.js +0 -29
- package/lib/view/Icons.js.map +0 -1
- package/lib/view/Layout.js +0 -881
- package/lib/view/Layout.js.map +0 -1
- package/lib/view/Overlay.js +0 -9
- package/lib/view/Overlay.js.map +0 -1
- package/lib/view/PopoutWindow.js +0 -129
- package/lib/view/PopoutWindow.js.map +0 -1
- package/lib/view/PopupMenu.js +0 -89
- package/lib/view/PopupMenu.js.map +0 -1
- package/lib/view/Row.js +0 -46
- package/lib/view/Row.js.map +0 -1
- package/lib/view/SizeTracker.js +0 -12
- package/lib/view/SizeTracker.js.map +0 -1
- package/lib/view/Splitter.js +0 -197
- package/lib/view/Splitter.js.map +0 -1
- package/lib/view/Tab.js +0 -91
- package/lib/view/Tab.js.map +0 -1
- package/lib/view/TabButton.js +0 -124
- package/lib/view/TabButton.js.map +0 -1
- package/lib/view/TabButtonStamp.js +0 -15
- package/lib/view/TabButtonStamp.js.map +0 -1
- package/lib/view/TabOverflowHook.js +0 -266
- package/lib/view/TabOverflowHook.js.map +0 -1
- package/lib/view/TabSet.js +0 -269
- package/lib/view/TabSet.js.map +0 -1
- package/lib/view/Utils.js +0 -110
- package/lib/view/Utils.js.map +0 -1
- package/src/Attribute.ts +0 -64
- package/src/AttributeDefinitions.ts +0 -144
- package/src/DockLocation.ts +0 -133
- package/src/DropInfo.ts +0 -20
- package/src/I18nLabel.ts +0 -12
- package/src/Orientation.ts +0 -28
- package/src/Rect.ts +0 -147
- package/src/Types.ts +0 -112
- package/src/index.ts +0 -23
- package/src/model/Action.ts +0 -9
- package/src/model/Actions.ts +0 -188
- package/src/model/BorderNode.ts +0 -458
- package/src/model/BorderSet.ts +0 -87
- package/src/model/ICloseType.ts +0 -5
- package/src/model/IDraggable.ts +0 -7
- package/src/model/IDropTarget.ts +0 -14
- package/src/model/IJsonModel.ts +0 -967
- package/src/model/LayoutWindow.ts +0 -119
- package/src/model/Model.ts +0 -704
- package/src/model/Node.ts +0 -280
- package/src/model/RowNode.ts +0 -559
- package/src/model/TabNode.ts +0 -424
- package/src/model/TabSetNode.ts +0 -592
- package/src/model/Utils.ts +0 -52
- package/src/view/BorderButton.tsx +0 -201
- package/src/view/BorderTab.tsx +0 -81
- package/src/view/BorderTabSet.tsx +0 -259
- package/src/view/DragContainer.tsx +0 -32
- package/src/view/ErrorBoundary.tsx +0 -42
- package/src/view/Icons.tsx +0 -57
- package/src/view/Layout.tsx +0 -1334
- package/src/view/Overlay.tsx +0 -21
- package/src/view/PopoutWindow.tsx +0 -152
- package/src/view/PopupMenu.tsx +0 -156
- package/src/view/Row.tsx +0 -68
- package/src/view/SizeTracker.tsx +0 -20
- package/src/view/Splitter.tsx +0 -262
- package/src/view/Tab.tsx +0 -128
- package/src/view/TabButton.tsx +0 -200
- package/src/view/TabButtonStamp.tsx +0 -42
- package/src/view/TabOverflowHook.tsx +0 -305
- package/src/view/TabSet.tsx +0 -475
- package/src/view/Utils.tsx +0 -135
package/src/view/Overlay.tsx
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { LayoutInternal } from "./Layout";
|
|
2
|
-
import { CLASSES } from "../Types";
|
|
3
|
-
|
|
4
|
-
/** @internal */
|
|
5
|
-
export interface IOverlayProps {
|
|
6
|
-
layout: LayoutInternal;
|
|
7
|
-
show: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/** @internal */
|
|
11
|
-
export const Overlay = (props: IOverlayProps) => {
|
|
12
|
-
const {layout, show} = props;
|
|
13
|
-
|
|
14
|
-
return (
|
|
15
|
-
<div
|
|
16
|
-
className={layout.getClassName(CLASSES.FLEXLAYOUT__LAYOUT_OVERLAY)}
|
|
17
|
-
style={{display: (show ? "flex" : "none")
|
|
18
|
-
}}
|
|
19
|
-
/>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { createPortal } from "react-dom";
|
|
3
|
-
import { CLASSES } from "../Types";
|
|
4
|
-
import { LayoutInternal } from "./Layout";
|
|
5
|
-
import { LayoutWindow } from "../model/LayoutWindow";
|
|
6
|
-
|
|
7
|
-
/** @internal */
|
|
8
|
-
export interface IPopoutWindowProps {
|
|
9
|
-
title: string;
|
|
10
|
-
layout: LayoutInternal;
|
|
11
|
-
layoutWindow: LayoutWindow;
|
|
12
|
-
url: string;
|
|
13
|
-
onCloseWindow: (layoutWindow: LayoutWindow) => void;
|
|
14
|
-
onSetWindow: (layoutWindow: LayoutWindow, window: Window) => void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @internal */
|
|
18
|
-
export const PopoutWindow = (props: React.PropsWithChildren<IPopoutWindowProps>) => {
|
|
19
|
-
const { title, layout, layoutWindow, url, onCloseWindow, onSetWindow, children } = props; const popoutWindow = React.useRef<Window | null>(null);
|
|
20
|
-
const [content, setContent] = React.useState<HTMLElement | undefined>(undefined);
|
|
21
|
-
// map from main docs style -> this docs equivalent style
|
|
22
|
-
const styleMap = new Map<HTMLElement, HTMLElement>();
|
|
23
|
-
|
|
24
|
-
React.useLayoutEffect(() => {
|
|
25
|
-
if (!popoutWindow.current) { // only create window once, even in strict mode
|
|
26
|
-
const windowId = layoutWindow.windowId;
|
|
27
|
-
const rect = layoutWindow.rect;
|
|
28
|
-
|
|
29
|
-
popoutWindow.current = window.open(url, windowId, `left=${rect.x},top=${rect.y},width=${rect.width},height=${rect.height}`);
|
|
30
|
-
|
|
31
|
-
if (popoutWindow.current) {
|
|
32
|
-
layoutWindow.window = popoutWindow.current;
|
|
33
|
-
onSetWindow(layoutWindow, popoutWindow.current);
|
|
34
|
-
|
|
35
|
-
// listen for parent unloading to remove all popouts
|
|
36
|
-
window.addEventListener("beforeunload", () => {
|
|
37
|
-
if (popoutWindow.current) {
|
|
38
|
-
const closedWindow = popoutWindow.current;
|
|
39
|
-
popoutWindow.current = null; // need to set to null before close, since this will trigger popup window before unload...
|
|
40
|
-
closedWindow.close();
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
popoutWindow.current.addEventListener("load", () => {
|
|
45
|
-
if (popoutWindow.current) {
|
|
46
|
-
popoutWindow.current.focus();
|
|
47
|
-
|
|
48
|
-
// note: resizeto must be before moveto in chrome otherwise the window will end up at 0,0
|
|
49
|
-
popoutWindow.current.resizeTo(rect.width, rect.height);
|
|
50
|
-
popoutWindow.current.moveTo(rect.x, rect.y);
|
|
51
|
-
|
|
52
|
-
const popoutDocument = popoutWindow.current.document;
|
|
53
|
-
popoutDocument.title = title;
|
|
54
|
-
const popoutContent = popoutDocument.createElement("div");
|
|
55
|
-
popoutContent.className = CLASSES.FLEXLAYOUT__FLOATING_WINDOW_CONTENT;
|
|
56
|
-
popoutDocument.body.appendChild(popoutContent);
|
|
57
|
-
copyStyles(popoutDocument, styleMap).then(() => {
|
|
58
|
-
setContent(popoutContent); // re-render once link styles loaded
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
// listen for style mutations
|
|
62
|
-
const observer = new MutationObserver((mutationsList: any) => handleStyleMutations(mutationsList, popoutDocument, styleMap));
|
|
63
|
-
observer.observe(document.head, { childList: true });
|
|
64
|
-
|
|
65
|
-
// listen for popout unloading (needs to be after load for safari)
|
|
66
|
-
popoutWindow.current.addEventListener("beforeunload", () => {
|
|
67
|
-
if (popoutWindow.current) {
|
|
68
|
-
onCloseWindow(layoutWindow); // remove the layoutWindow in the model
|
|
69
|
-
popoutWindow.current = null;
|
|
70
|
-
observer.disconnect();
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
} else {
|
|
76
|
-
console.warn(`Unable to open window ${url}`);
|
|
77
|
-
onCloseWindow(layoutWindow); // remove the layoutWindow in the model
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
return () => {
|
|
81
|
-
// only close popoutWindow if windowId has been removed from the model (ie this was due to model change)
|
|
82
|
-
if (!layout.getModel().getwindowsMap().has(layoutWindow.windowId)) {
|
|
83
|
-
popoutWindow.current?.close();
|
|
84
|
-
popoutWindow.current = null;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}, []);
|
|
88
|
-
|
|
89
|
-
if (content !== undefined) {
|
|
90
|
-
return createPortal(children, content!);
|
|
91
|
-
} else {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
function handleStyleMutations(mutationsList: any, popoutDocument: Document, styleMap: Map<HTMLElement, HTMLElement>) {
|
|
97
|
-
for (const mutation of mutationsList) {
|
|
98
|
-
if (mutation.type === 'childList') {
|
|
99
|
-
for (const addition of mutation.addedNodes) {
|
|
100
|
-
if (addition instanceof HTMLLinkElement || addition instanceof HTMLStyleElement) {
|
|
101
|
-
copyStyle(popoutDocument, addition, styleMap);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
for (const removal of mutation.removedNodes) {
|
|
105
|
-
if (removal instanceof HTMLLinkElement || removal instanceof HTMLStyleElement) {
|
|
106
|
-
const popoutStyle = styleMap.get(removal);
|
|
107
|
-
if (popoutStyle) {
|
|
108
|
-
popoutDocument.head.removeChild(popoutStyle);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
/** @internal */
|
|
119
|
-
function copyStyles(popoutDoc: Document, styleMap: Map<HTMLElement, HTMLElement>): Promise<boolean[]> {
|
|
120
|
-
const promises: Promise<boolean>[] = [];
|
|
121
|
-
const styleElements = document.querySelectorAll('style, link[rel="stylesheet"]') as NodeListOf<HTMLElement>
|
|
122
|
-
for (const element of styleElements) {
|
|
123
|
-
copyStyle(popoutDoc, element, styleMap, promises);
|
|
124
|
-
}
|
|
125
|
-
return Promise.all(promises);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/** @internal */
|
|
129
|
-
function copyStyle(popoutDoc: Document, element: HTMLElement, styleMap: Map<HTMLElement, HTMLElement>, promises?: Promise<boolean>[]) {
|
|
130
|
-
if (element instanceof HTMLLinkElement) {
|
|
131
|
-
// prefer links since they will keep paths to images etc
|
|
132
|
-
const linkElement = element.cloneNode(true) as HTMLLinkElement;
|
|
133
|
-
popoutDoc.head.appendChild(linkElement);
|
|
134
|
-
styleMap.set(element, linkElement);
|
|
135
|
-
|
|
136
|
-
if (promises) {
|
|
137
|
-
promises.push(new Promise((resolve) => {
|
|
138
|
-
linkElement.onload = () => resolve(true);
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
} else if (element instanceof HTMLStyleElement) {
|
|
142
|
-
try {
|
|
143
|
-
const styleElement = element.cloneNode(true) as HTMLStyleElement;
|
|
144
|
-
popoutDoc.head.appendChild(styleElement);
|
|
145
|
-
styleMap.set(element, styleElement);
|
|
146
|
-
} catch (e) {
|
|
147
|
-
// can throw an exception
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
|
package/src/view/PopupMenu.tsx
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { TabNode } from "../model/TabNode";
|
|
3
|
-
import { CLASSES } from "../Types";
|
|
4
|
-
import { LayoutInternal } from "./Layout";
|
|
5
|
-
import { TabButtonStamp } from "./TabButtonStamp";
|
|
6
|
-
import { TabSetNode } from "../model/TabSetNode";
|
|
7
|
-
import { BorderNode } from "../model/BorderNode";
|
|
8
|
-
import { useEffect, useRef } from "react";
|
|
9
|
-
|
|
10
|
-
/** @internal */
|
|
11
|
-
export function showPopup(
|
|
12
|
-
triggerElement: Element,
|
|
13
|
-
parentNode: TabSetNode | BorderNode,
|
|
14
|
-
items: { index: number; node: TabNode }[],
|
|
15
|
-
onSelect: (item: { index: number; node: TabNode }) => void,
|
|
16
|
-
layout: LayoutInternal,
|
|
17
|
-
) {
|
|
18
|
-
const layoutDiv = layout.getRootDiv();
|
|
19
|
-
const classNameMapper = layout.getClassName;
|
|
20
|
-
const currentDocument = triggerElement.ownerDocument;
|
|
21
|
-
const triggerRect = triggerElement.getBoundingClientRect();
|
|
22
|
-
const layoutRect = layoutDiv?.getBoundingClientRect() ?? new DOMRect(0, 0, 100, 100);
|
|
23
|
-
|
|
24
|
-
const elm = currentDocument.createElement("div");
|
|
25
|
-
elm.className = classNameMapper(CLASSES.FLEXLAYOUT__POPUP_MENU_CONTAINER);
|
|
26
|
-
if (triggerRect.left < layoutRect.left + layoutRect.width / 2) {
|
|
27
|
-
elm.style.left = triggerRect.left - layoutRect.left + "px";
|
|
28
|
-
} else {
|
|
29
|
-
elm.style.right = layoutRect.right - triggerRect.right + "px";
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (triggerRect.top < layoutRect.top + layoutRect.height / 2) {
|
|
33
|
-
elm.style.top = triggerRect.top - layoutRect.top + "px";
|
|
34
|
-
} else {
|
|
35
|
-
elm.style.bottom = layoutRect.bottom - triggerRect.bottom + "px";
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
layout.showOverlay(true);
|
|
39
|
-
|
|
40
|
-
if (layoutDiv) {
|
|
41
|
-
layoutDiv.appendChild(elm);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const onHide = () => {
|
|
45
|
-
layout.hideControlInPortal();
|
|
46
|
-
layout.showOverlay(false);
|
|
47
|
-
if (layoutDiv) {
|
|
48
|
-
layoutDiv.removeChild(elm);
|
|
49
|
-
}
|
|
50
|
-
elm.removeEventListener("pointerdown", onElementPointerDown);
|
|
51
|
-
currentDocument.removeEventListener("pointerdown", onDocPointerDown);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
const onElementPointerDown = (event: Event) => {
|
|
55
|
-
event.stopPropagation();
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const onDocPointerDown = (_event: Event) => {
|
|
59
|
-
onHide();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
elm.addEventListener("pointerdown", onElementPointerDown);
|
|
63
|
-
currentDocument.addEventListener("pointerdown", onDocPointerDown);
|
|
64
|
-
|
|
65
|
-
layout.showControlInPortal(<PopupMenu
|
|
66
|
-
currentDocument={currentDocument}
|
|
67
|
-
parentNode={parentNode}
|
|
68
|
-
onSelect={onSelect}
|
|
69
|
-
onHide={onHide}
|
|
70
|
-
items={items}
|
|
71
|
-
classNameMapper={classNameMapper}
|
|
72
|
-
layout={layout}
|
|
73
|
-
/>, elm);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/** @internal */
|
|
77
|
-
interface IPopupMenuProps {
|
|
78
|
-
parentNode: TabSetNode | BorderNode;
|
|
79
|
-
items: { index: number; node: TabNode }[];
|
|
80
|
-
currentDocument: Document;
|
|
81
|
-
onHide: () => void;
|
|
82
|
-
onSelect: (item: { index: number; node: TabNode }) => void;
|
|
83
|
-
classNameMapper: (defaultClassName: string) => string;
|
|
84
|
-
layout: LayoutInternal;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/** @internal */
|
|
88
|
-
const PopupMenu = (props: IPopupMenuProps) => {
|
|
89
|
-
const { parentNode, items, onHide, onSelect, classNameMapper, layout } = props;
|
|
90
|
-
const divRef = useRef<HTMLDivElement>(null);
|
|
91
|
-
|
|
92
|
-
useEffect(() => {
|
|
93
|
-
// Set focus when the component mounts
|
|
94
|
-
if (divRef.current) {
|
|
95
|
-
divRef.current.focus();
|
|
96
|
-
}
|
|
97
|
-
}, []);
|
|
98
|
-
|
|
99
|
-
const onItemClick = (item: { index: number; node: TabNode }, event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
100
|
-
onSelect(item);
|
|
101
|
-
onHide();
|
|
102
|
-
event.stopPropagation();
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const onDragStart = (event: React.DragEvent<HTMLElement>, node: TabNode) => {
|
|
106
|
-
event.stopPropagation(); // prevent starting a tabset drag as well
|
|
107
|
-
layout.setDragNode(event.nativeEvent, node as TabNode);
|
|
108
|
-
setTimeout(() => {
|
|
109
|
-
onHide();
|
|
110
|
-
}, 0);
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
const onDragEnd = (event: React.DragEvent<HTMLElement>) => {
|
|
115
|
-
layout.clearDragMain();
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
const handleKeyDown = (event: React.KeyboardEvent) => {
|
|
119
|
-
if (event.key === "Escape") {
|
|
120
|
-
onHide();
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const itemElements = items.map((item, i) => {
|
|
125
|
-
let classes = classNameMapper(CLASSES.FLEXLAYOUT__POPUP_MENU_ITEM);
|
|
126
|
-
if (parentNode.getSelected() === item.index) {
|
|
127
|
-
classes += " " + classNameMapper(CLASSES.FLEXLAYOUT__POPUP_MENU_ITEM__SELECTED);
|
|
128
|
-
}
|
|
129
|
-
return (
|
|
130
|
-
<div key={item.index}
|
|
131
|
-
className={classes}
|
|
132
|
-
data-layout-path={"/popup-menu/tb" + i}
|
|
133
|
-
onClick={(event) => onItemClick(item, event)}
|
|
134
|
-
draggable={true}
|
|
135
|
-
onDragStart={(e) => onDragStart(e, item.node)}
|
|
136
|
-
onDragEnd={onDragEnd}
|
|
137
|
-
title={item.node.getHelpText()} >
|
|
138
|
-
<TabButtonStamp
|
|
139
|
-
node={item.node}
|
|
140
|
-
layout={layout}
|
|
141
|
-
/>
|
|
142
|
-
</div>
|
|
143
|
-
)
|
|
144
|
-
}
|
|
145
|
-
);
|
|
146
|
-
|
|
147
|
-
return (
|
|
148
|
-
<div className={classNameMapper(CLASSES.FLEXLAYOUT__POPUP_MENU)}
|
|
149
|
-
ref={divRef}
|
|
150
|
-
tabIndex={0} // Make div focusable
|
|
151
|
-
onKeyDown={handleKeyDown}
|
|
152
|
-
data-layout-path="/popup-menu"
|
|
153
|
-
>
|
|
154
|
-
{itemElements}
|
|
155
|
-
</div>);
|
|
156
|
-
};
|
package/src/view/Row.tsx
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { RowNode } from "../model/RowNode";
|
|
3
|
-
import { TabSetNode } from "../model/TabSetNode";
|
|
4
|
-
import { CLASSES } from "../Types";
|
|
5
|
-
import { LayoutInternal } from "./Layout";
|
|
6
|
-
import { TabSet } from "./TabSet";
|
|
7
|
-
import { Splitter } from "./Splitter";
|
|
8
|
-
import { Orientation } from "../Orientation";
|
|
9
|
-
|
|
10
|
-
/** @internal */
|
|
11
|
-
export interface IRowProps {
|
|
12
|
-
layout: LayoutInternal;
|
|
13
|
-
node: RowNode;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/** @internal */
|
|
17
|
-
export const Row = (props: IRowProps) => {
|
|
18
|
-
const { layout, node } = props;
|
|
19
|
-
const selfRef = React.useRef<HTMLDivElement | null>(null);
|
|
20
|
-
|
|
21
|
-
const horizontal = node.getOrientation() === Orientation.HORZ;
|
|
22
|
-
|
|
23
|
-
React.useLayoutEffect(() => {
|
|
24
|
-
node.setRect(layout.getBoundingClientRect(selfRef.current!));
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const items: React.ReactNode[] = [];
|
|
28
|
-
|
|
29
|
-
let i = 0;
|
|
30
|
-
|
|
31
|
-
for (const child of node.getChildren()) {
|
|
32
|
-
if (i > 0) {
|
|
33
|
-
items.push(<Splitter key={"splitter" + i} layout={layout} node={node} index={i} horizontal={horizontal} />)
|
|
34
|
-
}
|
|
35
|
-
if (child instanceof RowNode) {
|
|
36
|
-
items.push(<Row key={child.getId()} layout={layout} node={child} />);
|
|
37
|
-
} else if (child instanceof TabSetNode) {
|
|
38
|
-
items.push(<TabSet key={child.getId()} layout={layout} node={child} />);
|
|
39
|
-
}
|
|
40
|
-
i++;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const style: Record<string, any> = {
|
|
44
|
-
flexGrow: Math.max(1, node.getWeight()*1000), // NOTE: flex-grow cannot have values < 1 otherwise will not fill parent, need to normalize
|
|
45
|
-
minWidth: node.getMinWidth(),
|
|
46
|
-
minHeight: node.getMinHeight(),
|
|
47
|
-
maxWidth: node.getMaxWidth(),
|
|
48
|
-
maxHeight: node.getMaxHeight(),
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
if (horizontal) {
|
|
52
|
-
style.flexDirection = "row";
|
|
53
|
-
} else {
|
|
54
|
-
style.flexDirection = "column";
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return (
|
|
58
|
-
<div
|
|
59
|
-
ref={selfRef}
|
|
60
|
-
className={layout.getClassName(CLASSES.FLEXLAYOUT__ROW)}
|
|
61
|
-
style={style}
|
|
62
|
-
>
|
|
63
|
-
{items}
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
|
package/src/view/SizeTracker.tsx
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Rect } from "../Rect";
|
|
3
|
-
|
|
4
|
-
export interface ISizeTrackerProps {
|
|
5
|
-
rect: Rect;
|
|
6
|
-
selected: boolean;
|
|
7
|
-
forceRevision: number;
|
|
8
|
-
tabsRevision: number;
|
|
9
|
-
children: React.ReactNode;
|
|
10
|
-
}
|
|
11
|
-
// only render if size changed or forceRevision changed or tabsRevision changed
|
|
12
|
-
export const SizeTracker = React.memo(({ children }: ISizeTrackerProps) => {
|
|
13
|
-
return <>{children}</>
|
|
14
|
-
}, (prevProps, nextProps) => {
|
|
15
|
-
return prevProps.rect.equalSize(nextProps.rect) &&
|
|
16
|
-
prevProps.selected === nextProps.selected &&
|
|
17
|
-
prevProps.forceRevision === nextProps.forceRevision &&
|
|
18
|
-
prevProps.tabsRevision === nextProps.tabsRevision
|
|
19
|
-
});
|
|
20
|
-
|
package/src/view/Splitter.tsx
DELETED
|
@@ -1,262 +0,0 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
|
-
import { Actions } from "../model/Actions";
|
|
3
|
-
import { BorderNode } from "../model/BorderNode";
|
|
4
|
-
import { RowNode } from "../model/RowNode";
|
|
5
|
-
import { Orientation } from "../Orientation";
|
|
6
|
-
import { CLASSES } from "../Types";
|
|
7
|
-
import { LayoutInternal } from "./Layout";
|
|
8
|
-
import { enablePointerOnIFrames, isDesktop, startDrag } from "./Utils";
|
|
9
|
-
import { Rect } from "../Rect";
|
|
10
|
-
|
|
11
|
-
/** @internal */
|
|
12
|
-
export interface ISplitterProps {
|
|
13
|
-
layout: LayoutInternal;
|
|
14
|
-
node: RowNode | BorderNode;
|
|
15
|
-
index: number;
|
|
16
|
-
horizontal: boolean;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** @internal */
|
|
20
|
-
export let splitterDragging:boolean = false; // used in tabset & borderTab
|
|
21
|
-
|
|
22
|
-
/** @internal */
|
|
23
|
-
export const Splitter = (props: ISplitterProps) => {
|
|
24
|
-
const { layout, node, index, horizontal } = props;
|
|
25
|
-
|
|
26
|
-
const [dragging, setDragging] = React.useState<boolean>(false);
|
|
27
|
-
const selfRef = React.useRef<HTMLDivElement | null>(null);
|
|
28
|
-
const extendedRef = React.useRef<HTMLDivElement | null>(null);
|
|
29
|
-
const pBounds = React.useRef<number[]>([]);
|
|
30
|
-
const outlineDiv = React.useRef<HTMLDivElement | undefined>(undefined);
|
|
31
|
-
const handleDiv = React.useRef<HTMLDivElement | undefined>(undefined);
|
|
32
|
-
const dragStartX = React.useRef<number>(0);
|
|
33
|
-
const dragStartY = React.useRef<number>(0);
|
|
34
|
-
const initalSizes = React.useRef<{ initialSizes: number[], sum: number, startPosition: number }>({ initialSizes: [], sum: 0, startPosition: 0 })
|
|
35
|
-
// const throttleTimer = React.useRef<NodeJS.Timeout | undefined>(undefined);
|
|
36
|
-
|
|
37
|
-
const size = node.getModel().getSplitterSize();
|
|
38
|
-
let extra = node.getModel().getSplitterExtra();
|
|
39
|
-
|
|
40
|
-
if (!isDesktop()) {
|
|
41
|
-
// make hit test area on mobile at least 20px
|
|
42
|
-
extra = Math.max(20, extra + size) - size;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
React.useEffect(() => {
|
|
46
|
-
// Android fix: must have passive touchstart handler to prevent default handling
|
|
47
|
-
selfRef.current?.addEventListener("touchstart", onTouchStart, { passive: false });
|
|
48
|
-
extendedRef.current?.addEventListener("touchstart", onTouchStart, { passive: false });
|
|
49
|
-
return () => {
|
|
50
|
-
selfRef.current?.removeEventListener("touchstart", onTouchStart);
|
|
51
|
-
extendedRef.current?.removeEventListener("touchstart", onTouchStart);
|
|
52
|
-
}
|
|
53
|
-
}, []);
|
|
54
|
-
|
|
55
|
-
const onTouchStart = (event: TouchEvent) => {
|
|
56
|
-
event.preventDefault();
|
|
57
|
-
event.stopImmediatePropagation();
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const onPointerDown = (event: React.PointerEvent<HTMLElement>) => {
|
|
61
|
-
event.stopPropagation();
|
|
62
|
-
if (node instanceof RowNode) {
|
|
63
|
-
initalSizes.current = node.getSplitterInitials(index);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
enablePointerOnIFrames(false, layout.getCurrentDocument()!);
|
|
67
|
-
startDrag(event.currentTarget.ownerDocument, event, onDragMove, onDragEnd, onDragCancel);
|
|
68
|
-
|
|
69
|
-
pBounds.current = node.getSplitterBounds(index, true);
|
|
70
|
-
const rootdiv = layout.getRootDiv();
|
|
71
|
-
outlineDiv.current = layout.getCurrentDocument()!.createElement("div");
|
|
72
|
-
outlineDiv.current.style.flexDirection = horizontal ? "row" : "column";
|
|
73
|
-
outlineDiv.current.className = layout.getClassName(CLASSES.FLEXLAYOUT__SPLITTER_DRAG);
|
|
74
|
-
outlineDiv.current.style.cursor = node.getOrientation() === Orientation.VERT ? "ns-resize" : "ew-resize";
|
|
75
|
-
|
|
76
|
-
if (node.getModel().isSplitterEnableHandle()) {
|
|
77
|
-
handleDiv.current = layout.getCurrentDocument()!.createElement("div");
|
|
78
|
-
handleDiv.current.className = cm(CLASSES.FLEXLAYOUT__SPLITTER_HANDLE) + " " +
|
|
79
|
-
(horizontal ? cm(CLASSES.FLEXLAYOUT__SPLITTER_HANDLE_HORZ) : cm(CLASSES.FLEXLAYOUT__SPLITTER_HANDLE_VERT));
|
|
80
|
-
outlineDiv.current.appendChild(handleDiv.current);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const r = selfRef.current?.getBoundingClientRect()!;
|
|
84
|
-
const rect = new Rect(
|
|
85
|
-
r.x - layout.getDomRect()!.x,
|
|
86
|
-
r.y - layout.getDomRect()!.y,
|
|
87
|
-
r.width,
|
|
88
|
-
r.height
|
|
89
|
-
);
|
|
90
|
-
|
|
91
|
-
dragStartX.current = event.clientX - r.x;
|
|
92
|
-
dragStartY.current = event.clientY - r.y;
|
|
93
|
-
|
|
94
|
-
rect.positionElement(outlineDiv.current);
|
|
95
|
-
if (rootdiv) {
|
|
96
|
-
rootdiv.appendChild(outlineDiv.current);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
setDragging(true);
|
|
100
|
-
splitterDragging = true;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
const onDragCancel = () => {
|
|
104
|
-
const rootdiv = layout.getRootDiv();
|
|
105
|
-
if (rootdiv && outlineDiv.current) {
|
|
106
|
-
rootdiv.removeChild(outlineDiv.current as Element);
|
|
107
|
-
}
|
|
108
|
-
outlineDiv.current = undefined;
|
|
109
|
-
setDragging(false);
|
|
110
|
-
splitterDragging = false;
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
const onDragMove = (x: number, y: number) => {
|
|
114
|
-
|
|
115
|
-
if (outlineDiv.current) {
|
|
116
|
-
const clientRect = layout.getDomRect();
|
|
117
|
-
if (!clientRect) {
|
|
118
|
-
return;
|
|
119
|
-
}
|
|
120
|
-
if (node.getOrientation() === Orientation.VERT) {
|
|
121
|
-
outlineDiv.current!.style.top = getBoundPosition(y - clientRect.y - dragStartY.current) + "px";
|
|
122
|
-
} else {
|
|
123
|
-
outlineDiv.current!.style.left = getBoundPosition(x - clientRect.x - dragStartX.current) + "px";
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (layout.isRealtimeResize()) {
|
|
127
|
-
updateLayout(true);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
const onDragEnd = () => {
|
|
133
|
-
if (outlineDiv.current) {
|
|
134
|
-
updateLayout(false);
|
|
135
|
-
|
|
136
|
-
const rootdiv = layout.getRootDiv();
|
|
137
|
-
if (rootdiv && outlineDiv.current) {
|
|
138
|
-
rootdiv.removeChild(outlineDiv.current as HTMLElement);
|
|
139
|
-
}
|
|
140
|
-
outlineDiv.current = undefined;
|
|
141
|
-
}
|
|
142
|
-
enablePointerOnIFrames(true, layout.getCurrentDocument()!);
|
|
143
|
-
setDragging(false);
|
|
144
|
-
splitterDragging = false;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
const updateLayout = (realtime: boolean) => {
|
|
148
|
-
|
|
149
|
-
const redraw = () => {
|
|
150
|
-
if (outlineDiv.current) {
|
|
151
|
-
let value = 0;
|
|
152
|
-
if (node.getOrientation() === Orientation.VERT) {
|
|
153
|
-
value = outlineDiv.current!.offsetTop;
|
|
154
|
-
} else {
|
|
155
|
-
value = outlineDiv.current!.offsetLeft;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
if (node instanceof BorderNode) {
|
|
160
|
-
const pos = (node as BorderNode).calculateSplit(node, value);
|
|
161
|
-
layout.doAction(Actions.adjustBorderSplit(node.getId(), pos));
|
|
162
|
-
} else {
|
|
163
|
-
const init = initalSizes.current;
|
|
164
|
-
const weights = node.calculateSplit(index, value, init.initialSizes, init.sum, init.startPosition);
|
|
165
|
-
layout.doAction(Actions.adjustWeights(node.getId(), weights));
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
redraw();
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
const getBoundPosition = (p: number) => {
|
|
174
|
-
const bounds = pBounds.current as number[];
|
|
175
|
-
let rtn = p;
|
|
176
|
-
if (p < bounds[0]) {
|
|
177
|
-
rtn = bounds[0];
|
|
178
|
-
}
|
|
179
|
-
if (p > bounds[1]) {
|
|
180
|
-
rtn = bounds[1];
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return rtn;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const cm = layout.getClassName;
|
|
187
|
-
const style: Record<string, any> = {
|
|
188
|
-
cursor: horizontal ? "ew-resize" : "ns-resize",
|
|
189
|
-
flexDirection: horizontal ? "column" : "row"
|
|
190
|
-
};
|
|
191
|
-
let className = cm(CLASSES.FLEXLAYOUT__SPLITTER) + " " + cm(CLASSES.FLEXLAYOUT__SPLITTER_ + node.getOrientation().getName());
|
|
192
|
-
|
|
193
|
-
if (node instanceof BorderNode) {
|
|
194
|
-
className += " " + cm(CLASSES.FLEXLAYOUT__SPLITTER_BORDER);
|
|
195
|
-
} else {
|
|
196
|
-
if (node.getModel().getMaximizedTabset(layout.getWindowId()) !== undefined) {
|
|
197
|
-
style.display = "none";
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
if (horizontal) {
|
|
202
|
-
style.width = size + "px";
|
|
203
|
-
style.minWidth = size + "px";
|
|
204
|
-
} else {
|
|
205
|
-
style.height = size + "px";
|
|
206
|
-
style.minHeight = size + "px";
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
let handle;
|
|
210
|
-
if (!dragging && node.getModel().isSplitterEnableHandle()) {
|
|
211
|
-
handle = (
|
|
212
|
-
<div
|
|
213
|
-
className={cm(CLASSES.FLEXLAYOUT__SPLITTER_HANDLE) + " " +
|
|
214
|
-
(horizontal ? cm(CLASSES.FLEXLAYOUT__SPLITTER_HANDLE_HORZ) : cm(CLASSES.FLEXLAYOUT__SPLITTER_HANDLE_VERT))
|
|
215
|
-
}>
|
|
216
|
-
</div>
|
|
217
|
-
);
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
if (extra === 0) {
|
|
221
|
-
return (<div
|
|
222
|
-
className={className}
|
|
223
|
-
style={style}
|
|
224
|
-
ref={selfRef}
|
|
225
|
-
data-layout-path={node.getPath() + "/s" + (index - 1)}
|
|
226
|
-
onPointerDown={onPointerDown}>
|
|
227
|
-
{handle}
|
|
228
|
-
</div>);
|
|
229
|
-
} else {
|
|
230
|
-
// add extended transparent div for hit testing
|
|
231
|
-
|
|
232
|
-
const style2: Record<string, any> = {};
|
|
233
|
-
if (node.getOrientation() === Orientation.HORZ) {
|
|
234
|
-
style2.height = "100%";
|
|
235
|
-
style2.width = size + extra + "px";
|
|
236
|
-
style2.cursor = "ew-resize";
|
|
237
|
-
} else {
|
|
238
|
-
style2.height = size + extra + "px";
|
|
239
|
-
style2.width = "100%";
|
|
240
|
-
style2.cursor = "ns-resize";
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
const className2 = cm(CLASSES.FLEXLAYOUT__SPLITTER_EXTRA);
|
|
244
|
-
|
|
245
|
-
return (
|
|
246
|
-
<div
|
|
247
|
-
className={className}
|
|
248
|
-
style={style}
|
|
249
|
-
ref={selfRef}
|
|
250
|
-
data-layout-path={node.getPath() + "/s" + (index - 1)}
|
|
251
|
-
onPointerDown={onPointerDown}
|
|
252
|
-
>
|
|
253
|
-
<div
|
|
254
|
-
style={style2}
|
|
255
|
-
ref={extendedRef}
|
|
256
|
-
className={className2}
|
|
257
|
-
onPointerDown={onPointerDown}>
|
|
258
|
-
</div>
|
|
259
|
-
</div>);
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|