flexlayout-react 0.5.15 → 0.5.19

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 (88) hide show
  1. package/ChangeLog.txt +26 -0
  2. package/README.md +121 -97
  3. package/declarations/DragDrop.d.ts +1 -0
  4. package/declarations/I18nLabel.d.ts +1 -0
  5. package/declarations/Rect.d.ts +4 -0
  6. package/declarations/Types.d.ts +9 -1
  7. package/declarations/model/Actions.d.ts +18 -11
  8. package/declarations/model/BorderNode.d.ts +2 -1
  9. package/declarations/model/IJsonModel.d.ts +10 -0
  10. package/declarations/model/Model.d.ts +1 -0
  11. package/declarations/model/TabNode.d.ts +1 -0
  12. package/declarations/model/TabSetNode.d.ts +1 -0
  13. package/declarations/view/Layout.d.ts +20 -6
  14. package/dist/flexlayout.js +20 -20
  15. package/dist/flexlayout_min.js +1 -1
  16. package/lib/DockLocation.js +25 -11
  17. package/lib/DockLocation.js.map +1 -1
  18. package/lib/DragDrop.js +19 -3
  19. package/lib/DragDrop.js.map +1 -1
  20. package/lib/I18nLabel.js +1 -0
  21. package/lib/I18nLabel.js.map +1 -1
  22. package/lib/PopupMenu.js +14 -9
  23. package/lib/PopupMenu.js.map +1 -1
  24. package/lib/Rect.js +3 -0
  25. package/lib/Rect.js.map +1 -1
  26. package/lib/Types.js +8 -0
  27. package/lib/Types.js.map +1 -1
  28. package/lib/model/Actions.js +20 -11
  29. package/lib/model/Actions.js.map +1 -1
  30. package/lib/model/BorderNode.js +61 -14
  31. package/lib/model/BorderNode.js.map +1 -1
  32. package/lib/model/BorderSet.js +33 -19
  33. package/lib/model/BorderSet.js.map +1 -1
  34. package/lib/model/Model.js +39 -1
  35. package/lib/model/Model.js.map +1 -1
  36. package/lib/model/RowNode.js +19 -5
  37. package/lib/model/RowNode.js.map +1 -1
  38. package/lib/model/TabNode.js +14 -0
  39. package/lib/model/TabNode.js.map +1 -1
  40. package/lib/model/TabSetNode.js +42 -19
  41. package/lib/model/TabSetNode.js.map +1 -1
  42. package/lib/view/BorderButton.js +14 -3
  43. package/lib/view/BorderButton.js.map +1 -1
  44. package/lib/view/BorderTabSet.js +15 -4
  45. package/lib/view/BorderTabSet.js.map +1 -1
  46. package/lib/view/Layout.js +206 -45
  47. package/lib/view/Layout.js.map +1 -1
  48. package/lib/view/Splitter.js +34 -3
  49. package/lib/view/Splitter.js.map +1 -1
  50. package/lib/view/TabButton.js +11 -2
  51. package/lib/view/TabButton.js.map +1 -1
  52. package/lib/view/TabFloating.js +23 -11
  53. package/lib/view/TabFloating.js.map +1 -1
  54. package/lib/view/TabSet.js +50 -17
  55. package/lib/view/TabSet.js.map +1 -1
  56. package/package.json +1 -1
  57. package/src/DockLocation.ts +30 -9
  58. package/src/DragDrop.ts +26 -3
  59. package/src/I18nLabel.ts +1 -0
  60. package/src/PopupMenu.tsx +28 -10
  61. package/src/Rect.ts +6 -2
  62. package/src/Types.ts +9 -0
  63. package/src/model/Actions.ts +21 -11
  64. package/src/model/BorderNode.ts +57 -15
  65. package/src/model/BorderSet.ts +32 -19
  66. package/src/model/IJsonModel.ts +10 -0
  67. package/src/model/Model.ts +43 -1
  68. package/src/model/RowNode.ts +8 -5
  69. package/src/model/TabNode.ts +16 -0
  70. package/src/model/TabSetNode.ts +43 -19
  71. package/src/view/BorderButton.tsx +22 -3
  72. package/src/view/BorderTabSet.tsx +21 -4
  73. package/src/view/Layout.tsx +263 -70
  74. package/src/view/Splitter.tsx +49 -3
  75. package/src/view/TabButton.tsx +17 -1
  76. package/src/view/TabFloating.tsx +36 -19
  77. package/src/view/TabSet.tsx +76 -16
  78. package/style/_base.scss +75 -44
  79. package/style/dark.css +90 -61
  80. package/style/dark.css.map +1 -1
  81. package/style/dark.scss +20 -20
  82. package/style/gray.css +90 -61
  83. package/style/gray.css.map +1 -1
  84. package/style/gray.scss +20 -20
  85. package/style/light.css +90 -61
  86. package/style/light.css.map +1 -1
  87. package/style/light.scss +18 -18
  88. package/yarn-error.log +0 -11828
@@ -4,6 +4,7 @@ import DockLocation from "../DockLocation";
4
4
  import DropInfo from "../DropInfo";
5
5
  import Orientation from "../Orientation";
6
6
  import Rect from "../Rect";
7
+ import { CLASSES } from "../Types";
7
8
  import BorderNode from "./BorderNode";
8
9
  import IDraggable from "./IDraggable";
9
10
  import IDropTarget from "./IDropTarget";
@@ -27,6 +28,9 @@ class TabSetNode extends Node implements IDraggable, IDropTarget {
27
28
  newLayoutNode._addChild(child);
28
29
  });
29
30
  }
31
+ if (newLayoutNode._children.length === 0) {
32
+ newLayoutNode._setSelected(-1);
33
+ }
30
34
 
31
35
  if (json.maximized && json.maximized === true) {
32
36
  model._setMaximizedTabset(newLayoutNode);
@@ -59,6 +63,7 @@ class TabSetNode extends Node implements IDraggable, IDropTarget {
59
63
  attributeDefinitions.addInherited("enableDrag", "tabSetEnableDrag");
60
64
  attributeDefinitions.addInherited("enableDivide", "tabSetEnableDivide");
61
65
  attributeDefinitions.addInherited("enableMaximize", "tabSetEnableMaximize");
66
+ attributeDefinitions.addInherited("enableClose", "tabSetEnableClose");
62
67
  attributeDefinitions.addInherited("classNameTabStrip", "tabSetClassNameTabStrip");
63
68
  attributeDefinitions.addInherited("classNameHeader", "tabSetClassNameHeader");
64
69
  attributeDefinitions.addInherited("enableTabStrip", "tabSetEnableTabStrip");
@@ -181,6 +186,10 @@ class TabSetNode extends Node implements IDraggable, IDropTarget {
181
186
  return this._getAttr("enableMaximize") as boolean;
182
187
  }
183
188
 
189
+ isEnableClose() {
190
+ return this._getAttr("enableClose") as boolean;
191
+ }
192
+
184
193
  canMaximize() {
185
194
  if (this.isEnableMaximize()) {
186
195
  // always allow maximize toggle if already maximized
@@ -263,34 +272,44 @@ class TabSetNode extends Node implements IDraggable, IDropTarget {
263
272
  if (dragNode === this) {
264
273
  const dockLocation = DockLocation.CENTER;
265
274
  const outlineRect = this._tabHeaderRect;
266
- dropInfo = new DropInfo(this, outlineRect!, dockLocation, -1, "flexlayout__outline_rect");
275
+ dropInfo = new DropInfo(this, outlineRect!, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
267
276
  } else if (this._contentRect!.contains(x, y)) {
268
277
  const dockLocation = DockLocation.getLocation(this._contentRect!, x, y);
269
278
  const outlineRect = dockLocation.getDockRect(this._rect);
270
- dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, "flexlayout__outline_rect");
271
- } else if (this._children.length > 0 && this._tabHeaderRect != null && this._tabHeaderRect.contains(x, y)) {
272
- let child = this._children[0] as TabNode;
273
- let r = child.getTabRect()!;
274
- const yy = r.y;
275
- const h = r.height;
276
- let p = this._tabHeaderRect.x;
277
- let childCenter = 0;
278
- for (let i = 0; i < this._children.length; i++) {
279
- child = this._children[i] as TabNode;
279
+ dropInfo = new DropInfo(this, outlineRect, dockLocation, -1, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
280
+ } else if (this._tabHeaderRect != null && this._tabHeaderRect.contains(x, y)) {
281
+ let r: Rect;
282
+ let yy: number;
283
+ let h: number;
284
+ if (this._children.length === 0) {
285
+ r = this._tabHeaderRect.clone();
286
+ yy = r.y + 3;
287
+ h = r.height - 4;
288
+ r.width = 2;
289
+ } else {
290
+ let child = this._children[0] as TabNode;
280
291
  r = child.getTabRect()!;
281
- childCenter = r.x + r.width / 2;
282
- if (x >= p && x < childCenter) {
283
- const dockLocation = DockLocation.CENTER;
284
- const outlineRect = new Rect(r.x - 2, yy, 3, h);
285
- dropInfo = new DropInfo(this, outlineRect, dockLocation, i, "flexlayout__outline_rect");
286
- break;
292
+ yy = r.y;
293
+ h = r.height;
294
+ let p = this._tabHeaderRect.x;
295
+ let childCenter = 0;
296
+ for (let i = 0; i < this._children.length; i++) {
297
+ child = this._children[i] as TabNode;
298
+ r = child.getTabRect()!;
299
+ childCenter = r.x + r.width / 2;
300
+ if (x >= p && x < childCenter) {
301
+ const dockLocation = DockLocation.CENTER;
302
+ const outlineRect = new Rect(r.x - 2, yy, 3, h);
303
+ dropInfo = new DropInfo(this, outlineRect, dockLocation, i, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
304
+ break;
305
+ }
306
+ p = childCenter;
287
307
  }
288
- p = childCenter;
289
308
  }
290
309
  if (dropInfo == null) {
291
310
  const dockLocation = DockLocation.CENTER;
292
311
  const outlineRect = new Rect(r.getRight() - 2, yy, 3, h);
293
- dropInfo = new DropInfo(this, outlineRect, dockLocation, this._children.length, "flexlayout__outline_rect");
312
+ dropInfo = new DropInfo(this, outlineRect, dockLocation, this._children.length, CLASSES.FLEXLAYOUT__OUTLINE_RECT);
294
313
  }
295
314
  }
296
315
 
@@ -340,6 +359,11 @@ class TabSetNode extends Node implements IDraggable, IDropTarget {
340
359
  });
341
360
  }
342
361
 
362
+ /** @hidden @internal */
363
+ _delete() {
364
+ (this._parent as RowNode)._removeChild(this);
365
+ }
366
+
343
367
  /** @hidden @internal */
344
368
  _remove(node: TabNode) {
345
369
  const removedIndex = this._removeChild(node);
@@ -6,6 +6,7 @@ import Rect from "../Rect";
6
6
  import { IIcons, ILayoutCallbacks, ITitleObject } from "./Layout";
7
7
  import { ICloseType } from "../model/ICloseType";
8
8
  import { CLASSES } from "../Types";
9
+ import { isAuxMouseEvent } from "./TabSet";
9
10
 
10
11
  /** @hidden @internal */
11
12
  export interface IBorderButtonProps {
@@ -24,8 +25,20 @@ export const BorderButton = (props: IBorderButtonProps) => {
24
25
  const selfRef = React.useRef<HTMLDivElement | null>(null);
25
26
 
26
27
  const onMouseDown = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | React.TouchEvent<HTMLDivElement>) => {
27
- const message = layout.i18nName(I18nLabel.Move_Tab, node.getName());
28
- props.layout.dragStart(event, message, node, node.isEnableDrag(), onClick, (event2: Event) => undefined);
28
+ if (!isAuxMouseEvent(event)) {
29
+ const message = layout.i18nName(I18nLabel.Move_Tab, node.getName());
30
+ props.layout.dragStart(event, message, node, node.isEnableDrag(), onClick, (event2: Event) => undefined);
31
+ }
32
+ };
33
+
34
+ const onAuxMouseClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
35
+ if (isAuxMouseEvent(event)) {
36
+ layout.auxMouseClick(node, event);
37
+ }
38
+ };
39
+
40
+ const onContextMenu = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
41
+ layout.showContextMenu(node, event);
29
42
  };
30
43
 
31
44
  const onClick = () => {
@@ -129,7 +142,13 @@ export const BorderButton = (props: IBorderButtonProps) => {
129
142
  }
130
143
 
131
144
  return (
132
- <div ref={selfRef} style={{}} className={classNames} onMouseDown={onMouseDown} onTouchStart={onMouseDown}>
145
+ <div ref={selfRef} style={{}} className={classNames}
146
+ onMouseDown={onMouseDown}
147
+ onClick={onAuxMouseClick}
148
+ onAuxClick={onAuxMouseClick}
149
+ onContextMenu={onContextMenu}
150
+ onTouchStart={onMouseDown}
151
+ title={node.getHelpText()}>
133
152
  {leading}
134
153
  {content}
135
154
  {buttons}
@@ -10,6 +10,7 @@ import { I18nLabel } from "../I18nLabel";
10
10
  import { useTabOverflow } from "./TabOverflowHook";
11
11
  import Orientation from "../Orientation";
12
12
  import { CLASSES } from "../Types";
13
+ import { isAuxMouseEvent } from "./TabSet";
13
14
 
14
15
  /** @hidden @internal */
15
16
  export interface IBorderTabSetProps {
@@ -30,13 +31,24 @@ export const BorderTabSet = (props: IBorderTabSetProps) => {
30
31
 
31
32
  const { selfRef, position, userControlledLeft, hiddenTabs, onMouseWheel } = useTabOverflow(border, Orientation.flip(border.getOrientation()), toolbarRef, stickyButtonsRef);
32
33
 
34
+ const onAuxMouseClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
35
+ if (isAuxMouseEvent(event)) {
36
+ layout.auxMouseClick(border, event);
37
+ }
38
+ };
39
+
40
+ const onContextMenu = (event: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
41
+ layout.showContextMenu(border, event);
42
+ };
43
+
33
44
  const onInterceptMouseDown = (event: React.MouseEvent<HTMLDivElement, MouseEvent> | React.MouseEvent<HTMLButtonElement, MouseEvent> | React.TouchEvent<HTMLButtonElement>) => {
34
45
  event.stopPropagation();
35
46
  };
36
47
 
37
- const onOverflowClick = () => {
48
+ const onOverflowClick = (event: React.MouseEvent<HTMLElement, MouseEvent>) => {
38
49
  const element = overflowbuttonRef.current!;
39
50
  showPopup(layout.getRootDiv(), element, hiddenTabs, onOverflowItemSelect, layout.getClassName);
51
+ event.stopPropagation();
40
52
  };
41
53
 
42
54
  const onOverflowItemSelect = (item: { node: TabNode; index: number }) => {
@@ -44,11 +56,12 @@ export const BorderTabSet = (props: IBorderTabSetProps) => {
44
56
  userControlledLeft.current = false;
45
57
  };
46
58
 
47
- const onFloatTab = () => {
59
+ const onFloatTab = (event: React.MouseEvent<HTMLElement, MouseEvent>) => {
48
60
  const selectedTabNode = border.getChildren()[border.getSelected()] as TabNode;
49
61
  if (selectedTabNode !== undefined) {
50
62
  layout.doAction(Actions.floatTab(selectedTabNode.getId()));
51
63
  }
64
+ event.stopPropagation();
52
65
  };
53
66
 
54
67
  const cm = layout.getClassName;
@@ -97,7 +110,7 @@ export const BorderTabSet = (props: IBorderTabSetProps) => {
97
110
  <button
98
111
  key="overflowbutton"
99
112
  ref={overflowbuttonRef}
100
- className={cm("flexlayout__border_toolbar_button_overflow") + " " + cm("flexlayout__border_toolbar_button_overflow_" + border.getLocation().getName())}
113
+ className={cm(CLASSES.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW) + " " + cm(CLASSES.FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW_ + border.getLocation().getName())}
101
114
  title={overflowTitle}
102
115
  onClick={onOverflowClick}
103
116
  onMouseDown={onInterceptMouseDown}
@@ -145,7 +158,11 @@ export const BorderTabSet = (props: IBorderTabSetProps) => {
145
158
  }
146
159
 
147
160
  return (
148
- <div ref={selfRef} style={style} className={borderClasses} onWheel={onMouseWheel}>
161
+ <div ref={selfRef} dir="ltr" style={style} className={borderClasses}
162
+ onClick={onAuxMouseClick}
163
+ onAuxClick={onAuxMouseClick}
164
+ onContextMenu={onContextMenu}
165
+ onWheel={onMouseWheel}>
149
166
  <div style={{ height: borderHeight }} className={cm(CLASSES.FLEXLAYOUT__BORDER_INNER) + " " + cm(CLASSES.FLEXLAYOUT__BORDER_INNER_ + border.getLocation().getName())}>
150
167
  <div style={innerStyle} className={cm(CLASSES.FLEXLAYOUT__BORDER_INNER_TAB_CONTAINER) + " " + cm(CLASSES.FLEXLAYOUT__BORDER_INNER_TAB_CONTAINER_ + border.getLocation().getName())}>
151
168
  {tabs}