@datagrok-libraries/dock-spawn-dg 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/.eslintrc.json +47 -0
  2. package/CHANGELOG.md +355 -0
  3. package/LICENSE +21 -0
  4. package/README.md +11 -0
  5. package/css/dock-manager-context-menu.css +19 -0
  6. package/css/dock-manager-style.css +190 -0
  7. package/css/dock-manager.css +411 -0
  8. package/images/close.svg +6 -0
  9. package/images/dock_bottom.png +0 -0
  10. package/images/dock_bottom_sel.png +0 -0
  11. package/images/dock_fill.png +0 -0
  12. package/images/dock_fill_sel.png +0 -0
  13. package/images/dock_left.png +0 -0
  14. package/images/dock_left_sel.png +0 -0
  15. package/images/dock_right.png +0 -0
  16. package/images/dock_right_sel.png +0 -0
  17. package/images/dock_top.png +0 -0
  18. package/images/dock_top_sel.png +0 -0
  19. package/index.ts +32 -0
  20. package/lib/BrowserDialogHelper.d.ts +8 -0
  21. package/lib/BrowserDialogHelper.d.ts.map +1 -0
  22. package/lib/BrowserDialogHelper.js +60 -0
  23. package/lib/ContainerType.d.ts +7 -0
  24. package/lib/ContainerType.d.ts.map +1 -0
  25. package/lib/ContainerType.js +7 -0
  26. package/lib/Dialog.d.ts +51 -0
  27. package/lib/Dialog.d.ts.map +1 -0
  28. package/lib/Dialog.js +209 -0
  29. package/lib/DockConfig.d.ts +9 -0
  30. package/lib/DockConfig.d.ts.map +1 -0
  31. package/lib/DockConfig.js +14 -0
  32. package/lib/DockGraphDeserializer.d.ts +19 -0
  33. package/lib/DockGraphDeserializer.d.ts.map +1 -0
  34. package/lib/DockGraphDeserializer.js +114 -0
  35. package/lib/DockGraphSerializer.d.ts +14 -0
  36. package/lib/DockGraphSerializer.d.ts.map +1 -0
  37. package/lib/DockGraphSerializer.js +40 -0
  38. package/lib/DockLayoutEngine.d.ts +36 -0
  39. package/lib/DockLayoutEngine.d.ts.map +1 -0
  40. package/lib/DockLayoutEngine.js +323 -0
  41. package/lib/DockManager.d.ts +155 -0
  42. package/lib/DockManager.d.ts.map +1 -0
  43. package/lib/DockManager.js +752 -0
  44. package/lib/DockManagerContext.d.ts +10 -0
  45. package/lib/DockManagerContext.d.ts.map +1 -0
  46. package/lib/DockManagerContext.js +12 -0
  47. package/lib/DockModel.d.ts +9 -0
  48. package/lib/DockModel.d.ts.map +1 -0
  49. package/lib/DockModel.js +8 -0
  50. package/lib/DockNode.d.ts +16 -0
  51. package/lib/DockNode.d.ts.map +1 -0
  52. package/lib/DockNode.js +64 -0
  53. package/lib/DockWheel.d.ts +41 -0
  54. package/lib/DockWheel.d.ts.map +1 -0
  55. package/lib/DockWheel.js +208 -0
  56. package/lib/DockWheelItem.d.ts +16 -0
  57. package/lib/DockWheelItem.d.ts.map +1 -0
  58. package/lib/DockWheelItem.js +34 -0
  59. package/lib/DocumentManagerContainer.d.ts +16 -0
  60. package/lib/DocumentManagerContainer.d.ts.map +1 -0
  61. package/lib/DocumentManagerContainer.js +28 -0
  62. package/lib/DocumentTabPage.d.ts +11 -0
  63. package/lib/DocumentTabPage.d.ts.map +1 -0
  64. package/lib/DocumentTabPage.js +26 -0
  65. package/lib/DraggableContainer.d.ts +51 -0
  66. package/lib/DraggableContainer.d.ts.map +1 -0
  67. package/lib/DraggableContainer.js +145 -0
  68. package/lib/EventHandler.d.ts +8 -0
  69. package/lib/EventHandler.d.ts.map +1 -0
  70. package/lib/EventHandler.js +14 -0
  71. package/lib/FillDockContainer.d.ts +34 -0
  72. package/lib/FillDockContainer.d.ts.map +1 -0
  73. package/lib/FillDockContainer.js +80 -0
  74. package/lib/HorizontalDockContainer.d.ts +7 -0
  75. package/lib/HorizontalDockContainer.d.ts.map +1 -0
  76. package/lib/HorizontalDockContainer.js +9 -0
  77. package/lib/PanelContainer.d.ts +114 -0
  78. package/lib/PanelContainer.d.ts.map +1 -0
  79. package/lib/PanelContainer.js +517 -0
  80. package/lib/Point.d.ts +6 -0
  81. package/lib/Point.d.ts.map +1 -0
  82. package/lib/Point.js +8 -0
  83. package/lib/ResizableContainer.d.ts +56 -0
  84. package/lib/ResizableContainer.d.ts.map +1 -0
  85. package/lib/ResizableContainer.js +254 -0
  86. package/lib/ResizeHandle.d.ts +16 -0
  87. package/lib/ResizeHandle.d.ts.map +1 -0
  88. package/lib/ResizeHandle.js +58 -0
  89. package/lib/SplitterBar.d.ts +33 -0
  90. package/lib/SplitterBar.d.ts.map +1 -0
  91. package/lib/SplitterBar.js +137 -0
  92. package/lib/SplitterDockContainer.d.ts +36 -0
  93. package/lib/SplitterDockContainer.d.ts.map +1 -0
  94. package/lib/SplitterDockContainer.js +75 -0
  95. package/lib/SplitterPanel.d.ts +27 -0
  96. package/lib/SplitterPanel.d.ts.map +1 -0
  97. package/lib/SplitterPanel.js +195 -0
  98. package/lib/TabHandle.d.ts +56 -0
  99. package/lib/TabHandle.d.ts.map +1 -0
  100. package/lib/TabHandle.js +292 -0
  101. package/lib/TabHost.d.ts +47 -0
  102. package/lib/TabHost.d.ts.map +1 -0
  103. package/lib/TabHost.js +238 -0
  104. package/lib/TabPage.d.ts +20 -0
  105. package/lib/TabPage.d.ts.map +1 -0
  106. package/lib/TabPage.js +81 -0
  107. package/lib/UndockInitiator.d.ts +32 -0
  108. package/lib/UndockInitiator.d.ts.map +1 -0
  109. package/lib/UndockInitiator.js +152 -0
  110. package/lib/Utils.d.ts +15 -0
  111. package/lib/Utils.d.ts.map +1 -0
  112. package/lib/Utils.js +69 -0
  113. package/lib/VerticalDockContainer.d.ts +7 -0
  114. package/lib/VerticalDockContainer.d.ts.map +1 -0
  115. package/lib/VerticalDockContainer.js +9 -0
  116. package/lib/enums/PanelType.d.ts +5 -0
  117. package/lib/enums/PanelType.d.ts.map +1 -0
  118. package/lib/enums/PanelType.js +5 -0
  119. package/lib/enums/TabHostDirection.d.ts +7 -0
  120. package/lib/enums/TabHostDirection.d.ts.map +1 -0
  121. package/lib/enums/TabHostDirection.js +7 -0
  122. package/lib/enums/WheelTypes.d.ts +12 -0
  123. package/lib/enums/WheelTypes.d.ts.map +1 -0
  124. package/lib/enums/WheelTypes.js +14 -0
  125. package/lib/i18n/Defaults.d.ts +12 -0
  126. package/lib/i18n/Defaults.d.ts.map +1 -0
  127. package/lib/i18n/Defaults.js +9 -0
  128. package/lib/i18n/Localizer.d.ts +7 -0
  129. package/lib/i18n/Localizer.d.ts.map +1 -0
  130. package/lib/i18n/Localizer.js +16 -0
  131. package/lib/index.d.ts +33 -0
  132. package/lib/index.d.ts.map +1 -0
  133. package/lib/index.js +32 -0
  134. package/lib/interfaces/IDockContainer.d.ts +26 -0
  135. package/lib/interfaces/IDockContainer.d.ts.map +1 -0
  136. package/lib/interfaces/IDockContainer.js +1 -0
  137. package/lib/interfaces/IDockContainerWithSize.d.ts +6 -0
  138. package/lib/interfaces/IDockContainerWithSize.d.ts.map +1 -0
  139. package/lib/interfaces/IDockContainerWithSize.js +1 -0
  140. package/lib/interfaces/ILayoutEventListener.d.ts +27 -0
  141. package/lib/interfaces/ILayoutEventListener.d.ts.map +1 -0
  142. package/lib/interfaces/ILayoutEventListener.js +1 -0
  143. package/lib/interfaces/IMouseOrTouchEvent.d.ts +7 -0
  144. package/lib/interfaces/IMouseOrTouchEvent.d.ts.map +1 -0
  145. package/lib/interfaces/IMouseOrTouchEvent.js +1 -0
  146. package/lib/interfaces/INodeInfo.d.ts +8 -0
  147. package/lib/interfaces/INodeInfo.d.ts.map +1 -0
  148. package/lib/interfaces/INodeInfo.js +1 -0
  149. package/lib/interfaces/IPanelInfo.d.ts +10 -0
  150. package/lib/interfaces/IPanelInfo.d.ts.map +1 -0
  151. package/lib/interfaces/IPanelInfo.js +1 -0
  152. package/lib/interfaces/IRectangle.d.ts +7 -0
  153. package/lib/interfaces/IRectangle.d.ts.map +1 -0
  154. package/lib/interfaces/IRectangle.js +1 -0
  155. package/lib/interfaces/ISize.d.ts +5 -0
  156. package/lib/interfaces/ISize.d.ts.map +1 -0
  157. package/lib/interfaces/ISize.js +1 -0
  158. package/lib/interfaces/IState.d.ts +12 -0
  159. package/lib/interfaces/IState.d.ts.map +1 -0
  160. package/lib/interfaces/IState.js +1 -0
  161. package/lib/interfaces/IThickness.d.ts +7 -0
  162. package/lib/interfaces/IThickness.d.ts.map +1 -0
  163. package/lib/interfaces/IThickness.js +1 -0
  164. package/lib/webcomponent/DockSpawnTsWebcomponent.d.ts +35 -0
  165. package/lib/webcomponent/DockSpawnTsWebcomponent.d.ts.map +1 -0
  166. package/lib/webcomponent/DockSpawnTsWebcomponent.js +209 -0
  167. package/lib/webcomponent/styles.d.ts +5 -0
  168. package/lib/webcomponent/styles.d.ts.map +1 -0
  169. package/lib/webcomponent/styles.js +537 -0
  170. package/package.json +36 -0
  171. package/src/BrowserDialogHelper.ts +76 -0
  172. package/src/ContainerType.ts +6 -0
  173. package/src/Dialog.ts +253 -0
  174. package/src/DockConfig.ts +15 -0
  175. package/src/DockGraphDeserializer.ts +129 -0
  176. package/src/DockGraphSerializer.ts +53 -0
  177. package/src/DockLayoutEngine.ts +370 -0
  178. package/src/DockManager.ts +880 -0
  179. package/src/DockManagerContext.ts +16 -0
  180. package/src/DockModel.ts +12 -0
  181. package/src/DockNode.ts +81 -0
  182. package/src/DockWheel.ts +215 -0
  183. package/src/DockWheelItem.ts +41 -0
  184. package/src/DocumentManagerContainer.ts +39 -0
  185. package/src/DocumentTabPage.ts +35 -0
  186. package/src/DraggableContainer.ts +177 -0
  187. package/src/EventHandler.ts +17 -0
  188. package/src/FillDockContainer.ts +98 -0
  189. package/src/HorizontalDockContainer.ts +13 -0
  190. package/src/PanelContainer.ts +596 -0
  191. package/src/Point.ts +10 -0
  192. package/src/ResizableContainer.ts +293 -0
  193. package/src/ResizeHandle.ts +59 -0
  194. package/src/SplitterBar.ts +157 -0
  195. package/src/SplitterDockContainer.ts +95 -0
  196. package/src/SplitterPanel.ts +228 -0
  197. package/src/TabHandle.ts +347 -0
  198. package/src/TabHost.ts +267 -0
  199. package/src/TabPage.ts +98 -0
  200. package/src/UndockInitiator.ts +181 -0
  201. package/src/Utils.ts +85 -0
  202. package/src/VerticalDockContainer.ts +13 -0
  203. package/src/enums/PanelType.ts +4 -0
  204. package/src/enums/TabHostDirection.ts +6 -0
  205. package/src/enums/WheelTypes.ts +14 -0
  206. package/src/i18n/Defaults.ts +20 -0
  207. package/src/i18n/Localizer.ts +23 -0
  208. package/src/index.ts +32 -0
  209. package/src/interfaces/IDockContainer.ts +27 -0
  210. package/src/interfaces/IDockContainerWithSize.ts +6 -0
  211. package/src/interfaces/ILayoutEventListener.ts +28 -0
  212. package/src/interfaces/IMouseOrTouchEvent.ts +6 -0
  213. package/src/interfaces/INodeInfo.ts +8 -0
  214. package/src/interfaces/IPanelInfo.ts +10 -0
  215. package/src/interfaces/IRectangle.ts +6 -0
  216. package/src/interfaces/ISize.ts +4 -0
  217. package/src/interfaces/IState.ts +12 -0
  218. package/src/interfaces/IThickness.ts +6 -0
  219. package/src/webcomponent/DockSpawnTsWebcomponent.ts +248 -0
  220. package/src/webcomponent/styles.ts +544 -0
  221. package/tsconfig.json +74 -0
  222. package/tsconfig.tsbuildinfo +1 -0
package/lib/TabHost.js ADDED
@@ -0,0 +1,238 @@
1
+ import { TabPage } from "./TabPage.js";
2
+ import { Utils } from "./Utils.js";
3
+ import { TabHostDirection } from "./enums/TabHostDirection.js";
4
+ import { EventHandler } from './EventHandler.js';
5
+ /**
6
+ * Tab Host control contains tabs known as TabPages.
7
+ * The tab strip can be aligned in different orientations
8
+ */
9
+ export class TabHost {
10
+ displayCloseButton;
11
+ dockManager;
12
+ tabStripDirection;
13
+ hostElement;
14
+ tabListElement;
15
+ separatorElement;
16
+ contentElement;
17
+ createTabPage;
18
+ tabHandleListener;
19
+ eventListeners;
20
+ pages;
21
+ activeTab;
22
+ _resizeRequested;
23
+ mouseDownHandler;
24
+ focusHandler;
25
+ constructor(dockManager, tabStripDirection, displayCloseButton) {
26
+ /**
27
+ * Create a tab host with the tab strip aligned in the [tabStripDirection] direciton
28
+ * Only TabHost.DIRECTION_BOTTOM and TabHost.DIRECTION_TOP are supported
29
+ */
30
+ if (tabStripDirection === undefined) {
31
+ tabStripDirection = TabHostDirection.BOTTOM;
32
+ }
33
+ if (displayCloseButton === undefined) {
34
+ displayCloseButton = false;
35
+ }
36
+ this.dockManager = dockManager;
37
+ this.tabStripDirection = tabStripDirection;
38
+ this.displayCloseButton = displayCloseButton; // Indicates if the close button next to the tab handle should be displayed
39
+ this.pages = [];
40
+ this.eventListeners = [];
41
+ this.tabHandleListener = {
42
+ onMoveTab: (e) => { this.onMoveTab(e); }
43
+ };
44
+ this.hostElement = document.createElement('div'); // The main tab host DOM element
45
+ this.tabListElement = document.createElement('div'); // Hosts the tab handles
46
+ this.separatorElement = document.createElement('div'); // A seperator line between the tabs and content
47
+ this.contentElement = document.createElement('div'); // Hosts the active tab content
48
+ this.contentElement.tabIndex = 0;
49
+ this.createTabPage = this._createDefaultTabPage; // Factory for creating tab pages
50
+ if (this.tabStripDirection === TabHostDirection.BOTTOM) {
51
+ this.hostElement.appendChild(this.contentElement);
52
+ this.hostElement.appendChild(this.separatorElement);
53
+ this.hostElement.appendChild(this.tabListElement);
54
+ }
55
+ else if (this.tabStripDirection === TabHostDirection.TOP) {
56
+ this.hostElement.appendChild(this.tabListElement);
57
+ this.hostElement.appendChild(this.separatorElement);
58
+ this.hostElement.appendChild(this.contentElement);
59
+ }
60
+ else {
61
+ throw new Error('Only top and bottom tab strip orientations are supported');
62
+ }
63
+ this.hostElement.classList.add('dockspan-tab-host');
64
+ this.tabListElement.classList.add('dockspan-tab-handle-list-container');
65
+ this.separatorElement.classList.add('dockspan-tab-handle-content-seperator');
66
+ this.contentElement.classList.add('dockspan-tab-content');
67
+ this.contentElement.tabIndex = 0;
68
+ this.focusHandler = new EventHandler(this.contentElement, 'focus', this.onFocus.bind(this), true);
69
+ this.mouseDownHandler = new EventHandler(this.contentElement, 'mousedown', this.onMousedown.bind(this), true);
70
+ }
71
+ onFocus() {
72
+ if (this.activeTab && this.dockManager.activePanel != this.activeTab.panel)
73
+ this.dockManager.activePanel = this.activeTab.panel;
74
+ }
75
+ setActive(isActive) {
76
+ if (isActive) {
77
+ this.separatorElement.classList.add('dockspan-tab-handle-content-seperator-active');
78
+ }
79
+ else {
80
+ this.separatorElement.classList.remove('dockspan-tab-handle-content-seperator-active');
81
+ }
82
+ if (this.activeTab) {
83
+ this.activeTab.handle.setActive(isActive);
84
+ }
85
+ }
86
+ onMousedown() {
87
+ if (this.activeTab && this.dockManager.activePanel != this.activeTab.panel)
88
+ this.dockManager.activePanel = this.activeTab.panel;
89
+ }
90
+ onMoveTab(e) {
91
+ let index = Array.prototype.slice.call(this.tabListElement.childNodes).indexOf(e.self.elementBase);
92
+ this.change(this, /*handle*/ e.self, e.state, index);
93
+ }
94
+ performTabsLayout(indexes) {
95
+ this.pages = Utils.orderByIndexes(this.pages, indexes);
96
+ let items = this.tabListElement.childNodes;
97
+ let itemsArr = [];
98
+ for (let i in items) {
99
+ if (items[i].nodeType === 1) { // get rid of the whitespace text nodes
100
+ itemsArr.push(items[i]);
101
+ }
102
+ }
103
+ itemsArr = Utils.orderByIndexes(itemsArr, indexes);
104
+ for (let i = 0; i < itemsArr.length; ++i) {
105
+ this.tabListElement.appendChild(itemsArr[i]);
106
+ }
107
+ if (this.activeTab)
108
+ this.onTabPageSelected(this.activeTab, false);
109
+ }
110
+ getActiveTab() {
111
+ return this.activeTab;
112
+ }
113
+ addListener(listener) {
114
+ this.eventListeners.push(listener);
115
+ }
116
+ removeListener(listener) {
117
+ this.eventListeners.splice(this.eventListeners.indexOf(listener), 1);
118
+ }
119
+ change(host, handle, state, index) {
120
+ this.eventListeners.forEach((listener) => {
121
+ if (listener.onChange) {
122
+ listener.onChange({ host: host, handle: handle, state: state, index: index });
123
+ }
124
+ });
125
+ }
126
+ _createDefaultTabPage(tabHost, container) {
127
+ return new TabPage(tabHost, container);
128
+ }
129
+ setActiveTab(container) {
130
+ let currentPage;
131
+ this.pages.forEach((itm) => {
132
+ if (itm.container === container) {
133
+ currentPage = itm;
134
+ }
135
+ });
136
+ if (this.pages.length > 0 && currentPage) {
137
+ this.onTabPageSelected(currentPage, true);
138
+ this.dockManager.activePanel = container;
139
+ }
140
+ }
141
+ resize(width, height) {
142
+ this.hostElement.style.width = width + 'px';
143
+ this.hostElement.style.height = height + 'px';
144
+ let tabHeight = this.tabListElement.clientHeight;
145
+ if (!this._resizeRequested)
146
+ requestAnimationFrame(() => this.resizeTabListElement(width, height));
147
+ this._resizeRequested = true;
148
+ let separatorHeight = this.separatorElement.clientHeight;
149
+ let contentHeight = height - tabHeight - separatorHeight;
150
+ this.contentElement.style.height = contentHeight + 'px';
151
+ if (this.activeTab)
152
+ this.activeTab.resize(width, contentHeight);
153
+ }
154
+ resizeTabListElement(width, height) {
155
+ this._resizeRequested = false;
156
+ if (this.pages.length === 0)
157
+ return;
158
+ let tabListWidth = 0;
159
+ this.pages.forEach((page) => {
160
+ let handle = page.handle;
161
+ if (handle.elementBase != null) {
162
+ handle.elementBase.style.width = ''; //clear
163
+ tabListWidth += handle.elementBase.clientWidth;
164
+ }
165
+ });
166
+ let scaleMultiplier = width / tabListWidth;
167
+ if (scaleMultiplier > 1.2)
168
+ return; //with a reserve
169
+ this.pages.forEach((page, index) => {
170
+ let handle = page.handle;
171
+ let newSize = scaleMultiplier * handle.elementBase.clientWidth;
172
+ if (index === this.pages.length - 1)
173
+ newSize = newSize - 5;
174
+ handle.elementBase.style.width = newSize + 'px';
175
+ });
176
+ }
177
+ performLayout(children) {
178
+ // Destroy all existing tab pages not in children
179
+ this.pages.forEach((tab) => {
180
+ if (!children.some((x) => x == tab.container)) {
181
+ tab.handle.removeListener(this.tabHandleListener);
182
+ tab.destroy();
183
+ let index = this.pages.indexOf(tab);
184
+ if (index > -1) {
185
+ this.pages.splice(index, 1);
186
+ }
187
+ }
188
+ });
189
+ let oldActiveTab = this.activeTab;
190
+ delete this.activeTab;
191
+ let childPanels = children.filter((child) => {
192
+ return child.containerType === 'panel';
193
+ });
194
+ if (childPanels.length > 0) {
195
+ // Rebuild new tab pages
196
+ childPanels.forEach((child) => {
197
+ let page = null;
198
+ if (!this.pages.some((x) => {
199
+ if (x.container == child) {
200
+ page = x;
201
+ return true;
202
+ }
203
+ return false;
204
+ })) {
205
+ page = this.createTabPage(this, child);
206
+ page.handle.addListener(this.tabHandleListener);
207
+ this.pages.push(page);
208
+ }
209
+ // Restore the active selected tab
210
+ if (oldActiveTab && page.container === oldActiveTab.container)
211
+ this.activeTab = page;
212
+ });
213
+ this._setTabHandlesVisible(true);
214
+ }
215
+ else
216
+ // Do not show an empty tab handle host with zero tabs
217
+ this._setTabHandlesVisible(false);
218
+ if (this.activeTab)
219
+ this.onTabPageSelected(this.activeTab, false);
220
+ }
221
+ _setTabHandlesVisible(visible) {
222
+ if (visible) {
223
+ this.tabListElement.classList.add('dockspan-tab-handle-list-container-visible');
224
+ this.separatorElement.classList.add('dockspan-tab-handle-content-seperator-visible');
225
+ }
226
+ else {
227
+ this.tabListElement.classList.remove('dockspan-tab-handle-list-container-visible');
228
+ this.separatorElement.classList.remove('dockspan-tab-handle-content-seperator-visible');
229
+ }
230
+ }
231
+ onTabPageSelected(page, active) {
232
+ this.activeTab = page;
233
+ this.pages.forEach((tabPage) => {
234
+ let selected = (tabPage === page);
235
+ tabPage.setSelected(selected, active);
236
+ });
237
+ }
238
+ }
@@ -0,0 +1,20 @@
1
+ import { TabHandle } from "./TabHandle.js";
2
+ import { PanelContainer } from "./PanelContainer.js";
3
+ import { IDockContainer } from "./interfaces/IDockContainer.js";
4
+ import { TabHost } from "./TabHost.js";
5
+ export declare class TabPage {
6
+ selected: boolean;
7
+ host: TabHost;
8
+ container: IDockContainer;
9
+ panel?: PanelContainer;
10
+ handle: TabHandle;
11
+ containerElement: HTMLElement;
12
+ _initContent: boolean;
13
+ constructor(host: TabHost, container: IDockContainer);
14
+ onTitleChanged(): void;
15
+ destroy(): void;
16
+ onSelected(): void;
17
+ setSelected(flag: boolean, isActive: boolean): void;
18
+ resize(width: number, height: number): void;
19
+ }
20
+ //# sourceMappingURL=TabPage.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabPage.d.ts","sourceRoot":"","sources":["../src/TabPage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,qBAAa,OAAO;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;IACd,SAAS,EAAE,cAAc,CAAC;IAC1B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,MAAM,EAAE,SAAS,CAAC;IAClB,gBAAgB,EAAE,WAAW,CAAC;IAC9B,YAAY,EAAE,OAAO,CAAC;gBAEV,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,cAAc;IAqBpD,cAAc;IAWd,OAAO;IAgBP,UAAU;IAQV,WAAW,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO;IAuB5C,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAGvC"}
package/lib/TabPage.js ADDED
@@ -0,0 +1,81 @@
1
+ import { TabHandle } from "./TabHandle.js";
2
+ import { PanelContainer } from "./PanelContainer.js";
3
+ import { Utils } from "./Utils.js";
4
+ export class TabPage {
5
+ selected;
6
+ host;
7
+ container;
8
+ panel;
9
+ handle;
10
+ containerElement;
11
+ _initContent;
12
+ constructor(host, container) {
13
+ if (arguments.length === 0) {
14
+ return;
15
+ }
16
+ this.selected = false;
17
+ this.host = host;
18
+ this.container = container;
19
+ this.handle = new TabHandle(this);
20
+ this.containerElement = container.containerElement;
21
+ if (container instanceof PanelContainer) {
22
+ this.panel = container;
23
+ this.panel.onTitleChanged = this.onTitleChanged.bind(this);
24
+ this.onTitleChanged();
25
+ }
26
+ container.tabPage = this;
27
+ }
28
+ onTitleChanged() {
29
+ this.handle.updateTitle();
30
+ if (this.panel) {
31
+ if (this.panel.hasChanges) {
32
+ this.handle.elementText.classList.add('panel-has-changes');
33
+ }
34
+ else {
35
+ this.handle.elementText.classList.remove('panel-has-changes');
36
+ }
37
+ }
38
+ }
39
+ destroy() {
40
+ this.handle.destroy();
41
+ if (this.container instanceof PanelContainer) {
42
+ let panel = this.container;
43
+ delete panel.onTitleChanged;
44
+ }
45
+ if (this.host.dockManager.activePanel == this.panel)
46
+ this.host.dockManager.activePanel = null;
47
+ this.container.tabPage = null;
48
+ Utils.removeNode(this.containerElement);
49
+ }
50
+ onSelected() {
51
+ this.host.onTabPageSelected(this, true);
52
+ if (this.container instanceof PanelContainer) {
53
+ let panel = this.container;
54
+ panel.dockManager.notifyOnTabChange(this);
55
+ }
56
+ }
57
+ setSelected(flag, isActive) {
58
+ this.selected = flag;
59
+ this.handle.setSelected(flag);
60
+ if (!this._initContent)
61
+ this.host.contentElement.appendChild(this.containerElement);
62
+ this._initContent = true;
63
+ if (this.selected) {
64
+ this.containerElement.style.display = 'block';
65
+ this.panel.setVisible(true);
66
+ // force a resize again
67
+ let width = this.host.contentElement.clientWidth;
68
+ let height = this.host.contentElement.clientHeight;
69
+ this.container.resize(width, height);
70
+ if (isActive)
71
+ this.host.dockManager.activePanel = this.container;
72
+ }
73
+ else {
74
+ this.containerElement.style.display = 'none';
75
+ this.panel.setVisible(false);
76
+ }
77
+ }
78
+ resize(width, height) {
79
+ this.container.resize(width, height);
80
+ }
81
+ }
@@ -0,0 +1,32 @@
1
+ import { EventHandler } from "./EventHandler.js";
2
+ import { Point } from "./Point.js";
3
+ import { Dialog } from "./Dialog.js";
4
+ import { IMouseOrTouchEvent } from "./interfaces/IMouseOrTouchEvent.js";
5
+ /**
6
+ * Listens for events on the [element] and notifies the [listener]
7
+ * if an undock event has been invoked. An undock event is invoked
8
+ * when the user clicks on the event and drags is beyond the
9
+ * specified [thresholdPixels]
10
+ */
11
+ export declare class UndockInitiator {
12
+ mouseUpHandler: EventHandler;
13
+ touchUpHandler: EventHandler;
14
+ mouseMoveHandler: EventHandler;
15
+ touchMoveHandler: EventHandler;
16
+ dragStartPosition: Point;
17
+ thresholdPixels: number;
18
+ _enabled: boolean;
19
+ mouseDownHandler: EventHandler;
20
+ touchDownHandler: EventHandler;
21
+ element: HTMLElement;
22
+ _undockededCallback: (e: MouseEvent, dragOffset: Point) => Dialog;
23
+ touchDownUndockedHandler: EventHandler;
24
+ constructor(element: Element, undockededCallback: (e: MouseEvent, dragOffset: Point) => Dialog, thresholdPixels?: number);
25
+ get enabled(): boolean;
26
+ set enabled(value: boolean);
27
+ onMouseDown(e: any): void;
28
+ onMouseUp(): void;
29
+ onMouseMove(e: IMouseOrTouchEvent): void;
30
+ _requestUndock(e: any): void;
31
+ }
32
+ //# sourceMappingURL=UndockInitiator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UndockInitiator.d.ts","sourceRoot":"","sources":["../src/UndockInitiator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE;;;;;GAKG;AACH,qBAAa,eAAe;IACxB,cAAc,EAAE,YAAY,CAAC;IAC7B,cAAc,EAAE,YAAY,CAAC;IAC7B,gBAAgB,EAAE,YAAY,CAAC;IAC/B,gBAAgB,EAAE,YAAY,CAAC;IAC/B,iBAAiB,EAAE,KAAK,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,EAAE,OAAO,CAAC;IAClB,gBAAgB,EAAE,YAAY,CAAC;IAC/B,gBAAgB,EAAE,YAAY,CAAC;IAC/B,OAAO,EAAE,WAAW,CAAC;IACrB,mBAAmB,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,KAAK,MAAM,CAAC;IAClE,wBAAwB,EAAE,YAAY,CAAC;gBAE3B,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,CAAC,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,KAAK,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM;IAWxH,IAAI,OAAO,IAAI,OAAO,CAErB;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,OAAO,EA8CzB;IAED,WAAW,CAAC,CAAC,KAAA;IAuCb,SAAS;IAsBT,WAAW,CAAC,CAAC,EAAE,kBAAkB;IAgBjC,cAAc,CAAC,CAAC,KAAA;CAgBnB"}
@@ -0,0 +1,152 @@
1
+ import { EventHandler } from "./EventHandler.js";
2
+ import { Point } from "./Point.js";
3
+ /**
4
+ * Listens for events on the [element] and notifies the [listener]
5
+ * if an undock event has been invoked. An undock event is invoked
6
+ * when the user clicks on the event and drags is beyond the
7
+ * specified [thresholdPixels]
8
+ */
9
+ export class UndockInitiator {
10
+ mouseUpHandler;
11
+ touchUpHandler;
12
+ mouseMoveHandler;
13
+ touchMoveHandler;
14
+ dragStartPosition;
15
+ thresholdPixels;
16
+ _enabled;
17
+ mouseDownHandler;
18
+ touchDownHandler;
19
+ element;
20
+ _undockededCallback;
21
+ touchDownUndockedHandler;
22
+ constructor(element, undockededCallback, thresholdPixels) {
23
+ if (!thresholdPixels) {
24
+ thresholdPixels = 7;
25
+ }
26
+ this.element = element;
27
+ this._undockededCallback = undockededCallback;
28
+ this.thresholdPixels = thresholdPixels;
29
+ this._enabled = false;
30
+ }
31
+ get enabled() {
32
+ return this._enabled;
33
+ }
34
+ set enabled(value) {
35
+ this._enabled = value;
36
+ if (this._enabled) {
37
+ if (this.mouseDownHandler) {
38
+ this.mouseDownHandler.cancel();
39
+ delete this.mouseDownHandler;
40
+ }
41
+ if (this.touchDownHandler) {
42
+ this.touchDownHandler.cancel();
43
+ delete this.touchDownHandler;
44
+ }
45
+ this.mouseDownHandler = new EventHandler(this.element, 'mousedown', this.onMouseDown.bind(this));
46
+ this.touchDownHandler = new EventHandler(this.element, 'touchstart', this.onMouseDown.bind(this), { passive: false });
47
+ }
48
+ else {
49
+ if (this.mouseDownHandler) {
50
+ this.mouseDownHandler.cancel();
51
+ delete this.mouseDownHandler;
52
+ }
53
+ if (this.touchDownHandler) {
54
+ this.touchDownHandler.cancel();
55
+ delete this.touchDownHandler;
56
+ }
57
+ if (this.mouseUpHandler) {
58
+ this.mouseUpHandler.cancel();
59
+ delete this.mouseUpHandler;
60
+ }
61
+ if (this.touchUpHandler) {
62
+ this.touchUpHandler.cancel();
63
+ delete this.touchUpHandler;
64
+ }
65
+ if (this.mouseMoveHandler) {
66
+ this.mouseMoveHandler.cancel();
67
+ delete this.mouseMoveHandler;
68
+ }
69
+ if (this.touchMoveHandler) {
70
+ this.touchMoveHandler.cancel();
71
+ delete this.touchMoveHandler;
72
+ }
73
+ }
74
+ }
75
+ onMouseDown(e) {
76
+ e.preventDefault();
77
+ // Make sure we dont do this on floating dialogs
78
+ if (this.enabled) {
79
+ if (e.touches) {
80
+ if (e.touches.length > 1)
81
+ return;
82
+ e = e.touches[0];
83
+ }
84
+ if (this.mouseUpHandler) {
85
+ this.mouseUpHandler.cancel();
86
+ delete this.mouseUpHandler;
87
+ }
88
+ if (this.touchUpHandler) {
89
+ this.touchUpHandler.cancel();
90
+ delete this.touchUpHandler;
91
+ }
92
+ if (this.mouseMoveHandler) {
93
+ this.mouseMoveHandler.cancel();
94
+ delete this.mouseMoveHandler;
95
+ }
96
+ if (this.touchMoveHandler) {
97
+ this.touchMoveHandler.cancel();
98
+ delete this.touchMoveHandler;
99
+ }
100
+ this.mouseUpHandler = new EventHandler(window, 'mouseup', this.onMouseUp.bind(this));
101
+ this.touchUpHandler = new EventHandler(window, 'touchend', this.onMouseUp.bind(this));
102
+ this.mouseMoveHandler = new EventHandler(window, 'mousemove', this.onMouseMove.bind(this));
103
+ this.touchMoveHandler = new EventHandler(window, 'touchmove', this.onMouseMove.bind(this));
104
+ this.dragStartPosition = new Point(e.clientX, e.clientY);
105
+ }
106
+ }
107
+ onMouseUp() {
108
+ if (this.mouseUpHandler) {
109
+ this.mouseUpHandler.cancel();
110
+ delete this.mouseUpHandler;
111
+ }
112
+ if (this.touchUpHandler) {
113
+ this.touchUpHandler.cancel();
114
+ delete this.touchUpHandler;
115
+ }
116
+ if (this.mouseMoveHandler) {
117
+ this.mouseMoveHandler.cancel();
118
+ delete this.mouseMoveHandler;
119
+ }
120
+ if (this.touchMoveHandler) {
121
+ this.touchMoveHandler.cancel();
122
+ delete this.touchMoveHandler;
123
+ }
124
+ }
125
+ onMouseMove(e) {
126
+ if (e.touches) {
127
+ if (e.touches.length > 1)
128
+ return;
129
+ e = e.touches[0];
130
+ }
131
+ let position = new Point(e.clientX, e.clientY);
132
+ let dy = position.y - this.dragStartPosition.y;
133
+ if (dy > this.thresholdPixels || dy < -this.thresholdPixels) {
134
+ this.enabled = false;
135
+ this._requestUndock(e);
136
+ }
137
+ }
138
+ _requestUndock(e) {
139
+ let top = 0;
140
+ let left = 0;
141
+ let currentElement = this.element;
142
+ do {
143
+ top += currentElement.offsetTop || 0;
144
+ left += currentElement.offsetLeft || 0;
145
+ currentElement = currentElement.offsetParent;
146
+ } while (currentElement);
147
+ let dragOffsetX = this.dragStartPosition.x - left;
148
+ let dragOffsetY = this.dragStartPosition.y - top;
149
+ let dragOffset = new Point(dragOffsetX, dragOffsetY);
150
+ this._undockededCallback(e, dragOffset);
151
+ }
152
+ }
package/lib/Utils.d.ts ADDED
@@ -0,0 +1,15 @@
1
+ import { DockNode } from "./DockNode";
2
+ export declare class Utils {
3
+ private static _counter;
4
+ static getPixels(pixels: string): number;
5
+ static disableGlobalTextSelection(element: HTMLElement): void;
6
+ static enableGlobalTextSelection(element: HTMLElement): void;
7
+ static isPointInsideNode(px: number, py: number, node: DockNode): boolean;
8
+ static getNextId(prefix: string): string;
9
+ static removeNode(node: Node): boolean;
10
+ static orderByIndexes<T>(array: T[], indexes: number[]): any[];
11
+ static arrayRemove<T>(array: T[], value: any): T[] | false;
12
+ static arrayContains<T>(array: T[], value: T): boolean;
13
+ static arrayEqual<T>(a: T[], b: T[]): boolean;
14
+ }
15
+ //# sourceMappingURL=Utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Utils.d.ts","sourceRoot":"","sources":["../src/Utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,qBAAa,KAAK;IAEd,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAa;IAEpC,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAQxC,MAAM,CAAC,0BAA0B,CAAC,OAAO,EAAE,WAAW;IAItD,MAAM,CAAC,yBAAyB,CAAC,OAAO,EAAE,WAAW;IAIrD,MAAM,CAAC,iBAAiB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,OAAO;IAYzE,MAAM,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IAIxC,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAUtC,MAAM,CAAC,cAAc,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,OAAO,EAAE,MAAM,EAAE;IAQtD,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,GAAG,GAAG,CAAC,EAAE,GAAG,KAAK;IAQ1D,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO;IAUtD,MAAM,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,OAAO;CAUhD"}
package/lib/Utils.js ADDED
@@ -0,0 +1,69 @@
1
+ export class Utils {
2
+ static _counter = 0;
3
+ static getPixels(pixels) {
4
+ if (pixels === null) {
5
+ return 0;
6
+ }
7
+ return parseInt(pixels.replace('px', ''));
8
+ }
9
+ static disableGlobalTextSelection(element) {
10
+ element.classList.add('disable-selection');
11
+ }
12
+ static enableGlobalTextSelection(element) {
13
+ element.classList.remove('disable-selection');
14
+ }
15
+ static isPointInsideNode(px, py, node) {
16
+ let element = node.container.containerElement;
17
+ let rect = element.getBoundingClientRect();
18
+ return (px >= rect.left &&
19
+ px <= rect.left + rect.width &&
20
+ py >= rect.top &&
21
+ py <= rect.top + rect.height);
22
+ }
23
+ static getNextId(prefix) {
24
+ return prefix + Utils._counter++;
25
+ }
26
+ static removeNode(node) {
27
+ if (node.parentNode === null) {
28
+ return false;
29
+ }
30
+ node.parentNode.removeChild(node);
31
+ return true;
32
+ }
33
+ static orderByIndexes(array, indexes) {
34
+ let sortedArray = [];
35
+ for (let i = 0; i < indexes.length; i++) {
36
+ sortedArray.push(array[indexes[i]]);
37
+ }
38
+ return sortedArray;
39
+ }
40
+ static arrayRemove(array, value) {
41
+ let idx = array.indexOf(value);
42
+ if (idx !== -1) {
43
+ return array.splice(idx, 1);
44
+ }
45
+ return false;
46
+ }
47
+ static arrayContains(array, value) {
48
+ let i = array.length;
49
+ while (i--) {
50
+ if (array[i] === value) {
51
+ return true;
52
+ }
53
+ }
54
+ return false;
55
+ }
56
+ static arrayEqual(a, b) {
57
+ if (a === b)
58
+ return true;
59
+ if (a == null || b == null)
60
+ return false;
61
+ if (a.length != b.length)
62
+ return false;
63
+ for (let i = 0; i < a.length; ++i) {
64
+ if (a[i] !== b[i])
65
+ return false;
66
+ }
67
+ return true;
68
+ }
69
+ }
@@ -0,0 +1,7 @@
1
+ import { SplitterDockContainer } from "./SplitterDockContainer.js";
2
+ import { DockManager } from "./DockManager.js";
3
+ import { IDockContainer } from "./interfaces/IDockContainer.js";
4
+ export declare class VerticalDockContainer extends SplitterDockContainer {
5
+ constructor(dockManager: DockManager, childContainers: IDockContainer[]);
6
+ }
7
+ //# sourceMappingURL=VerticalDockContainer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VerticalDockContainer.d.ts","sourceRoot":"","sources":["../src/VerticalDockContainer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,qBAAa,qBAAsB,SAAQ,qBAAqB;gBAEhD,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,cAAc,EAAE;CAI1E"}
@@ -0,0 +1,9 @@
1
+ import { SplitterDockContainer } from "./SplitterDockContainer.js";
2
+ import { Utils } from "./Utils.js";
3
+ import { ContainerType } from "./ContainerType.js";
4
+ export class VerticalDockContainer extends SplitterDockContainer {
5
+ constructor(dockManager, childContainers) {
6
+ super(Utils.getNextId('vertical_splitter_'), dockManager, childContainers, true);
7
+ this.containerType = ContainerType.vertical;
8
+ }
9
+ }
@@ -0,0 +1,5 @@
1
+ export declare enum PanelType {
2
+ 'document' = "document",
3
+ 'panel' = "panel"
4
+ }
5
+ //# sourceMappingURL=PanelType.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PanelType.d.ts","sourceRoot":"","sources":["../../src/enums/PanelType.ts"],"names":[],"mappings":"AAAA,oBAAY,SAAS;IACjB,UAAU,aAAa;IACvB,OAAO,UAAU;CACpB"}
@@ -0,0 +1,5 @@
1
+ export var PanelType;
2
+ (function (PanelType) {
3
+ PanelType["document"] = "document";
4
+ PanelType["panel"] = "panel";
5
+ })(PanelType || (PanelType = {}));
@@ -0,0 +1,7 @@
1
+ export declare enum TabHostDirection {
2
+ TOP = 0,
3
+ BOTTOM = 1,
4
+ LEFT = 2,
5
+ RIGHT = 3
6
+ }
7
+ //# sourceMappingURL=TabHostDirection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TabHostDirection.d.ts","sourceRoot":"","sources":["../../src/enums/TabHostDirection.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IACxB,GAAG,IAAI;IACP,MAAM,IAAI;IACV,IAAI,IAAI;IACR,KAAK,IAAI;CACZ"}