flexlayout-react 0.7.1 → 0.7.4

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 (103) hide show
  1. package/ChangeLog.txt +12 -0
  2. package/README.md +33 -34
  3. package/declarations/view/Icons.d.ts +1 -0
  4. package/declarations/view/Layout.d.ts +1 -0
  5. package/dist/flexlayout.js +96 -184
  6. package/dist/flexlayout_min.js +1 -1
  7. package/lib/Attribute.js +12 -17
  8. package/lib/Attribute.js.map +1 -1
  9. package/lib/AttributeDefinitions.js +44 -53
  10. package/lib/AttributeDefinitions.js.map +1 -1
  11. package/lib/DockLocation.js +41 -46
  12. package/lib/DockLocation.js.map +1 -1
  13. package/lib/DragDrop.js +55 -60
  14. package/lib/DragDrop.js.map +1 -1
  15. package/lib/DropInfo.js +3 -8
  16. package/lib/DropInfo.js.map +1 -1
  17. package/lib/I18nLabel.js +2 -5
  18. package/lib/I18nLabel.js.map +1 -1
  19. package/lib/Orientation.js +11 -16
  20. package/lib/Orientation.js.map +1 -1
  21. package/lib/PopupMenu.js +24 -28
  22. package/lib/PopupMenu.js.map +1 -1
  23. package/lib/Rect.js +35 -41
  24. package/lib/Rect.js.map +1 -1
  25. package/lib/Types.js +2 -5
  26. package/lib/Types.js.map +1 -1
  27. package/lib/index.js +22 -38
  28. package/lib/index.js.map +1 -1
  29. package/lib/model/Action.js +3 -8
  30. package/lib/model/Action.js.map +1 -1
  31. package/lib/model/Actions.js +68 -75
  32. package/lib/model/Actions.js.map +1 -1
  33. package/lib/model/BorderNode.js +189 -206
  34. package/lib/model/BorderNode.js.map +1 -1
  35. package/lib/model/BorderSet.js +44 -55
  36. package/lib/model/BorderSet.js.map +1 -1
  37. package/lib/model/ICloseType.js +2 -5
  38. package/lib/model/ICloseType.js.map +1 -1
  39. package/lib/model/IDraggable.js +1 -2
  40. package/lib/model/IDropTarget.js +1 -2
  41. package/lib/model/IJsonModel.js +1 -2
  42. package/lib/model/Model.js +217 -232
  43. package/lib/model/Model.js.map +1 -1
  44. package/lib/model/Node.js +87 -94
  45. package/lib/model/Node.js.map +1 -1
  46. package/lib/model/RowNode.js +204 -250
  47. package/lib/model/RowNode.js.map +1 -1
  48. package/lib/model/SplitterNode.js +35 -57
  49. package/lib/model/SplitterNode.js.map +1 -1
  50. package/lib/model/TabNode.js +100 -124
  51. package/lib/model/TabNode.js.map +1 -1
  52. package/lib/model/TabSetNode.js +181 -197
  53. package/lib/model/TabSetNode.js.map +1 -1
  54. package/lib/model/Utils.js +20 -26
  55. package/lib/model/Utils.js.map +1 -1
  56. package/lib/view/BorderButton.js +45 -49
  57. package/lib/view/BorderButton.js.map +1 -1
  58. package/lib/view/BorderTabSet.js +57 -61
  59. package/lib/view/BorderTabSet.js.map +1 -1
  60. package/lib/view/ErrorBoundary.js +15 -37
  61. package/lib/view/ErrorBoundary.js.map +1 -1
  62. package/lib/view/FloatingWindow.js +43 -56
  63. package/lib/view/FloatingWindow.js.map +1 -1
  64. package/lib/view/FloatingWindowTab.js +12 -16
  65. package/lib/view/FloatingWindowTab.js.map +1 -1
  66. package/lib/view/Icons.js +17 -25
  67. package/lib/view/Icons.js.map +1 -1
  68. package/lib/view/Layout.js +396 -508
  69. package/lib/view/Layout.js.map +1 -1
  70. package/lib/view/Splitter.js +53 -57
  71. package/lib/view/Splitter.js.map +1 -1
  72. package/lib/view/Tab.js +31 -35
  73. package/lib/view/Tab.js.map +1 -1
  74. package/lib/view/TabButton.js +46 -50
  75. package/lib/view/TabButton.js.map +1 -1
  76. package/lib/view/TabButtonStamp.js +11 -15
  77. package/lib/view/TabButtonStamp.js.map +1 -1
  78. package/lib/view/TabFloating.js +30 -34
  79. package/lib/view/TabFloating.js.map +1 -1
  80. package/lib/view/TabOverflowHook.js +46 -50
  81. package/lib/view/TabOverflowHook.js.map +1 -1
  82. package/lib/view/TabSet.js +93 -106
  83. package/lib/view/TabSet.js.map +1 -1
  84. package/lib/view/Utils.js +11 -17
  85. package/lib/view/Utils.js.map +1 -1
  86. package/package.json +5 -3
  87. package/src/model/BorderNode.ts +6 -1
  88. package/src/model/TabSetNode.ts +6 -1
  89. package/src/view/FloatingWindow.tsx +5 -1
  90. package/src/view/Icons.tsx +7 -7
  91. package/src/view/Layout.tsx +23 -104
  92. package/style/dark.css +1 -0
  93. package/style/dark.css.map +1 -1
  94. package/style/dark.scss +1 -0
  95. package/style/gray.css +1 -0
  96. package/style/gray.css.map +1 -1
  97. package/style/gray.scss +1 -0
  98. package/style/light.css +1 -0
  99. package/style/light.css.map +1 -1
  100. package/style/light.scss +1 -0
  101. package/style/underline.css +1 -0
  102. package/style/underline.css.map +1 -1
  103. package/style/underline.scss +1 -0
@@ -1,242 +1,230 @@
1
- "use strict";
2
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
- if (ar || !(i in from)) {
5
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
- ar[i] = from[i];
7
- }
8
- }
9
- return to.concat(ar || Array.prototype.slice.call(from));
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Model = void 0;
13
- var uuid_1 = require("uuid");
14
- var Attribute_1 = require("../Attribute");
15
- var AttributeDefinitions_1 = require("../AttributeDefinitions");
16
- var DockLocation_1 = require("../DockLocation");
17
- var Orientation_1 = require("../Orientation");
18
- var Rect_1 = require("../Rect");
19
- var Actions_1 = require("./Actions");
20
- var BorderNode_1 = require("./BorderNode");
21
- var BorderSet_1 = require("./BorderSet");
22
- var RowNode_1 = require("./RowNode");
23
- var TabNode_1 = require("./TabNode");
24
- var TabSetNode_1 = require("./TabSetNode");
25
- var Utils_1 = require("./Utils");
1
+ import { v4 as getUUID } from "uuid";
2
+ import { Attribute } from "../Attribute";
3
+ import { AttributeDefinitions } from "../AttributeDefinitions";
4
+ import { DockLocation } from "../DockLocation";
5
+ import { Orientation } from "../Orientation";
6
+ import { Rect } from "../Rect";
7
+ import { Actions } from "./Actions";
8
+ import { BorderNode } from "./BorderNode";
9
+ import { BorderSet } from "./BorderSet";
10
+ import { RowNode } from "./RowNode";
11
+ import { TabNode } from "./TabNode";
12
+ import { TabSetNode } from "./TabSetNode";
13
+ import { adjustSelectedIndexAfterDock, adjustSelectedIndexAfterFloat } from "./Utils";
26
14
  /**
27
15
  * Class containing the Tree of Nodes used by the FlexLayout component
28
16
  */
29
- var Model = /** @class */ (function () {
17
+ export class Model {
30
18
  /**
31
19
  * 'private' constructor. Use the static method Model.fromJson(json) to create a model
32
20
  * @internal
33
21
  */
34
- function Model() {
22
+ constructor() {
35
23
  /** @internal */
36
- this._borderRects = { inner: Rect_1.Rect.empty(), outer: Rect_1.Rect.empty() };
24
+ this._borderRects = { inner: Rect.empty(), outer: Rect.empty() };
37
25
  this._attributes = {};
38
26
  this._idMap = {};
39
- this._borders = new BorderSet_1.BorderSet(this);
27
+ this._borders = new BorderSet(this);
40
28
  this._pointerFine = true;
41
- this._showHiddenBorder = DockLocation_1.DockLocation.CENTER;
29
+ this._showHiddenBorder = DockLocation.CENTER;
42
30
  }
43
31
  /**
44
32
  * Loads the model from the given json object
45
33
  * @param json the json model to load
46
34
  * @returns {Model} a new Model object
47
35
  */
48
- Model.fromJson = function (json) {
49
- var model = new Model();
36
+ static fromJson(json) {
37
+ const model = new Model();
50
38
  Model._attributeDefinitions.fromJson(json.global, model._attributes);
51
39
  if (json.borders) {
52
- model._borders = BorderSet_1.BorderSet._fromJson(json.borders, model);
40
+ model._borders = BorderSet._fromJson(json.borders, model);
53
41
  }
54
- model._root = RowNode_1.RowNode._fromJson(json.layout, model);
42
+ model._root = RowNode._fromJson(json.layout, model);
55
43
  model._tidy(); // initial tidy of node tree
56
44
  return model;
57
- };
45
+ }
58
46
  /** @internal */
59
- Model._createAttributeDefinitions = function () {
60
- var attributeDefinitions = new AttributeDefinitions_1.AttributeDefinitions();
61
- attributeDefinitions.add("legacyOverflowMenu", false).setType(Attribute_1.Attribute.BOOLEAN);
47
+ static _createAttributeDefinitions() {
48
+ const attributeDefinitions = new AttributeDefinitions();
49
+ attributeDefinitions.add("legacyOverflowMenu", false).setType(Attribute.BOOLEAN);
62
50
  // splitter
63
- attributeDefinitions.add("splitterSize", -1).setType(Attribute_1.Attribute.NUMBER);
64
- attributeDefinitions.add("splitterExtra", 0).setType(Attribute_1.Attribute.NUMBER);
65
- attributeDefinitions.add("enableEdgeDock", true).setType(Attribute_1.Attribute.BOOLEAN);
66
- attributeDefinitions.add("rootOrientationVertical", false).setType(Attribute_1.Attribute.BOOLEAN);
51
+ attributeDefinitions.add("splitterSize", -1).setType(Attribute.NUMBER);
52
+ attributeDefinitions.add("splitterExtra", 0).setType(Attribute.NUMBER);
53
+ attributeDefinitions.add("enableEdgeDock", true).setType(Attribute.BOOLEAN);
54
+ attributeDefinitions.add("rootOrientationVertical", false).setType(Attribute.BOOLEAN);
67
55
  attributeDefinitions.add("marginInsets", { top: 0, right: 0, bottom: 0, left: 0 })
68
56
  .setType("IInsets");
69
- attributeDefinitions.add("enableUseVisibility", false).setType(Attribute_1.Attribute.BOOLEAN);
57
+ attributeDefinitions.add("enableUseVisibility", false).setType(Attribute.BOOLEAN);
70
58
  // tab
71
- attributeDefinitions.add("tabEnableClose", true).setType(Attribute_1.Attribute.BOOLEAN);
59
+ attributeDefinitions.add("tabEnableClose", true).setType(Attribute.BOOLEAN);
72
60
  attributeDefinitions.add("tabCloseType", 1).setType("ICloseType");
73
- attributeDefinitions.add("tabEnableFloat", false).setType(Attribute_1.Attribute.BOOLEAN);
74
- attributeDefinitions.add("tabEnableDrag", true).setType(Attribute_1.Attribute.BOOLEAN);
75
- attributeDefinitions.add("tabEnableRename", true).setType(Attribute_1.Attribute.BOOLEAN);
76
- attributeDefinitions.add("tabClassName", undefined).setType(Attribute_1.Attribute.STRING);
77
- attributeDefinitions.add("tabIcon", undefined).setType(Attribute_1.Attribute.STRING);
78
- attributeDefinitions.add("tabEnableRenderOnDemand", true).setType(Attribute_1.Attribute.BOOLEAN);
79
- attributeDefinitions.add("tabDragSpeed", 0.3).setType(Attribute_1.Attribute.NUMBER);
80
- attributeDefinitions.add("tabBorderWidth", -1).setType(Attribute_1.Attribute.NUMBER);
81
- attributeDefinitions.add("tabBorderHeight", -1).setType(Attribute_1.Attribute.NUMBER);
61
+ attributeDefinitions.add("tabEnableFloat", false).setType(Attribute.BOOLEAN);
62
+ attributeDefinitions.add("tabEnableDrag", true).setType(Attribute.BOOLEAN);
63
+ attributeDefinitions.add("tabEnableRename", true).setType(Attribute.BOOLEAN);
64
+ attributeDefinitions.add("tabClassName", undefined).setType(Attribute.STRING);
65
+ attributeDefinitions.add("tabIcon", undefined).setType(Attribute.STRING);
66
+ attributeDefinitions.add("tabEnableRenderOnDemand", true).setType(Attribute.BOOLEAN);
67
+ attributeDefinitions.add("tabDragSpeed", 0.3).setType(Attribute.NUMBER);
68
+ attributeDefinitions.add("tabBorderWidth", -1).setType(Attribute.NUMBER);
69
+ attributeDefinitions.add("tabBorderHeight", -1).setType(Attribute.NUMBER);
82
70
  // tabset
83
- attributeDefinitions.add("tabSetEnableDeleteWhenEmpty", true).setType(Attribute_1.Attribute.BOOLEAN);
84
- attributeDefinitions.add("tabSetEnableDrop", true).setType(Attribute_1.Attribute.BOOLEAN);
85
- attributeDefinitions.add("tabSetEnableDrag", true).setType(Attribute_1.Attribute.BOOLEAN);
86
- attributeDefinitions.add("tabSetEnableDivide", true).setType(Attribute_1.Attribute.BOOLEAN);
87
- attributeDefinitions.add("tabSetEnableMaximize", true).setType(Attribute_1.Attribute.BOOLEAN);
88
- attributeDefinitions.add("tabSetEnableClose", false).setType(Attribute_1.Attribute.BOOLEAN);
89
- attributeDefinitions.add("tabSetAutoSelectTab", true).setType(Attribute_1.Attribute.BOOLEAN);
90
- attributeDefinitions.add("tabSetClassNameTabStrip", undefined).setType(Attribute_1.Attribute.STRING);
91
- attributeDefinitions.add("tabSetClassNameHeader", undefined).setType(Attribute_1.Attribute.STRING);
92
- attributeDefinitions.add("tabSetEnableTabStrip", true).setType(Attribute_1.Attribute.BOOLEAN);
93
- attributeDefinitions.add("tabSetHeaderHeight", 0).setType(Attribute_1.Attribute.NUMBER);
94
- attributeDefinitions.add("tabSetTabStripHeight", 0).setType(Attribute_1.Attribute.NUMBER);
71
+ attributeDefinitions.add("tabSetEnableDeleteWhenEmpty", true).setType(Attribute.BOOLEAN);
72
+ attributeDefinitions.add("tabSetEnableDrop", true).setType(Attribute.BOOLEAN);
73
+ attributeDefinitions.add("tabSetEnableDrag", true).setType(Attribute.BOOLEAN);
74
+ attributeDefinitions.add("tabSetEnableDivide", true).setType(Attribute.BOOLEAN);
75
+ attributeDefinitions.add("tabSetEnableMaximize", true).setType(Attribute.BOOLEAN);
76
+ attributeDefinitions.add("tabSetEnableClose", false).setType(Attribute.BOOLEAN);
77
+ attributeDefinitions.add("tabSetAutoSelectTab", true).setType(Attribute.BOOLEAN);
78
+ attributeDefinitions.add("tabSetClassNameTabStrip", undefined).setType(Attribute.STRING);
79
+ attributeDefinitions.add("tabSetClassNameHeader", undefined).setType(Attribute.STRING);
80
+ attributeDefinitions.add("tabSetEnableTabStrip", true).setType(Attribute.BOOLEAN);
81
+ attributeDefinitions.add("tabSetHeaderHeight", 0).setType(Attribute.NUMBER);
82
+ attributeDefinitions.add("tabSetTabStripHeight", 0).setType(Attribute.NUMBER);
95
83
  attributeDefinitions.add("tabSetMarginInsets", { top: 0, right: 0, bottom: 0, left: 0 })
96
84
  .setType("IInsets");
97
85
  attributeDefinitions.add("tabSetBorderInsets", { top: 0, right: 0, bottom: 0, left: 0 })
98
86
  .setType("IInsets");
99
87
  attributeDefinitions.add("tabSetTabLocation", "top").setType("ITabLocation");
100
- attributeDefinitions.add("tabSetMinWidth", 0).setType(Attribute_1.Attribute.NUMBER);
101
- attributeDefinitions.add("tabSetMinHeight", 0).setType(Attribute_1.Attribute.NUMBER);
88
+ attributeDefinitions.add("tabSetMinWidth", 0).setType(Attribute.NUMBER);
89
+ attributeDefinitions.add("tabSetMinHeight", 0).setType(Attribute.NUMBER);
102
90
  // border
103
- attributeDefinitions.add("borderSize", 200).setType(Attribute_1.Attribute.NUMBER);
104
- attributeDefinitions.add("borderMinSize", 0).setType(Attribute_1.Attribute.NUMBER);
105
- attributeDefinitions.add("borderBarSize", 0).setType(Attribute_1.Attribute.NUMBER);
106
- attributeDefinitions.add("borderEnableDrop", true).setType(Attribute_1.Attribute.BOOLEAN);
107
- attributeDefinitions.add("borderAutoSelectTabWhenOpen", true).setType(Attribute_1.Attribute.BOOLEAN);
108
- attributeDefinitions.add("borderAutoSelectTabWhenClosed", false).setType(Attribute_1.Attribute.BOOLEAN);
109
- attributeDefinitions.add("borderClassName", undefined).setType(Attribute_1.Attribute.STRING);
110
- attributeDefinitions.add("borderEnableAutoHide", false).setType(Attribute_1.Attribute.BOOLEAN);
91
+ attributeDefinitions.add("borderSize", 200).setType(Attribute.NUMBER);
92
+ attributeDefinitions.add("borderMinSize", 0).setType(Attribute.NUMBER);
93
+ attributeDefinitions.add("borderBarSize", 0).setType(Attribute.NUMBER);
94
+ attributeDefinitions.add("borderEnableDrop", true).setType(Attribute.BOOLEAN);
95
+ attributeDefinitions.add("borderAutoSelectTabWhenOpen", true).setType(Attribute.BOOLEAN);
96
+ attributeDefinitions.add("borderAutoSelectTabWhenClosed", false).setType(Attribute.BOOLEAN);
97
+ attributeDefinitions.add("borderClassName", undefined).setType(Attribute.STRING);
98
+ attributeDefinitions.add("borderEnableAutoHide", false).setType(Attribute.BOOLEAN);
111
99
  return attributeDefinitions;
112
- };
100
+ }
113
101
  /** @internal */
114
- Model.prototype._setChangeListener = function (listener) {
102
+ _setChangeListener(listener) {
115
103
  this._changeListener = listener;
116
- };
104
+ }
117
105
  /**
118
106
  * Get the currently active tabset node
119
107
  */
120
- Model.prototype.getActiveTabset = function () {
108
+ getActiveTabset() {
121
109
  if (this._activeTabSet && this.getNodeById(this._activeTabSet.getId())) {
122
110
  return this._activeTabSet;
123
111
  }
124
112
  else {
125
113
  return undefined;
126
114
  }
127
- };
115
+ }
128
116
  /** @internal */
129
- Model.prototype._getShowHiddenBorder = function () {
117
+ _getShowHiddenBorder() {
130
118
  return this._showHiddenBorder;
131
- };
119
+ }
132
120
  /** @internal */
133
- Model.prototype._setShowHiddenBorder = function (location) {
121
+ _setShowHiddenBorder(location) {
134
122
  this._showHiddenBorder = location;
135
- };
123
+ }
136
124
  /** @internal */
137
- Model.prototype._setActiveTabset = function (tabsetNode) {
125
+ _setActiveTabset(tabsetNode) {
138
126
  this._activeTabSet = tabsetNode;
139
- };
127
+ }
140
128
  /**
141
129
  * Get the currently maximized tabset node
142
130
  */
143
- Model.prototype.getMaximizedTabset = function () {
131
+ getMaximizedTabset() {
144
132
  return this._maximizedTabSet;
145
- };
133
+ }
146
134
  /** @internal */
147
- Model.prototype._setMaximizedTabset = function (tabsetNode) {
135
+ _setMaximizedTabset(tabsetNode) {
148
136
  this._maximizedTabSet = tabsetNode;
149
- };
137
+ }
150
138
  /**
151
139
  * Gets the root RowNode of the model
152
140
  * @returns {RowNode}
153
141
  */
154
- Model.prototype.getRoot = function () {
142
+ getRoot() {
155
143
  return this._root;
156
- };
157
- Model.prototype.isRootOrientationVertical = function () {
144
+ }
145
+ isRootOrientationVertical() {
158
146
  return this._attributes.rootOrientationVertical;
159
- };
160
- Model.prototype.isUseVisibility = function () {
147
+ }
148
+ isUseVisibility() {
161
149
  return this._attributes.enableUseVisibility;
162
- };
150
+ }
163
151
  /**
164
152
  * Gets the
165
153
  * @returns {BorderSet|*}
166
154
  */
167
- Model.prototype.getBorderSet = function () {
155
+ getBorderSet() {
168
156
  return this._borders;
169
- };
157
+ }
170
158
  /** @internal */
171
- Model.prototype._getOuterInnerRects = function () {
159
+ _getOuterInnerRects() {
172
160
  return this._borderRects;
173
- };
161
+ }
174
162
  /** @internal */
175
- Model.prototype._getPointerFine = function () {
163
+ _getPointerFine() {
176
164
  return this._pointerFine;
177
- };
165
+ }
178
166
  /** @internal */
179
- Model.prototype._setPointerFine = function (pointerFine) {
167
+ _setPointerFine(pointerFine) {
180
168
  this._pointerFine = pointerFine;
181
- };
169
+ }
182
170
  /**
183
171
  * Visits all the nodes in the model and calls the given function for each
184
172
  * @param fn a function that takes visited node and a integer level as parameters
185
173
  */
186
- Model.prototype.visitNodes = function (fn) {
174
+ visitNodes(fn) {
187
175
  this._borders._forEachNode(fn);
188
176
  this._root._forEachNode(fn, 0);
189
- };
177
+ }
190
178
  /**
191
179
  * Gets a node by its id
192
180
  * @param id the id to find
193
181
  */
194
- Model.prototype.getNodeById = function (id) {
182
+ getNodeById(id) {
195
183
  return this._idMap[id];
196
- };
184
+ }
197
185
  /**
198
186
  * Update the node tree by performing the given action,
199
187
  * Actions should be generated via static methods on the Actions class
200
188
  * @param action the action to perform
201
189
  * @returns added Node for Actions.addNode; undefined otherwise
202
190
  */
203
- Model.prototype.doAction = function (action) {
204
- var returnVal = undefined;
191
+ doAction(action) {
192
+ let returnVal = undefined;
205
193
  // console.log(action);
206
194
  switch (action.type) {
207
- case Actions_1.Actions.ADD_NODE: {
208
- var newNode = new TabNode_1.TabNode(this, action.data.json, true);
209
- var toNode = this._idMap[action.data.toNode];
210
- if (toNode instanceof TabSetNode_1.TabSetNode || toNode instanceof BorderNode_1.BorderNode || toNode instanceof RowNode_1.RowNode) {
211
- toNode.drop(newNode, DockLocation_1.DockLocation.getByName(action.data.location), action.data.index, action.data.select);
195
+ case Actions.ADD_NODE: {
196
+ const newNode = new TabNode(this, action.data.json, true);
197
+ const toNode = this._idMap[action.data.toNode];
198
+ if (toNode instanceof TabSetNode || toNode instanceof BorderNode || toNode instanceof RowNode) {
199
+ toNode.drop(newNode, DockLocation.getByName(action.data.location), action.data.index, action.data.select);
212
200
  returnVal = newNode;
213
201
  }
214
202
  break;
215
203
  }
216
- case Actions_1.Actions.MOVE_NODE: {
217
- var fromNode = this._idMap[action.data.fromNode];
218
- if (fromNode instanceof TabNode_1.TabNode || fromNode instanceof TabSetNode_1.TabSetNode) {
219
- var toNode = this._idMap[action.data.toNode];
220
- if (toNode instanceof TabSetNode_1.TabSetNode || toNode instanceof BorderNode_1.BorderNode || toNode instanceof RowNode_1.RowNode) {
221
- toNode.drop(fromNode, DockLocation_1.DockLocation.getByName(action.data.location), action.data.index, action.data.select);
204
+ case Actions.MOVE_NODE: {
205
+ const fromNode = this._idMap[action.data.fromNode];
206
+ if (fromNode instanceof TabNode || fromNode instanceof TabSetNode) {
207
+ const toNode = this._idMap[action.data.toNode];
208
+ if (toNode instanceof TabSetNode || toNode instanceof BorderNode || toNode instanceof RowNode) {
209
+ toNode.drop(fromNode, DockLocation.getByName(action.data.location), action.data.index, action.data.select);
222
210
  }
223
211
  }
224
212
  break;
225
213
  }
226
- case Actions_1.Actions.DELETE_TAB: {
227
- var node = this._idMap[action.data.node];
228
- if (node instanceof TabNode_1.TabNode) {
214
+ case Actions.DELETE_TAB: {
215
+ const node = this._idMap[action.data.node];
216
+ if (node instanceof TabNode) {
229
217
  node._delete();
230
218
  }
231
219
  break;
232
220
  }
233
- case Actions_1.Actions.DELETE_TABSET: {
234
- var node = this._idMap[action.data.node];
235
- if (node instanceof TabSetNode_1.TabSetNode) {
221
+ case Actions.DELETE_TABSET: {
222
+ const node = this._idMap[action.data.node];
223
+ if (node instanceof TabSetNode) {
236
224
  // first delete all child tabs that are closeable
237
- var children = __spreadArray([], node.getChildren(), true);
238
- for (var i = 0; i < children.length; i++) {
239
- var child = children[i];
225
+ const children = [...node.getChildren()];
226
+ for (let i = 0; i < children.length; i++) {
227
+ const child = children[i];
240
228
  if (child.isEnableClose()) {
241
229
  child._delete();
242
230
  }
@@ -248,77 +236,77 @@ var Model = /** @class */ (function () {
248
236
  }
249
237
  break;
250
238
  }
251
- case Actions_1.Actions.FLOAT_TAB: {
252
- var node = this._idMap[action.data.node];
253
- if (node instanceof TabNode_1.TabNode) {
239
+ case Actions.FLOAT_TAB: {
240
+ const node = this._idMap[action.data.node];
241
+ if (node instanceof TabNode) {
254
242
  node._setFloating(true);
255
- (0, Utils_1.adjustSelectedIndexAfterFloat)(node);
243
+ adjustSelectedIndexAfterFloat(node);
256
244
  }
257
245
  break;
258
246
  }
259
- case Actions_1.Actions.UNFLOAT_TAB: {
260
- var node = this._idMap[action.data.node];
261
- if (node instanceof TabNode_1.TabNode) {
247
+ case Actions.UNFLOAT_TAB: {
248
+ const node = this._idMap[action.data.node];
249
+ if (node instanceof TabNode) {
262
250
  node._setFloating(false);
263
- (0, Utils_1.adjustSelectedIndexAfterDock)(node);
251
+ adjustSelectedIndexAfterDock(node);
264
252
  }
265
253
  break;
266
254
  }
267
- case Actions_1.Actions.RENAME_TAB: {
268
- var node = this._idMap[action.data.node];
269
- if (node instanceof TabNode_1.TabNode) {
255
+ case Actions.RENAME_TAB: {
256
+ const node = this._idMap[action.data.node];
257
+ if (node instanceof TabNode) {
270
258
  node._setName(action.data.text);
271
259
  }
272
260
  break;
273
261
  }
274
- case Actions_1.Actions.SELECT_TAB: {
275
- var tabNode = this._idMap[action.data.tabNode];
276
- if (tabNode instanceof TabNode_1.TabNode) {
277
- var parent_1 = tabNode.getParent();
278
- var pos = parent_1.getChildren().indexOf(tabNode);
279
- if (parent_1 instanceof BorderNode_1.BorderNode) {
280
- if (parent_1.getSelected() === pos) {
281
- parent_1._setSelected(-1);
262
+ case Actions.SELECT_TAB: {
263
+ const tabNode = this._idMap[action.data.tabNode];
264
+ if (tabNode instanceof TabNode) {
265
+ const parent = tabNode.getParent();
266
+ const pos = parent.getChildren().indexOf(tabNode);
267
+ if (parent instanceof BorderNode) {
268
+ if (parent.getSelected() === pos) {
269
+ parent._setSelected(-1);
282
270
  }
283
271
  else {
284
- parent_1._setSelected(pos);
272
+ parent._setSelected(pos);
285
273
  }
286
274
  }
287
- else if (parent_1 instanceof TabSetNode_1.TabSetNode) {
288
- if (parent_1.getSelected() !== pos) {
289
- parent_1._setSelected(pos);
275
+ else if (parent instanceof TabSetNode) {
276
+ if (parent.getSelected() !== pos) {
277
+ parent._setSelected(pos);
290
278
  }
291
- this._activeTabSet = parent_1;
279
+ this._activeTabSet = parent;
292
280
  }
293
281
  }
294
282
  break;
295
283
  }
296
- case Actions_1.Actions.SET_ACTIVE_TABSET: {
297
- var tabsetNode = this._idMap[action.data.tabsetNode];
298
- if (tabsetNode instanceof TabSetNode_1.TabSetNode) {
284
+ case Actions.SET_ACTIVE_TABSET: {
285
+ const tabsetNode = this._idMap[action.data.tabsetNode];
286
+ if (tabsetNode instanceof TabSetNode) {
299
287
  this._activeTabSet = tabsetNode;
300
288
  }
301
289
  break;
302
290
  }
303
- case Actions_1.Actions.ADJUST_SPLIT: {
304
- var node1 = this._idMap[action.data.node1];
305
- var node2 = this._idMap[action.data.node2];
306
- if ((node1 instanceof TabSetNode_1.TabSetNode || node1 instanceof RowNode_1.RowNode) && (node2 instanceof TabSetNode_1.TabSetNode || node2 instanceof RowNode_1.RowNode)) {
291
+ case Actions.ADJUST_SPLIT: {
292
+ const node1 = this._idMap[action.data.node1];
293
+ const node2 = this._idMap[action.data.node2];
294
+ if ((node1 instanceof TabSetNode || node1 instanceof RowNode) && (node2 instanceof TabSetNode || node2 instanceof RowNode)) {
307
295
  this._adjustSplitSide(node1, action.data.weight1, action.data.pixelWidth1);
308
296
  this._adjustSplitSide(node2, action.data.weight2, action.data.pixelWidth2);
309
297
  }
310
298
  break;
311
299
  }
312
- case Actions_1.Actions.ADJUST_BORDER_SPLIT: {
313
- var node = this._idMap[action.data.node];
314
- if (node instanceof BorderNode_1.BorderNode) {
300
+ case Actions.ADJUST_BORDER_SPLIT: {
301
+ const node = this._idMap[action.data.node];
302
+ if (node instanceof BorderNode) {
315
303
  node._setSize(action.data.pos);
316
304
  }
317
305
  break;
318
306
  }
319
- case Actions_1.Actions.MAXIMIZE_TOGGLE: {
320
- var node = this._idMap[action.data.node];
321
- if (node instanceof TabSetNode_1.TabSetNode) {
307
+ case Actions.MAXIMIZE_TOGGLE: {
308
+ const node = this._idMap[action.data.node];
309
+ if (node instanceof TabSetNode) {
322
310
  if (node === this._maximizedTabSet) {
323
311
  this._maximizedTabSet = undefined;
324
312
  }
@@ -329,12 +317,12 @@ var Model = /** @class */ (function () {
329
317
  }
330
318
  break;
331
319
  }
332
- case Actions_1.Actions.UPDATE_MODEL_ATTRIBUTES: {
320
+ case Actions.UPDATE_MODEL_ATTRIBUTES: {
333
321
  this._updateAttrs(action.data.json);
334
322
  break;
335
323
  }
336
- case Actions_1.Actions.UPDATE_NODE_ATTRIBUTES: {
337
- var node = this._idMap[action.data.node];
324
+ case Actions.UPDATE_NODE_ATTRIBUTES: {
325
+ const node = this._idMap[action.data.node];
338
326
  node._updateAttrs(action.data.json);
339
327
  break;
340
328
  }
@@ -346,67 +334,66 @@ var Model = /** @class */ (function () {
346
334
  this._changeListener();
347
335
  }
348
336
  return returnVal;
349
- };
337
+ }
350
338
  /** @internal */
351
- Model.prototype._updateIdMap = function () {
352
- var _this = this;
339
+ _updateIdMap() {
353
340
  // regenerate idMap to stop it building up
354
341
  this._idMap = {};
355
- this.visitNodes(function (node) { return (_this._idMap[node.getId()] = node); });
342
+ this.visitNodes((node) => (this._idMap[node.getId()] = node));
356
343
  // console.log(JSON.stringify(Object.keys(this._idMap)));
357
- };
344
+ }
358
345
  /** @internal */
359
- Model.prototype._adjustSplitSide = function (node, weight, pixels) {
346
+ _adjustSplitSide(node, weight, pixels) {
360
347
  node._setWeight(weight);
361
- if (node.getWidth() != null && node.getOrientation() === Orientation_1.Orientation.VERT) {
348
+ if (node.getWidth() != null && node.getOrientation() === Orientation.VERT) {
362
349
  node._updateAttrs({ width: pixels });
363
350
  }
364
- else if (node.getHeight() != null && node.getOrientation() === Orientation_1.Orientation.HORZ) {
351
+ else if (node.getHeight() != null && node.getOrientation() === Orientation.HORZ) {
365
352
  node._updateAttrs({ height: pixels });
366
353
  }
367
- };
354
+ }
368
355
  /**
369
356
  * Converts the model to a json object
370
357
  * @returns {IJsonModel} json object that represents this model
371
358
  */
372
- Model.prototype.toJson = function () {
373
- var global = {};
359
+ toJson() {
360
+ const global = {};
374
361
  Model._attributeDefinitions.toJson(global, this._attributes);
375
362
  // save state of nodes
376
- this.visitNodes(function (node) {
363
+ this.visitNodes((node) => {
377
364
  node._fireEvent("save", undefined);
378
365
  });
379
- return { global: global, borders: this._borders._toJson(), layout: this._root.toJson() };
380
- };
381
- Model.prototype.getSplitterSize = function () {
382
- var splitterSize = this._attributes.splitterSize;
366
+ return { global, borders: this._borders._toJson(), layout: this._root.toJson() };
367
+ }
368
+ getSplitterSize() {
369
+ let splitterSize = this._attributes.splitterSize;
383
370
  if (splitterSize === -1) {
384
371
  // use defaults
385
372
  splitterSize = this._pointerFine ? 8 : 12; // larger for mobile
386
373
  }
387
374
  return splitterSize;
388
- };
389
- Model.prototype.isLegacyOverflowMenu = function () {
375
+ }
376
+ isLegacyOverflowMenu() {
390
377
  return this._attributes.legacyOverflowMenu;
391
- };
392
- Model.prototype.getSplitterExtra = function () {
378
+ }
379
+ getSplitterExtra() {
393
380
  return this._attributes.splitterExtra;
394
- };
395
- Model.prototype.isEnableEdgeDock = function () {
381
+ }
382
+ isEnableEdgeDock() {
396
383
  return this._attributes.enableEdgeDock;
397
- };
384
+ }
398
385
  /** @internal */
399
- Model.prototype._addNode = function (node) {
400
- var id = node.getId();
386
+ _addNode(node) {
387
+ const id = node.getId();
401
388
  if (this._idMap[id] !== undefined) {
402
- throw new Error("Error: each node must have a unique id, duplicate id:".concat(node.getId()));
389
+ throw new Error(`Error: each node must have a unique id, duplicate id:${node.getId()}`);
403
390
  }
404
391
  if (node.getType() !== "splitter") {
405
392
  this._idMap[id] = node;
406
393
  }
407
- };
394
+ }
408
395
  /** @internal */
409
- Model.prototype._layout = function (rect, metrics) {
396
+ _layout(rect, metrics) {
410
397
  var _a;
411
398
  // let start = Date.now();
412
399
  this._borderRects = this._borders._layoutBorder({ outer: rect, inner: rect }, metrics);
@@ -415,70 +402,68 @@ var Model = /** @class */ (function () {
415
402
  this._root._layout(rect, metrics);
416
403
  // console.log("layout time: " + (Date.now() - start));
417
404
  return rect;
418
- };
405
+ }
419
406
  /** @internal */
420
- Model.prototype._findDropTargetNode = function (dragNode, x, y) {
421
- var node = this._root._findDropTargetNode(dragNode, x, y);
407
+ _findDropTargetNode(dragNode, x, y) {
408
+ let node = this._root._findDropTargetNode(dragNode, x, y);
422
409
  if (node === undefined) {
423
410
  node = this._borders._findDropTargetNode(dragNode, x, y);
424
411
  }
425
412
  return node;
426
- };
413
+ }
427
414
  /** @internal */
428
- Model.prototype._tidy = function () {
415
+ _tidy() {
429
416
  // console.log("before _tidy", this.toString());
430
417
  this._root._tidy();
431
418
  // console.log("after _tidy", this.toString());
432
- };
419
+ }
433
420
  /** @internal */
434
- Model.prototype._updateAttrs = function (json) {
421
+ _updateAttrs(json) {
435
422
  Model._attributeDefinitions.update(json, this._attributes);
436
- };
423
+ }
437
424
  /** @internal */
438
- Model.prototype._nextUniqueId = function () {
439
- return '#' + (0, uuid_1.v4)();
440
- };
425
+ _nextUniqueId() {
426
+ return '#' + getUUID();
427
+ }
441
428
  /** @internal */
442
- Model.prototype._getAttribute = function (name) {
429
+ _getAttribute(name) {
443
430
  return this._attributes[name];
444
- };
431
+ }
445
432
  /**
446
433
  * Sets a function to allow/deny dropping a node
447
434
  * @param onAllowDrop function that takes the drag node and DropInfo and returns true if the drop is allowed
448
435
  */
449
- Model.prototype.setOnAllowDrop = function (onAllowDrop) {
436
+ setOnAllowDrop(onAllowDrop) {
450
437
  this._onAllowDrop = onAllowDrop;
451
- };
438
+ }
452
439
  /** @internal */
453
- Model.prototype._getOnAllowDrop = function () {
440
+ _getOnAllowDrop() {
454
441
  return this._onAllowDrop;
455
- };
442
+ }
456
443
  /**
457
444
  * set callback called when a new TabSet is created.
458
445
  * The tabNode can be undefined if it's the auto created first tabset in the root row (when the last
459
446
  * tab is deleted, the root tabset can be recreated)
460
447
  * @param onCreateTabSet
461
448
  */
462
- Model.prototype.setOnCreateTabSet = function (onCreateTabSet) {
449
+ setOnCreateTabSet(onCreateTabSet) {
463
450
  this._onCreateTabSet = onCreateTabSet;
464
- };
451
+ }
465
452
  /** @internal */
466
- Model.prototype._getOnCreateTabSet = function () {
453
+ _getOnCreateTabSet() {
467
454
  return this._onCreateTabSet;
468
- };
469
- Model.toTypescriptInterfaces = function () {
455
+ }
456
+ static toTypescriptInterfaces() {
470
457
  console.log(Model._attributeDefinitions.toTypescriptInterface("Global", undefined));
471
- console.log(RowNode_1.RowNode.getAttributeDefinitions().toTypescriptInterface("Row", Model._attributeDefinitions));
472
- console.log(TabSetNode_1.TabSetNode.getAttributeDefinitions().toTypescriptInterface("TabSet", Model._attributeDefinitions));
473
- console.log(TabNode_1.TabNode.getAttributeDefinitions().toTypescriptInterface("Tab", Model._attributeDefinitions));
474
- console.log(BorderNode_1.BorderNode.getAttributeDefinitions().toTypescriptInterface("Border", Model._attributeDefinitions));
475
- };
476
- Model.prototype.toString = function () {
458
+ console.log(RowNode.getAttributeDefinitions().toTypescriptInterface("Row", Model._attributeDefinitions));
459
+ console.log(TabSetNode.getAttributeDefinitions().toTypescriptInterface("TabSet", Model._attributeDefinitions));
460
+ console.log(TabNode.getAttributeDefinitions().toTypescriptInterface("Tab", Model._attributeDefinitions));
461
+ console.log(BorderNode.getAttributeDefinitions().toTypescriptInterface("Border", Model._attributeDefinitions));
462
+ }
463
+ toString() {
477
464
  return JSON.stringify(this.toJson());
478
- };
479
- /** @internal */
480
- Model._attributeDefinitions = Model._createAttributeDefinitions();
481
- return Model;
482
- }());
483
- exports.Model = Model;
465
+ }
466
+ }
467
+ /** @internal */
468
+ Model._attributeDefinitions = Model._createAttributeDefinitions();
484
469
  //# sourceMappingURL=Model.js.map