flexlayout-react 0.7.14 → 0.8.0
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.
- package/ChangeLog.txt +26 -0
- package/README.md +157 -330
- package/Screenshot_light.png +0 -0
- package/Screenshot_rounded.png +0 -0
- package/declarations/Attribute.d.ts +1 -1
- package/declarations/AttributeDefinitions.d.ts +1 -1
- package/declarations/DockLocation.d.ts +12 -12
- package/declarations/DropInfo.d.ts +12 -12
- package/declarations/I18nLabel.d.ts +12 -14
- package/declarations/Orientation.d.ts +7 -7
- package/declarations/PopupMenu.d.ts +1 -1
- package/declarations/Rect.d.ts +41 -28
- package/declarations/Types.d.ts +95 -79
- package/declarations/examples/demo/Utils.d.ts +4 -0
- package/declarations/index.d.ts +21 -22
- package/declarations/model/Action.d.ts +5 -5
- package/declarations/model/Actions.d.ts +127 -110
- package/declarations/model/BorderNode.d.ts +30 -34
- package/declarations/model/BorderSet.d.ts +3 -4
- package/declarations/model/ICloseType.d.ts +5 -5
- package/declarations/model/IDraggable.d.ts +2 -2
- package/declarations/model/IDropTarget.d.ts +2 -2
- package/declarations/model/IJsonModel.d.ts +811 -149
- package/declarations/model/LayoutWindow.d.ts +28 -0
- package/declarations/model/Model.d.ts +91 -86
- package/declarations/model/Node.d.ts +17 -17
- package/declarations/model/RowNode.d.ts +10 -11
- package/declarations/model/TabNode.d.ts +44 -37
- package/declarations/model/TabSetNode.d.ts +44 -41
- package/declarations/model/Utils.d.ts +1 -1
- package/declarations/model/WindowLayout.d.ts +24 -0
- package/declarations/src/Attribute.d.ts +1 -0
- package/declarations/src/AttributeDefinitions.d.ts +1 -0
- package/declarations/src/DockLocation.d.ts +12 -0
- package/declarations/src/DropInfo.d.ts +12 -0
- package/declarations/src/I18nLabel.d.ts +10 -0
- package/declarations/src/Orientation.d.ts +7 -0
- package/declarations/src/PopupMenu.d.ts +1 -0
- package/declarations/src/Rect.d.ts +31 -0
- package/declarations/src/Types.d.ts +92 -0
- package/declarations/src/index.d.ts +20 -0
- package/declarations/src/model/Action.d.ts +5 -0
- package/declarations/src/model/Actions.d.ts +110 -0
- package/declarations/src/model/BorderNode.d.ts +28 -0
- package/declarations/src/model/BorderSet.d.ts +3 -0
- package/declarations/src/model/ICloseType.d.ts +5 -0
- package/declarations/src/model/IDraggable.d.ts +2 -0
- package/declarations/src/model/IDropTarget.d.ts +2 -0
- package/declarations/src/model/IJsonModel.d.ts +153 -0
- package/declarations/src/model/Model.d.ts +98 -0
- package/declarations/src/model/Node.d.ts +16 -0
- package/declarations/src/model/RowNode.d.ts +11 -0
- package/declarations/src/model/TabNode.d.ts +36 -0
- package/declarations/src/model/TabSetNode.d.ts +37 -0
- package/declarations/src/model/Utils.d.ts +1 -0
- package/declarations/src/view/BorderButton.d.ts +1 -0
- package/declarations/src/view/BorderTab.d.ts +2 -0
- package/declarations/src/view/BorderTabSet.d.ts +1 -0
- package/declarations/src/view/DragContainer.d.ts +1 -0
- package/declarations/src/view/ErrorBoundary.d.ts +1 -0
- package/declarations/src/view/FloatingWindow.d.ts +1 -0
- package/declarations/src/view/Icons.d.ts +7 -0
- package/declarations/src/view/Layout.d.ts +113 -0
- package/declarations/src/view/Overlay.d.ts +1 -0
- package/declarations/src/view/PopupMenu.d.ts +1 -0
- package/declarations/src/view/Row.d.ts +1 -0
- package/declarations/src/view/Splitter.d.ts +1 -0
- package/declarations/src/view/Tab.d.ts +1 -0
- package/declarations/src/view/TabButton.d.ts +1 -0
- package/declarations/src/view/TabButtonStamp.d.ts +1 -0
- package/declarations/src/view/TabOverflowHook.d.ts +1 -0
- package/declarations/src/view/TabSet.d.ts +1 -0
- package/declarations/src/view/Utils.d.ts +4 -0
- package/declarations/view/BorderButton.d.ts +1 -1
- package/declarations/view/BorderTab.d.ts +2 -0
- package/declarations/view/BorderTabSet.d.ts +1 -1
- package/declarations/view/DragContainer.d.ts +1 -0
- package/declarations/view/ErrorBoundary.d.ts +1 -1
- package/declarations/view/ExtendedResizeObserver.d.ts +23 -0
- package/declarations/view/FloatingWindow.d.ts +1 -1
- package/declarations/view/Icons.d.ts +8 -6
- package/declarations/view/Layout.d.ts +139 -160
- package/declarations/view/Overlay.d.ts +1 -0
- package/declarations/view/PopoutWindow.d.ts +1 -0
- package/declarations/view/PopupMenu.d.ts +1 -0
- package/declarations/view/Row.d.ts +1 -0
- package/declarations/view/SizeTracker.d.ts +10 -0
- package/declarations/view/Splitter.d.ts +1 -1
- package/declarations/view/Tab.d.ts +1 -1
- package/declarations/view/TabButton.d.ts +1 -1
- package/declarations/view/TabButtonStamp.d.ts +1 -1
- package/declarations/view/TabOverflowHook.d.ts +1 -1
- package/declarations/view/TabSet.d.ts +1 -1
- package/declarations/view/Utils.d.ts +11 -1
- package/dist/bundles/demo.js +232052 -0
- package/dist/bundles/demo.js.map +1 -0
- package/dist/flexlayout.js +122 -92
- package/dist/flexlayout_min.js +1 -1
- package/lib/Attribute.js +42 -31
- package/lib/Attribute.js.map +1 -1
- package/lib/AttributeDefinitions.js +131 -108
- package/lib/AttributeDefinitions.js.map +1 -1
- package/lib/DockLocation.js +120 -124
- package/lib/DockLocation.js.map +1 -1
- package/lib/DropInfo.js +9 -13
- package/lib/DropInfo.js.map +1 -1
- package/lib/I18nLabel.js +13 -18
- package/lib/I18nLabel.js.map +1 -1
- package/lib/Orientation.js +22 -26
- package/lib/Orientation.js.map +1 -1
- package/lib/Rect.js +104 -72
- package/lib/Rect.js.map +1 -1
- package/lib/Types.js +96 -83
- package/lib/Types.js.map +1 -1
- package/lib/index.js +21 -38
- package/lib/index.js.map +1 -1
- package/lib/model/Action.js +6 -10
- package/lib/model/Action.js.map +1 -1
- package/lib/model/Actions.js +169 -155
- package/lib/model/Actions.js.map +1 -1
- package/lib/model/BorderNode.js +385 -406
- package/lib/model/BorderNode.js.map +1 -1
- package/lib/model/BorderSet.js +66 -121
- package/lib/model/BorderSet.js.map +1 -1
- package/lib/model/ICloseType.js +6 -9
- package/lib/model/ICloseType.js.map +1 -1
- package/lib/model/IDraggable.js +1 -2
- package/lib/model/IDropTarget.js +1 -2
- package/lib/model/IJsonModel.js +1 -2
- package/lib/model/LayoutWindow.js +83 -0
- package/lib/model/LayoutWindow.js.map +1 -0
- package/lib/model/Model.js +614 -496
- package/lib/model/Model.js.map +1 -1
- package/lib/model/Node.js +217 -228
- package/lib/model/Node.js.map +1 -1
- package/lib/model/RowNode.js +491 -504
- package/lib/model/RowNode.js.map +1 -1
- package/lib/model/TabNode.js +289 -184
- package/lib/model/TabNode.js.map +1 -1
- package/lib/model/TabSetNode.js +457 -446
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/model/Utils.js +47 -82
- package/lib/model/Utils.js.map +1 -1
- package/lib/view/BorderButton.js +124 -138
- package/lib/view/BorderButton.js.map +1 -1
- package/lib/view/BorderTab.js +47 -0
- package/lib/view/BorderTab.js.map +1 -0
- package/lib/view/BorderTabSet.js +134 -128
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/DragContainer.js +16 -0
- package/lib/view/DragContainer.js.map +1 -0
- package/lib/view/ErrorBoundary.js +23 -27
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/Icons.js +40 -40
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +918 -901
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/Overlay.js +9 -0
- package/lib/view/Overlay.js.map +1 -0
- package/lib/view/PopoutWindow.js +129 -0
- package/lib/view/PopoutWindow.js.map +1 -0
- package/lib/view/PopupMenu.js +71 -0
- package/lib/view/PopupMenu.js.map +1 -0
- package/lib/view/Row.js +45 -0
- package/lib/view/Row.js.map +1 -0
- package/lib/view/SizeTracker.js +11 -0
- package/lib/view/SizeTracker.js.map +1 -0
- package/lib/view/Splitter.js +191 -147
- package/lib/view/Splitter.js.map +1 -1
- package/lib/view/Tab.js +86 -60
- package/lib/view/Tab.js.map +1 -1
- package/lib/view/TabButton.js +122 -135
- package/lib/view/TabButton.js.map +1 -1
- package/lib/view/TabButtonStamp.js +16 -21
- package/lib/view/TabButtonStamp.js.map +1 -1
- package/lib/view/TabOverflowHook.js +150 -149
- package/lib/view/TabOverflowHook.js.map +1 -1
- package/lib/view/TabSet.js +267 -234
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js +126 -68
- package/lib/view/Utils.js.map +1 -1
- package/package.json +36 -30
- package/src/Attribute.ts +23 -0
- package/src/AttributeDefinitions.ts +38 -15
- package/src/DockLocation.ts +13 -13
- package/src/I18nLabel.ts +7 -9
- package/src/Rect.ts +53 -1
- package/src/Types.ts +16 -0
- package/src/index.ts +1 -2
- package/src/model/Actions.ts +49 -29
- package/src/model/BorderNode.ts +208 -214
- package/src/model/BorderSet.ts +42 -91
- package/src/model/IJsonModel.ts +883 -103
- package/src/model/LayoutWindow.ts +121 -0
- package/src/model/Model.ts +488 -366
- package/src/model/Node.ts +98 -111
- package/src/model/RowNode.ts +323 -319
- package/src/model/TabNode.ts +294 -110
- package/src/model/TabSetNode.ts +300 -242
- package/src/model/Utils.ts +6 -32
- package/src/view/BorderButton.tsx +32 -52
- package/src/view/BorderTab.tsx +70 -0
- package/src/view/BorderTabSet.tsx +64 -52
- package/src/view/DragContainer.tsx +32 -0
- package/src/view/Icons.tsx +13 -0
- package/src/view/Layout.tsx +1071 -1047
- package/src/view/Overlay.tsx +22 -0
- package/src/view/PopoutWindow.tsx +152 -0
- package/src/{PopupMenu.tsx → view/PopupMenu.tsx} +36 -31
- package/src/view/Row.tsx +68 -0
- package/src/view/SizeTracker.tsx +20 -0
- package/src/view/Splitter.tsx +167 -112
- package/src/view/Tab.tsx +76 -42
- package/src/view/TabButton.tsx +36 -55
- package/src/view/TabButtonStamp.tsx +5 -9
- package/src/view/TabOverflowHook.tsx +14 -9
- package/src/view/TabSet.tsx +217 -176
- package/src/view/Utils.tsx +119 -39
- package/style/_base.scss +143 -35
- package/style/dark.css +685 -577
- package/style/dark.css.map +1 -1
- package/style/dark.scss +4 -1
- package/style/gray.css +668 -560
- package/style/gray.css.map +1 -1
- package/style/gray.scss +4 -1
- package/style/light.css +669 -561
- package/style/light.css.map +1 -1
- package/style/light.scss +6 -3
- package/style/rounded.css +697 -0
- package/style/rounded.css.map +1 -0
- package/style/rounded.scss +194 -0
- package/style/underline.css +690 -582
- package/style/underline.css.map +1 -1
- package/style/underline.scss +4 -1
- package/cypress.config.ts +0 -16
- package/lib/DragDrop.js +0 -316
- package/lib/DragDrop.js.map +0 -1
- package/lib/PopupMenu.js +0 -68
- package/lib/PopupMenu.js.map +0 -1
- package/lib/model/SplitterNode.js +0 -72
- package/lib/model/SplitterNode.js.map +0 -1
- package/lib/view/FloatingWindow.js +0 -123
- package/lib/view/FloatingWindow.js.map +0 -1
- package/lib/view/FloatingWindowTab.js +0 -19
- package/lib/view/FloatingWindowTab.js.map +0 -1
- package/lib/view/TabFloating.js +0 -66
- package/lib/view/TabFloating.js.map +0 -1
- package/src/DragDrop.ts +0 -392
- package/src/model/SplitterNode.ts +0 -78
- package/src/view/FloatingWindow.tsx +0 -140
- package/src/view/FloatingWindowTab.tsx +0 -29
- package/src/view/TabFloating.tsx +0 -101
package/README.md
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
FlexLayout is a layout manager that arranges React components in multiple tab sets, tabs can be resized and moved.
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|
|
|
11
|
-
[Run the Demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.
|
|
11
|
+
[Run the Demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/demo/index.html)
|
|
12
12
|
|
|
13
|
-
Try it now using [JSFiddle](https://jsfiddle.net/
|
|
13
|
+
Try it now using [JSFiddle](https://jsfiddle.net/fvd9btea/)
|
|
14
14
|
|
|
15
|
-
[API Doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.
|
|
15
|
+
[API Doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/index.html)
|
|
16
16
|
|
|
17
17
|
[Screenshot of Caplin Liberator Explorer using FlexLayout](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.20/images/LiberatorExplorerV3_3.PNG)
|
|
18
18
|
|
|
@@ -22,23 +22,21 @@ Features:
|
|
|
22
22
|
* splitters
|
|
23
23
|
* tabs
|
|
24
24
|
* tab dragging and ordering
|
|
25
|
-
*
|
|
26
|
-
* dock to
|
|
27
|
-
* maximize
|
|
25
|
+
* tab set dragging (move all the tabs in a tab set in one operation)
|
|
26
|
+
* dock to tab set or edge of frame
|
|
27
|
+
* maximize tab set (double click tab set header or use icon)
|
|
28
28
|
* tab overflow (show menu when tabs overflow, scroll tabs using mouse wheel)
|
|
29
|
-
* border
|
|
29
|
+
* border tab sets
|
|
30
30
|
* popout tabs into new browser windows
|
|
31
31
|
* submodels, allow layouts inside layouts
|
|
32
32
|
* tab renaming (double click tab text to rename)
|
|
33
|
-
* theming - light, underline, gray and dark
|
|
34
|
-
*
|
|
35
|
-
* add tabs using drag,
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* tab and tabset attributes: enableHeader, enableTabStrip, enableDock, enableDrop...
|
|
39
|
-
* customizable tabs and tabset header rendering
|
|
33
|
+
* theming - light, underline, gray, round and dark
|
|
34
|
+
* works on mobile devices (iPad, Android)
|
|
35
|
+
* add tabs using drag, add to active tab set, add to tab set by id
|
|
36
|
+
* tab and tab set attributes: enableTabStrip, enableDock, enableDrop...
|
|
37
|
+
* customizable tabs and tab set rendering
|
|
40
38
|
* component state is preserved when tabs are moved
|
|
41
|
-
* typescript type declarations
|
|
39
|
+
* typescript type declarations
|
|
42
40
|
|
|
43
41
|
## Installation
|
|
44
42
|
|
|
@@ -70,7 +68,7 @@ or by adding the css to your html:
|
|
|
70
68
|
|
|
71
69
|
## Usage
|
|
72
70
|
|
|
73
|
-
The `<Layout>` component renders the
|
|
71
|
+
The `<Layout>` component renders the tab sets and splitters, it takes the following props:
|
|
74
72
|
|
|
75
73
|
|
|
76
74
|
#### Required props:
|
|
@@ -81,7 +79,7 @@ The `<Layout>` component renders the tabsets and splitters, it takes the followi
|
|
|
81
79
|
| model | the layout model |
|
|
82
80
|
| factory | a factory function for creating React components |
|
|
83
81
|
|
|
84
|
-
Additional [optional props](#optional-props)
|
|
82
|
+
Additional [optional props](#optional-layout-props)
|
|
85
83
|
|
|
86
84
|
The model is tree of Node objects that define the structure of the layout.
|
|
87
85
|
|
|
@@ -149,62 +147,46 @@ function App() {
|
|
|
149
147
|
}
|
|
150
148
|
```
|
|
151
149
|
|
|
152
|
-
The above code would render two
|
|
150
|
+
The above code would render two tab sets 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.
|
|
153
151
|
|
|
154
|
-
Try it now using [JSFiddle](https://jsfiddle.net/
|
|
152
|
+
Try it now using [JSFiddle](https://jsfiddle.net/fvd9btea/)
|
|
155
153
|
|
|
156
154
|
A simple Typescript example can be found here:
|
|
157
155
|
|
|
158
156
|
https://github.com/nealus/FlexLayout_cra_example
|
|
159
157
|
|
|
160
|
-
The model
|
|
158
|
+
The model json contains 4 top level elements:
|
|
159
|
+
|
|
160
|
+
* global - (optional) where global options are defined
|
|
161
|
+
* layout - where the main row/tabset/tabs layout hierarchy is defined
|
|
162
|
+
* borders - (optional) where up to 4 borders are defined ("top", "bottom", "left", "right").
|
|
163
|
+
* popouts - (optional) where the popout windows are defined
|
|
164
|
+
|
|
165
|
+
The layout element is built up using 3 types of 'node':
|
|
161
166
|
|
|
162
167
|
* row - rows contains a list of tabsets and child rows, the top level 'row' will render horizontally (unless the global attribute rootOrientationVertical is set)
|
|
163
|
-
, child 'rows' will render in the opposite orientation to their parent.
|
|
168
|
+
, child 'rows' will render in the opposite orientation to their parent row.
|
|
164
169
|
|
|
165
170
|
* tabset - tabsets contain a list of tabs and the index of the selected tab
|
|
166
171
|
|
|
167
172
|
* tab - tabs specify the name of the component that they should host (that will be loaded via the factory) and the text of the actual tab.
|
|
168
173
|
|
|
174
|
+
The layout structure is defined with rows within rows that contain tabsets that themselves contain tabs.
|
|
175
|
+
|
|
176
|
+
The optional borders element is made up of border nodes
|
|
177
|
+
|
|
169
178
|
* border - borders contain a list of tabs and the index of the selected tab, they can only be used in the borders
|
|
170
179
|
top level element.
|
|
171
180
|
|
|
172
|
-
The
|
|
173
|
-
|
|
174
|
-
The model json contains 3 top level elements:
|
|
181
|
+
The tree structure for the JSON model is well defined as Typescript interfaces, see [JSON Model](#json-model-definition)
|
|
175
182
|
|
|
176
|
-
|
|
177
|
-
* layout - where the main row/tabset/tabs layout hierarchy is defined
|
|
178
|
-
* borders - (optional) where up to 4 borders are defined ("top", "bottom", "left", "right").
|
|
183
|
+
Each type of node has a defined set of requires/optional attributes.
|
|
179
184
|
|
|
180
185
|
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).
|
|
181
186
|
|
|
182
|
-
NOTE: the easiest way to create your initial layout JSON is to use the [demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.
|
|
187
|
+
NOTE: the easiest way to create your initial layout JSON is to use the [demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/demo/index.html) app, modify one of the
|
|
183
188
|
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.
|
|
184
189
|
|
|
185
|
-
To control where nodes can be dropped you can add a callback function to the model:
|
|
186
|
-
|
|
187
|
-
```
|
|
188
|
-
model.setOnAllowDrop(this.allowDrop);
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
example:
|
|
192
|
-
```javascript
|
|
193
|
-
allowDrop(dragNode, dropInfo) {
|
|
194
|
-
let dropNode = dropInfo.node;
|
|
195
|
-
|
|
196
|
-
// prevent non-border tabs dropping into borders
|
|
197
|
-
if (dropNode.getType() == "border" && (dragNode.getParent() == null || dragNode.getParent().getType() != "border"))
|
|
198
|
-
return false;
|
|
199
|
-
|
|
200
|
-
// prevent border tabs dropping into main layout
|
|
201
|
-
if (dropNode.getType() != "border" && (dragNode.getParent() != null && dragNode.getParent().getType() == "border"))
|
|
202
|
-
return false;
|
|
203
|
-
|
|
204
|
-
return true;
|
|
205
|
-
}
|
|
206
|
-
```
|
|
207
|
-
|
|
208
190
|
By changing global or node attributes you can change the layout appearance and functionality, for example:
|
|
209
191
|
|
|
210
192
|
Setting tabSetEnableTabStrip:false in the global options would change the layout into a multi-splitter (without
|
|
@@ -213,255 +195,28 @@ tabs or drag and drop).
|
|
|
213
195
|
```
|
|
214
196
|
global: {tabSetEnableTabStrip:false},
|
|
215
197
|
```
|
|
216
|
-
## Floating Tabs (Popouts)
|
|
217
|
-
|
|
218
|
-
Tabs can be rendered into external browser windows (for use in multi-monitor setups)
|
|
219
|
-
by configuring them with the enableFloat attribute. When this attribute is present
|
|
220
|
-
an additional icon is shown in the tab header bar allowing the tab to be popped out
|
|
221
|
-
into an external window.
|
|
222
|
-
|
|
223
|
-
For popouts to work there needs to be an additional html page 'popout.html' hosted
|
|
224
|
-
at the same location as the main page (copy the one from examples/demo). The popout.html is the host page for the
|
|
225
|
-
popped out tab, the styles from the main page will be copied into it at runtime.
|
|
226
|
-
|
|
227
|
-
Because popouts are rendering into a different document to the main layout any code in the popped out
|
|
228
|
-
tab that uses the global document or window objects will not work correctly (for example custom popup menus),
|
|
229
|
-
they need to instead use the document/window of the popout. To get the document/window of the popout use the
|
|
230
|
-
following method on one of the elements rendered in the popout (for example a ref or target in an event handler):
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
const currentDocument = this.selfRef.current.ownerDocument;
|
|
234
|
-
const currentWindow = currentDocument.defaultView!;
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
In the above code selfRef is a React ref to the toplevel element in the tab being rendered.
|
|
238
|
-
|
|
239
|
-
Note: some libraries support popout windows by allowing you to specify the document to use,
|
|
240
|
-
for example see the getDocument() callback in agGrid at https://www.ag-grid.com/javascript-grid-callbacks/
|
|
241
|
-
|
|
242
|
-
## Optional Props
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
| Prop | Description |
|
|
246
|
-
| --------------- | ----------------- |
|
|
247
|
-
| font | the tab font (overrides value in css). Example: font={{size:"12px", style:"italic"}}|
|
|
248
|
-
| 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 |
|
|
249
|
-
| 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 |
|
|
250
|
-
| onRenderTab | function called when rendering a tab, allows leading (icon), content section, buttons and name used in overflow menu to be customized |
|
|
251
|
-
| onRenderTabSet | function called when rendering a tabset, allows header and buttons to be customized |
|
|
252
|
-
| onModelChange | function called when model has changed |
|
|
253
|
-
| onExternalDrag | function called when an external object (not a tab) gets dragged onto the layout, with a single `dragenter` argument. Should return either `undefined` to reject the drag/drop or an object with keys `dragText`, `json`Drop`, to create a tab via drag (similar to a call to `addTabToTabSet`). Function `onDrop` is passed the added tab `Node` and the `drop` `DragEvent`, unless the drag was canceled. |
|
|
254
|
-
| classNameMapper | function called with default css class name, return value is class name that will be used. Mainly for use with css modules.|
|
|
255
|
-
| i18nMapper | function called for each I18nLabel to allow user translation, currently used for tab and tabset move messages, return undefined to use default values |
|
|
256
|
-
| supportsPopout | if left undefined will do simple check based on userAgent |
|
|
257
|
-
| popoutURL | URL of popout window relative to origin, defaults to popout.html |
|
|
258
|
-
| realtimeResize | boolean value, defaults to false, resize tabs as splitters are dragged. Warning: this can cause resizing to become choppy when tabs are slow to draw |
|
|
259
|
-
| onTabDrag | function called while dragging a tab, whether from the layout or using `addTabWithDragAndDrop`. Called with the `TabNode` being dragged / the tab json from `addTabWithDragAndDrop`, the `TabNode` being dragged over, the x and y coordinates relative to the dragged-over tab, and the `DockLocation` that would be used. Should return undefined for default behavior, or an object containing `x`, `y`, `width`, `height`, `callback`, `cursor` fields. Coordinates are in pixels relative to the dragged-over tab, and `callback` will be called with the same arguments if the tab is dropped. `cursor` is an optional string field that should contain a CSS cursor value, such as `copy` or `row-resize`. If `callback` is called, the layout does not perform its default behavior on drop. |
|
|
260
|
-
| onRenderDragRect | callback for rendering the drag rectangles |
|
|
261
|
-
| onRenderFloatingTabPlaceholder | callback for rendering the floating tab placeholder |
|
|
262
|
-
| onContextMenu | callback for handling context actions on tabs and tabsets |
|
|
263
|
-
| onAuxMouseClick | callback for handling mouse clicks on tabs and tabsets with alt, meta, shift keys, also handles center mouse clicks |
|
|
264
|
-
| onShowOverflowMenu | callback for handling the display of the tab overflow menu |
|
|
265
|
-
| onTabSetPlaceHolder | callback for rendering a placeholder when a tabset is empty |
|
|
266
|
-
| 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 |
|
|
267
|
-
| 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 |
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
## Global Config attributes
|
|
271
|
-
|
|
272
|
-
Attributes allowed in the 'global' element
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
| Attribute | Default | Description |
|
|
276
|
-
|-------------------------------|:-------:|--------------------------------------------------------------------------------------------------------------|
|
|
277
|
-
| splitterSize | 8 | width in pixels of all splitters between tabsets/borders |
|
|
278
|
-
| splitterExtra | 0 | additional width in pixels of the splitter hit test area |
|
|
279
|
-
| legacyOverflowMenu | false | use the legacy text only overflow menu |
|
|
280
|
-
| enableEdgeDock | true | |
|
|
281
|
-
| enableRotateBorderIcons | true | boolean indicating if tab icons should rotate with the text in the left and right borders |
|
|
282
|
-
| tabEnableClose | true | allow user to close all tabs via close button |
|
|
283
|
-
| tabCloseType | 1 | see values in ICloseType |
|
|
284
|
-
| tabEnableDrag | true | allow user to drag all tabs to new location |
|
|
285
|
-
| tabEnableRename | true | allow user to rename all tabs by double clicking |
|
|
286
|
-
| tabEnableFloat | false | enable popouts in all tabs (in popout capable browser) |
|
|
287
|
-
| tabClassName | null | |
|
|
288
|
-
| tabContentClassName | null | |
|
|
289
|
-
| tabIcon | null | |
|
|
290
|
-
| tabEnableRenderOnDemand | true | whether to avoid rendering component until tab is visible |
|
|
291
|
-
| tabDragSpeed | 0.3 | CSS transition speed of drag outlines (in seconds) |
|
|
292
|
-
| tabBorderWidth | -1 | width when added to border, -1 will use border size |
|
|
293
|
-
| tabBorderHeight | -1 | height when added to border, -1 will use border size |
|
|
294
|
-
| tabSetEnableDeleteWhenEmpty | true | |
|
|
295
|
-
| tabSetEnableDrop | true | allow user to drag tabs into all tabsets |
|
|
296
|
-
| tabSetEnableDrag | true | allow user to drag tabs out of all tabsets |
|
|
297
|
-
| tabSetEnableDivide | true | allow user to drag tabs to region of all tabsets, splitting into new tabset |
|
|
298
|
-
| tabSetEnableMaximize | true | allow user to maximize all tabsets to fill view via maximize button |
|
|
299
|
-
| tabSetEnableClose | false | allow user to close all tabsets via close button |
|
|
300
|
-
| tabSetAutoSelectTab | true | whether to select new/moved tabs in all tabsets |
|
|
301
|
-
| tabSetClassNameTabStrip | null | height in pixels of tab strips in all tabsets |
|
|
302
|
-
| tabSetEnableSingleTabStretch | false | if a tabset has only a single tab then stretch the single tab to fill area and display in a header style |
|
|
303
|
-
| tabSetClassNameHeader | null | |
|
|
304
|
-
| tabSetEnableTabStrip | true | enable tab strip and allow multiple tabs in all tabsets |
|
|
305
|
-
| tabSetHeaderHeight | 0 | height of tabset header in pixels; if left as 0 then the value will be calculated from the current fontSize |
|
|
306
|
-
| tabSetTabStripHeight | 0 | height of tabset tab bar in pixels; if left as 0 then the value will be calculated from the current fontSize |
|
|
307
|
-
| borderBarSize | 0 | size of the border bars in pixels; if left as 0 then the value will be calculated from the current fontSize |
|
|
308
|
-
| borderEnableAutoHide | false | hide border if it has zero tabs |
|
|
309
|
-
| borderEnableDrop | true | allow user to drag tabs into this border |
|
|
310
|
-
| borderAutoSelectTabWhenOpen | true | whether to select new/moved tabs in border when the border is already open |
|
|
311
|
-
| borderAutoSelectTabWhenClosed | false | whether to select new/moved tabs in border when the border is curently closed |
|
|
312
|
-
| borderClassName | null | |
|
|
313
|
-
| borderSize | 200 | initial width in pixels for left/right borders, height for top/bottom borders |
|
|
314
|
-
| borderMinSize | 0 | minimum width in pixels for left/right borders, height for top/bottom borders |
|
|
315
|
-
| tabSetMinHeight | 0 | minimum width (in px) for all tabsets |
|
|
316
|
-
| tabSetMinWidth | 0 | minimum height (in px) for all tabsets |
|
|
317
|
-
| tabSetTabLocation | top | show tabs in location top or bottom |
|
|
318
|
-
| rootOrientationVertical | false | the top level 'row' will layout horizontally by default, set this option true to make it layout vertically |
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
## Row Attributes
|
|
322
|
-
|
|
323
|
-
Attributes allowed in nodes of type 'row'.
|
|
324
|
-
|
|
325
|
-
| Attribute | Default | Description |
|
|
326
|
-
| ------------- |:-------------:| -----|
|
|
327
|
-
| type | row | |
|
|
328
|
-
| weight | 100 | |
|
|
329
|
-
| width | null | preferred pixel width |
|
|
330
|
-
| height | null | preferred pixel height |
|
|
331
|
-
| children | *required* | a list of row and tabset nodes |
|
|
332
|
-
|
|
333
|
-
## Tab Attributes
|
|
334
|
-
|
|
335
|
-
Attributes allowed in nodes of type 'tab'.
|
|
336
198
|
|
|
337
|
-
|
|
199
|
+
## Model Actions
|
|
338
200
|
|
|
201
|
+
Once the model json has been loaded all changes to the model are applied through actions.
|
|
339
202
|
|
|
340
|
-
| Attribute | Default | Description |
|
|
341
|
-
| ------------- |:-------------:| -----|
|
|
342
|
-
| type | tab | |
|
|
343
|
-
| name | *required* | name of tab to be displayed in the tab button |
|
|
344
|
-
| altName | *optional* | if there is no name specifed then this value will be used in the overflow menu |
|
|
345
|
-
| component | *required* | string identifying which component to run (for factory) |
|
|
346
|
-
| config | null | a place to hold json config for the hosted component |
|
|
347
|
-
| id | auto generated | |
|
|
348
|
-
| helpText | *optional* | An optional help text for the tab to be displayed upon tab hover. |
|
|
349
|
-
| enableClose | *inherited* | allow user to close tab via close button |
|
|
350
|
-
| closeType | *inherited* | see values in ICloseType |
|
|
351
|
-
| enableDrag | *inherited* | allow user to drag tab to new location |
|
|
352
|
-
| enableRename | *inherited* | allow user to rename tabs by double clicking |
|
|
353
|
-
| enableFloat | *inherited* | enable popout (in popout capable browser) |
|
|
354
|
-
| floating | false | |
|
|
355
|
-
| className | *inherited* | class applied to tab button |
|
|
356
|
-
| contentClassName | *inherited* | class applied to tab content |
|
|
357
|
-
| tabsetClassName | undefined | class applied to parent tabset when this is the only tab and it is stretched to fill the tabset |
|
|
358
|
-
| icon | *inherited* | |
|
|
359
|
-
| enableRenderOnDemand | *inherited* | whether to avoid rendering component until tab is visible |
|
|
360
|
-
| borderWidth | *inherited* | width when added to border, -1 will use border size |
|
|
361
|
-
| borderHeight | *inherited* | height when added to border, -1 will use border size |
|
|
362
|
-
|
|
363
|
-
Tab nodes have a getExtraData() method that initially returns an empty object, this is the place to
|
|
364
|
-
add extra data to a tab node that will not be saved.
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
## TabSet Attributes
|
|
368
|
-
|
|
369
|
-
Attributes allowed in nodes of type 'tabset'.
|
|
370
|
-
|
|
371
|
-
Inherited defaults will take their value from the associated global attributes (see above).
|
|
372
|
-
|
|
373
|
-
Note: tabsets can be dynamically created as tabs are moved and deleted when all their tabs are removed (unless enableDeleteWhenEmpty is false).
|
|
374
|
-
|
|
375
|
-
| Attribute | Default | Description |
|
|
376
|
-
|-------------------------|:-------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
|
377
|
-
| type | tabset | |
|
|
378
|
-
| weight | 100 | relative weight for sizing of this tabset in parent row |
|
|
379
|
-
| width | null | preferred pixel width |
|
|
380
|
-
| height | null | preferred pixel height |
|
|
381
|
-
| name | null | named tabsets will show a header bar above the tabs |
|
|
382
|
-
| config | null | a place to hold json config used in your own code |
|
|
383
|
-
| selected | 0 | index of selected/visible tab in tabset |
|
|
384
|
-
| active | false | whether tabset is currently active; this attribute can only be used in the initial configuration, to change the active tabset you should use the `setActiveTabset` action on the model |
|
|
385
|
-
| maximized | false | whether tabset is currently maximized to fill view |
|
|
386
|
-
| enableClose | false | allow user to close tabset via a close button |
|
|
387
|
-
| id | auto generated | |
|
|
388
|
-
| children | *required* | a list of tab nodes |
|
|
389
|
-
| enableDeleteWhenEmpty | *inherited* | |
|
|
390
|
-
| enableDrop | *inherited* | allow user to drag tabs into this tabset |
|
|
391
|
-
| enableDrag | *inherited* | allow user to drag tabs out this tabset |
|
|
392
|
-
| enableDivide | *inherited* | allow user to drag tabs to region of this tabset, splitting into new tabset |
|
|
393
|
-
| enableMaximize | *inherited* | allow user to maximize tabset to fill view via maximize button |
|
|
394
|
-
| enableSingleTabStretch | *inherited* | if the tabset has only a single tab then stretch the single tab to fill area and display in a header style |
|
|
395
|
-
| autoSelectTab | *inherited* | whether to select new/moved tabs in tabset |
|
|
396
|
-
| classNameTabStrip | *inherited* | |
|
|
397
|
-
| classNameHeader | *inherited* | |
|
|
398
|
-
| enableTabStrip | *inherited* | enable tab strip and allow multiple tabs in this tabset |
|
|
399
|
-
| headerHeight | *inherited* | |
|
|
400
|
-
| tabStripHeight | *inherited* | height in pixels of tab strip |
|
|
401
|
-
| tabLocation | *inherited* | show tabs in location top or bottom |
|
|
402
|
-
| minHeight | *inherited* | minimum height (in px) for this tabset |
|
|
403
|
-
| minWidth | *inherited* | minimum width (in px) for this tabset |
|
|
404
|
-
|
|
405
|
-
## Border Attributes
|
|
406
|
-
|
|
407
|
-
Attributes allowed in nodes of type 'border'.
|
|
408
|
-
|
|
409
|
-
Inherited defaults will take their value from the associated global attributes (see above).
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
| Attribute | Default | Description |
|
|
413
|
-
| ------------- |:-------------:| -----|
|
|
414
|
-
| type | border | |
|
|
415
|
-
| size | *inherited* | size of the tab body when selected |
|
|
416
|
-
| minSize | *inherited* | |
|
|
417
|
-
| selected | -1 | index of selected/visible tab in border; -1 means no tab unselected / border closed |
|
|
418
|
-
| id | auto generated | border_ + border name e.g. border_left |
|
|
419
|
-
| config | null | a place to hold json config used in your own code |
|
|
420
|
-
| show | true | show/hide this border |
|
|
421
|
-
| enableAutoHide | false | hide border if it has zero tabs |
|
|
422
|
-
| children | *required* | a list of tab nodes |
|
|
423
|
-
| barSize | *inherited* | size of this border's bar in pixels; if left as 0 then the value will be calculated from the current fontSize |
|
|
424
|
-
| enableDrop | *inherited* | |
|
|
425
|
-
| autoSelectTabWhenOpen | *inherited* | whether to select new/moved tabs in border when the border is already open |
|
|
426
|
-
| autoSelectTabWhenClosed | *inherited* | whether to select new/moved tabs in border when the border is currently closed |
|
|
427
|
-
| className | *inherited* | class applied to tab button |
|
|
428
203
|
|
|
429
|
-
|
|
204
|
+
You apply actions using the `Model.doAction()` method.
|
|
430
205
|
|
|
431
|
-
|
|
432
|
-
You can intercept actions resulting from GUI changes before they are applied by
|
|
433
|
-
implementing the `onAction` callback property of the `Layout`.
|
|
434
|
-
You can also apply actions directly using the `Model.doAction()` method.
|
|
435
|
-
This method takes a single argument, created by one of the following action
|
|
206
|
+
This method takes a single argument, created by one of the action
|
|
436
207
|
generators (typically accessed as `FlexLayout.Actions.<actionName>`):
|
|
437
208
|
|
|
438
|
-
|
|
439
|
-
| ------------- | -----|
|
|
440
|
-
| Actions.addNode(newNodeJson, toNodeId, location, index, select?) | add a new tab node to the given tabset node; `select` specifies whether to select new tab, defaulting to `autoSelectTab` attribute; returns the created `Node` |
|
|
441
|
-
| Actions.moveNode(fromNodeId, toNodeId, location, index, select?) | move a tab node from its current location to the new node and location; `select` specifies whether to select tab, defaulting to new tabset's `autoSelectTab` attribute |
|
|
442
|
-
| Actions.deleteTab(tabNodeId) | delete the given tab |
|
|
443
|
-
| Actions.renameTab(tabNodeId, newName) | rename the given tab |
|
|
444
|
-
| Actions.selectTab(tabNodeId) | select the given tab |
|
|
445
|
-
| Actions.setActiveTabset(tabsetNodeId) | set the tabset as the active tabset |
|
|
446
|
-
| Actions.adjustSplit(splitterNodeId, value) | adjust the size of the given splitter |
|
|
447
|
-
| Actions.adjustBorderSplit(borderNodeId, pos) | updates the size of the given border node |
|
|
448
|
-
| Actions.maximizeToggle(tabsetNodeId) | toggles whether the given tabset node is maximized |
|
|
449
|
-
| Actions.updateModelAttributes(attributes) | updates the global attributes |
|
|
450
|
-
| Actions.updateNodeAttributes(nodeId, attributes) | updates the attributes of the given node |
|
|
451
|
-
| Actions.floatTab(nodeId) | popout the tab into a floating browser window |
|
|
452
|
-
| Actions.unFloatTab(nodeId) | restore a popped out tab to the main layout |
|
|
209
|
+
[Actions doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/classes/Actions.html)
|
|
453
210
|
|
|
454
211
|
### Examples
|
|
455
212
|
|
|
456
213
|
```js
|
|
457
214
|
model.doAction(FlexLayout.Actions.updateModelAttributes({
|
|
458
|
-
splitterSize:40
|
|
459
|
-
tabSetHeaderHeight:40,
|
|
460
|
-
tabSetTabStripHeight:40
|
|
215
|
+
splitterSize:40
|
|
461
216
|
}));
|
|
462
217
|
```
|
|
463
218
|
|
|
464
|
-
The above example would increase the size of the splitters,
|
|
219
|
+
The above example would increase the size of the splitters, this could be used to make
|
|
465
220
|
adjusting the layout easier on a small device.
|
|
466
221
|
|
|
467
222
|
```js
|
|
@@ -471,97 +226,169 @@ model.doAction(FlexLayout.Actions.addNode(
|
|
|
471
226
|
```
|
|
472
227
|
|
|
473
228
|
This example adds a new grid component to the center of tabset with id "1" and at the 0'th tab position (use value -1 to add to the end of the tabs).
|
|
229
|
+
|
|
474
230
|
Note: you can get the id of a node (e.g., the node returned by the `addNode`
|
|
475
231
|
action) using the method `node.getId()`.
|
|
476
232
|
If an id wasn't assigned when the node was created, then one will be created for you of the form `#<uuid>` (e.g. `#0c459064-8dee-444e-8636-eb9ab910fb27`).
|
|
477
233
|
|
|
234
|
+
Note: You can intercept actions resulting from GUI changes before they are applied by
|
|
235
|
+
implementing the `onAction` callback property of the `Layout`.
|
|
236
|
+
|
|
237
|
+
## Optional Layout Props
|
|
238
|
+
|
|
239
|
+
There are many optional properties that can be applied to the layout:
|
|
240
|
+
|
|
241
|
+
[Layout Properties doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/interfaces/ILayoutProps.html)
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
## JSON Model Definition
|
|
245
|
+
|
|
246
|
+
The JSON model is well defined as a set of TypeScript interfaces, see the doc for details of all the attributes allowed:
|
|
247
|
+
|
|
248
|
+
## Model Config Attributes
|
|
249
|
+
|
|
250
|
+
[Model Attributes doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/interfaces/IJsonModel.html)
|
|
251
|
+
|
|
252
|
+
## Global Config Attributes
|
|
253
|
+
|
|
254
|
+
[Global Attributes doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/interfaces/IGlobalAttributes.html)
|
|
255
|
+
|
|
256
|
+
## Row Config Attributes
|
|
257
|
+
|
|
258
|
+
[Row Attributes doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/interfaces/IJsonRowNode.html)
|
|
259
|
+
|
|
260
|
+
## Tab Set Config Attributes
|
|
261
|
+
|
|
262
|
+
[Tab set Attributes doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/interfaces/IJsonTabSetNode.html)
|
|
263
|
+
|
|
264
|
+
Note: tab sets will be dynamically created as tabs are moved, and deleted when all their tabs are removed (unless enableDeleteWhenEmpty is false).
|
|
265
|
+
|
|
266
|
+
## Tab Config attributes
|
|
267
|
+
|
|
268
|
+
[Tab Attributes doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/interfaces/IJsonTabNode.html)
|
|
269
|
+
|
|
270
|
+
## Border Config attributes
|
|
271
|
+
|
|
272
|
+
[Border Attributes doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/interfaces/IJsonBorderNode.html)
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
|
|
478
277
|
|
|
479
278
|
## Layout Component Methods to Create New Tabs
|
|
480
279
|
|
|
481
|
-
|
|
280
|
+
There are methods on the Layout Component for adding tabs:
|
|
281
|
+
|
|
282
|
+
[Layout Methods doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/classes/Layout.html)
|
|
482
283
|
|
|
483
284
|
Example:
|
|
484
285
|
|
|
485
286
|
```
|
|
486
|
-
|
|
287
|
+
layoutRef.current.addTabToTabSet("NAVIGATION", {type:"tab", component:"grid", name:"a grid"});
|
|
487
288
|
```
|
|
488
|
-
This would add a new grid component to the
|
|
289
|
+
This would add a new grid component to the tab set with id "NAVIGATION" (where layoutRef is a ref to the Layout element, see https://reactjs.org/docs/refs-and-the-dom.html ).
|
|
489
290
|
|
|
490
291
|
|
|
491
|
-
| Layout Method | Description |
|
|
492
|
-
| ------------- | -----|
|
|
493
|
-
| addTabToTabSet(tabsetId, json) | adds a new tab to the tabset with the given Id |
|
|
494
|
-
| addTabToActiveTabSet(json) | adds a new tab to the active tabset |
|
|
495
|
-
| addTabWithDragAndDrop(dragText, json, onDrop) | adds a new tab by dragging a marker to the required location, with the drag starting immediately; on success, `onDrop` is passed the created tab `Node`; on cancel, no arguments are passed |
|
|
496
|
-
| addTabWithDragAndDropIndirect(dragText, json, onDrop) | adds a new tab by dragging a marker to the required location, the marker is shown and must be clicked on to start dragging |
|
|
497
|
-
| moveTabWithDragAndDrop( node, dragText) | Move a tab/tabset using drag and drop triggered from a custom event |
|
|
498
292
|
|
|
499
293
|
## Tab Node Events
|
|
500
294
|
|
|
501
|
-
You can handle events on nodes by adding a listener, this would typically be done
|
|
502
|
-
|
|
295
|
+
You can handle events on nodes by adding a listener, this would typically be done
|
|
296
|
+
when the component is mounted in a useEffect method:
|
|
503
297
|
|
|
504
298
|
Example:
|
|
505
299
|
```
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
};
|
|
300
|
+
function MyComponent({node}) {
|
|
301
|
+
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
// save subject in flexlayout node tree
|
|
304
|
+
node.setEventListener("save", () => {
|
|
305
|
+
node.getConfig().subject = subject;
|
|
306
|
+
};
|
|
307
|
+
}, []);
|
|
514
308
|
}
|
|
515
309
|
|
|
516
310
|
```
|
|
517
311
|
|
|
518
312
|
| Event | parameters | Description |
|
|
519
313
|
| ------------- |:-------------:| -----|
|
|
520
|
-
| resize |
|
|
521
|
-
| close |
|
|
522
|
-
| visibility |
|
|
523
|
-
| save |
|
|
314
|
+
| resize | {rect} | called when tab is resized during layout, called before it is rendered with the new size|
|
|
315
|
+
| close | none | called when a tab is closed |
|
|
316
|
+
| visibility | {visible} | called when the visibility of a tab changes |
|
|
317
|
+
| save | none | called before a tabnode is serialized to json, use to save node config by adding data to the object returned by node.getConfig()|
|
|
524
318
|
|
|
319
|
+
## Popout Windows
|
|
320
|
+
|
|
321
|
+
Tabs can be rendered into external browser windows (for use in multi-monitor setups)
|
|
322
|
+
by configuring them with the enablePopout attribute. When this attribute is present
|
|
323
|
+
an additional icon is shown in the tab header bar allowing the tab to be popped out
|
|
324
|
+
into an external window.
|
|
325
|
+
|
|
326
|
+
For popouts to work there needs to be an additional html page 'popout.html' hosted
|
|
327
|
+
at the same location as the main page (copy the one from examples/demo). The popout.html is the host page for the
|
|
328
|
+
popped out tab, the styles from the main page will be copied into it at runtime.
|
|
329
|
+
|
|
330
|
+
Because popouts are rendering into a different document to the main layout any code in the popped out
|
|
331
|
+
tab that uses the global document or window objects for event listeners will not work correctly (for example custom popup menus where the code uses document.addEventListener(...)),
|
|
332
|
+
they need to instead use the document/window of the popout. To get the document/window of the popout use the
|
|
333
|
+
following method on one of the elements rendered in the popout (for example a ref or target in an event handler):
|
|
334
|
+
|
|
335
|
+
```
|
|
336
|
+
const currentDocument = selfRef.current.ownerDocument;
|
|
337
|
+
const currentWindow = currentDocument.defaultView!;
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
In the above code selfRef is a React ref to the toplevel element in the tab being rendered.
|
|
341
|
+
|
|
342
|
+
Note: libraries may support popout windows by allowing you to specify the document to use,
|
|
343
|
+
for example see the getDocument() callback in agGrid at https://www.ag-grid.com/javascript-grid-callbacks/
|
|
344
|
+
|
|
345
|
+
### Limitations of Popouts
|
|
346
|
+
* FlexLayout uses React Portals to draw the popout window content,
|
|
347
|
+
this means all the code runs in the main Window's JS context, so effectively the popout windows are just extensions of the area on which the main window can render panels.
|
|
348
|
+
|
|
349
|
+
* Your code must use the popout window/document in popout windows when adding event listeners (e.g popoutDocument.addEventListener(...)).
|
|
350
|
+
|
|
351
|
+
* Timers throttle when main window is in the background
|
|
352
|
+
you could implement a webworker timer replacement if needed (which will not throttle)
|
|
353
|
+
* Many third party controls will use the global document for some event listeners,
|
|
354
|
+
these will not work correctly without modification
|
|
355
|
+
* Some third party controls will suspend when the global document is hidden
|
|
356
|
+
you can use the tab overlay attribute to 'gray out' these tabs when the main window is hidden
|
|
357
|
+
* Resize observers may be throttled (or stay attached to the main window), so you may need to use some other way to resize the component when in a popout (see aggrid component in demo).
|
|
358
|
+
* Popouts will not size and position correctly when the browser is zoomed (ie set to 50% zoom)
|
|
359
|
+
* Popouts cannot reload in maximized or minimized states
|
|
360
|
+
* by default flexlayout will maintain react state when moving tabs between windows, but you can use the
|
|
361
|
+
enableWindowReMount tab attribute to force the component to re-mount.
|
|
362
|
+
|
|
363
|
+
See this article about using React portals in this way: https://dev.to/noriste/the-challenges-of-rendering-an-openlayers-map-in-a-popup-through-react-2elh
|
|
525
364
|
|
|
526
365
|
## Running the Examples and Building the Project
|
|
527
366
|
|
|
528
367
|
First install dependencies:
|
|
529
368
|
|
|
530
369
|
```
|
|
531
|
-
|
|
370
|
+
pnpm install
|
|
532
371
|
```
|
|
533
372
|
|
|
534
373
|
Compile the project and run the examples:
|
|
535
|
-
|
|
374
|
+
|
|
536
375
|
```
|
|
537
|
-
|
|
376
|
+
pnpm start
|
|
538
377
|
```
|
|
539
378
|
|
|
540
379
|
Open your browser at http://localhost:8080/examples/ to show the examples directory, click on the examples to run them.
|
|
541
380
|
|
|
542
|
-
The '
|
|
381
|
+
The 'pnpm start' command will watch for changes to flexlayout and example source, so you can make changes to the code
|
|
543
382
|
and then refresh the browser to see the result.
|
|
544
383
|
|
|
545
|
-
To run the
|
|
546
|
-
|
|
547
|
-
```
|
|
548
|
-
yarn cypress
|
|
549
|
-
```
|
|
550
|
-
|
|
551
|
-

|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
To build the npm distribution run 'yarn build', this will create the artifacts in the dist dir.
|
|
384
|
+
To build the npm distribution run 'pnpm build', this will create the artifacts in the dist dir.
|
|
555
385
|
|
|
556
386
|
## Alternative Layout Managers
|
|
557
387
|
|
|
558
388
|
| Name | Repository |
|
|
559
389
|
| ------------- |:-------------|
|
|
560
|
-
| rc-dock | https://github.com/ticlo/rc-dock |
|
|
561
|
-
| Dockview | https://dockview.dev/ |
|
|
562
|
-
| lumino | https://github.com/jupyterlab/lumino |
|
|
390
|
+
| rc-dock | https://github.com/ticlo/rc-dock |
|
|
391
|
+
| Dockview | https://dockview.dev/ |
|
|
392
|
+
| lumino | https://github.com/jupyterlab/lumino |
|
|
563
393
|
| golden-layout | https://github.com/golden-layout/golden-layout |
|
|
564
394
|
| react-mosaic | https://github.com/nomcopter/react-mosaic |
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export {};
|