flexlayout-react 0.7.15 → 0.8.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 (252) hide show
  1. package/ChangeLog.txt +28 -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 +140 -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 +459 -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 +129 -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 +919 -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 +127 -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 +272 -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 +303 -242
  200. package/src/model/Utils.ts +6 -32
  201. package/src/view/BorderButton.tsx +36 -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 +1053 -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 +39 -54
  215. package/src/view/TabButtonStamp.tsx +5 -9
  216. package/src/view/TabOverflowHook.tsx +14 -9
  217. package/src/view/TabSet.tsx +221 -176
  218. package/src/view/Utils.tsx +119 -39
  219. package/style/_base.scss +140 -34
  220. package/style/dark.css +140 -35
  221. package/style/dark.css.map +1 -1
  222. package/style/dark.scss +3 -1
  223. package/style/gray.css +139 -34
  224. package/style/gray.css.map +1 -1
  225. package/style/gray.scss +2 -0
  226. package/style/light.css +141 -36
  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 +139 -34
  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
package/lib/view/Utils.js CHANGED
@@ -1,69 +1,127 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAuxMouseEvent = exports.hideElement = exports.getRenderStateEx = void 0;
4
- const React = require("react");
5
- /** @internal */
6
- function getRenderStateEx(layout, node, iconFactory, titleFactory, iconAngle) {
7
- let leadingContent = iconFactory ? iconFactory(node) : undefined;
8
- let titleContent = node.getName();
9
- let name = node.getName();
10
- if (iconAngle === undefined) {
11
- iconAngle = 0;
12
- }
13
- function isTitleObject(obj) {
14
- return obj.titleContent !== undefined;
15
- }
16
- if (titleFactory !== undefined) {
17
- const titleObj = titleFactory(node);
18
- if (titleObj !== undefined) {
19
- if (typeof titleObj === "string") {
20
- titleContent = titleObj;
21
- name = titleObj;
22
- }
23
- else if (isTitleObject(titleObj)) {
24
- titleContent = titleObj.titleContent;
25
- name = titleObj.name;
26
- }
27
- else {
28
- titleContent = titleObj;
29
- }
30
- }
31
- }
32
- if (leadingContent === undefined && node.getIcon() !== undefined) {
33
- if (iconAngle !== 0) {
34
- leadingContent = React.createElement("img", { style: { width: "1em", height: "1em", transform: "rotate(" + iconAngle + "deg)" }, src: node.getIcon(), alt: "leadingContent" });
35
- }
36
- else {
37
- leadingContent = React.createElement("img", { style: { width: "1em", height: "1em" }, src: node.getIcon(), alt: "leadingContent" });
38
- }
39
- }
40
- let buttons = [];
41
- // allow customization of leading contents (icon) and contents
42
- const renderState = { leading: leadingContent, content: titleContent, name, buttons };
43
- layout.customizeTab(node, renderState);
44
- node._setRenderedName(renderState.name);
45
- return renderState;
46
- }
47
- exports.getRenderStateEx = getRenderStateEx;
48
- /** @internal */
49
- function hideElement(style, useVisibility) {
50
- if (useVisibility) {
51
- style.visibility = "hidden";
52
- }
53
- else {
54
- style.display = "none";
55
- }
56
- }
57
- exports.hideElement = hideElement;
58
- /** @internal */
59
- function isAuxMouseEvent(event) {
60
- let auxEvent = false;
61
- if (event.nativeEvent instanceof MouseEvent) {
62
- if (event.nativeEvent.button !== 0 || event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) {
63
- auxEvent = true;
64
- }
65
- }
66
- return auxEvent;
67
- }
68
- exports.isAuxMouseEvent = isAuxMouseEvent;
1
+ import * as React from "react";
2
+ import { TabNode } from "../model/TabNode";
3
+ import { TabSetNode } from "../model/TabSetNode";
4
+ /** @internal */
5
+ export function isDesktop() {
6
+ const desktop = typeof window !== "undefined" && window.matchMedia && window.matchMedia("(hover: hover) and (pointer: fine)").matches;
7
+ return desktop;
8
+ }
9
+ /** @internal */
10
+ export function getRenderStateEx(layout, node, iconAngle) {
11
+ let leadingContent = undefined;
12
+ let titleContent = node.getName();
13
+ let name = node.getName();
14
+ if (iconAngle === undefined) {
15
+ iconAngle = 0;
16
+ }
17
+ if (leadingContent === undefined && node.getIcon() !== undefined) {
18
+ if (iconAngle !== 0) {
19
+ leadingContent = React.createElement("img", { style: { width: "1em", height: "1em", transform: "rotate(" + iconAngle + "deg)" }, src: node.getIcon(), alt: "leadingContent" });
20
+ }
21
+ else {
22
+ leadingContent = React.createElement("img", { style: { width: "1em", height: "1em" }, src: node.getIcon(), alt: "leadingContent" });
23
+ }
24
+ }
25
+ let buttons = [];
26
+ // allow customization of leading contents (icon) and contents
27
+ const renderState = { leading: leadingContent, content: titleContent, name, buttons };
28
+ layout.customizeTab(node, renderState);
29
+ node.setRenderedName(renderState.name);
30
+ return renderState;
31
+ }
32
+ /** @internal */
33
+ export function isAuxMouseEvent(event) {
34
+ let auxEvent = false;
35
+ if (event.nativeEvent instanceof MouseEvent) {
36
+ if (event.nativeEvent.button !== 0 || event.ctrlKey || event.altKey || event.metaKey || event.shiftKey) {
37
+ auxEvent = true;
38
+ }
39
+ }
40
+ return auxEvent;
41
+ }
42
+ export function enablePointerOnIFrames(enable, currentDocument) {
43
+ const iframes = [
44
+ ...getElementsByTagName('iframe', currentDocument),
45
+ ...getElementsByTagName('webview', currentDocument),
46
+ ];
47
+ for (const iframe of iframes) {
48
+ iframe.style.pointerEvents = enable ? 'auto' : 'none';
49
+ }
50
+ }
51
+ ;
52
+ export function getElementsByTagName(tag, currentDocument) {
53
+ return [...currentDocument.getElementsByTagName(tag)];
54
+ }
55
+ export function startDrag(doc, event, drag, dragEnd, dragCancel) {
56
+ event.preventDefault();
57
+ const pointerMove = (ev) => {
58
+ ev.preventDefault();
59
+ drag(ev.clientX, ev.clientY);
60
+ };
61
+ const pointerCancel = (ev) => {
62
+ ev.preventDefault();
63
+ dragCancel();
64
+ };
65
+ const pointerUp = () => {
66
+ doc.removeEventListener("pointermove", pointerMove);
67
+ doc.removeEventListener("pointerup", pointerUp);
68
+ doc.removeEventListener("pointercancel", pointerCancel);
69
+ dragEnd();
70
+ };
71
+ doc.addEventListener("pointermove", pointerMove);
72
+ doc.addEventListener("pointerup", pointerUp);
73
+ doc.addEventListener('pointercancel', pointerCancel);
74
+ }
75
+ export function canDockToWindow(node) {
76
+ if (node instanceof TabNode) {
77
+ return node.isEnablePopout();
78
+ }
79
+ else if (node instanceof TabSetNode) {
80
+ for (const child of node.getChildren()) {
81
+ if (child.isEnablePopout() === false) {
82
+ return false;
83
+ }
84
+ }
85
+ return true;
86
+ }
87
+ return false;
88
+ }
89
+ export function keepOnScreen(rect) {
90
+ rect.snap(10);
91
+ const availableScreenWidth = window.screen.availWidth;
92
+ const availableScreenHeight = window.screen.availHeight;
93
+ if (rect.x + rect.width > availableScreenWidth || rect.y + rect.height > availableScreenHeight) {
94
+ // Adjust the rectangle to fit within the available screen space
95
+ rect.x = Math.max(0, Math.min(rect.x, availableScreenWidth - rect.width));
96
+ rect.y = Math.max(0, Math.min(rect.y, availableScreenHeight - rect.height));
97
+ }
98
+ return rect;
99
+ }
100
+ export function isOnScreen(rect) {
101
+ const availableScreenWidth = window.screen.availWidth;
102
+ const availableScreenHeight = window.screen.availHeight;
103
+ return (rect.x >= 0 && rect.getRight() <= availableScreenWidth &&
104
+ rect.y >= 0 || rect.getBottom() <= availableScreenHeight);
105
+ }
106
+ export function copyInlineStyles(source, target) {
107
+ // Get the inline style attribute from the source element
108
+ const sourceStyle = source.getAttribute('style');
109
+ const targetStyle = target.getAttribute('style');
110
+ if (sourceStyle === targetStyle)
111
+ return false;
112
+ // console.log("copyInlineStyles", sourceStyle);
113
+ if (sourceStyle) {
114
+ // Set the style attribute on the target element
115
+ target.setAttribute('style', sourceStyle);
116
+ }
117
+ else {
118
+ // If the source has no inline style, clear the target's style attribute
119
+ target.removeAttribute('style');
120
+ }
121
+ return true;
122
+ }
123
+ export function isSafari() {
124
+ const userAgent = navigator.userAgent;
125
+ return userAgent.includes("Safari") && !userAgent.includes("Chrome") && !userAgent.includes("Chromium");
126
+ }
69
127
  //# sourceMappingURL=Utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Utils.js","sourceRoot":"","sources":["../../src/view/Utils.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAI/B,gBAAgB;AAChB,SAAgB,gBAAgB,CAC5B,MAAwB,EACxB,IAAa,EACb,WAAyB,EACzB,YAA2B,EAC3B,SAAkB;IAElB,IAAI,cAAc,GAAG,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACjE,IAAI,YAAY,GAAoB,IAAI,CAAC,OAAO,EAAE,CAAC;IACnD,IAAI,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC1B,IAAI,SAAS,KAAK,SAAS,EAAE;QACzB,SAAS,GAAG,CAAC,CAAC;KACjB;IAED,SAAS,aAAa,CAAC,GAAQ;QAC3B,OAAO,GAAG,CAAC,YAAY,KAAK,SAAS,CAAA;IACzC,CAAC;IAED,IAAI,YAAY,KAAK,SAAS,EAAE;QAC5B,MAAM,QAAQ,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,QAAQ,KAAK,SAAS,EAAE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AQ,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;AAC1G,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flexlayout-react",
3
- "version": "0.7.15",
3
+ "version": "0.8.1",
4
4
  "description": "A multi-tab docking layout manager",
5
5
  "main": "lib/index.js",
6
6
  "types": "./declarations/index.d.ts",
@@ -25,17 +25,14 @@
25
25
  ],
26
26
  "scripts": {
27
27
  "start": "webpack serve",
28
- "build": "npm run css && npm run test && npm run doc && npm run build:demo && npm run build:commonjs && npm run build:umd && npm run build:umd:min",
29
- "build:commonjs": "tsc -p tsconfig2.json",
28
+ "build": "npm run css && npm run doc && npm run build:demo && npm run build:esm && npm run build:umd && npm run build:umd:min",
29
+ "build:esm": "tsc -p tsconfig2.json",
30
30
  "build:umd": "webpack --mode=development --config webpack_build.config.js",
31
31
  "build:umd:min": "webpack --mode=production --config webpack_build_min.config.js",
32
32
  "build:demo": "webpack",
33
33
  "lint:eslint": "eslint src/*",
34
34
  "doc": "typedoc --out typedoc --exclude \"**/examples/**/*.tsx\" --excludeInternal --disableSources --excludePrivate --excludeProtected --readme none ./src",
35
- "css": "sass style/underline.scss style/underline.css && sass style/gray.scss style/gray.css && sass style/light.scss style/light.css && sass style/light.scss test/style/light.css && sass style/dark.scss style/dark.css",
36
- "cypress": "cypress open-ct",
37
- "cypress-firefox": "cypress open-ct --browser firefox",
38
- "test": "cypress run --component"
35
+ "css": "sass style/rounded.scss style/rounded.css && sass style/underline.scss style/underline.css && sass style/gray.scss style/gray.css && sass style/light.scss style/light.css && sass style/light.scss test/style/light.css && sass style/dark.scss style/dark.css"
39
36
  },
40
37
  "author": "Caplin Systems Ltd",
41
38
  "repository": "https://github.com/caplin/FlexLayout",
@@ -48,29 +45,38 @@
48
45
  "extends": "react-app"
49
46
  },
50
47
  "devDependencies": {
51
- "@cypress/react": "^7.0.3",
52
- "@cypress/webpack-dev-server": "^3.4.1",
53
- "@types/node": "^18.15.13",
54
- "@types/prismjs": "^1.26.0",
55
- "@types/react": "^18.0.5",
56
- "@types/react-dom": "^18.0.1",
57
- "css-loader": "^6.7.1",
58
- "cypress": "^12.10.0",
59
- "html-webpack-plugin": "^5.5.0",
60
- "prettier": "^2.6.2",
61
- "prismjs": "^1.28.0",
62
- "react": "^18.0.0",
63
- "react-dom": "^18.0.0",
48
+ "@emotion/react": "^11.13.3",
49
+ "@emotion/styled": "^11.13.0",
50
+ "@fontsource/roboto": "^5.0.14",
51
+ "@mui/material": "^6.0.1",
52
+ "@types/node": "^22.5.0",
53
+ "@types/prismjs": "^1.26.4",
54
+ "@types/react": "^18.3.4",
55
+ "@types/react-dom": "^18.3.0",
56
+ "ag-grid-community": "^32.1.0",
57
+ "ag-grid-react": "^32.1.0",
58
+ "chart.js": "^4.4.4",
59
+ "css-loader": "^7.1.2",
60
+ "html-webpack-plugin": "^5.6.0",
61
+ "ol": "^10.1.0",
62
+ "prettier": "^3.3.3",
63
+ "prismjs": "^1.29.0",
64
+ "react": "^18.3.1",
65
+ "react-chartjs-2": "^5.2.0",
66
+ "react-dom": "^18.3.1",
64
67
  "react-scripts": "5.0.1",
65
- "sass": "^1.50.0",
66
- "source-map-loader": "^4.0.1",
67
- "style-loader": "^3.3.1",
68
- "ts-loader": "~9.2.8",
69
- "typedoc": "^0.24.4",
70
- "typescript": "^4.9.5",
71
- "webpack": "^5.72.0",
72
- "webpack-cli": "^5.0.1",
73
- "webpack-dev-server": "^4.8.1"
68
+ "sass": "^1.77.8",
69
+ "source-map-loader": "^5.0.0",
70
+ "style-loader": "^4.0.0",
71
+ "styled-components": "^6.1.13",
72
+ "ts-loader": "~9.5.1",
73
+ "typedoc": "^0.26.6",
74
+ "typescript": "^5.5.4",
75
+ "webpack": "^5.94.0",
76
+ "webpack-cli": "^5.1.4",
77
+ "webpack-dev-server": "^5.0.4",
78
+ "@mui/x-data-grid": "^7.15.0"
74
79
  },
75
- "dependencies": {}
80
+ "dependencies": {
81
+ }
76
82
  }
package/src/Attribute.ts CHANGED
@@ -5,15 +5,20 @@ export class Attribute {
5
5
  static BOOLEAN = "boolean";
6
6
 
7
7
  name: string;
8
+ alias: string | undefined;
8
9
  modelName?: string;
10
+ pairedAttr?: Attribute;
11
+ pairedType?: string;
9
12
  defaultValue: any;
10
13
  alwaysWriteJson?: boolean;
11
14
  type?: string;
12
15
  required: boolean;
13
16
  fixed: boolean;
17
+ description?: string;
14
18
 
15
19
  constructor(name: string, modelName: string | undefined, defaultValue: any, alwaysWriteJson?: boolean) {
16
20
  this.name = name;
21
+ this.alias = undefined;
17
22
  this.modelName = modelName;
18
23
  this.defaultValue = defaultValue;
19
24
  this.alwaysWriteJson = alwaysWriteJson;
@@ -28,6 +33,15 @@ export class Attribute {
28
33
  return this;
29
34
  }
30
35
 
36
+ setAlias(value: string) {
37
+ this.alias = value;
38
+ return this;
39
+ }
40
+
41
+ setDescription(value: string) {
42
+ this.description = value;
43
+ }
44
+
31
45
  setRequired() {
32
46
  this.required = true;
33
47
  return this;
@@ -38,4 +52,13 @@ export class Attribute {
38
52
  return this;
39
53
  }
40
54
 
55
+ // sets modelAttr for nodes, and nodeAttr for model
56
+ setpairedAttr(value: Attribute) {
57
+ this.pairedAttr = value;
58
+ }
59
+
60
+ setPairedType(value: string) {
61
+ this.pairedType = value;
62
+ }
63
+
41
64
  }
@@ -3,17 +3,17 @@ import { Attribute } from "./Attribute";
3
3
  /** @internal */
4
4
  export class AttributeDefinitions {
5
5
  attributes: Attribute[];
6
- nameToAttribute: Record<string, Attribute>;
6
+ nameToAttribute: Map<string, Attribute>;
7
7
 
8
8
  constructor() {
9
9
  this.attributes = [];
10
- this.nameToAttribute = {};
10
+ this.nameToAttribute = new Map();
11
11
  }
12
12
 
13
13
  addWithAll(name: string, modelName: string | undefined, defaultValue: any, alwaysWriteJson?: boolean) {
14
14
  const attr = new Attribute(name, modelName, defaultValue, alwaysWriteJson);
15
15
  this.attributes.push(attr);
16
- this.nameToAttribute[name] = attr;
16
+ this.nameToAttribute.set(name, attr);
17
17
  return attr;
18
18
  }
19
19
 
@@ -30,7 +30,7 @@ export class AttributeDefinitions {
30
30
  }
31
31
 
32
32
  getModelName(name: string) {
33
- const conversion = this.nameToAttribute[name];
33
+ const conversion = this.nameToAttribute.get(name);
34
34
  if (conversion !== undefined) {
35
35
  return conversion.modelName;
36
36
  }
@@ -48,7 +48,10 @@ export class AttributeDefinitions {
48
48
 
49
49
  fromJson(jsonObj: any, obj: any) {
50
50
  for (const attr of this.attributes) {
51
- const fromValue = jsonObj[attr.name];
51
+ let fromValue = jsonObj[attr.name];
52
+ if (fromValue === undefined && attr.alias) {
53
+ fromValue = jsonObj[attr.alias];
54
+ }
52
55
  if (fromValue === undefined) {
53
56
  obj[attr.name] = attr.defaultValue;
54
57
  } else {
@@ -76,6 +79,17 @@ export class AttributeDefinitions {
76
79
  }
77
80
  }
78
81
 
82
+ pairAttributes(type: string, childAttributes: AttributeDefinitions) {
83
+ for (const attr of childAttributes.attributes) {
84
+ if (attr.modelName && this.nameToAttribute.has(attr.modelName)) {
85
+ const pairedAttr = this.nameToAttribute.get(attr.modelName)!;
86
+ pairedAttr.setpairedAttr(attr);
87
+ attr.setpairedAttr(pairedAttr);
88
+ pairedAttr.setPairedType(type);
89
+ }
90
+ }
91
+ }
92
+
79
93
  toTypescriptInterface(name: string, parentAttributes: AttributeDefinitions | undefined) {
80
94
  const lines = [];
81
95
  const sorted = this.attributes.sort((a, b) => a.name.localeCompare(b.name));
@@ -92,27 +106,36 @@ export class AttributeDefinitions {
92
106
  defaultValue = attr.defaultValue;
93
107
  } else if (attr.modelName !== undefined
94
108
  && parentAttributes !== undefined
95
- && parentAttributes.nameToAttribute[attr.modelName] !== undefined) {
109
+ && parentAttributes.nameToAttribute.get(attr.modelName) !== undefined) {
96
110
  inherited = attr.modelName;
97
- attr = parentAttributes.nameToAttribute[attr.modelName];
111
+ attr = parentAttributes.nameToAttribute.get(inherited)!;
98
112
  defaultValue = attr.defaultValue;
99
113
  type = attr.type;
100
114
  }
101
115
 
102
116
  let defValue = JSON.stringify(defaultValue);
103
117
 
104
- const required = attr.required || attr.fixed ? "" : "?";
118
+ const required = attr.required ? "" : "?";
105
119
 
120
+ let sb = "\t/**\n\t ";
121
+ if (c.description) {
122
+ sb += c.description;
123
+ } else if (c.pairedType && c.pairedAttr?.description) {
124
+ sb += `Value for ${c.pairedType} attribute ${c.pairedAttr.name} if not overridden`
125
+ sb += "\n\n\t ";
126
+ sb += c.pairedAttr?.description;
127
+ }
128
+ sb += "\n\n\t ";
106
129
  if (c.fixed) {
107
- lines.push("\t" + c.name + ": " + defValue + ";");
130
+ sb += `Fixed value: ${defValue}`;
131
+ } else if (inherited) {
132
+ sb += `Default: inherited from Global attribute ${c.modelName} (default ${defValue})`;
108
133
  } else {
109
- const comment = (defaultValue !== undefined ? "default: " + defValue : "") +
110
- (inherited !== undefined ? " - inherited from global " + inherited : "");
111
-
112
- lines.push("\t" + c.name + required + ": " + type + ";" +
113
- (comment.length > 0 ? " // " + comment : "")
114
- );
134
+ sb += `Default: ${defValue}`;
115
135
  }
136
+ sb += "\n\t */";
137
+ lines.push(sb);
138
+ lines.push("\t" + c.name + required + ": " + type + ";\n");
116
139
  }
117
140
  lines.push("}");
118
141
 
@@ -2,7 +2,7 @@ import { Orientation } from "./Orientation";
2
2
  import { Rect } from "./Rect";
3
3
 
4
4
  export class DockLocation {
5
- static values: Record<string, DockLocation> = {};
5
+ static values = new Map<string, DockLocation>();
6
6
  static TOP = new DockLocation("top", Orientation.VERT, 0);
7
7
  static BOTTOM = new DockLocation("bottom", Orientation.VERT, 1);
8
8
  static LEFT = new DockLocation("left", Orientation.HORZ, 0);
@@ -11,7 +11,7 @@ export class DockLocation {
11
11
 
12
12
  /** @internal */
13
13
  static getByName(name: string): DockLocation {
14
- return DockLocation.values[name];
14
+ return DockLocation.values.get(name)!;
15
15
  }
16
16
 
17
17
  /** @internal */
@@ -51,26 +51,26 @@ export class DockLocation {
51
51
  }
52
52
 
53
53
  /** @internal */
54
- _name: string;
54
+ name: string;
55
55
  /** @internal */
56
- _orientation: Orientation;
56
+ orientation: Orientation;
57
57
  /** @internal */
58
- _indexPlus: number;
58
+ indexPlus: number;
59
59
 
60
60
  /** @internal */
61
- constructor(name: string, orientation: Orientation, indexPlus: number) {
62
- this._name = name;
63
- this._orientation = orientation;
64
- this._indexPlus = indexPlus;
65
- DockLocation.values[this._name] = this;
61
+ constructor(_name: string, _orientation: Orientation, _indexPlus: number) {
62
+ this.name = _name;
63
+ this.orientation = _orientation;
64
+ this.indexPlus = _indexPlus;
65
+ DockLocation.values.set(this.name, this);
66
66
  }
67
67
 
68
68
  getName() {
69
- return this._name;
69
+ return this.name;
70
70
  }
71
71
 
72
72
  getOrientation() {
73
- return this._orientation;
73
+ return this.orientation;
74
74
  }
75
75
 
76
76
  /** @internal */
@@ -128,6 +128,6 @@ export class DockLocation {
128
128
  }
129
129
 
130
130
  toString() {
131
- return "(DockLocation: name=" + this._name + ", orientation=" + this._orientation + ")";
131
+ return "(DockLocation: name=" + this.name + ", orientation=" + this.orientation + ")";
132
132
  }
133
133
  }
package/src/I18nLabel.ts CHANGED
@@ -1,14 +1,12 @@
1
1
  export enum I18nLabel {
2
2
  Close_Tab = "Close",
3
- Close_Tabset = "Close tabset",
4
- Move_Tab = "Move: ", // no longer used
5
- Move_Tabset = "Move tabset",
6
- Maximize = "Maximize tabset",
7
- Restore = "Restore tabset",
8
- Float_Tab = "Show selected tab in floating window",
3
+ Close_Tabset = "Close tab set",
4
+ Active_Tabset = "Active tab set",
5
+ Move_Tabset = "Move tab set",
6
+ Move_Tabs = "Move tabs(?)",
7
+ Maximize = "Maximize tab set",
8
+ Restore = "Restore tab set",
9
+ Popout_Tab = "Popout selected tab",
9
10
  Overflow_Menu_Tooltip = "Hidden tabs",
10
- Floating_Window_Message = "This panel is shown in a floating window",
11
- Floating_Window_Show_Window = "Show window",
12
- Floating_Window_Dock_Window = "Dock window",
13
11
  Error_rendering_component = "Error rendering component",
14
12
  }
package/src/Rect.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { IJsonRect } from "./model/IJsonModel";
1
2
  import { Orientation } from "./Orientation";
2
3
 
3
4
  export class Rect {
@@ -5,6 +6,10 @@ export class Rect {
5
6
  return new Rect(0, 0, 0, 0);
6
7
  }
7
8
 
9
+ static fromJson(json: IJsonRect): Rect {
10
+ return new Rect(json.x, json.y, json.width, json.height);
11
+ }
12
+
8
13
  x: number;
9
14
  y: number;
10
15
  width: number;
@@ -17,11 +22,54 @@ export class Rect {
17
22
  this.height = height;
18
23
  }
19
24
 
20
- static fromElement(element: Element) {
25
+ toJson() {
26
+ return {x: this.x, y: this.y, width: this.width, height: this.height};
27
+ }
28
+
29
+ snap(round: number) {
30
+ this.x = Math.round(this.x / round) * round;
31
+ this.y = Math.round(this.y / round) * round;
32
+ this.width = Math.round(this.width / round) * round;
33
+ this.height= Math.round(this.height / round) * round;
34
+ }
35
+
36
+ static getBoundingClientRect(element: Element) {
21
37
  let { x, y, width, height } = element.getBoundingClientRect();
22
38
  return new Rect(x, y, width, height);
23
39
  }
24
40
 
41
+ static getContentRect(element: HTMLElement) {
42
+ const rect = element.getBoundingClientRect();
43
+ const style = window.getComputedStyle(element);
44
+
45
+ const paddingLeft = parseFloat(style.paddingLeft);
46
+ const paddingRight = parseFloat(style.paddingRight);
47
+ const paddingTop = parseFloat(style.paddingTop);
48
+ const paddingBottom = parseFloat(style.paddingBottom);
49
+ const borderLeftWidth = parseFloat(style.borderLeftWidth);
50
+ const borderRightWidth = parseFloat(style.borderRightWidth);
51
+ const borderTopWidth = parseFloat(style.borderTopWidth);
52
+ const borderBottomWidth = parseFloat(style.borderBottomWidth);
53
+
54
+ const contentWidth = rect.width - borderLeftWidth - paddingLeft - paddingRight - borderRightWidth;
55
+ const contentHeight = rect.height - borderTopWidth - paddingTop - paddingBottom - borderBottomWidth;
56
+
57
+ return new Rect(
58
+ rect.left + borderLeftWidth + paddingLeft,
59
+ rect.top + borderTopWidth + paddingTop,
60
+ contentWidth,
61
+ contentHeight,
62
+ );
63
+ }
64
+
65
+ static fromDomRect(domRect: DOMRect) {
66
+ return new Rect(domRect.x, domRect.y, domRect.width, domRect.height);
67
+ }
68
+
69
+ relativeTo(r: Rect | DOMRect) {
70
+ return new Rect(this.x - r.x, this.y - r.y, this.width, this.height);
71
+ }
72
+
25
73
  clone() {
26
74
  return new Rect(this.x, this.y, this.width, this.height);
27
75
  }
@@ -30,6 +78,10 @@ export class Rect {
30
78
  return this.x === rect?.x && this.y === rect?.y && this.width === rect?.width && this.height === rect?.height
31
79
  }
32
80
 
81
+ equalSize(rect: Rect | null | undefined) {
82
+ return this.width === rect?.width && this.height === rect?.height
83
+ }
84
+
33
85
  getBottom() {
34
86
  return this.y + this.height;
35
87
  }