flexlayout-react 0.7.15 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/ChangeLog.txt +23 -0
  2. package/README.md +157 -330
  3. package/Screenshot_light.png +0 -0
  4. package/Screenshot_rounded.png +0 -0
  5. package/declarations/Attribute.d.ts +1 -1
  6. package/declarations/AttributeDefinitions.d.ts +1 -1
  7. package/declarations/DockLocation.d.ts +12 -12
  8. package/declarations/DropInfo.d.ts +12 -12
  9. package/declarations/I18nLabel.d.ts +12 -14
  10. package/declarations/Orientation.d.ts +7 -7
  11. package/declarations/PopupMenu.d.ts +1 -1
  12. package/declarations/Rect.d.ts +41 -28
  13. package/declarations/Types.d.ts +95 -79
  14. package/declarations/examples/demo/Utils.d.ts +4 -0
  15. package/declarations/index.d.ts +21 -22
  16. package/declarations/model/Action.d.ts +5 -5
  17. package/declarations/model/Actions.d.ts +127 -110
  18. package/declarations/model/BorderNode.d.ts +30 -34
  19. package/declarations/model/BorderSet.d.ts +3 -4
  20. package/declarations/model/ICloseType.d.ts +5 -5
  21. package/declarations/model/IDraggable.d.ts +2 -2
  22. package/declarations/model/IDropTarget.d.ts +2 -2
  23. package/declarations/model/IJsonModel.d.ts +811 -149
  24. package/declarations/model/LayoutWindow.d.ts +28 -0
  25. package/declarations/model/Model.d.ts +91 -86
  26. package/declarations/model/Node.d.ts +17 -17
  27. package/declarations/model/RowNode.d.ts +10 -11
  28. package/declarations/model/TabNode.d.ts +44 -37
  29. package/declarations/model/TabSetNode.d.ts +44 -41
  30. package/declarations/model/Utils.d.ts +1 -1
  31. package/declarations/model/WindowLayout.d.ts +24 -0
  32. package/declarations/src/Attribute.d.ts +1 -0
  33. package/declarations/src/AttributeDefinitions.d.ts +1 -0
  34. package/declarations/src/DockLocation.d.ts +12 -0
  35. package/declarations/src/DropInfo.d.ts +12 -0
  36. package/declarations/src/I18nLabel.d.ts +10 -0
  37. package/declarations/src/Orientation.d.ts +7 -0
  38. package/declarations/src/PopupMenu.d.ts +1 -0
  39. package/declarations/src/Rect.d.ts +31 -0
  40. package/declarations/src/Types.d.ts +92 -0
  41. package/declarations/src/index.d.ts +20 -0
  42. package/declarations/src/model/Action.d.ts +5 -0
  43. package/declarations/src/model/Actions.d.ts +110 -0
  44. package/declarations/src/model/BorderNode.d.ts +28 -0
  45. package/declarations/src/model/BorderSet.d.ts +3 -0
  46. package/declarations/src/model/ICloseType.d.ts +5 -0
  47. package/declarations/src/model/IDraggable.d.ts +2 -0
  48. package/declarations/src/model/IDropTarget.d.ts +2 -0
  49. package/declarations/src/model/IJsonModel.d.ts +153 -0
  50. package/declarations/src/model/Model.d.ts +98 -0
  51. package/declarations/src/model/Node.d.ts +16 -0
  52. package/declarations/src/model/RowNode.d.ts +11 -0
  53. package/declarations/src/model/TabNode.d.ts +36 -0
  54. package/declarations/src/model/TabSetNode.d.ts +37 -0
  55. package/declarations/src/model/Utils.d.ts +1 -0
  56. package/declarations/src/view/BorderButton.d.ts +1 -0
  57. package/declarations/src/view/BorderTab.d.ts +2 -0
  58. package/declarations/src/view/BorderTabSet.d.ts +1 -0
  59. package/declarations/src/view/DragContainer.d.ts +1 -0
  60. package/declarations/src/view/ErrorBoundary.d.ts +1 -0
  61. package/declarations/src/view/FloatingWindow.d.ts +1 -0
  62. package/declarations/src/view/Icons.d.ts +7 -0
  63. package/declarations/src/view/Layout.d.ts +113 -0
  64. package/declarations/src/view/Overlay.d.ts +1 -0
  65. package/declarations/src/view/PopupMenu.d.ts +1 -0
  66. package/declarations/src/view/Row.d.ts +1 -0
  67. package/declarations/src/view/Splitter.d.ts +1 -0
  68. package/declarations/src/view/Tab.d.ts +1 -0
  69. package/declarations/src/view/TabButton.d.ts +1 -0
  70. package/declarations/src/view/TabButtonStamp.d.ts +1 -0
  71. package/declarations/src/view/TabOverflowHook.d.ts +1 -0
  72. package/declarations/src/view/TabSet.d.ts +1 -0
  73. package/declarations/src/view/Utils.d.ts +4 -0
  74. package/declarations/view/BorderButton.d.ts +1 -1
  75. package/declarations/view/BorderTab.d.ts +2 -0
  76. package/declarations/view/BorderTabSet.d.ts +1 -1
  77. package/declarations/view/DragContainer.d.ts +1 -0
  78. package/declarations/view/ErrorBoundary.d.ts +1 -1
  79. package/declarations/view/ExtendedResizeObserver.d.ts +23 -0
  80. package/declarations/view/FloatingWindow.d.ts +1 -1
  81. package/declarations/view/Icons.d.ts +8 -7
  82. package/declarations/view/Layout.d.ts +139 -161
  83. package/declarations/view/Overlay.d.ts +1 -0
  84. package/declarations/view/PopoutWindow.d.ts +1 -0
  85. package/declarations/view/PopupMenu.d.ts +1 -0
  86. package/declarations/view/Row.d.ts +1 -0
  87. package/declarations/view/SizeTracker.d.ts +10 -0
  88. package/declarations/view/Splitter.d.ts +1 -1
  89. package/declarations/view/Tab.d.ts +1 -1
  90. package/declarations/view/TabButton.d.ts +1 -1
  91. package/declarations/view/TabButtonStamp.d.ts +1 -1
  92. package/declarations/view/TabOverflowHook.d.ts +1 -1
  93. package/declarations/view/TabSet.d.ts +1 -1
  94. package/declarations/view/Utils.d.ts +11 -1
  95. package/dist/bundles/demo.js +232052 -0
  96. package/dist/bundles/demo.js.map +1 -0
  97. package/dist/flexlayout.js +122 -92
  98. package/dist/flexlayout_min.js +1 -1
  99. package/lib/Attribute.js +42 -31
  100. package/lib/Attribute.js.map +1 -1
  101. package/lib/AttributeDefinitions.js +131 -108
  102. package/lib/AttributeDefinitions.js.map +1 -1
  103. package/lib/DockLocation.js +120 -124
  104. package/lib/DockLocation.js.map +1 -1
  105. package/lib/DropInfo.js +9 -13
  106. package/lib/DropInfo.js.map +1 -1
  107. package/lib/I18nLabel.js +13 -18
  108. package/lib/I18nLabel.js.map +1 -1
  109. package/lib/Orientation.js +22 -26
  110. package/lib/Orientation.js.map +1 -1
  111. package/lib/Rect.js +104 -72
  112. package/lib/Rect.js.map +1 -1
  113. package/lib/Types.js +96 -83
  114. package/lib/Types.js.map +1 -1
  115. package/lib/index.js +21 -38
  116. package/lib/index.js.map +1 -1
  117. package/lib/model/Action.js +6 -10
  118. package/lib/model/Action.js.map +1 -1
  119. package/lib/model/Actions.js +169 -155
  120. package/lib/model/Actions.js.map +1 -1
  121. package/lib/model/BorderNode.js +385 -406
  122. package/lib/model/BorderNode.js.map +1 -1
  123. package/lib/model/BorderSet.js +66 -121
  124. package/lib/model/BorderSet.js.map +1 -1
  125. package/lib/model/ICloseType.js +6 -9
  126. package/lib/model/ICloseType.js.map +1 -1
  127. package/lib/model/IDraggable.js +1 -2
  128. package/lib/model/IDropTarget.js +1 -2
  129. package/lib/model/IJsonModel.js +1 -2
  130. package/lib/model/LayoutWindow.js +83 -0
  131. package/lib/model/LayoutWindow.js.map +1 -0
  132. package/lib/model/Model.js +614 -496
  133. package/lib/model/Model.js.map +1 -1
  134. package/lib/model/Node.js +217 -228
  135. package/lib/model/Node.js.map +1 -1
  136. package/lib/model/RowNode.js +491 -504
  137. package/lib/model/RowNode.js.map +1 -1
  138. package/lib/model/TabNode.js +289 -184
  139. package/lib/model/TabNode.js.map +1 -1
  140. package/lib/model/TabSetNode.js +457 -446
  141. package/lib/model/TabSetNode.js.map +1 -1
  142. package/lib/model/Utils.js +47 -82
  143. package/lib/model/Utils.js.map +1 -1
  144. package/lib/view/BorderButton.js +124 -138
  145. package/lib/view/BorderButton.js.map +1 -1
  146. package/lib/view/BorderTab.js +47 -0
  147. package/lib/view/BorderTab.js.map +1 -0
  148. package/lib/view/BorderTabSet.js +134 -128
  149. package/lib/view/BorderTabSet.js.map +1 -1
  150. package/lib/view/DragContainer.js +16 -0
  151. package/lib/view/DragContainer.js.map +1 -0
  152. package/lib/view/ErrorBoundary.js +23 -27
  153. package/lib/view/ErrorBoundary.js.map +1 -1
  154. package/lib/view/Icons.js +40 -45
  155. package/lib/view/Icons.js.map +1 -1
  156. package/lib/view/Layout.js +918 -907
  157. package/lib/view/Layout.js.map +1 -1
  158. package/lib/view/Overlay.js +9 -0
  159. package/lib/view/Overlay.js.map +1 -0
  160. package/lib/view/PopoutWindow.js +129 -0
  161. package/lib/view/PopoutWindow.js.map +1 -0
  162. package/lib/view/PopupMenu.js +71 -0
  163. package/lib/view/PopupMenu.js.map +1 -0
  164. package/lib/view/Row.js +45 -0
  165. package/lib/view/Row.js.map +1 -0
  166. package/lib/view/SizeTracker.js +11 -0
  167. package/lib/view/SizeTracker.js.map +1 -0
  168. package/lib/view/Splitter.js +191 -147
  169. package/lib/view/Splitter.js.map +1 -1
  170. package/lib/view/Tab.js +86 -60
  171. package/lib/view/Tab.js.map +1 -1
  172. package/lib/view/TabButton.js +122 -135
  173. package/lib/view/TabButton.js.map +1 -1
  174. package/lib/view/TabButtonStamp.js +16 -21
  175. package/lib/view/TabButtonStamp.js.map +1 -1
  176. package/lib/view/TabOverflowHook.js +150 -149
  177. package/lib/view/TabOverflowHook.js.map +1 -1
  178. package/lib/view/TabSet.js +267 -234
  179. package/lib/view/TabSet.js.map +1 -1
  180. package/lib/view/Utils.js +126 -68
  181. package/lib/view/Utils.js.map +1 -1
  182. package/package.json +36 -30
  183. package/src/Attribute.ts +23 -0
  184. package/src/AttributeDefinitions.ts +38 -15
  185. package/src/DockLocation.ts +13 -13
  186. package/src/I18nLabel.ts +7 -9
  187. package/src/Rect.ts +53 -1
  188. package/src/Types.ts +16 -0
  189. package/src/index.ts +1 -2
  190. package/src/model/Actions.ts +49 -29
  191. package/src/model/BorderNode.ts +208 -214
  192. package/src/model/BorderSet.ts +42 -91
  193. package/src/model/IJsonModel.ts +883 -103
  194. package/src/model/LayoutWindow.ts +121 -0
  195. package/src/model/Model.ts +488 -366
  196. package/src/model/Node.ts +98 -111
  197. package/src/model/RowNode.ts +323 -319
  198. package/src/model/TabNode.ts +294 -110
  199. package/src/model/TabSetNode.ts +300 -242
  200. package/src/model/Utils.ts +6 -32
  201. package/src/view/BorderButton.tsx +32 -52
  202. package/src/view/BorderTab.tsx +70 -0
  203. package/src/view/BorderTabSet.tsx +64 -52
  204. package/src/view/DragContainer.tsx +32 -0
  205. package/src/view/Icons.tsx +6 -0
  206. package/src/view/Layout.tsx +1051 -1046
  207. package/src/view/Overlay.tsx +22 -0
  208. package/src/view/PopoutWindow.tsx +152 -0
  209. package/src/{PopupMenu.tsx → view/PopupMenu.tsx} +36 -31
  210. package/src/view/Row.tsx +68 -0
  211. package/src/view/SizeTracker.tsx +20 -0
  212. package/src/view/Splitter.tsx +167 -112
  213. package/src/view/Tab.tsx +76 -42
  214. package/src/view/TabButton.tsx +36 -55
  215. package/src/view/TabButtonStamp.tsx +5 -9
  216. package/src/view/TabOverflowHook.tsx +14 -9
  217. package/src/view/TabSet.tsx +217 -176
  218. package/src/view/Utils.tsx +119 -39
  219. package/style/_base.scss +140 -34
  220. package/style/dark.css +685 -580
  221. package/style/dark.css.map +1 -1
  222. package/style/dark.scss +3 -1
  223. package/style/gray.css +668 -563
  224. package/style/gray.css.map +1 -1
  225. package/style/gray.scss +2 -0
  226. package/style/light.css +669 -564
  227. package/style/light.css.map +1 -1
  228. package/style/light.scss +4 -2
  229. package/style/rounded.css +697 -0
  230. package/style/rounded.css.map +1 -0
  231. package/style/rounded.scss +194 -0
  232. package/style/underline.css +690 -585
  233. package/style/underline.css.map +1 -1
  234. package/style/underline.scss +2 -0
  235. package/cypress.config.ts +0 -16
  236. package/lib/DragDrop.js +0 -316
  237. package/lib/DragDrop.js.map +0 -1
  238. package/lib/PopupMenu.js +0 -68
  239. package/lib/PopupMenu.js.map +0 -1
  240. package/lib/model/SplitterNode.js +0 -72
  241. package/lib/model/SplitterNode.js.map +0 -1
  242. package/lib/view/FloatingWindow.js +0 -123
  243. package/lib/view/FloatingWindow.js.map +0 -1
  244. package/lib/view/FloatingWindowTab.js +0 -19
  245. package/lib/view/FloatingWindowTab.js.map +0 -1
  246. package/lib/view/TabFloating.js +0 -66
  247. package/lib/view/TabFloating.js.map +0 -1
  248. package/src/DragDrop.ts +0 -392
  249. package/src/model/SplitterNode.ts +0 -78
  250. package/src/view/FloatingWindow.tsx +0 -140
  251. package/src/view/FloatingWindowTab.tsx +0 -29
  252. package/src/view/TabFloating.tsx +0 -101
@@ -4,7 +4,7 @@ import { Rect } from "../Rect";
4
4
  import { BorderNode } from "./BorderNode";
5
5
  import { IDraggable } from "./IDraggable";
6
6
  import { IJsonTabNode } from "./IJsonModel";
7
- import { Model, ILayoutMetrics } from "./Model";
7
+ import { Model } from "./Model";
8
8
  import { Node } from "./Node";
9
9
  import { TabSetNode } from "./TabSetNode";
10
10
 
@@ -12,99 +12,71 @@ export class TabNode extends Node implements IDraggable {
12
12
  static readonly TYPE = "tab";
13
13
 
14
14
  /** @internal */
15
- static _fromJson(json: any, model: Model, addToModel: boolean = true) {
15
+ static fromJson(json: any, model: Model, addToModel: boolean = true) {
16
16
  const newLayoutNode = new TabNode(model, json, addToModel);
17
17
  return newLayoutNode;
18
18
  }
19
- /** @internal */
20
- private static _attributeDefinitions: AttributeDefinitions = TabNode._createAttributeDefinitions();
21
19
 
22
20
  /** @internal */
23
- private static _createAttributeDefinitions(): AttributeDefinitions {
24
- const attributeDefinitions = new AttributeDefinitions();
25
- attributeDefinitions.add("type", TabNode.TYPE, true).setType(Attribute.STRING);
26
- attributeDefinitions.add("id", undefined).setType(Attribute.STRING);
27
-
28
- attributeDefinitions.add("name", "[Unnamed Tab]").setType(Attribute.STRING);
29
- attributeDefinitions.add("altName", undefined).setType(Attribute.STRING);
30
- attributeDefinitions.add("helpText", undefined).setType(Attribute.STRING);
31
- attributeDefinitions.add("component", undefined).setType(Attribute.STRING);
32
- attributeDefinitions.add("config", undefined).setType("any");
33
- attributeDefinitions.add("floating", false).setType(Attribute.BOOLEAN);
34
- attributeDefinitions.add("tabsetClassName", undefined).setType(Attribute.STRING);
35
-
36
- attributeDefinitions.addInherited("enableClose", "tabEnableClose").setType(Attribute.BOOLEAN);
37
- attributeDefinitions.addInherited("closeType", "tabCloseType").setType("ICloseType");
38
- attributeDefinitions.addInherited("enableDrag", "tabEnableDrag").setType(Attribute.BOOLEAN);
39
- attributeDefinitions.addInherited("enableRename", "tabEnableRename").setType(Attribute.BOOLEAN);
40
- attributeDefinitions.addInherited("className", "tabClassName").setType(Attribute.STRING);
41
- attributeDefinitions.addInherited("contentClassName", "tabContentClassName").setType(Attribute.STRING);
42
- attributeDefinitions.addInherited("icon", "tabIcon").setType(Attribute.STRING);
43
- attributeDefinitions.addInherited("enableRenderOnDemand", "tabEnableRenderOnDemand").setType(Attribute.BOOLEAN);
44
- attributeDefinitions.addInherited("enableFloat", "tabEnableFloat").setType(Attribute.BOOLEAN);
45
- attributeDefinitions.addInherited("borderWidth", "tabBorderWidth").setType(Attribute.NUMBER);
46
- attributeDefinitions.addInherited("borderHeight", "tabBorderHeight").setType(Attribute.NUMBER);
47
- return attributeDefinitions;
48
- }
49
-
21
+ private tabRect: Rect = Rect.empty();
22
+ /** @internal */
23
+ private moveableElement: HTMLElement | null;
24
+ /** @internal */
25
+ private tabStamp: HTMLElement | null;
50
26
  /** @internal */
51
- private _tabRect?: Rect;
27
+ private renderedName?: string;
52
28
  /** @internal */
53
- private _renderedName?: string;
29
+ private extra: Record<string, any>;
54
30
  /** @internal */
55
- private _extra: Record<string, any>;
31
+ private visible: boolean;
56
32
  /** @internal */
57
- private _window?: Window;
33
+ private rendered: boolean;
34
+ /** @internal */
35
+ private scrollTop?: number;
36
+ /** @internal */
37
+ private scrollLeft?: number;
58
38
 
59
39
  /** @internal */
60
40
  constructor(model: Model, json: any, addToModel: boolean = true) {
61
41
  super(model);
62
42
 
63
- this._extra = {}; // extra data added to node not saved in json
43
+ this.extra = {}; // extra data added to node not saved in json
44
+ this.moveableElement = null;
45
+ this.tabStamp = null;
46
+ this.rendered = false;
47
+ this.visible = false;
64
48
 
65
- TabNode._attributeDefinitions.fromJson(json, this._attributes);
49
+ TabNode.attributeDefinitions.fromJson(json, this.attributes);
66
50
  if (addToModel === true) {
67
- model._addNode(this);
51
+ model.addNode(this);
68
52
  }
69
53
  }
70
54
 
71
- getWindow() {
72
- return this._window;
73
- }
74
-
75
- getTabRect() {
76
- return this._tabRect;
55
+ getName() {
56
+ return this.getAttr("name") as string;
77
57
  }
78
58
 
79
- /** @internal */
80
- _setTabRect(rect: Rect) {
81
- this._tabRect = rect;
59
+ getHelpText() {
60
+ return this.getAttr("helpText") as string | undefined;
82
61
  }
83
62
 
84
- /** @internal */
85
- _setRenderedName(name: string) {
86
- this._renderedName = name;
63
+ getComponent() {
64
+ return this.getAttr("component") as string | undefined;
87
65
  }
88
66
 
89
- /** @internal */
90
- _getNameForOverflowMenu() {
91
- const altName = this._getAttr("altName") as string;
92
- if (altName !== undefined) {
93
- return altName;
67
+ getWindowId() {
68
+ if (this.parent instanceof TabSetNode) {
69
+ return this.parent.getWindowId();
94
70
  }
95
- return this._renderedName;
71
+ return Model.MAIN_WINDOW_ID;
96
72
  }
97
73
 
98
- getName() {
99
- return this._getAttr("name") as string;
100
- }
101
-
102
- getHelpText() {
103
- return this._getAttr("helpText") as string | undefined;
104
- }
105
-
106
- getComponent() {
107
- return this._getAttr("component") as string | undefined;
74
+ getWindow() : Window | undefined {
75
+ const layoutWindow = this.model.getwindowsMap().get(this.getWindowId());
76
+ if (layoutWindow) {
77
+ return layoutWindow.window;
78
+ }
79
+ return undefined;
108
80
  }
109
81
 
110
82
  /**
@@ -115,7 +87,7 @@ export class TabNode extends Node implements IDraggable {
115
87
  * FlexLayout.Actions.updateNodeAttributes(node.getId(), {config:myConfigObject}));
116
88
  */
117
89
  getConfig() {
118
- return this._attributes.config;
90
+ return this.attributes.config;
119
91
  }
120
92
 
121
93
  /**
@@ -123,114 +95,326 @@ export class TabNode extends Node implements IDraggable {
123
95
  * NOT be saved in the json.
124
96
  */
125
97
  getExtraData() {
126
- return this._extra;
98
+ return this.extra;
99
+ }
100
+
101
+ isPoppedOut() {
102
+ return this.getWindowId() !== Model.MAIN_WINDOW_ID;
127
103
  }
128
104
 
129
- isFloating() {
130
- return this._getAttr("floating") as boolean;
105
+ isSelected() {
106
+ return (this.getParent() as TabSetNode | BorderNode).getSelectedNode() === this;
131
107
  }
132
108
 
133
109
  getIcon() {
134
- return this._getAttr("icon") as string | undefined;
110
+ return this.getAttr("icon") as string | undefined;
135
111
  }
136
112
 
137
113
  isEnableClose() {
138
- return this._getAttr("enableClose") as boolean;
114
+ return this.getAttr("enableClose") as boolean;
139
115
  }
140
116
 
141
117
  getCloseType() {
142
- return this._getAttr("closeType") as number;
118
+ return this.getAttr("closeType") as number;
119
+ }
120
+
121
+ isEnablePopout() {
122
+ return this.getAttr("enablePopout") as boolean;
123
+ }
124
+
125
+ isEnablePopoutIcon() {
126
+ return this.getAttr("enablePopoutIcon") as boolean;
143
127
  }
144
128
 
145
- isEnableFloat() {
146
- return this._getAttr("enableFloat") as boolean;
129
+ isEnablePopoutOverlay() {
130
+ return this.getAttr("enablePopoutOverlay") as boolean;
147
131
  }
148
132
 
149
133
  isEnableDrag() {
150
- return this._getAttr("enableDrag") as boolean;
134
+ return this.getAttr("enableDrag") as boolean;
151
135
  }
152
136
 
153
137
  isEnableRename() {
154
- return this._getAttr("enableRename") as boolean;
138
+ return this.getAttr("enableRename") as boolean;
139
+ }
140
+
141
+ isEnableWindowReMount() {
142
+ return this.getAttr("enableWindowReMount") as boolean;
155
143
  }
156
144
 
157
145
  getClassName() {
158
- return this._getAttr("className") as string | undefined;
146
+ return this.getAttr("className") as string | undefined;
159
147
  }
160
-
148
+
161
149
  getContentClassName() {
162
- return this._getAttr("contentClassName") as string | undefined;
150
+ return this.getAttr("contentClassName") as string | undefined;
163
151
  }
164
152
 
165
153
  getTabSetClassName() {
166
- return this._getAttr("tabsetClassName") as string | undefined;
154
+ return this.getAttr("tabsetClassName") as string | undefined;
167
155
  }
168
156
 
169
157
  isEnableRenderOnDemand() {
170
- return this._getAttr("enableRenderOnDemand") as boolean;
158
+ return this.getAttr("enableRenderOnDemand") as boolean;
159
+ }
160
+
161
+ getMinWidth() {
162
+ return this.getAttr("minWidth") as number;
163
+ }
164
+
165
+ getMinHeight() {
166
+ return this.getAttr("minHeight") as number;
167
+ }
168
+
169
+ getMaxWidth() {
170
+ return this.getAttr("maxWidth") as number;
171
+ }
172
+
173
+ getMaxHeight() {
174
+ return this.getAttr("maxHeight") as number;
175
+ }
176
+
177
+ toJson(): IJsonTabNode {
178
+ const json = {};
179
+ TabNode.attributeDefinitions.toJson(json, this.attributes);
180
+ return json;
171
181
  }
172
182
 
173
183
  /** @internal */
174
- _setName(name: string) {
175
- this._attributes.name = name;
176
- if (this._window && this._window.document) {
177
- this._window.document.title = name;
184
+ saveScrollPosition() {
185
+ if (this.moveableElement) {
186
+ this.scrollLeft = this.moveableElement.scrollLeft;
187
+ this.scrollTop = this.moveableElement.scrollTop;
188
+ // console.log("save", this.getName(), this.scrollTop);
178
189
  }
179
190
  }
180
191
 
181
192
  /** @internal */
182
- _setFloating(float: boolean) {
183
- this._attributes.floating = float;
193
+ restoreScrollPosition() {
194
+ if (this.scrollTop) {
195
+ requestAnimationFrame(() => {
196
+ if (this.moveableElement) {
197
+ if (this.scrollTop) {
198
+ // console.log("restore", this.getName(), this.scrollTop);
199
+ this.moveableElement.scrollTop = this.scrollTop;
200
+ this.moveableElement.scrollLeft = this.scrollLeft!;
201
+ }
202
+ }
203
+ });
204
+ }
184
205
  }
185
206
 
186
207
  /** @internal */
187
- _layout(rect: Rect, metrics: ILayoutMetrics) {
188
- if (!rect.equals(this._rect)) {
189
- this._fireEvent("resize", { rect });
208
+ setRect(rect: Rect) {
209
+ if (!rect.equals(this.rect)) {
210
+ this.fireEvent("resize", {rect});
211
+ this.rect = rect;
190
212
  }
191
- this._rect = rect;
192
213
  }
193
214
 
194
215
  /** @internal */
195
- _delete() {
196
- (this._parent as TabSetNode | BorderNode)._remove(this);
197
- this._fireEvent("close", {});
216
+ setVisible(visible: boolean) {
217
+ if (visible !== this.visible) {
218
+ this.fireEvent("visibility", { visible });
219
+ this.visible = visible;
220
+ }
198
221
  }
199
222
 
200
- toJson(): IJsonTabNode {
201
- const json = {};
202
- TabNode._attributeDefinitions.toJson(json, this._attributes);
203
- return json;
223
+ /** @internal */
224
+ getScrollTop() {
225
+ return this.scrollTop;
226
+ }
227
+
228
+ /** @internal */
229
+ setScrollTop(scrollTop: number | undefined) {
230
+ this.scrollTop = scrollTop;
231
+ }
232
+ /** @internal */
233
+ getScrollLeft() {
234
+ return this.scrollLeft;
204
235
  }
205
236
 
206
237
  /** @internal */
207
- _updateAttrs(json: any) {
208
- TabNode._attributeDefinitions.update(json, this._attributes);
238
+ setScrollLeft(scrollLeft: number | undefined) {
239
+ this.scrollLeft = scrollLeft;
240
+ }
241
+ /** @internal */
242
+ isRendered() {
243
+ return this.rendered;
209
244
  }
210
245
 
211
246
  /** @internal */
212
- _getAttributeDefinitions() {
213
- return TabNode._attributeDefinitions;
247
+ setRendered(rendered: boolean) {
248
+ this.rendered = rendered;
214
249
  }
215
250
 
216
251
  /** @internal */
217
- _setWindow(window: Window | undefined) {
218
- this._window = window;
252
+ getTabRect() {
253
+ return this.tabRect;
219
254
  }
220
255
 
221
256
  /** @internal */
222
- _setBorderWidth(width: number) {
223
- this._attributes.borderWidth = width;
257
+ setTabRect(rect: Rect) {
258
+ this.tabRect = rect;
224
259
  }
225
260
 
226
261
  /** @internal */
227
- _setBorderHeight(height: number) {
228
- this._attributes.borderHeight = height;
262
+ getTabStamp() {
263
+ return this.tabStamp;
264
+ }
265
+
266
+ /** @internal */
267
+ setTabStamp(stamp: HTMLElement | null) {
268
+ this.tabStamp = stamp;
269
+ }
270
+
271
+ /** @internal */
272
+ getMoveableElement() {
273
+ return this.moveableElement;
274
+ }
275
+
276
+ /** @internal */
277
+ setMoveableElement(element: HTMLElement | null) {
278
+ this.moveableElement = element;
279
+ }
280
+
281
+ /** @internal */
282
+ setRenderedName(name: string) {
283
+ this.renderedName = name;
284
+ }
285
+
286
+ /** @internal */
287
+ getNameForOverflowMenu() {
288
+ const altName = this.getAttr("altName") as string;
289
+ if (altName !== undefined) {
290
+ return altName;
291
+ }
292
+ return this.renderedName;
293
+ }
294
+
295
+ /** @internal */
296
+ setName(name: string) {
297
+ this.attributes.name = name;
298
+ }
299
+
300
+ /** @internal */
301
+ delete() {
302
+ (this.parent as TabSetNode | BorderNode).remove(this);
303
+ this.fireEvent("close", {});
304
+ }
305
+
306
+ /** @internal */
307
+ updateAttrs(json: any) {
308
+ TabNode.attributeDefinitions.update(json, this.attributes);
309
+ }
310
+
311
+ /** @internal */
312
+ getAttributeDefinitions() {
313
+ return TabNode.attributeDefinitions;
314
+ }
315
+
316
+ /** @internal */
317
+ setBorderWidth(width: number) {
318
+ this.attributes.borderWidth = width;
319
+ }
320
+
321
+ /** @internal */
322
+ setBorderHeight(height: number) {
323
+ this.attributes.borderHeight = height;
229
324
  }
230
325
 
231
326
  /** @internal */
232
327
  static getAttributeDefinitions() {
233
- return TabNode._attributeDefinitions;
328
+ return TabNode.attributeDefinitions;
234
329
  }
235
330
 
331
+ /** @internal */
332
+ private static attributeDefinitions: AttributeDefinitions = TabNode.createAttributeDefinitions();
333
+
334
+ /** @internal */
335
+ private static createAttributeDefinitions(): AttributeDefinitions {
336
+ const attributeDefinitions = new AttributeDefinitions();
337
+ attributeDefinitions.add("type", TabNode.TYPE, true).setType(Attribute.STRING).setFixed();
338
+ attributeDefinitions.add("id", undefined).setType(Attribute.STRING).setDescription(
339
+ `the unique id of the tab, if left undefined a uuid will be assigned`
340
+ );
341
+
342
+ attributeDefinitions.add("name", "[Unnamed Tab]").setType(Attribute.STRING).setDescription(
343
+ `name of tab to be displayed in the tab button`
344
+ );
345
+ attributeDefinitions.add("altName", undefined).setType(Attribute.STRING).setDescription(
346
+ `if there is no name specifed then this value will be used in the overflow menu`
347
+ );
348
+ attributeDefinitions.add("helpText", undefined).setType(Attribute.STRING).setDescription(
349
+ `An optional help text for the tab to be displayed upon tab hover.`
350
+ );
351
+ attributeDefinitions.add("component", undefined).setType(Attribute.STRING).setDescription(
352
+ `string identifying which component to run (for factory)`
353
+ );
354
+ attributeDefinitions.add("config", undefined).setType("any").setDescription(
355
+ `a place to hold json config for the hosted component`
356
+ );
357
+ attributeDefinitions.add("tabsetClassName", undefined).setType(Attribute.STRING).setDescription(
358
+ `class applied to parent tabset when this is the only tab and it is stretched to fill the tabset`
359
+ );
360
+ attributeDefinitions.add("enableWindowReMount", false).setType(Attribute.BOOLEAN).setDescription(
361
+ `if enabled the tab will re-mount when popped out/in`
362
+ );
363
+
364
+ attributeDefinitions.addInherited("enableClose", "tabEnableClose").setType(Attribute.BOOLEAN).setDescription(
365
+ `allow user to close tab via close button`
366
+ );
367
+ attributeDefinitions.addInherited("closeType", "tabCloseType").setType("ICloseType").setDescription(
368
+ `see values in ICloseType`
369
+ );
370
+ attributeDefinitions.addInherited("enableDrag", "tabEnableDrag").setType(Attribute.BOOLEAN).setDescription(
371
+ `allow user to drag tab to new location`
372
+ );
373
+ attributeDefinitions.addInherited("enableRename", "tabEnableRename").setType(Attribute.BOOLEAN).setDescription(
374
+ `allow user to rename tabs by double clicking`
375
+ );
376
+ attributeDefinitions.addInherited("className", "tabClassName").setType(Attribute.STRING).setDescription(
377
+ `class applied to tab button`
378
+ );
379
+ attributeDefinitions.addInherited("contentClassName", "tabContentClassName").setType(Attribute.STRING).setDescription(
380
+ `class applied to tab content`
381
+ );
382
+ attributeDefinitions.addInherited("icon", "tabIcon").setType(Attribute.STRING).setDescription(
383
+ `the tab icon`
384
+ );
385
+ attributeDefinitions.addInherited("enableRenderOnDemand", "tabEnableRenderOnDemand").setType(Attribute.BOOLEAN).setDescription(
386
+ `whether to avoid rendering component until tab is visible`
387
+ );
388
+ attributeDefinitions.addInherited("enablePopout", "tabEnablePopout").setType(Attribute.BOOLEAN).setAlias("enableFloat").setDescription(
389
+ `enable popout (in popout capable browser)`
390
+ );
391
+ attributeDefinitions.addInherited("enablePopoutIcon", "tabEnablePopoutIcon").setType(Attribute.BOOLEAN).setDescription(
392
+ `whether to show the popout icon in the tabset header if this tab enables popouts`
393
+ );
394
+ attributeDefinitions.addInherited("enablePopoutOverlay", "tabEnablePopoutOverlay").setType(Attribute.BOOLEAN).setDescription(
395
+ `if this tab will not work correctly in a popout window when the main window is backgrounded (inactive)
396
+ then enabling this option will gray out this tab`
397
+ );
398
+
399
+ attributeDefinitions.addInherited("borderWidth", "tabBorderWidth").setType(Attribute.NUMBER).setDescription(
400
+ `width when added to border, -1 will use border size`
401
+ );
402
+ attributeDefinitions.addInherited("borderHeight", "tabBorderHeight").setType(Attribute.NUMBER).setDescription(
403
+ `height when added to border, -1 will use border size`
404
+ );
405
+ attributeDefinitions.addInherited("minWidth", "tabMinWidth").setType(Attribute.NUMBER).setDescription(
406
+ `the min width of this tab`
407
+ );
408
+ attributeDefinitions.addInherited("minHeight", "tabMinHeight").setType(Attribute.NUMBER).setDescription(
409
+ `the min height of this tab`
410
+ );
411
+ attributeDefinitions.addInherited("maxWidth", "tabMaxWidth").setType(Attribute.NUMBER).setDescription(
412
+ `the max width of this tab`
413
+ );
414
+ attributeDefinitions.addInherited("maxHeight", "tabMaxHeight").setType(Attribute.NUMBER).setDescription(
415
+ `the max height of this tab`
416
+ );
417
+
418
+ return attributeDefinitions;
419
+ }
236
420
  }