flexlayout-react 0.7.15 → 0.8.1
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 +28 -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 -7
- package/declarations/view/Layout.d.ts +140 -161
- 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 +459 -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 +129 -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 -45
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +919 -907
- 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 +127 -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 +272 -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 +303 -242
- package/src/model/Utils.ts +6 -32
- package/src/view/BorderButton.tsx +36 -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 +6 -0
- package/src/view/Layout.tsx +1053 -1046
- 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 +39 -54
- package/src/view/TabButtonStamp.tsx +5 -9
- package/src/view/TabOverflowHook.tsx +14 -9
- package/src/view/TabSet.tsx +221 -176
- package/src/view/Utils.tsx +119 -39
- package/style/_base.scss +140 -34
- package/style/dark.css +140 -35
- package/style/dark.css.map +1 -1
- package/style/dark.scss +3 -1
- package/style/gray.css +139 -34
- package/style/gray.css.map +1 -1
- package/style/gray.scss +2 -0
- package/style/light.css +141 -36
- package/style/light.css.map +1 -1
- package/style/light.scss +4 -2
- package/style/rounded.css +697 -0
- package/style/rounded.css.map +1 -0
- package/style/rounded.scss +194 -0
- package/style/underline.css +139 -34
- package/style/underline.css.map +1 -1
- package/style/underline.scss +2 -0
- 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
package/src/view/TabButton.tsx
CHANGED
|
@@ -3,43 +3,53 @@ import { I18nLabel } from "../I18nLabel";
|
|
|
3
3
|
import { Actions } from "../model/Actions";
|
|
4
4
|
import { TabNode } from "../model/TabNode";
|
|
5
5
|
import { TabSetNode } from "../model/TabSetNode";
|
|
6
|
-
import {
|
|
7
|
-
import { IconFactory, IIcons, ILayoutCallbacks, TitleFactory } from "./Layout";
|
|
6
|
+
import { LayoutInternal } from "./Layout";
|
|
8
7
|
import { ICloseType } from "../model/ICloseType";
|
|
9
8
|
import { CLASSES } from "../Types";
|
|
10
9
|
import { getRenderStateEx, isAuxMouseEvent } from "./Utils";
|
|
11
10
|
|
|
12
11
|
/** @internal */
|
|
13
12
|
export interface ITabButtonProps {
|
|
14
|
-
layout:
|
|
13
|
+
layout: LayoutInternal;
|
|
15
14
|
node: TabNode;
|
|
16
15
|
selected: boolean;
|
|
17
|
-
iconFactory?: IconFactory;
|
|
18
|
-
titleFactory?: TitleFactory;
|
|
19
|
-
icons: IIcons;
|
|
20
16
|
path: string;
|
|
21
17
|
}
|
|
22
18
|
|
|
23
19
|
/** @internal */
|
|
24
20
|
export const TabButton = (props: ITabButtonProps) => {
|
|
25
|
-
const { layout, node, selected,
|
|
21
|
+
const { layout, node, selected, path } = props;
|
|
26
22
|
const selfRef = React.useRef<HTMLDivElement | null>(null);
|
|
27
23
|
const contentRef = React.useRef<HTMLInputElement | null>(null);
|
|
24
|
+
const icons = layout.getIcons();
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
React.useLayoutEffect(() => {
|
|
27
|
+
node.setTabRect(layout.getBoundingClientRect(selfRef.current!));
|
|
28
|
+
if (layout.getEditingTab() === node) {
|
|
29
|
+
(contentRef.current! as HTMLInputElement).select();
|
|
30
|
+
}
|
|
31
|
+
});
|
|
30
32
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
const onDragStart = (event: React.DragEvent<HTMLElement>) => {
|
|
34
|
+
if (node.isEnableDrag()) {
|
|
35
|
+
event.stopPropagation(); // prevent starting a tabset drag as well
|
|
36
|
+
layout.setDragNode(event.nativeEvent, node as TabNode);
|
|
37
|
+
} else {
|
|
38
|
+
event.preventDefault();
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
41
|
|
|
36
|
-
const
|
|
42
|
+
const onDragEnd = (event: React.DragEvent<HTMLElement>) => {
|
|
43
|
+
layout.clearDragMain();
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const onAuxMouseClick = (event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
37
47
|
if (isAuxMouseEvent(event)) {
|
|
38
48
|
layout.auxMouseClick(node, event);
|
|
39
|
-
}
|
|
49
|
+
}
|
|
40
50
|
};
|
|
41
51
|
|
|
42
|
-
const onContextMenu = (event: React.MouseEvent<
|
|
52
|
+
const onContextMenu = (event: React.MouseEvent<HTMLElement, MouseEvent>) => {
|
|
43
53
|
layout.showContextMenu(node, event);
|
|
44
54
|
};
|
|
45
55
|
|
|
@@ -47,22 +57,21 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
47
57
|
layout.doAction(Actions.selectTab(node.getId()));
|
|
48
58
|
};
|
|
49
59
|
|
|
50
|
-
const onDoubleClick = (event:
|
|
60
|
+
const onDoubleClick = (event: React.MouseEvent<HTMLElement>) => {
|
|
51
61
|
if (node.isEnableRename()) {
|
|
52
62
|
onRename();
|
|
63
|
+
event.stopPropagation();
|
|
53
64
|
}
|
|
54
65
|
};
|
|
55
66
|
|
|
56
67
|
const onRename = () => {
|
|
57
68
|
layout.setEditingTab(node);
|
|
58
|
-
layout.getCurrentDocument()!.body.addEventListener("
|
|
59
|
-
layout.getCurrentDocument()!.body.addEventListener("touchstart", onEndEdit);
|
|
69
|
+
layout.getCurrentDocument()!.body.addEventListener("pointerdown", onEndEdit);
|
|
60
70
|
};
|
|
61
71
|
|
|
62
72
|
const onEndEdit = (event: Event) => {
|
|
63
73
|
if (event.target !== contentRef.current!) {
|
|
64
|
-
layout.getCurrentDocument()!.body.removeEventListener("
|
|
65
|
-
layout.getCurrentDocument()!.body.removeEventListener("touchstart", onEndEdit);
|
|
74
|
+
layout.getCurrentDocument()!.body.removeEventListener("pointerdown", onEndEdit);
|
|
66
75
|
layout.setEditingTab(undefined);
|
|
67
76
|
}
|
|
68
77
|
};
|
|
@@ -81,7 +90,7 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
81
90
|
return false;
|
|
82
91
|
};
|
|
83
92
|
|
|
84
|
-
const onClose = (event: React.MouseEvent<
|
|
93
|
+
const onClose = (event: React.MouseEvent<HTMLElement>) => {
|
|
85
94
|
if (isClosable()) {
|
|
86
95
|
layout.doAction(Actions.deleteTab(node.getId()));
|
|
87
96
|
} else {
|
|
@@ -89,35 +98,11 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
89
98
|
}
|
|
90
99
|
};
|
|
91
100
|
|
|
92
|
-
const
|
|
101
|
+
const onClosePointerDown = (event: React.PointerEvent<HTMLElement>) => {
|
|
93
102
|
event.stopPropagation();
|
|
94
103
|
};
|
|
95
104
|
|
|
96
|
-
React.
|
|
97
|
-
updateRect();
|
|
98
|
-
if (layout.getEditingTab() === node) {
|
|
99
|
-
(contentRef.current! as HTMLInputElement).select();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const updateRect = () => {
|
|
104
|
-
// record position of tab in node
|
|
105
|
-
const layoutRect = layout.getDomRect();
|
|
106
|
-
const r = selfRef.current?.getBoundingClientRect();
|
|
107
|
-
if (r && layoutRect) {
|
|
108
|
-
node._setTabRect(
|
|
109
|
-
new Rect(
|
|
110
|
-
r.left - layoutRect.left,
|
|
111
|
-
r.top - layoutRect.top,
|
|
112
|
-
r.width,
|
|
113
|
-
r.height
|
|
114
|
-
)
|
|
115
|
-
);
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
const onTextBoxMouseDown = (event: React.MouseEvent<HTMLInputElement> | React.TouchEvent<HTMLInputElement>) => {
|
|
120
|
-
// console.log("onTextBoxMouseDown");
|
|
105
|
+
const onTextBoxPointerDown = (event: React.PointerEvent<HTMLInputElement>) => {
|
|
121
106
|
event.stopPropagation();
|
|
122
107
|
};
|
|
123
108
|
|
|
@@ -152,7 +137,7 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
152
137
|
classNames += " " + node.getClassName();
|
|
153
138
|
}
|
|
154
139
|
|
|
155
|
-
const renderState = getRenderStateEx(layout, node
|
|
140
|
+
const renderState = getRenderStateEx(layout, node);
|
|
156
141
|
|
|
157
142
|
let content = renderState.content ? (
|
|
158
143
|
<div className={cm(CLASSES.FLEXLAYOUT__TAB_BUTTON_CONTENT)}>
|
|
@@ -174,8 +159,7 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
174
159
|
autoFocus={true}
|
|
175
160
|
defaultValue={node.getName()}
|
|
176
161
|
onKeyDown={onTextBoxKeyPress}
|
|
177
|
-
|
|
178
|
-
onTouchStart={onTextBoxMouseDown}
|
|
162
|
+
onPointerDown={onTextBoxPointerDown}
|
|
179
163
|
/>
|
|
180
164
|
);
|
|
181
165
|
}
|
|
@@ -188,9 +172,8 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
188
172
|
data-layout-path={path + "/button/close"}
|
|
189
173
|
title={closeTitle}
|
|
190
174
|
className={cm(CLASSES.FLEXLAYOUT__TAB_BUTTON_TRAILING)}
|
|
191
|
-
|
|
192
|
-
onClick={onClose}
|
|
193
|
-
onTouchStart={onCloseMouseDown}>
|
|
175
|
+
onPointerDown={onClosePointerDown}
|
|
176
|
+
onClick={onClose}>
|
|
194
177
|
{(typeof icons.close === "function") ? icons.close(node) : icons.close}
|
|
195
178
|
</div>
|
|
196
179
|
);
|
|
@@ -201,12 +184,14 @@ export const TabButton = (props: ITabButtonProps) => {
|
|
|
201
184
|
ref={selfRef}
|
|
202
185
|
data-layout-path={path}
|
|
203
186
|
className={classNames}
|
|
204
|
-
|
|
205
|
-
onClick={onAuxMouseClick}
|
|
187
|
+
onClick={onClick}
|
|
206
188
|
onAuxClick={onAuxMouseClick}
|
|
207
189
|
onContextMenu={onContextMenu}
|
|
208
|
-
onTouchStart={onMouseDown}
|
|
209
190
|
title={node.getHelpText()}
|
|
191
|
+
draggable={true}
|
|
192
|
+
onDragStart={onDragStart}
|
|
193
|
+
onDragEnd={onDragEnd}
|
|
194
|
+
onDoubleClick={onDoubleClick}
|
|
210
195
|
>
|
|
211
196
|
{leading}
|
|
212
197
|
{content}
|
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { TabNode } from "../model/TabNode";
|
|
3
|
-
import {
|
|
3
|
+
import { LayoutInternal } from "./Layout";
|
|
4
4
|
import { CLASSES } from "../Types";
|
|
5
5
|
import { getRenderStateEx } from "./Utils";
|
|
6
6
|
|
|
7
7
|
/** @internal */
|
|
8
8
|
export interface ITabButtonStampProps {
|
|
9
9
|
node: TabNode;
|
|
10
|
-
layout:
|
|
11
|
-
iconFactory?: IconFactory;
|
|
12
|
-
titleFactory?: TitleFactory;
|
|
10
|
+
layout: LayoutInternal;
|
|
13
11
|
}
|
|
14
12
|
|
|
15
13
|
/** @internal */
|
|
16
14
|
export const TabButtonStamp = (props: ITabButtonStampProps) => {
|
|
17
|
-
const { layout, node
|
|
18
|
-
const selfRef = React.useRef<HTMLDivElement | null>(null);
|
|
15
|
+
const { layout, node } = props;
|
|
19
16
|
|
|
20
17
|
const cm = layout.getClassName;
|
|
21
18
|
|
|
22
19
|
let classNames = cm(CLASSES.FLEXLAYOUT__TAB_BUTTON_STAMP);
|
|
23
20
|
|
|
24
|
-
const renderState = getRenderStateEx(layout, node
|
|
21
|
+
const renderState = getRenderStateEx(layout, node);
|
|
25
22
|
|
|
26
23
|
let content = renderState.content ? (
|
|
27
24
|
<div className={cm(CLASSES.FLEXLAYOUT__TAB_BUTTON_CONTENT)}>
|
|
28
25
|
{renderState.content}
|
|
29
26
|
</div>)
|
|
30
|
-
: node.
|
|
27
|
+
: node.getNameForOverflowMenu();
|
|
31
28
|
|
|
32
29
|
const leading = renderState.leading ? (
|
|
33
30
|
<div className={cm(CLASSES.FLEXLAYOUT__TAB_BUTTON_LEADING)}>
|
|
@@ -36,7 +33,6 @@ export const TabButtonStamp = (props: ITabButtonStampProps) => {
|
|
|
36
33
|
|
|
37
34
|
return (
|
|
38
35
|
<div
|
|
39
|
-
ref={selfRef}
|
|
40
36
|
className={classNames}
|
|
41
37
|
title={node.getHelpText()}
|
|
42
38
|
>
|
|
@@ -9,12 +9,12 @@ import { Orientation } from "../Orientation";
|
|
|
9
9
|
export const useTabOverflow = (
|
|
10
10
|
node: TabSetNode | BorderNode,
|
|
11
11
|
orientation: Orientation,
|
|
12
|
-
toolbarRef: React.MutableRefObject<
|
|
13
|
-
stickyButtonsRef: React.MutableRefObject<
|
|
12
|
+
toolbarRef: React.MutableRefObject<HTMLElement | null>,
|
|
13
|
+
stickyButtonsRef: React.MutableRefObject<HTMLElement | null>
|
|
14
14
|
) => {
|
|
15
15
|
const firstRender = React.useRef<boolean>(true);
|
|
16
16
|
const tabsTruncated = React.useRef<boolean>(false);
|
|
17
|
-
const lastRect = React.useRef<Rect>(
|
|
17
|
+
const lastRect = React.useRef<Rect>(Rect.empty());
|
|
18
18
|
const selfRef = React.useRef<HTMLDivElement | null>(null);
|
|
19
19
|
|
|
20
20
|
const [position, setPosition] = React.useState<number>(0);
|
|
@@ -28,10 +28,13 @@ export const useTabOverflow = (
|
|
|
28
28
|
}, [node.getSelectedNode(), node.getRect().width, node.getRect().height]);
|
|
29
29
|
|
|
30
30
|
React.useLayoutEffect(() => {
|
|
31
|
-
|
|
31
|
+
const nodeRect = node instanceof TabSetNode ? node.getRect() : (node as BorderNode).getTabHeaderRect()!;
|
|
32
|
+
if (nodeRect.width > 0 && nodeRect.height > 0) {
|
|
33
|
+
updateVisibleTabs();
|
|
34
|
+
}
|
|
32
35
|
});
|
|
33
36
|
|
|
34
|
-
const instance =
|
|
37
|
+
const instance = toolbarRef.current;
|
|
35
38
|
React.useEffect(() => {
|
|
36
39
|
if (!instance) {
|
|
37
40
|
return;
|
|
@@ -109,10 +112,12 @@ export const useTabOverflow = (
|
|
|
109
112
|
// when selected tab is larger than available space then align left
|
|
110
113
|
if (getSize(selectedRect) + 2 * tabMargin >= endPos - getNear(nodeRect)) {
|
|
111
114
|
shiftPos = getNear(nodeRect) - selectedStart;
|
|
115
|
+
// console.log("shiftPos1", shiftPos, getNear(nodeRect), selectedStart);
|
|
112
116
|
} else {
|
|
113
117
|
if (selectedEnd > endPos || selectedStart < getNear(nodeRect)) {
|
|
114
118
|
if (selectedStart < getNear(nodeRect)) {
|
|
115
119
|
shiftPos = getNear(nodeRect) - selectedStart;
|
|
120
|
+
// console.log("shiftPos2", shiftPos, getNear(nodeRect), selectedStart);
|
|
116
121
|
}
|
|
117
122
|
// use second if statement to prevent tab moving back then forwards if not enough space for single tab
|
|
118
123
|
if (selectedEnd + shiftPos > endPos) {
|
|
@@ -124,6 +129,7 @@ export const useTabOverflow = (
|
|
|
124
129
|
|
|
125
130
|
const extraSpace = Math.max(0, endPos - (getFar(lastChild.getTabRect()!) + tabMargin + shiftPos));
|
|
126
131
|
const newPosition = Math.min(0, position + shiftPos + extraSpace);
|
|
132
|
+
// console.log("newPosition", newPosition, position, shiftPos, extraSpace);
|
|
127
133
|
|
|
128
134
|
// find hidden tabs
|
|
129
135
|
const diff = newPosition - position;
|
|
@@ -135,12 +141,11 @@ export const useTabOverflow = (
|
|
|
135
141
|
}
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
|
|
139
|
-
tabsTruncated.current = true;
|
|
140
|
-
}
|
|
144
|
+
tabsTruncated.current = hidden.length > 0;
|
|
141
145
|
|
|
142
146
|
firstRender.current = false; // need to do a second render
|
|
143
147
|
setHiddenTabs(hidden);
|
|
148
|
+
// console.log(newPosition);
|
|
144
149
|
setPosition(newPosition);
|
|
145
150
|
}
|
|
146
151
|
} else {
|
|
@@ -148,7 +153,7 @@ export const useTabOverflow = (
|
|
|
148
153
|
}
|
|
149
154
|
};
|
|
150
155
|
|
|
151
|
-
const onMouseWheel = (event: React.WheelEvent<
|
|
156
|
+
const onMouseWheel = (event: React.WheelEvent<HTMLElement>) => {
|
|
152
157
|
let delta = 0;
|
|
153
158
|
if (Math.abs(event.deltaX) > Math.abs(event.deltaY)) {
|
|
154
159
|
delta = -event.deltaX;
|