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,559 +0,0 @@
1
- import { TabNode } from "./TabNode";
2
- import { Attribute } from "../Attribute";
3
- import { AttributeDefinitions } from "../AttributeDefinitions";
4
- import { DockLocation } from "../DockLocation";
5
- import { DropInfo } from "../DropInfo";
6
- import { Orientation } from "../Orientation";
7
- import { CLASSES } from "../Types";
8
- import { BorderNode } from "./BorderNode";
9
- import { IDraggable } from "./IDraggable";
10
- import { IDropTarget } from "./IDropTarget";
11
- import { IJsonRowNode } from "./IJsonModel";
12
- import { DefaultMax, DefaultMin, Model } from "./Model";
13
- import { Node } from "./Node";
14
- import { TabSetNode } from "./TabSetNode";
15
- import { canDockToWindow } from "../view/Utils";
16
- import { LayoutWindow } from "./LayoutWindow";
17
-
18
- export class RowNode extends Node implements IDropTarget {
19
- static readonly TYPE = "row";
20
-
21
- /** @internal */
22
- static fromJson(json: any, model: Model, layoutWindow: LayoutWindow) {
23
- const newLayoutNode = new RowNode(model, layoutWindow.windowId, json);
24
-
25
- if (json.children != null) {
26
- for (const jsonChild of json.children) {
27
- if (jsonChild.type === TabSetNode.TYPE) {
28
- const child = TabSetNode.fromJson(jsonChild, model, layoutWindow);
29
- newLayoutNode.addChild(child);
30
- } else {
31
- const child = RowNode.fromJson(jsonChild, model, layoutWindow);
32
- newLayoutNode.addChild(child);
33
- }
34
- }
35
- }
36
-
37
- return newLayoutNode;
38
- }
39
-
40
- /** @internal */
41
- private static attributeDefinitions: AttributeDefinitions = RowNode.createAttributeDefinitions();
42
-
43
- /** @internal */
44
- private windowId: string;
45
- /** @internal */
46
- private minHeight: number;
47
- /** @internal */
48
- private minWidth: number;
49
- /** @internal */
50
- private maxHeight: number;
51
- /** @internal */
52
- private maxWidth: number;
53
-
54
- /** @internal */
55
- constructor(model: Model, windowId: string, json: any) {
56
- super(model);
57
-
58
- this.windowId = windowId;
59
- this.minHeight = DefaultMin;
60
- this.minWidth = DefaultMin;
61
- this.maxHeight = DefaultMax;
62
- this.maxWidth = DefaultMax;
63
- RowNode.attributeDefinitions.fromJson(json, this.attributes);
64
- this.normalizeWeights();
65
- model.addNode(this);
66
- }
67
-
68
- getWeight() {
69
- return this.attributes.weight as number;
70
- }
71
-
72
- toJson(): IJsonRowNode {
73
- const json: any = {};
74
- RowNode.attributeDefinitions.toJson(json, this.attributes);
75
-
76
- json.children = [];
77
- for (const child of this.children) {
78
- json.children.push(child.toJson());
79
- }
80
-
81
- return json;
82
- }
83
-
84
- /** @internal */
85
- getWindowId() {
86
- return this.windowId;
87
- }
88
-
89
- setWindowId(windowId: string) {
90
- this.windowId = windowId;
91
- }
92
-
93
- /** @internal */
94
- setWeight(weight: number) {
95
- this.attributes.weight = weight;
96
- }
97
-
98
- /** @internal */
99
- getSplitterBounds(index: number) {
100
- const h = this.getOrientation() === Orientation.HORZ;
101
- const c = this.getChildren();
102
- const ss = this.model.getSplitterSize();
103
- const fr = c[0].getRect();
104
- const lr = c[c.length - 1].getRect();
105
- let p = h ? [fr.x, lr.getRight()] : [fr.y, lr.getBottom()];
106
- const q = h ? [fr.x, lr.getRight()] : [fr.y, lr.getBottom()];
107
-
108
- for (let i = 0; i < index; i++) {
109
- const n = c[i] as TabSetNode | RowNode;
110
- p[0] += h ? n.getMinWidth() : n.getMinHeight();
111
- q[0] += h ? n.getMaxWidth() : n.getMaxHeight();
112
- if (i > 0) {
113
- p[0] += ss;
114
- q[0] += ss;
115
- }
116
- }
117
-
118
- for (let i = c.length - 1; i >= index; i--) {
119
- const n = c[i] as TabSetNode | RowNode;
120
- p[1] -= (h ? n.getMinWidth() : n.getMinHeight()) + ss;
121
- q[1] -= (h ? n.getMaxWidth() : n.getMaxHeight()) + ss;
122
- }
123
-
124
- p = [Math.max(q[1], p[0]), Math.min(q[0], p[1])];
125
-
126
- return p;
127
- }
128
-
129
- /** @internal */
130
- getSplitterInitials(index: number) {
131
- const h = this.getOrientation() === Orientation.HORZ;
132
- const c = this.getChildren();
133
- const ss = this.model.getSplitterSize();
134
- const initialSizes = [];
135
-
136
- let sum = 0;
137
-
138
- for (let i = 0; i < c.length; i++) {
139
- const n = c[i] as TabSetNode | RowNode;
140
- const r = n.getRect();
141
- const s = h ? r.width : r.height;
142
- initialSizes.push(s);
143
- sum += s;
144
- }
145
-
146
- const startRect = c[index].getRect()
147
- const startPosition = (h ? startRect.x : startRect.y) - ss;
148
-
149
- return { initialSizes, sum, startPosition };
150
- }
151
-
152
- /** @internal */
153
- calculateSplit(index: number, splitterPos: number, initialSizes: number[], sum: number, startPosition: number) {
154
- const h = this.getOrientation() === Orientation.HORZ;
155
- const c = this.getChildren();
156
- const sn = c[index] as TabSetNode | RowNode;
157
- const smax = h ? sn.getMaxWidth() : sn.getMaxHeight();
158
-
159
- const sizes = [...initialSizes];
160
-
161
- if (splitterPos < startPosition) { // moved left
162
- let shift = startPosition - splitterPos;
163
- let altShift = 0;
164
- if (sizes[index] + shift > smax) {
165
- altShift = sizes[index] + shift - smax;
166
- sizes[index] = smax;
167
- } else {
168
- sizes[index] += shift;
169
- }
170
-
171
- for (let i = index - 1; i >= 0; i--) {
172
- const n = c[i] as TabSetNode | RowNode;
173
- const m = h ? n.getMinWidth() : n.getMinHeight();
174
- if (sizes[i] - shift > m) {
175
- sizes[i] -= shift;
176
- break;
177
- } else {
178
- shift -= sizes[i] - m;
179
- sizes[i] = m;
180
- }
181
- }
182
-
183
- for (let i = index+1; i < c.length; i++) {
184
- const n = c[i] as TabSetNode | RowNode;
185
- const m = h ? n.getMaxWidth() : n.getMaxHeight();
186
- if (sizes[i] + altShift < m) {
187
- sizes[i] += altShift;
188
- break;
189
- } else {
190
- altShift -= m - sizes[i];
191
- sizes[i] = m;
192
- }
193
- }
194
-
195
-
196
- } else {
197
- let shift = splitterPos - startPosition;
198
- let altShift = 0;
199
- if (sizes[index-1] + shift > smax) {
200
- altShift = sizes[index-1] + shift - smax;
201
- sizes[index-1] = smax;
202
- } else {
203
- sizes[index-1] += shift;
204
- }
205
-
206
- for (let i = index; i < c.length; i++) {
207
- const n = c[i] as TabSetNode | RowNode;
208
- const m = h ? n.getMinWidth() : n.getMinHeight();
209
- if (sizes[i] - shift > m) {
210
- sizes[i] -= shift;
211
- break;
212
- } else {
213
- shift -= sizes[i] - m;
214
- sizes[i] = m;
215
- }
216
- }
217
-
218
- for (let i = index - 1; i >= 0; i--) {
219
- const n = c[i] as TabSetNode | RowNode;
220
- const m = h ? n.getMaxWidth() : n.getMaxHeight();
221
- if (sizes[i] + altShift < m) {
222
- sizes[i] += altShift;
223
- break;
224
- } else {
225
- altShift -= m - sizes[i];
226
- sizes[i] = m;
227
- }
228
- }
229
- }
230
-
231
- // 0.1 is to prevent weight ever going to zero
232
- const weights = sizes.map(s => Math.max(0.1, s) * 100 / sum);
233
-
234
- // console.log(splitterPos, startPosition, "sizes", sizes);
235
- // console.log("weights",weights);
236
- return weights;
237
- }
238
-
239
- /** @internal */
240
- getMinSize(orientation: Orientation) {
241
- if (orientation === Orientation.HORZ) {
242
- return this.getMinWidth();
243
- } else {
244
- return this.getMinHeight();
245
- }
246
- }
247
-
248
- /** @internal */
249
- getMinWidth() {
250
- return this.minWidth;
251
- }
252
-
253
- /** @internal */
254
- getMinHeight() {
255
- return this.minHeight;
256
- }
257
-
258
- /** @internal */
259
- getMaxSize(orientation: Orientation) {
260
- if (orientation === Orientation.HORZ) {
261
- return this.getMaxWidth();
262
- } else {
263
- return this.getMaxHeight();
264
- }
265
- }
266
-
267
- /** @internal */
268
- getMaxWidth() {
269
- return this.maxWidth;
270
- }
271
-
272
- /** @internal */
273
- getMaxHeight() {
274
- return this.maxHeight;
275
- }
276
-
277
- /** @internal */
278
- calcMinMaxSize() {
279
- this.minHeight = DefaultMin;
280
- this.minWidth = DefaultMin;
281
- this.maxHeight = DefaultMax;
282
- this.maxWidth = DefaultMax;
283
- let first = true;
284
- for (const child of this.children) {
285
- const c = child as RowNode | TabSetNode;
286
- c.calcMinMaxSize();
287
- if (this.getOrientation() === Orientation.VERT) {
288
- this.minHeight += c.getMinHeight();
289
- this.maxHeight += c.getMaxHeight();
290
- if (!first) {
291
- this.minHeight += this.model.getSplitterSize();
292
- this.maxHeight += this.model.getSplitterSize();
293
- }
294
- this.minWidth = Math.max(this.minWidth, c.getMinWidth());
295
- this.maxWidth = Math.min(this.maxWidth, c.getMaxWidth());
296
- } else {
297
- this.minWidth += c.getMinWidth();
298
- this.maxWidth += c.getMaxWidth();
299
- if (!first) {
300
- this.minWidth += this.model.getSplitterSize();
301
- this.maxWidth += this.model.getSplitterSize();
302
- }
303
- this.minHeight = Math.max(this.minHeight, c.getMinHeight());
304
- this.maxHeight = Math.min(this.maxHeight, c.getMaxHeight());
305
- }
306
- first = false;
307
- }
308
- }
309
-
310
- /** @internal */
311
- tidy() {
312
- let i = 0;
313
- while (i < this.children.length) {
314
- const child = this.children[i];
315
- if (child instanceof RowNode) {
316
- child.tidy();
317
-
318
- const childChildren = child.getChildren();
319
- if (childChildren.length === 0) {
320
- this.removeChild(child);
321
- } else if (childChildren.length === 1) {
322
- // hoist child/children up to this level
323
- const subchild = childChildren[0];
324
- this.removeChild(child);
325
- if (subchild instanceof RowNode) {
326
- let subChildrenTotal = 0;
327
- const subChildChildren = subchild.getChildren();
328
- for (const ssc of subChildChildren) {
329
- const subsubChild = ssc as RowNode | TabSetNode;
330
- subChildrenTotal += subsubChild.getWeight();
331
- }
332
- for (let j = 0; j < subChildChildren.length; j++) {
333
- const subsubChild = subChildChildren[j] as RowNode | TabSetNode;
334
- subsubChild.setWeight((child.getWeight() * subsubChild.getWeight()) / subChildrenTotal);
335
- this.addChild(subsubChild, i + j);
336
- }
337
- } else {
338
- subchild.setWeight(child.getWeight());
339
- this.addChild(subchild, i);
340
- }
341
- } else {
342
- i++;
343
- }
344
- } else if (child instanceof TabSetNode && child.getChildren().length === 0) {
345
- if (child.isEnableDeleteWhenEmpty()) {
346
- this.removeChild(child);
347
- if (child === this.model.getMaximizedTabset(this.windowId)) {
348
- this.model.setMaximizedTabset(undefined, this.windowId);
349
- }
350
- } else {
351
- i++;
352
- }
353
- } else {
354
- i++;
355
- }
356
- }
357
-
358
- // add tabset into empty root
359
- if (this === this.model.getRoot(this.windowId) && this.children.length === 0) {
360
- const callback = this.model.getOnCreateTabSet();
361
- let attrs = callback ? callback() : {};
362
- attrs = { ...attrs, selected: -1 };
363
- const child = new TabSetNode(this.model, attrs);
364
- this.model.setActiveTabset(child, this.windowId);
365
- this.addChild(child);
366
- }
367
-
368
- }
369
-
370
- /** @internal */
371
- canDrop(dragNode: Node & IDraggable, x: number, y: number): DropInfo | undefined {
372
- const yy = y - this.rect.y;
373
- const xx = x - this.rect.x;
374
- const w = this.rect.width;
375
- const h = this.rect.height;
376
- const margin = 10; // height of edge rect
377
- const half = 50; // half width of edge rect
378
- let dropInfo;
379
-
380
- if (this.getWindowId() !== Model.MAIN_WINDOW_ID && !canDockToWindow(dragNode)) {
381
- return undefined;
382
- }
383
-
384
- if (this.model.isEnableEdgeDock() && this.parent === undefined) {
385
- if (x < this.rect.x + margin && yy > h / 2 - half && yy < h / 2 + half) {
386
- const dockLocation = DockLocation.LEFT;
387
- const outlineRect = dockLocation.getDockRect(this.rect);
388
- outlineRect.width = outlineRect.width / 2;
389
- dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
390
- } else if (x > this.rect.getRight() - margin && yy > h / 2 - half && yy < h / 2 + half) {
391
- const dockLocation = DockLocation.RIGHT;
392
- const outlineRect = dockLocation.getDockRect(this.rect);
393
- outlineRect.width = outlineRect.width / 2;
394
- outlineRect.x += outlineRect.width;
395
- dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
396
- } else if (y < this.rect.y + margin && xx > w / 2 - half && xx < w / 2 + half) {
397
- const dockLocation = DockLocation.TOP;
398
- const outlineRect = dockLocation.getDockRect(this.rect);
399
- outlineRect.height = outlineRect.height / 2;
400
- dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
401
- } else if (y > this.rect.getBottom() - margin && xx > w / 2 - half && xx < w / 2 + half) {
402
- const dockLocation = DockLocation.BOTTOM;
403
- const outlineRect = dockLocation.getDockRect(this.rect);
404
- outlineRect.height = outlineRect.height / 2;
405
- outlineRect.y += outlineRect.height;
406
- dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT_EDGE);
407
- }
408
-
409
- if (dropInfo !== undefined) {
410
- if (!dragNode.canDockInto(dragNode, dropInfo)) {
411
- return undefined;
412
- }
413
- }
414
- }
415
-
416
- return dropInfo;
417
- }
418
-
419
- /** @internal */
420
- drop(dragNode: Node, location: DockLocation, index: number): void {
421
- const dockLocation = location;
422
-
423
- const parent = dragNode.getParent();
424
-
425
- if (parent) {
426
- parent.removeChild(dragNode);
427
- }
428
-
429
- if (parent !== undefined && parent! instanceof TabSetNode) {
430
- parent.setSelected(0);
431
- }
432
-
433
- if (parent !== undefined && parent! instanceof BorderNode) {
434
- parent.setSelected(-1);
435
- }
436
-
437
- let node: TabSetNode | RowNode | undefined;
438
- if (dragNode instanceof TabSetNode || dragNode instanceof RowNode) {
439
- node = dragNode;
440
- // need to turn round if same orientation unless docking oposite direction
441
- if (node instanceof RowNode && node.getOrientation() === this.getOrientation() &&
442
- (location.getOrientation() === this.getOrientation() || location === DockLocation.CENTER)) {
443
- node = new RowNode(this.model, this.windowId, {});
444
- node.addChild(dragNode);
445
- }
446
- } else {
447
- const callback = this.model.getOnCreateTabSet();
448
- node = new TabSetNode(this.model, callback ? callback(dragNode as TabNode) : {});
449
- node.addChild(dragNode);
450
- }
451
- let size = this.children.reduce((sum, child) => {
452
- return sum + (child as RowNode | TabSetNode).getWeight();
453
- }, 0);
454
-
455
- if (size === 0) {
456
- size = 100;
457
- }
458
-
459
- node.setWeight(size / 3);
460
-
461
- const horz = !this.model.isRootOrientationVertical();
462
- if (dockLocation === DockLocation.CENTER) {
463
- if (index === -1) {
464
- this.addChild(node, this.children.length);
465
- } else {
466
- this.addChild(node, index);
467
- }
468
- } else if (horz && dockLocation === DockLocation.LEFT || !horz && dockLocation === DockLocation.TOP) {
469
- this.addChild(node, 0);
470
- } else if (horz && dockLocation === DockLocation.RIGHT || !horz && dockLocation === DockLocation.BOTTOM) {
471
- this.addChild(node);
472
- } else if (horz && dockLocation === DockLocation.TOP || !horz && dockLocation === DockLocation.LEFT) {
473
- const vrow = new RowNode(this.model, this.windowId, {});
474
- const hrow = new RowNode(this.model, this.windowId, {});
475
- hrow.setWeight(75);
476
- node.setWeight(25);
477
- for (const child of this.children) {
478
- hrow.addChild(child);
479
- }
480
- this.removeAll();
481
- vrow.addChild(node);
482
- vrow.addChild(hrow);
483
- this.addChild(vrow);
484
- } else if (horz && dockLocation === DockLocation.BOTTOM || !horz && dockLocation === DockLocation.RIGHT) {
485
- const vrow = new RowNode(this.model, this.windowId, {});
486
- const hrow = new RowNode(this.model, this.windowId, {});
487
- hrow.setWeight(75);
488
- node.setWeight(25);
489
- for (const child of this.children) {
490
- hrow.addChild(child);
491
- }
492
- this.removeAll();
493
- vrow.addChild(hrow);
494
- vrow.addChild(node);
495
- this.addChild(vrow);
496
- }
497
-
498
- if (node instanceof TabSetNode) {
499
- this.model.setActiveTabset(node, this.windowId);
500
- }
501
-
502
- this.model.tidy();
503
- }
504
-
505
-
506
-
507
- /** @internal */
508
- isEnableDrop() {
509
- return true;
510
- }
511
-
512
- /** @internal */
513
- getAttributeDefinitions() {
514
- return RowNode.attributeDefinitions;
515
- }
516
-
517
- /** @internal */
518
- updateAttrs(json: any) {
519
- RowNode.attributeDefinitions.update(json, this.attributes);
520
- }
521
-
522
- /** @internal */
523
- static getAttributeDefinitions() {
524
- return RowNode.attributeDefinitions;
525
- }
526
-
527
-
528
- // NOTE: flex-grow cannot have values < 1 otherwise will not fill parent, need to normalize
529
- normalizeWeights() {
530
- let sum = 0;
531
- for (const n of this.children) {
532
- const node = (n as TabSetNode | RowNode);
533
- sum += node.getWeight();
534
- }
535
-
536
- if (sum === 0) {
537
- sum = 1;
538
- }
539
-
540
- for (const n of this.children) {
541
- const node = (n as TabSetNode | RowNode);
542
- node.setWeight(Math.max(0.001, 100 * node.getWeight() / sum));
543
- }
544
- }
545
-
546
- /** @internal */
547
- private static createAttributeDefinitions(): AttributeDefinitions {
548
- const attributeDefinitions = new AttributeDefinitions();
549
- attributeDefinitions.add("type", RowNode.TYPE, true).setType(Attribute.STRING).setFixed();
550
- attributeDefinitions.add("id", undefined).setType(Attribute.STRING).setDescription(
551
- `the unique id of the row, if left undefined a uuid will be assigned`
552
- );
553
- attributeDefinitions.add("weight", 100).setType(Attribute.NUMBER).setDescription(
554
- `relative weight for sizing of this row in parent row`
555
- );
556
-
557
- return attributeDefinitions;
558
- }
559
- }