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.
Files changed (307) hide show
  1. package/README.md +16 -5
  2. package/declarations/Attribute.d.ts +25 -1
  3. package/declarations/AttributeDefinitions.d.ts +18 -1
  4. package/declarations/DockLocation.d.ts +22 -0
  5. package/declarations/I18nLabel.d.ts +2 -1
  6. package/declarations/Orientation.d.ts +4 -0
  7. package/declarations/Rect.d.ts +3 -0
  8. package/declarations/index.d.ts +1 -0
  9. package/declarations/model/BorderNode.d.ts +53 -0
  10. package/declarations/model/BorderSet.d.ts +28 -0
  11. package/declarations/model/IDraggable.d.ts +4 -0
  12. package/declarations/model/IDropTarget.d.ts +10 -0
  13. package/declarations/model/LayoutWindow.d.ts +16 -0
  14. package/declarations/model/Model.d.ts +55 -0
  15. package/declarations/model/Node.d.ts +61 -0
  16. package/declarations/model/RowNode.d.ts +67 -0
  17. package/declarations/model/TabNode.d.ts +79 -0
  18. package/declarations/model/TabSetNode.d.ts +60 -0
  19. package/declarations/model/Utils.d.ts +8 -0
  20. package/declarations/view/BorderButton.d.ts +13 -1
  21. package/declarations/view/BorderTab.d.ts +8 -0
  22. package/declarations/view/BorderTabSet.d.ts +10 -1
  23. package/declarations/view/DragContainer.d.ts +9 -1
  24. package/declarations/view/ErrorBoundary.d.ts +22 -1
  25. package/declarations/view/Icons.d.ts +1 -0
  26. package/declarations/view/Layout.d.ts +143 -1
  27. package/declarations/view/Overlay.d.ts +8 -1
  28. package/declarations/view/PopoutWindow.d.ts +14 -1
  29. package/declarations/view/PopupMenu.d.ts +12 -1
  30. package/declarations/view/Row.d.ts +9 -1
  31. package/declarations/view/Splitter.d.ts +14 -1
  32. package/declarations/view/Tab.d.ts +11 -1
  33. package/declarations/view/TabButton.d.ts +11 -1
  34. package/declarations/view/TabButtonStamp.d.ts +9 -1
  35. package/declarations/view/TabOverflowHook.d.ts +16 -1
  36. package/declarations/view/TabSet.d.ts +9 -1
  37. package/declarations/view/Utils.d.ts +13 -0
  38. package/lib/index.js +6410 -22
  39. package/package.json +35 -26
  40. package/ChangeLog.txt +0 -372
  41. package/declarations/DragDrop.d.ts +0 -15
  42. package/declarations/PopupMenu.d.ts +0 -1
  43. package/declarations/model/SplitterNode.d.ts +0 -5
  44. package/declarations/model/WindowLayout.d.ts +0 -24
  45. package/declarations/src/Attribute.d.ts +0 -1
  46. package/declarations/src/AttributeDefinitions.d.ts +0 -1
  47. package/declarations/src/DockLocation.d.ts +0 -12
  48. package/declarations/src/DropInfo.d.ts +0 -12
  49. package/declarations/src/I18nLabel.d.ts +0 -10
  50. package/declarations/src/Orientation.d.ts +0 -7
  51. package/declarations/src/PopupMenu.d.ts +0 -1
  52. package/declarations/src/Rect.d.ts +0 -31
  53. package/declarations/src/Types.d.ts +0 -92
  54. package/declarations/src/index.d.ts +0 -20
  55. package/declarations/src/model/Action.d.ts +0 -5
  56. package/declarations/src/model/Actions.d.ts +0 -110
  57. package/declarations/src/model/BorderNode.d.ts +0 -28
  58. package/declarations/src/model/BorderSet.d.ts +0 -3
  59. package/declarations/src/model/ICloseType.d.ts +0 -5
  60. package/declarations/src/model/IDraggable.d.ts +0 -2
  61. package/declarations/src/model/IDropTarget.d.ts +0 -2
  62. package/declarations/src/model/IJsonModel.d.ts +0 -153
  63. package/declarations/src/model/Model.d.ts +0 -98
  64. package/declarations/src/model/Node.d.ts +0 -16
  65. package/declarations/src/model/RowNode.d.ts +0 -11
  66. package/declarations/src/model/TabNode.d.ts +0 -36
  67. package/declarations/src/model/TabSetNode.d.ts +0 -37
  68. package/declarations/src/model/Utils.d.ts +0 -1
  69. package/declarations/src/view/BorderButton.d.ts +0 -1
  70. package/declarations/src/view/BorderTab.d.ts +0 -2
  71. package/declarations/src/view/BorderTabSet.d.ts +0 -1
  72. package/declarations/src/view/DragContainer.d.ts +0 -1
  73. package/declarations/src/view/ErrorBoundary.d.ts +0 -1
  74. package/declarations/src/view/FloatingWindow.d.ts +0 -1
  75. package/declarations/src/view/Icons.d.ts +0 -7
  76. package/declarations/src/view/Layout.d.ts +0 -113
  77. package/declarations/src/view/Overlay.d.ts +0 -1
  78. package/declarations/src/view/PopupMenu.d.ts +0 -1
  79. package/declarations/src/view/Row.d.ts +0 -1
  80. package/declarations/src/view/Splitter.d.ts +0 -1
  81. package/declarations/src/view/Tab.d.ts +0 -1
  82. package/declarations/src/view/TabButton.d.ts +0 -1
  83. package/declarations/src/view/TabButtonStamp.d.ts +0 -1
  84. package/declarations/src/view/TabOverflowHook.d.ts +0 -1
  85. package/declarations/src/view/TabSet.d.ts +0 -1
  86. package/declarations/src/view/Utils.d.ts +0 -4
  87. package/declarations/view/ExtendedResizeObserver.d.ts +0 -23
  88. package/declarations/view/FloatingWindow.d.ts +0 -1
  89. package/declarations/view/FloatingWindowTab.d.ts +0 -1
  90. package/declarations/view/TabFloating.d.ts +0 -1
  91. package/dist/flexlayout.js +0 -610
  92. package/dist/flexlayout_min.js +0 -2
  93. package/dist/flexlayout_min.js.LICENSE.txt +0 -29
  94. package/dist/src/Attribute.js +0 -43
  95. package/dist/src/Attribute.js.map +0 -1
  96. package/dist/src/AttributeDefinitions.js +0 -132
  97. package/dist/src/AttributeDefinitions.js.map +0 -1
  98. package/dist/src/DockLocation.js +0 -121
  99. package/dist/src/DockLocation.js.map +0 -1
  100. package/dist/src/DropInfo.js +0 -10
  101. package/dist/src/DropInfo.js.map +0 -1
  102. package/dist/src/I18nLabel.js +0 -14
  103. package/dist/src/I18nLabel.js.map +0 -1
  104. package/dist/src/Orientation.js +0 -23
  105. package/dist/src/Orientation.js.map +0 -1
  106. package/dist/src/Rect.js +0 -111
  107. package/dist/src/Rect.js.map +0 -1
  108. package/dist/src/Types.js +0 -95
  109. package/dist/src/Types.js.map +0 -1
  110. package/dist/src/index.js +0 -22
  111. package/dist/src/index.js.map +0 -1
  112. package/dist/src/model/Action.js +0 -7
  113. package/dist/src/model/Action.js.map +0 -1
  114. package/dist/src/model/Actions.js +0 -170
  115. package/dist/src/model/Actions.js.map +0 -1
  116. package/dist/src/model/BorderNode.js +0 -390
  117. package/dist/src/model/BorderNode.js.map +0 -1
  118. package/dist/src/model/BorderSet.js +0 -67
  119. package/dist/src/model/BorderSet.js.map +0 -1
  120. package/dist/src/model/ICloseType.js +0 -7
  121. package/dist/src/model/ICloseType.js.map +0 -1
  122. package/dist/src/model/IDraggable.js +0 -2
  123. package/dist/src/model/IDraggable.js.map +0 -1
  124. package/dist/src/model/IDropTarget.js +0 -2
  125. package/dist/src/model/IDropTarget.js.map +0 -1
  126. package/dist/src/model/IJsonModel.js +0 -2
  127. package/dist/src/model/IJsonModel.js.map +0 -1
  128. package/dist/src/model/LayoutWindow.js +0 -81
  129. package/dist/src/model/LayoutWindow.js.map +0 -1
  130. package/dist/src/model/Model.js +0 -608
  131. package/dist/src/model/Model.js.map +0 -1
  132. package/dist/src/model/Node.js +0 -218
  133. package/dist/src/model/Node.js.map +0 -1
  134. package/dist/src/model/RowNode.js +0 -492
  135. package/dist/src/model/RowNode.js.map +0 -1
  136. package/dist/src/model/TabNode.js +0 -293
  137. package/dist/src/model/TabNode.js.map +0 -1
  138. package/dist/src/model/TabSetNode.js +0 -469
  139. package/dist/src/model/TabSetNode.js.map +0 -1
  140. package/dist/src/model/Utils.js +0 -48
  141. package/dist/src/model/Utils.js.map +0 -1
  142. package/dist/src/view/BorderButton.js +0 -126
  143. package/dist/src/view/BorderButton.js.map +0 -1
  144. package/dist/src/view/BorderTab.js +0 -44
  145. package/dist/src/view/BorderTab.js.map +0 -1
  146. package/dist/src/view/BorderTabSet.js +0 -138
  147. package/dist/src/view/BorderTabSet.js.map +0 -1
  148. package/dist/src/view/DragContainer.js +0 -16
  149. package/dist/src/view/DragContainer.js.map +0 -1
  150. package/dist/src/view/ErrorBoundary.js +0 -24
  151. package/dist/src/view/ErrorBoundary.js.map +0 -1
  152. package/dist/src/view/Icons.js +0 -29
  153. package/dist/src/view/Icons.js.map +0 -1
  154. package/dist/src/view/Layout.js +0 -881
  155. package/dist/src/view/Layout.js.map +0 -1
  156. package/dist/src/view/Overlay.js +0 -9
  157. package/dist/src/view/Overlay.js.map +0 -1
  158. package/dist/src/view/PopoutWindow.js +0 -129
  159. package/dist/src/view/PopoutWindow.js.map +0 -1
  160. package/dist/src/view/PopupMenu.js +0 -89
  161. package/dist/src/view/PopupMenu.js.map +0 -1
  162. package/dist/src/view/Row.js +0 -46
  163. package/dist/src/view/Row.js.map +0 -1
  164. package/dist/src/view/SizeTracker.js +0 -12
  165. package/dist/src/view/SizeTracker.js.map +0 -1
  166. package/dist/src/view/Splitter.js +0 -192
  167. package/dist/src/view/Splitter.js.map +0 -1
  168. package/dist/src/view/Tab.js +0 -91
  169. package/dist/src/view/Tab.js.map +0 -1
  170. package/dist/src/view/TabButton.js +0 -124
  171. package/dist/src/view/TabButton.js.map +0 -1
  172. package/dist/src/view/TabButtonStamp.js +0 -15
  173. package/dist/src/view/TabButtonStamp.js.map +0 -1
  174. package/dist/src/view/TabOverflowHook.js +0 -266
  175. package/dist/src/view/TabOverflowHook.js.map +0 -1
  176. package/dist/src/view/TabSet.js +0 -256
  177. package/dist/src/view/TabSet.js.map +0 -1
  178. package/dist/src/view/Utils.js +0 -110
  179. package/dist/src/view/Utils.js.map +0 -1
  180. package/lib/Attribute.js +0 -43
  181. package/lib/Attribute.js.map +0 -1
  182. package/lib/AttributeDefinitions.js +0 -132
  183. package/lib/AttributeDefinitions.js.map +0 -1
  184. package/lib/DockLocation.js +0 -121
  185. package/lib/DockLocation.js.map +0 -1
  186. package/lib/DropInfo.js +0 -10
  187. package/lib/DropInfo.js.map +0 -1
  188. package/lib/I18nLabel.js +0 -14
  189. package/lib/I18nLabel.js.map +0 -1
  190. package/lib/Orientation.js +0 -23
  191. package/lib/Orientation.js.map +0 -1
  192. package/lib/Rect.js +0 -111
  193. package/lib/Rect.js.map +0 -1
  194. package/lib/Types.js +0 -95
  195. package/lib/Types.js.map +0 -1
  196. package/lib/index.js.map +0 -1
  197. package/lib/model/Action.js +0 -7
  198. package/lib/model/Action.js.map +0 -1
  199. package/lib/model/Actions.js +0 -170
  200. package/lib/model/Actions.js.map +0 -1
  201. package/lib/model/BorderNode.js +0 -390
  202. package/lib/model/BorderNode.js.map +0 -1
  203. package/lib/model/BorderSet.js +0 -67
  204. package/lib/model/BorderSet.js.map +0 -1
  205. package/lib/model/ICloseType.js +0 -7
  206. package/lib/model/ICloseType.js.map +0 -1
  207. package/lib/model/IDraggable.js +0 -2
  208. package/lib/model/IDraggable.js.map +0 -1
  209. package/lib/model/IDropTarget.js +0 -2
  210. package/lib/model/IDropTarget.js.map +0 -1
  211. package/lib/model/IJsonModel.js +0 -2
  212. package/lib/model/IJsonModel.js.map +0 -1
  213. package/lib/model/LayoutWindow.js +0 -81
  214. package/lib/model/LayoutWindow.js.map +0 -1
  215. package/lib/model/Model.js +0 -608
  216. package/lib/model/Model.js.map +0 -1
  217. package/lib/model/Node.js +0 -218
  218. package/lib/model/Node.js.map +0 -1
  219. package/lib/model/RowNode.js +0 -492
  220. package/lib/model/RowNode.js.map +0 -1
  221. package/lib/model/TabNode.js +0 -293
  222. package/lib/model/TabNode.js.map +0 -1
  223. package/lib/model/TabSetNode.js +0 -469
  224. package/lib/model/TabSetNode.js.map +0 -1
  225. package/lib/model/Utils.js +0 -48
  226. package/lib/model/Utils.js.map +0 -1
  227. package/lib/view/BorderButton.js +0 -126
  228. package/lib/view/BorderButton.js.map +0 -1
  229. package/lib/view/BorderTab.js +0 -56
  230. package/lib/view/BorderTab.js.map +0 -1
  231. package/lib/view/BorderTabSet.js +0 -138
  232. package/lib/view/BorderTabSet.js.map +0 -1
  233. package/lib/view/DragContainer.js +0 -16
  234. package/lib/view/DragContainer.js.map +0 -1
  235. package/lib/view/ErrorBoundary.js +0 -24
  236. package/lib/view/ErrorBoundary.js.map +0 -1
  237. package/lib/view/Icons.js +0 -29
  238. package/lib/view/Icons.js.map +0 -1
  239. package/lib/view/Layout.js +0 -881
  240. package/lib/view/Layout.js.map +0 -1
  241. package/lib/view/Overlay.js +0 -9
  242. package/lib/view/Overlay.js.map +0 -1
  243. package/lib/view/PopoutWindow.js +0 -129
  244. package/lib/view/PopoutWindow.js.map +0 -1
  245. package/lib/view/PopupMenu.js +0 -89
  246. package/lib/view/PopupMenu.js.map +0 -1
  247. package/lib/view/Row.js +0 -46
  248. package/lib/view/Row.js.map +0 -1
  249. package/lib/view/SizeTracker.js +0 -12
  250. package/lib/view/SizeTracker.js.map +0 -1
  251. package/lib/view/Splitter.js +0 -197
  252. package/lib/view/Splitter.js.map +0 -1
  253. package/lib/view/Tab.js +0 -91
  254. package/lib/view/Tab.js.map +0 -1
  255. package/lib/view/TabButton.js +0 -124
  256. package/lib/view/TabButton.js.map +0 -1
  257. package/lib/view/TabButtonStamp.js +0 -15
  258. package/lib/view/TabButtonStamp.js.map +0 -1
  259. package/lib/view/TabOverflowHook.js +0 -266
  260. package/lib/view/TabOverflowHook.js.map +0 -1
  261. package/lib/view/TabSet.js +0 -269
  262. package/lib/view/TabSet.js.map +0 -1
  263. package/lib/view/Utils.js +0 -110
  264. package/lib/view/Utils.js.map +0 -1
  265. package/src/Attribute.ts +0 -64
  266. package/src/AttributeDefinitions.ts +0 -144
  267. package/src/DockLocation.ts +0 -133
  268. package/src/DropInfo.ts +0 -20
  269. package/src/I18nLabel.ts +0 -12
  270. package/src/Orientation.ts +0 -28
  271. package/src/Rect.ts +0 -147
  272. package/src/Types.ts +0 -112
  273. package/src/index.ts +0 -23
  274. package/src/model/Action.ts +0 -9
  275. package/src/model/Actions.ts +0 -188
  276. package/src/model/BorderNode.ts +0 -458
  277. package/src/model/BorderSet.ts +0 -87
  278. package/src/model/ICloseType.ts +0 -5
  279. package/src/model/IDraggable.ts +0 -7
  280. package/src/model/IDropTarget.ts +0 -14
  281. package/src/model/IJsonModel.ts +0 -967
  282. package/src/model/LayoutWindow.ts +0 -119
  283. package/src/model/Model.ts +0 -704
  284. package/src/model/Node.ts +0 -280
  285. package/src/model/RowNode.ts +0 -559
  286. package/src/model/TabNode.ts +0 -424
  287. package/src/model/TabSetNode.ts +0 -592
  288. package/src/model/Utils.ts +0 -52
  289. package/src/view/BorderButton.tsx +0 -201
  290. package/src/view/BorderTab.tsx +0 -81
  291. package/src/view/BorderTabSet.tsx +0 -259
  292. package/src/view/DragContainer.tsx +0 -32
  293. package/src/view/ErrorBoundary.tsx +0 -42
  294. package/src/view/Icons.tsx +0 -57
  295. package/src/view/Layout.tsx +0 -1334
  296. package/src/view/Overlay.tsx +0 -21
  297. package/src/view/PopoutWindow.tsx +0 -152
  298. package/src/view/PopupMenu.tsx +0 -156
  299. package/src/view/Row.tsx +0 -68
  300. package/src/view/SizeTracker.tsx +0 -20
  301. package/src/view/Splitter.tsx +0 -262
  302. package/src/view/Tab.tsx +0 -128
  303. package/src/view/TabButton.tsx +0 -200
  304. package/src/view/TabButtonStamp.tsx +0 -42
  305. package/src/view/TabOverflowHook.tsx +0 -305
  306. package/src/view/TabSet.tsx +0 -475
  307. package/src/view/Utils.tsx +0 -135
@@ -1,458 +0,0 @@
1
- import { Attribute } from "../Attribute";
2
- import { AttributeDefinitions } from "../AttributeDefinitions";
3
- import { DockLocation } from "../DockLocation";
4
- import { DropInfo } from "../DropInfo";
5
- import { Orientation } from "../Orientation";
6
- import { Rect } from "../Rect";
7
- import { CLASSES } from "../Types";
8
- import { IDraggable } from "./IDraggable";
9
- import { IDropTarget } from "./IDropTarget";
10
- import { IJsonBorderNode } from "./IJsonModel";
11
- import { Model } from "./Model";
12
- import { Node } from "./Node";
13
- import { TabNode } from "./TabNode";
14
- import { TabSetNode } from "./TabSetNode";
15
- import { adjustSelectedIndex } from "./Utils";
16
-
17
- export class BorderNode extends Node implements IDropTarget {
18
- static readonly TYPE = "border";
19
-
20
- /** @internal */
21
- static fromJson(json: any, model: Model) {
22
- const location = DockLocation.getByName(json.location);
23
- const border = new BorderNode(location, json, model);
24
- if (json.children) {
25
- border.children = json.children.map((jsonChild: any) => {
26
- const child = TabNode.fromJson(jsonChild, model);
27
- child.setParent(border);
28
- return child;
29
- });
30
- }
31
-
32
- return border;
33
- }
34
- /** @internal */
35
- private static attributeDefinitions: AttributeDefinitions = BorderNode.createAttributeDefinitions();
36
-
37
- /** @internal */
38
- private outerRect: Rect = Rect.empty();
39
- /** @internal */
40
- private contentRect: Rect = Rect.empty();
41
- /** @internal */
42
- private tabHeaderRect: Rect = Rect.empty();
43
- /** @internal */
44
- private location: DockLocation;
45
-
46
- /** @internal */
47
- constructor(location: DockLocation, json: any, model: Model) {
48
- super(model);
49
-
50
- this.location = location;
51
- this.attributes.id = `border_${location.getName()}`;
52
- BorderNode.attributeDefinitions.fromJson(json, this.attributes);
53
- model.addNode(this);
54
- }
55
-
56
- getLocation() {
57
- return this.location;
58
- }
59
-
60
- getClassName() {
61
- return this.getAttr("className") as string | undefined;
62
- }
63
-
64
- isHorizontal() {
65
- return this.location.orientation === Orientation.HORZ;
66
- }
67
-
68
- getSize() {
69
- const defaultSize = this.getAttr("size") as number;
70
- const selected = this.getSelected();
71
- if (selected === -1) {
72
- return defaultSize;
73
- } else {
74
- const tabNode = this.children[selected] as TabNode;
75
- const tabBorderSize = this.isHorizontal() ? tabNode.getAttr("borderWidth") : tabNode.getAttr("borderHeight");
76
- if (tabBorderSize === -1) {
77
- return defaultSize;
78
- } else {
79
- return tabBorderSize;
80
- }
81
- }
82
- }
83
-
84
- getMinSize() {
85
- const selectedNode = this.getSelectedNode();
86
- let min = this.getAttr("minSize") as number;
87
- if (selectedNode) {
88
- const nodeMin = this.isHorizontal() ? selectedNode.getMinWidth() : selectedNode.getMinHeight();
89
- min = Math.max(min, nodeMin);
90
- }
91
- return min;
92
- }
93
-
94
- getMaxSize() {
95
- const selectedNode = this.getSelectedNode();
96
- let max = this.getAttr("maxSize") as number;
97
- if (selectedNode) {
98
- const nodeMax = this.isHorizontal() ? selectedNode.getMaxWidth() : selectedNode.getMaxHeight();
99
- max = Math.min(max, nodeMax);
100
- }
101
- return max;
102
- }
103
-
104
- getSelected(): number {
105
- return this.attributes.selected as number;
106
- }
107
-
108
- isAutoHide() {
109
- return this.getAttr("enableAutoHide") as boolean;
110
- }
111
-
112
- getSelectedNode(): TabNode | undefined {
113
- if (this.getSelected() !== -1) {
114
- return this.children[this.getSelected()] as TabNode;
115
- }
116
- return undefined;
117
- }
118
-
119
- getOrientation() {
120
- return this.location.getOrientation();
121
- }
122
-
123
- /**
124
- * Returns the config attribute that can be used to store node specific data that
125
- * WILL be saved to the json. The config attribute should be changed via the action Actions.updateNodeAttributes rather
126
- * than directly, for example:
127
- * this.state.model.doAction(
128
- * FlexLayout.Actions.updateNodeAttributes(node.getId(), {config:myConfigObject}));
129
- */
130
- getConfig() {
131
- return this.attributes.config;
132
- }
133
-
134
- isMaximized() {
135
- return false;
136
- }
137
-
138
- isShowing() {
139
- return this.attributes.show as boolean;
140
- }
141
-
142
- toJson(): IJsonBorderNode {
143
- const json: any = {};
144
- BorderNode.attributeDefinitions.toJson(json, this.attributes);
145
- json.location = this.location.getName();
146
- json.children = this.children.map((child) => (child as TabNode).toJson());
147
- return json;
148
- }
149
-
150
- /** @internal */
151
- isAutoSelectTab(whenOpen?: boolean) {
152
- if (whenOpen == null) {
153
- whenOpen = this.getSelected() !== -1;
154
- }
155
- if (whenOpen) {
156
- return this.getAttr("autoSelectTabWhenOpen") as boolean;
157
- } else {
158
- return this.getAttr("autoSelectTabWhenClosed") as boolean;
159
- }
160
- }
161
-
162
- isEnableTabScrollbar() {
163
- return this.getAttr("enableTabScrollbar") as boolean;
164
- }
165
-
166
- /** @internal */
167
- setSelected(index: number) {
168
- this.attributes.selected = index;
169
- }
170
-
171
- /** @internal */
172
- getTabHeaderRect() {
173
- return this.tabHeaderRect;
174
- }
175
-
176
- /** @internal */
177
- setTabHeaderRect(r: Rect) {
178
- this.tabHeaderRect = r;
179
- }
180
-
181
- /** @internal */
182
- getOuterRect() {
183
- return this.outerRect;
184
- }
185
-
186
- /** @internal */
187
- setOuterRect(r: Rect) {
188
- this.outerRect = r;
189
- }
190
-
191
- /** @internal */
192
- getRect() {
193
- return this.tabHeaderRect!;
194
- }
195
-
196
- /** @internal */
197
- getContentRect() {
198
- return this.contentRect;
199
- }
200
-
201
- /** @internal */
202
- setContentRect(r: Rect) {
203
- this.contentRect = r;
204
- }
205
-
206
- /** @internal */
207
- isEnableDrop() {
208
- return this.getAttr("enableDrop") as boolean;
209
- }
210
-
211
- /** @internal */
212
- setSize(pos: number) {
213
- const selected = this.getSelected();
214
- if (selected === -1) {
215
- this.attributes.size = pos;
216
- } else {
217
- const tabNode = this.children[selected] as TabNode;
218
- const tabBorderSize = this.isHorizontal() ? tabNode.getAttr("borderWidth") : tabNode.getAttr("borderHeight");
219
- if (tabBorderSize === -1) {
220
- this.attributes.size = pos;
221
- } else {
222
- if (this.isHorizontal()) {
223
- tabNode.setBorderWidth(pos);
224
- } else {
225
- tabNode.setBorderHeight(pos);
226
- }
227
- }
228
- }
229
- }
230
-
231
- /** @internal */
232
- updateAttrs(json: any) {
233
- BorderNode.attributeDefinitions.update(json, this.attributes);
234
- }
235
-
236
- /** @internal */
237
- remove(node: TabNode) {
238
- const removedIndex = this.removeChild(node);
239
- if (this.getSelected() !== -1) {
240
- adjustSelectedIndex(this, removedIndex);
241
- }
242
- }
243
-
244
- /** @internal */
245
- canDrop(dragNode: Node & IDraggable, x: number, y: number): DropInfo | undefined {
246
- if (!(dragNode instanceof TabNode)) {
247
- return undefined;
248
- }
249
-
250
- let dropInfo;
251
- const dockLocation = DockLocation.CENTER;
252
-
253
- if (this.tabHeaderRect!.contains(x, y)) {
254
- if (this.location.orientation === Orientation.VERT) {
255
- if (this.children.length > 0) {
256
- let child = this.children[0];
257
- let childRect = (child as TabNode).getTabRect()!;
258
- const childY = childRect.y;
259
-
260
- const childHeight = childRect.height;
261
-
262
- let pos = this.tabHeaderRect!.x;
263
- let childCenter = 0;
264
- for (let i = 0; i < this.children.length; i++) {
265
- child = this.children[i];
266
- childRect = (child as TabNode).getTabRect()!;
267
- childCenter = childRect.x + childRect.width / 2;
268
- if (x >= pos && x < childCenter) {
269
- const outlineRect = new Rect(childRect.x - 2, childY, 3, childHeight);
270
- dropInfo = new DropInfo(this, outlineRect, dockLocation, i, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
271
- break;
272
- }
273
- pos = childCenter;
274
- }
275
- if (dropInfo == null) {
276
- const outlineRect = new Rect(childRect.getRight() - 2, childY, 3, childHeight);
277
- dropInfo = new DropInfo(this, outlineRect, dockLocation, this.children.length, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
278
- }
279
- } else {
280
- const outlineRect = new Rect(this.tabHeaderRect!.x + 1, this.tabHeaderRect!.y + 2, 3, 18);
281
- dropInfo = new DropInfo(this, outlineRect, dockLocation, 0, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
282
- }
283
- } else {
284
- if (this.children.length > 0) {
285
- let child = this.children[0];
286
- let childRect = (child as TabNode).getTabRect()!;
287
- const childX = childRect.x;
288
- const childWidth = childRect.width;
289
-
290
- let pos = this.tabHeaderRect!.y;
291
- let childCenter = 0;
292
- for (let i = 0; i < this.children.length; i++) {
293
- child = this.children[i];
294
- childRect = (child as TabNode).getTabRect()!;
295
- childCenter = childRect.y + childRect.height / 2;
296
- if (y >= pos && y < childCenter) {
297
- const outlineRect = new Rect(childX, childRect.y - 2, childWidth, 3);
298
- dropInfo = new DropInfo(this, outlineRect, dockLocation, i, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
299
- break;
300
- }
301
- pos = childCenter;
302
- }
303
- if (dropInfo == null) {
304
- const outlineRect = new Rect(childX, childRect.getBottom() - 2, childWidth, 3);
305
- dropInfo = new DropInfo(this, outlineRect, dockLocation, this.children.length, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
306
- }
307
- } else {
308
- const outlineRect = new Rect(this.tabHeaderRect!.x + 2, this.tabHeaderRect!.y + 1, 18, 3);
309
- dropInfo = new DropInfo(this, outlineRect, dockLocation, 0, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
310
- }
311
- }
312
- if (!dragNode.canDockInto(dragNode, dropInfo)) {
313
- return undefined;
314
- }
315
- } else if (this.getSelected() !== -1 && this.outerRect!.contains(x, y)) {
316
- const outlineRect = this.outerRect;
317
- dropInfo = new DropInfo(this, outlineRect!, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
318
- if (!dragNode.canDockInto(dragNode, dropInfo)) {
319
- return undefined;
320
- }
321
- }
322
-
323
- return dropInfo;
324
- }
325
-
326
- /** @internal */
327
- drop(dragNode: Node & IDraggable, location: DockLocation, index: number, select?: boolean): void {
328
- let fromIndex = 0;
329
- const dragParent = dragNode.getParent() as BorderNode | TabSetNode;
330
- if (dragParent !== undefined) {
331
- fromIndex = dragParent.removeChild(dragNode);
332
- // if selected node in border is being docked into a different border then deselect border tabs
333
- if (dragParent !== this && dragParent instanceof BorderNode && dragParent.getSelected() === fromIndex) {
334
- dragParent.setSelected(-1);
335
- } else {
336
- adjustSelectedIndex(dragParent, fromIndex);
337
- }
338
- }
339
-
340
- // if dropping a tab back to same tabset and moving to forward position then reduce insertion index
341
- if (dragNode instanceof TabNode && dragParent === this && fromIndex < index && index > 0) {
342
- index--;
343
- }
344
-
345
- // simple_bundled dock to existing tabset
346
- let insertPos = index;
347
- if (insertPos === -1) {
348
- insertPos = this.children.length;
349
- }
350
-
351
- if (dragNode instanceof TabNode) {
352
- this.addChild(dragNode, insertPos);
353
- }
354
-
355
- if (select || (select !== false && this.isAutoSelectTab())) {
356
- this.setSelected(insertPos);
357
- }
358
-
359
- this.model.tidy();
360
- }
361
-
362
- /** @internal */
363
- getSplitterBounds(index: number, useMinSize: boolean = false) {
364
- const pBounds = [0, 0];
365
- const minSize = useMinSize ? this.getMinSize() : 0;
366
- const maxSize = useMinSize ? this.getMaxSize() : 99999;
367
- const rootRow = this.model.getRoot(Model.MAIN_WINDOW_ID);
368
- const innerRect = rootRow.getRect();
369
- const splitterSize = this.model.getSplitterSize()
370
- if (this.location === DockLocation.TOP) {
371
- pBounds[0] = this.tabHeaderRect!.getBottom() + minSize;
372
- const maxPos = this.tabHeaderRect!.getBottom() + maxSize;
373
- pBounds[1] = Math.max(pBounds[0], innerRect.getBottom() - rootRow.getMinHeight() - splitterSize);
374
- pBounds[1] = Math.min(pBounds[1], maxPos);
375
- } else if (this.location === DockLocation.LEFT) {
376
- pBounds[0] = this.tabHeaderRect!.getRight() + minSize;
377
- const maxPos = this.tabHeaderRect!.getRight() + maxSize;
378
- pBounds[1] = Math.max(pBounds[0], innerRect.getRight() - rootRow.getMinWidth() - splitterSize);
379
- pBounds[1] = Math.min(pBounds[1], maxPos);
380
- } else if (this.location === DockLocation.BOTTOM) {
381
- pBounds[1] = this.tabHeaderRect!.y - minSize - splitterSize;
382
- const maxPos = this.tabHeaderRect!.y - maxSize - splitterSize;
383
- pBounds[0] = Math.min(pBounds[1], innerRect.y + rootRow.getMinHeight());
384
- pBounds[0] = Math.max(pBounds[0], maxPos);
385
- } else if (this.location === DockLocation.RIGHT) {
386
- pBounds[1] = this.tabHeaderRect!.x - minSize - splitterSize;
387
- const maxPos = this.tabHeaderRect!.x - maxSize - splitterSize;
388
- pBounds[0] = Math.min(pBounds[1], innerRect.x + rootRow.getMinWidth());
389
- pBounds[0] = Math.max(pBounds[0], maxPos);
390
- }
391
- return pBounds;
392
- }
393
-
394
- /** @internal */
395
- calculateSplit(splitter: BorderNode, splitterPos: number) {
396
- const pBounds = this.getSplitterBounds(splitterPos);
397
- if (this.location === DockLocation.BOTTOM || this.location === DockLocation.RIGHT) {
398
- return Math.max(0, pBounds[1] - splitterPos);
399
- } else {
400
- return Math.max(0, splitterPos - pBounds[0]);
401
- }
402
- }
403
-
404
- /** @internal */
405
- getAttributeDefinitions() {
406
- return BorderNode.attributeDefinitions;
407
- }
408
-
409
- /** @internal */
410
- static getAttributeDefinitions() {
411
- return BorderNode.attributeDefinitions;
412
- }
413
-
414
- /** @internal */
415
- private static createAttributeDefinitions(): AttributeDefinitions {
416
- const attributeDefinitions = new AttributeDefinitions();
417
- attributeDefinitions.add("type", BorderNode.TYPE, true).setType(Attribute.STRING).setFixed();
418
-
419
- attributeDefinitions.add("selected", -1).setType(Attribute.NUMBER).setDescription(
420
- `index of selected/visible tab in border; -1 means no tab selected`
421
- );
422
- attributeDefinitions.add("show", true).setType(Attribute.BOOLEAN).setDescription(
423
- `show/hide this border`
424
- );
425
- attributeDefinitions.add("config", undefined).setType("any").setDescription(
426
- `a place to hold json config used in your own code`
427
- );
428
-
429
- attributeDefinitions.addInherited("enableDrop", "borderEnableDrop").setType(Attribute.BOOLEAN).setDescription(
430
- `whether tabs can be dropped into this border`
431
- );
432
- attributeDefinitions.addInherited("className", "borderClassName").setType(Attribute.STRING).setDescription(
433
- `class applied to tab button`
434
- );
435
- attributeDefinitions.addInherited("autoSelectTabWhenOpen", "borderAutoSelectTabWhenOpen").setType(Attribute.BOOLEAN).setDescription(
436
- `whether to select new/moved tabs in border when the border is already open`
437
- );
438
- attributeDefinitions.addInherited("autoSelectTabWhenClosed", "borderAutoSelectTabWhenClosed").setType(Attribute.BOOLEAN).setDescription(
439
- `whether to select new/moved tabs in border when the border is currently closed`
440
- );
441
- attributeDefinitions.addInherited("size", "borderSize").setType(Attribute.NUMBER).setDescription(
442
- `size of the tab area when selected`
443
- );
444
- attributeDefinitions.addInherited("minSize", "borderMinSize").setType(Attribute.NUMBER).setDescription(
445
- `the minimum size of the tab area`
446
- );
447
- attributeDefinitions.addInherited("maxSize", "borderMaxSize").setType(Attribute.NUMBER).setDescription(
448
- `the maximum size of the tab area`
449
- );
450
- attributeDefinitions.addInherited("enableAutoHide", "borderEnableAutoHide").setType(Attribute.BOOLEAN).setDescription(
451
- `hide border if it has zero tabs`
452
- );
453
- attributeDefinitions.addInherited("enableTabScrollbar", "borderEnableTabScrollbar").setType(Attribute.BOOLEAN).setDescription(
454
- `whether to show a mini scrollbar for the tabs`
455
- );
456
- return attributeDefinitions;
457
- }
458
- }
@@ -1,87 +0,0 @@
1
- import { DockLocation } from "../DockLocation";
2
- import { DropInfo } from "../DropInfo";
3
- import { BorderNode } from "./BorderNode";
4
- import { IDraggable } from "./IDraggable";
5
- import { Model } from "./Model";
6
- import { Node } from "./Node";
7
-
8
- export class BorderSet {
9
- /** @internal */
10
- static fromJson(json: any, model: Model) {
11
- const borderSet = new BorderSet(model);
12
- borderSet.borders = json.map((borderJson: any) => BorderNode.fromJson(borderJson, model));
13
- for (const border of borderSet.borders) {
14
- borderSet.borderMap.set(border.getLocation(), border);
15
- }
16
- return borderSet;
17
- }
18
- /** @internal */
19
- private borders: BorderNode[];
20
- /** @internal */
21
- private borderMap: Map<DockLocation, BorderNode>;
22
- /** @internal */
23
- private layoutHorizontal: boolean;
24
-
25
- /** @internal */
26
- constructor(_model: Model) {
27
- this.borders = [];
28
- this.borderMap = new Map<DockLocation, BorderNode>();
29
- this.layoutHorizontal = true;
30
- }
31
-
32
- toJson() {
33
- return this.borders.map((borderNode) => borderNode.toJson());
34
- }
35
-
36
- /** @internal */
37
- getLayoutHorizontal () {
38
- return this.layoutHorizontal;
39
- }
40
-
41
- /** @internal */
42
- getBorders() {
43
- return this.borders;
44
- }
45
-
46
- /** @internal */
47
- getBorderMap() {
48
- return this.borderMap;
49
- }
50
-
51
- /** @internal */
52
- forEachNode(fn: (node: Node, level: number) => void) {
53
- for (const borderNode of this.borders) {
54
- fn(borderNode, 0);
55
- for (const node of borderNode.getChildren()) {
56
- node.forEachNode(fn, 1);
57
- }
58
- }
59
- }
60
-
61
- /** @internal */
62
- setPaths() {
63
- for (const borderNode of this.borders) {
64
- const path = "/border/" + borderNode.getLocation().getName();
65
- borderNode.setPath(path);
66
- let i = 0;
67
- for (const node of borderNode.getChildren()) {
68
- node.setPath( path + "/t" + i);
69
- i++;
70
- }
71
- }
72
- }
73
-
74
-
75
- /** @internal */
76
- findDropTargetNode(dragNode: Node & IDraggable, x: number, y: number): DropInfo | undefined {
77
- for (const border of this.borders) {
78
- if (border.isShowing()) {
79
- const dropInfo = border.canDrop(dragNode, x, y);
80
- if (dropInfo !== undefined) {
81
- return dropInfo;
82
- }
83
- }
84
- }
85
- return undefined;
86
- }
87
- }
@@ -1,5 +0,0 @@
1
- export enum ICloseType {
2
- Visible = 1, // close if selected or hovered, i.e. when x is visible (will only close selected on mobile, where css hover is not available)
3
- Always = 2, // close always (both selected and unselected when x rect tapped e.g where a custom image has been added for close)
4
- Selected = 3, // close only if selected
5
- }
@@ -1,7 +0,0 @@
1
- export interface IDraggable {
2
- /** @internal */
3
- isEnableDrag(): boolean;
4
- /** @internal */
5
- getName(): string | undefined;
6
- }
7
-
@@ -1,14 +0,0 @@
1
- import { DockLocation } from "../DockLocation";
2
- import { DropInfo } from "../DropInfo";
3
- import { IDraggable } from "./IDraggable";
4
- import { Node } from "./Node";
5
-
6
- export interface IDropTarget {
7
- /** @internal */
8
- canDrop(dragNode: Node & IDraggable, x: number, y: number): DropInfo | undefined;
9
- /** @internal */
10
- drop(dragNode: Node & IDraggable, location: DockLocation, index: number, select?: boolean): void;
11
- /** @internal */
12
- isEnableDrop(): boolean;
13
- }
14
-