flexlayout-react 0.5.20 → 0.6.2

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 (81) hide show
  1. package/ChangeLog.txt +22 -0
  2. package/README.md +9 -13
  3. package/declarations/Types.d.ts +2 -0
  4. package/declarations/model/IJsonModel.d.ts +3 -0
  5. package/declarations/model/Model.d.ts +2 -0
  6. package/declarations/view/Icons.d.ts +6 -0
  7. package/declarations/view/Layout.d.ts +23 -10
  8. package/declarations/view/MenuTabButton.d.ts +1 -0
  9. package/declarations/view/TabButtonStamp.d.ts +1 -0
  10. package/declarations/view/Utils.d.ts +1 -0
  11. package/dist/flexlayout.js +49 -13
  12. package/dist/flexlayout_min.js +1 -1
  13. package/lib/PopupMenu.js +10 -6
  14. package/lib/PopupMenu.js.map +1 -1
  15. package/lib/Types.js +2 -0
  16. package/lib/Types.js.map +1 -1
  17. package/lib/model/Model.js +8 -0
  18. package/lib/model/Model.js.map +1 -1
  19. package/lib/model/TabNode.js +6 -1
  20. package/lib/model/TabNode.js.map +1 -1
  21. package/lib/view/BorderButton.js +9 -39
  22. package/lib/view/BorderButton.js.map +1 -1
  23. package/lib/view/BorderTabSet.js +21 -8
  24. package/lib/view/BorderTabSet.js.map +1 -1
  25. package/lib/view/FloatingWindow.js +13 -5
  26. package/lib/view/FloatingWindow.js.map +1 -1
  27. package/lib/view/Icons.js +36 -0
  28. package/lib/view/Icons.js.map +1 -0
  29. package/lib/view/Layout.js +58 -13
  30. package/lib/view/Layout.js.map +1 -1
  31. package/lib/view/MenuTabButton.js +22 -0
  32. package/lib/view/MenuTabButton.js.map +1 -0
  33. package/lib/view/Tab.js +7 -4
  34. package/lib/view/Tab.js.map +1 -1
  35. package/lib/view/TabButton.js +13 -46
  36. package/lib/view/TabButton.js.map +1 -1
  37. package/lib/view/TabButtonStamp.js +22 -0
  38. package/lib/view/TabButtonStamp.js.map +1 -0
  39. package/lib/view/TabFloating.js +5 -3
  40. package/lib/view/TabFloating.js.map +1 -1
  41. package/lib/view/TabOverflowHook.js +3 -1
  42. package/lib/view/TabOverflowHook.js.map +1 -1
  43. package/lib/view/TabSet.js +29 -24
  44. package/lib/view/TabSet.js.map +1 -1
  45. package/lib/view/Utils.js +61 -0
  46. package/lib/view/Utils.js.map +1 -0
  47. package/package.json +3 -3
  48. package/src/I18nLabel.ts +1 -1
  49. package/src/PopupMenu.tsx +25 -8
  50. package/src/Types.ts +2 -0
  51. package/src/model/IJsonModel.ts +3 -0
  52. package/src/model/Model.ts +12 -0
  53. package/src/model/TabNode.ts +6 -1
  54. package/src/view/BorderButton.tsx +8 -41
  55. package/src/view/BorderTabSet.tsx +28 -8
  56. package/src/view/FloatingWindow.tsx +14 -6
  57. package/src/view/Icons.tsx +36 -0
  58. package/src/view/Layout.tsx +88 -34
  59. package/src/view/Tab.tsx +9 -4
  60. package/src/view/TabButton.tsx +18 -55
  61. package/src/view/TabButtonStamp.tsx +47 -0
  62. package/src/view/TabFloating.tsx +5 -3
  63. package/src/view/TabOverflowHook.tsx +3 -2
  64. package/src/view/TabSet.tsx +33 -21
  65. package/src/view/Utils.tsx +71 -0
  66. package/style/_base.scss +81 -46
  67. package/style/dark.css +79 -68
  68. package/style/dark.css.map +1 -1
  69. package/style/dark.scss +15 -5
  70. package/style/gray.css +76 -65
  71. package/style/gray.css.map +1 -1
  72. package/style/gray.scss +10 -3
  73. package/style/light.css +80 -69
  74. package/style/light.css.map +1 -1
  75. package/style/light.scss +16 -6
  76. package/images/close.png +0 -0
  77. package/images/maximize.png +0 -0
  78. package/images/more.png +0 -0
  79. package/images/more2.png +0 -0
  80. package/images/popout.png +0 -0
  81. package/images/restore.png +0 -0
package/ChangeLog.txt CHANGED
@@ -1,3 +1,25 @@
1
+ 0.6.2
2
+ Extended icons prop to allow use of functions to set icons.
3
+ Added onShowOverflowMenu callback for handling the display of the tab overflow menu.
4
+
5
+ 0.6.1
6
+ Use portal for drag rectangle to preserve React context in onRenderTab.
7
+
8
+ 0.6.0
9
+ Changed icons to use svg images, these will now scale with the font size.
10
+ Improved element spacing, removed most margin/padding spacers.
11
+ The overflow menu and drag rectangle will now show the tab icon and content as rendered in the tab.
12
+ Added altName attribute to TabNode, this will be used as the name in the overflow menu if there is no
13
+ name attribute (e.g the tab has just an icon).
14
+ Changed the drag outline colors from red/green to light blue/green.
15
+ Removed closeIcon prop from Layout, use the icons property instead.
16
+ Changed onRenderDragRect callback to take a ReactElement rather than a string, the content now
17
+ contains the tabbutton as rendered.
18
+
19
+ 0.5.21
20
+ Fixed copying stylesheet links for popout windows when cssRules throw exception.
21
+ Added option, enableUseVisibility, to allow use of visibility: hidden rather than display:none for hiding elements.
22
+
1
23
  0.5.20
2
24
  Added Cypress Tests
3
25
  Fixed bug with tab icon not showing
package/README.md CHANGED
@@ -4,9 +4,9 @@ FlexLayout is a layout manager that arranges React components in multiple tab se
4
4
 
5
5
  ![FlexLayout Demo Screenshot](/../screenshots/github_images/v0.5/demo1.png?raw=true "FlexLayout Demo Screenshot")
6
6
 
7
- [Run the Demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.5/demo/index.html)
7
+ [Run the Demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.6/demo/index.html)
8
8
 
9
- Try it now using [JSFiddle](https://jsfiddle.net/7oe4q2pc/)
9
+ Try it now using [JSFiddle](https://jsfiddle.net/18zfp0qm/)
10
10
 
11
11
  <!-- [API Doc](./typedoc/index.html) -->
12
12
 
@@ -80,7 +80,7 @@ The `<Layout>` component renders the tabsets and splitters, it takes the followi
80
80
  | Prop | Description |
81
81
  | --------------- | ----------------- |
82
82
  | font | the tab font (overrides value in css). Example: font={{size:"12px", style:"italic"}}|
83
- | icons | object mapping keys among `close`, `maximize`, `restore`, `more`, `popout` to React nodes to use in place of the default icons |
83
+ | icons | object mapping keys among `close`, `maximize`, `restore`, `more`, `popout` to React nodes to use in place of the default icons, can alternatively return functions for creating the React nodes |
84
84
  | onAction | function called whenever the layout generates an action to update the model (allows for intercepting actions before they are dispatched to the model, for example, asking the user to confirm a tab close.) Returning `undefined` from the function will halt the action, otherwise return the action to continue |
85
85
  | onRenderTab | function called when rendering a tab, allows leading (icon), content section, buttons and name used in overflow menu to be customized |
86
86
  | onRenderTabSet | function called when rendering a tabset, allows header and buttons to be customized |
@@ -96,6 +96,7 @@ The `<Layout>` component renders the tabsets and splitters, it takes the followi
96
96
  | onRenderFloatingTabPlaceholder | callback for rendering the floating tab placeholder |
97
97
  | onContextMenu | callback for handling context actions on tabs and tabsets |
98
98
  | onAuxMouseClick | callback for handling mouse clicks on tabs and tabsets with alt, meta, shift keys, also handles center mouse clicks |
99
+ | onShowOverflowMenu | callback for handling the display of the tab overflow menu |
99
100
  | iconFactory | a factory function for creating icon components for tab bar buttons. <br/><br/> NOTE: for greater customization of the tab use onRenderTab instead of this callback |
100
101
  | titleFactory | a factory function for creating title components for tab bar buttons. <br /><br /> NOTE: for greater customization of the tab use onRenderTab instead of this callback |
101
102
 
@@ -185,7 +186,7 @@ ReactDOM.render(<Main/>, document.getElementById("container"));
185
186
 
186
187
  The above code would render two tabsets horizontally each containing a single tab that hosts a button component. The tabs could be moved and resized by dragging and dropping. Additional grids could be added to the layout by sending actions to the model.
187
188
 
188
- Try it now using [JSFiddle](https://jsfiddle.net/7oe4q2pc/)
189
+ Try it now using [JSFiddle](https://jsfiddle.net/18zfp0qm/)
189
190
 
190
191
  A simple Create React App (CRA) example (using typescript) can be found here:
191
192
 
@@ -213,7 +214,7 @@ The model json contains 3 top level elements:
213
214
 
214
215
  Weights on rows and tabsets specify the relative weight of these nodes within the parent row, the actual values do not matter just their relative values (ie two tabsets of weights 30,70 would render the same if they had weights of 3,7).
215
216
 
216
- NOTE: the easiest way to create your initial layout JSON is to use the [demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.5/demo/index.html) app, modify one of the
217
+ NOTE: the easiest way to create your initial layout JSON is to use the [demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.6/demo/index.html) app, modify one of the
217
218
  existing layouts by dragging/dropping and adding nodes then press the 'Show Layout JSON in console' button to print the JSON to the browser developer console.
218
219
 
219
220
 
@@ -335,6 +336,7 @@ Attributes allowed in the 'global' element
335
336
  | ------------- |:-------------:| -----|
336
337
  | splitterSize | 8 | width in pixels of all splitters between tabsets/borders |
337
338
  | splitterExtra | 0 | additional width in pixels of the splitter hit test area |
339
+ | legacyOverflowMenu | false | use the legacy text only overflow menu |
338
340
  | enableEdgeDock | true | |
339
341
  | tabEnableClose | true | allow user to close all tabs via close button |
340
342
  | tabCloseType | 1 | see values in ICloseType |
@@ -395,7 +397,8 @@ Inherited defaults will take their value from the associated global attributes (
395
397
  | Attribute | Default | Description |
396
398
  | ------------- |:-------------:| -----|
397
399
  | type | tab | |
398
- | name | *required* | internal unique string identifying tab (for factory) |
400
+ | name | *required* | name of tab to be displayed in the tab button |
401
+ | altName | *optional* | if there is no name specifed then this value will be used in the overflow menu |
399
402
  | component | *required* | string identifying which component to run (for factory) |
400
403
  | config | null | a place to hold json config for the hosted component |
401
404
  | id | auto generated | |
@@ -581,13 +584,6 @@ First install dependencies:
581
584
  yarn install
582
585
  ```
583
586
 
584
- Install the peer dependencies:
585
-
586
- ```
587
- yarn add react
588
- yarn add react-dom
589
- ```
590
-
591
587
  Compile the project and run the examples:
592
588
 
593
589
  ```
@@ -53,8 +53,10 @@ export declare enum CLASSES {
53
53
  FLEXLAYOUT__TAB_BUTTON_CONTENT = "flexlayout__tab_button_content",
54
54
  FLEXLAYOUT__TAB_BUTTON_LEADING = "flexlayout__tab_button_leading",
55
55
  FLEXLAYOUT__TAB_BUTTON_OVERFLOW = "flexlayout__tab_button_overflow",
56
+ FLEXLAYOUT__TAB_BUTTON_OVERFLOW_COUNT = "flexlayout__tab_button_overflow_count",
56
57
  FLEXLAYOUT__TAB_BUTTON_TEXTBOX = "flexlayout__tab_button_textbox",
57
58
  FLEXLAYOUT__TAB_BUTTON_TRAILING = "flexlayout__tab_button_trailing",
59
+ FLEXLAYOUT__TAB_BUTTON_STAMP = "flexlayout__tab_button_stamp",
58
60
  FLEXLAYOUT__TAB_FLOATING = "flexlayout__tab_floating",
59
61
  FLEXLAYOUT__TAB_FLOATING_INNER = "flexlayout__tab_floating_inner",
60
62
  FLEXLAYOUT__TAB_TOOLBAR = "flexlayout__tab_toolbar",
@@ -36,6 +36,8 @@ export interface IGlobalAttributes {
36
36
  borderMinSize?: number;
37
37
  borderSize?: number;
38
38
  enableEdgeDock?: boolean;
39
+ enableUseVisibility?: boolean;
40
+ legacyOverflowMenu?: boolean;
39
41
  marginInsets?: IInsets;
40
42
  rootOrientationVertical?: boolean;
41
43
  splitterExtra?: number;
@@ -104,6 +106,7 @@ export interface ITabSetAttributes {
104
106
  width?: number;
105
107
  }
106
108
  export interface ITabAttributes {
109
+ altName?: string;
107
110
  borderHeight?: number;
108
111
  borderWidth?: number;
109
112
  className?: string;
@@ -31,6 +31,7 @@ declare class Model {
31
31
  */
32
32
  getRoot(): RowNode;
33
33
  isRootOrientationVertical(): boolean;
34
+ isUseVisibility(): boolean;
34
35
  /**
35
36
  * Gets the
36
37
  * @returns {BorderSet|*}
@@ -59,6 +60,7 @@ declare class Model {
59
60
  */
60
61
  toJson(): IJsonModel;
61
62
  getSplitterSize(): number;
63
+ isLegacyOverflowMenu(): boolean;
62
64
  getSplitterExtra(): number;
63
65
  isEnableEdgeDock(): boolean;
64
66
  /**
@@ -0,0 +1,6 @@
1
+ /// <reference types="react" />
2
+ export declare const CloseIcon: () => JSX.Element;
3
+ export declare const MaximizeIcon: () => JSX.Element;
4
+ export declare const OverflowIcon: () => JSX.Element;
5
+ export declare const PopoutIcon: () => JSX.Element;
6
+ export declare const RestoreIcon: () => JSX.Element;
@@ -10,9 +10,16 @@ import TabSetNode from "../model/TabSetNode";
10
10
  import Rect from "../Rect";
11
11
  import { IJsonTabNode } from "../model/IJsonModel";
12
12
  export declare type CustomDragCallback = (dragging: TabNode | IJsonTabNode, over: TabNode, x: number, y: number, location: DockLocation) => void;
13
- export declare type DragRectRenderCallback = (text: String, node?: Node, json?: IJsonTabNode) => React.ReactElement | undefined;
13
+ export declare type DragRectRenderCallback = (content: React.ReactElement | undefined, node?: Node, json?: IJsonTabNode) => React.ReactElement | undefined;
14
14
  export declare type FloatingTabPlaceholderRenderCallback = (dockPopout: () => void, showPopout: () => void) => React.ReactElement | undefined;
15
15
  export declare type NodeMouseEvent = (node: TabNode | TabSetNode | BorderNode, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
16
+ export declare type ShowOverflowMenuCallback = (node: TabSetNode | BorderNode, mouseEvent: React.MouseEvent<HTMLElement, MouseEvent>, items: {
17
+ index: number;
18
+ node: TabNode;
19
+ }[], onSelect: (item: {
20
+ index: number;
21
+ node: TabNode;
22
+ }) => void) => void;
16
23
  export interface ILayoutProps {
17
24
  model: Model;
18
25
  factory: (node: TabNode) => React.ReactNode;
@@ -20,7 +27,6 @@ export interface ILayoutProps {
20
27
  fontFamily?: string;
21
28
  iconFactory?: (node: TabNode) => React.ReactNode | undefined;
22
29
  titleFactory?: (node: TabNode) => ITitleObject | React.ReactNode | undefined;
23
- closeIcon?: React.ReactNode;
24
30
  icons?: IIcons;
25
31
  onAction?: (action: Action) => Action | undefined;
26
32
  onRenderTab?: (node: TabNode, renderValues: ITabRenderValues) => void;
@@ -49,6 +55,7 @@ export interface ILayoutProps {
49
55
  onRenderFloatingTabPlaceholder?: FloatingTabPlaceholderRenderCallback;
50
56
  onContextMenu?: NodeMouseEvent;
51
57
  onAuxMouseClick?: NodeMouseEvent;
58
+ onShowOverflowMenu?: ShowOverflowMenuCallback;
52
59
  }
53
60
  export interface IFontValues {
54
61
  size?: string;
@@ -79,14 +86,18 @@ export interface ILayoutState {
79
86
  calculatedBorderBarSize: number;
80
87
  editingTab?: TabNode;
81
88
  showHiddenBorder: DockLocation;
89
+ portal?: React.ReactNode;
82
90
  }
83
91
  export interface IIcons {
84
- close?: React.ReactNode;
85
- closeTabset?: React.ReactNode;
86
- popout?: React.ReactNode;
87
- maximize?: React.ReactNode;
88
- restore?: React.ReactNode;
89
- more?: React.ReactNode;
92
+ close?: (React.ReactNode | ((tabNode: TabNode) => React.ReactNode));
93
+ closeTabset?: (React.ReactNode | ((tabSetNode: TabSetNode) => React.ReactNode));
94
+ popout?: (React.ReactNode | ((tabNode: TabNode) => React.ReactNode));
95
+ maximize?: (React.ReactNode | ((tabSetNode: TabSetNode) => React.ReactNode));
96
+ restore?: (React.ReactNode | ((tabSetNode: TabSetNode) => React.ReactNode));
97
+ more?: (React.ReactNode | ((tabSetNode: (TabSetNode | BorderNode), hiddenTabs: {
98
+ node: TabNode;
99
+ index: number;
100
+ }[]) => React.ReactNode));
90
101
  }
91
102
  export interface ICustomDropDestination {
92
103
  rect: Rect;
@@ -121,7 +132,7 @@ export declare class Layout extends React.Component<ILayoutProps, ILayoutState>
121
132
  * @param json the json for the new tab node
122
133
  * @param onDrop a callback to call when the drag is complete (node and event will be undefined if the drag was cancelled)
123
134
  */
124
- addTabWithDragAndDrop(dragText: string, json: IJsonTabNode, onDrop?: (node?: Node, event?: Event) => void): void;
135
+ addTabWithDragAndDrop(dragText: string | undefined, json: IJsonTabNode, onDrop?: (node?: Node, event?: Event) => void): void;
125
136
  /**
126
137
  * Adds a new tab by dragging a labeled panel to the drop location, dragging starts when you
127
138
  * mouse down on the panel
@@ -130,6 +141,8 @@ export declare class Layout extends React.Component<ILayoutProps, ILayoutState>
130
141
  * @param json the json for the new tab node
131
142
  * @param onDrop a callback to call when the drag is complete (node and event will be undefined if the drag was cancelled)
132
143
  */
133
- addTabWithDragAndDropIndirect(dragText: string, json: IJsonTabNode, onDrop?: (node?: Node, event?: Event) => void): void;
144
+ addTabWithDragAndDropIndirect(dragText: string | undefined, json: IJsonTabNode, onDrop?: (node?: Node, event?: Event) => void): void;
145
+ showPortal: (control: React.ReactNode, element: HTMLElement) => void;
146
+ hidePortal: () => void;
134
147
  }
135
148
  export default Layout;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};