@aptre/flex-layout 0.2.4 → 0.3.0-beta.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 (112) hide show
  1. package/README.md +154 -311
  2. package/dist/DockLocation.d.ts +2 -2
  3. package/dist/DropInfo.d.ts +4 -4
  4. package/dist/I18nLabel.d.ts +7 -9
  5. package/dist/Rect.d.ts +14 -1
  6. package/dist/Types.d.ts +16 -0
  7. package/dist/index.d.ts +21 -22
  8. package/dist/index.mjs +4675 -4830
  9. package/dist/model/Actions.d.ts +40 -23
  10. package/dist/model/BorderNode.d.ts +10 -14
  11. package/dist/model/BorderSet.d.ts +1 -2
  12. package/dist/model/IJsonModel.d.ts +697 -35
  13. package/dist/model/LayoutWindow.d.ts +28 -0
  14. package/dist/model/Model.d.ts +29 -24
  15. package/dist/model/Node.d.ts +5 -5
  16. package/dist/model/RowNode.d.ts +5 -6
  17. package/dist/model/TabNode.d.ts +15 -8
  18. package/dist/model/TabSetNode.d.ts +13 -10
  19. package/dist/view/BorderTab.d.ts +2 -0
  20. package/dist/view/Icons.d.ts +1 -0
  21. package/dist/view/Layout.d.ts +95 -116
  22. package/dist/view/Row.d.ts +1 -0
  23. package/dist/view/SizeTracker.d.ts +10 -0
  24. package/dist/view/Utils.d.ts +11 -1
  25. package/package.json +21 -25
  26. package/style/_base.scss +138 -32
  27. package/style/dark.css +145 -40
  28. package/style/dark.css.map +1 -1
  29. package/style/dark.scss +3 -1
  30. package/style/gray.css +144 -39
  31. package/style/gray.css.map +1 -1
  32. package/style/gray.scss +2 -0
  33. package/style/light.css +147 -42
  34. package/style/light.css.map +1 -1
  35. package/style/light.scss +4 -2
  36. package/style/rounded.css +697 -0
  37. package/style/rounded.css.map +1 -0
  38. package/style/rounded.scss +193 -0
  39. package/style/underline.css +145 -40
  40. package/style/underline.css.map +1 -1
  41. package/style/underline.scss +2 -0
  42. package/tsconfig.json +4 -5
  43. package/typedoc/assets/hierarchy.js +1 -0
  44. package/typedoc/assets/highlight.css +18 -18
  45. package/typedoc/assets/icons.js +17 -14
  46. package/typedoc/assets/icons.svg +1 -1
  47. package/typedoc/assets/main.js +5 -4
  48. package/typedoc/assets/navigation.js +1 -1
  49. package/typedoc/assets/search.js +1 -1
  50. package/typedoc/assets/style.css +1422 -1224
  51. package/typedoc/classes/Action.html +2 -2
  52. package/typedoc/classes/Actions.html +65 -52
  53. package/typedoc/classes/BorderNode.html +26 -30
  54. package/typedoc/classes/BorderSet.html +2 -2
  55. package/typedoc/classes/DockLocation.html +9 -9
  56. package/typedoc/classes/DropInfo.html +3 -3
  57. package/typedoc/classes/Layout.html +99 -83
  58. package/typedoc/classes/LayoutWindow.html +12 -0
  59. package/typedoc/classes/Model.html +44 -40
  60. package/typedoc/classes/Node.html +12 -12
  61. package/typedoc/classes/Orientation.html +5 -5
  62. package/typedoc/classes/Rect.html +18 -11
  63. package/typedoc/classes/RowNode.html +16 -17
  64. package/typedoc/classes/TabNode.html +40 -34
  65. package/typedoc/classes/TabSetNode.html +40 -41
  66. package/typedoc/enums/CLASSES.html +94 -78
  67. package/typedoc/enums/I18nLabel.html +11 -13
  68. package/typedoc/enums/ICloseType.html +4 -4
  69. package/typedoc/hierarchy.html +1 -1
  70. package/typedoc/index.html +1 -51
  71. package/typedoc/interfaces/IBorderAttributes.html +32 -9
  72. package/typedoc/interfaces/IDraggable.html +1 -1
  73. package/typedoc/interfaces/IDropTarget.html +1 -1
  74. package/typedoc/interfaces/IGlobalAttributes.html +190 -47
  75. package/typedoc/interfaces/IIcons.html +5 -4
  76. package/typedoc/interfaces/IJsonBorderNode.html +32 -9
  77. package/typedoc/interfaces/IJsonModel.html +3 -2
  78. package/typedoc/interfaces/IJsonPopout.html +3 -0
  79. package/typedoc/interfaces/IJsonRect.html +5 -0
  80. package/typedoc/interfaces/IJsonRowNode.html +8 -5
  81. package/typedoc/interfaces/IJsonTabNode.html +73 -15
  82. package/typedoc/interfaces/IJsonTabSetNode.html +68 -23
  83. package/typedoc/interfaces/ILayoutProps.html +36 -22
  84. package/typedoc/interfaces/IRowAttributes.html +8 -5
  85. package/typedoc/interfaces/ITabAttributes.html +73 -15
  86. package/typedoc/interfaces/ITabRenderValues.html +5 -3
  87. package/typedoc/interfaces/ITabSetAttributes.html +63 -24
  88. package/typedoc/interfaces/ITabSetRenderValues.html +8 -7
  89. package/typedoc/types/DragRectRenderCallback.html +1 -1
  90. package/typedoc/types/IBorderLocation.html +1 -1
  91. package/typedoc/types/ITabLocation.html +1 -1
  92. package/typedoc/types/NodeMouseEvent.html +1 -1
  93. package/typedoc/types/ShowOverflowMenuCallback.html +1 -1
  94. package/typedoc/types/TabSetPlaceHolderCallback.html +1 -1
  95. package/typedoc/variables/FlexLayoutVersion.html +1 -0
  96. package/dist/DragDrop.d.ts +0 -15
  97. package/dist/model/SplitterNode.d.ts +0 -5
  98. package/typedoc/classes/DragDrop.html +0 -10
  99. package/typedoc/classes/SplitterNode.html +0 -13
  100. package/typedoc/interfaces/ICustomDropDestination.html +0 -10
  101. package/typedoc/interfaces/IFontValues.html +0 -5
  102. package/typedoc/interfaces/ILayoutState.html +0 -9
  103. package/typedoc/interfaces/ITitleObject.html +0 -3
  104. package/typedoc/types/CustomDragCallback.html +0 -1
  105. package/typedoc/types/FloatingTabPlaceholderRenderCallback.html +0 -1
  106. package/typedoc/types/IInsets.html +0 -1
  107. package/typedoc/types/IconFactory.html +0 -1
  108. package/typedoc/types/TitleFactory.html +0 -1
  109. /package/dist/{PopupMenu.d.ts → view/DragContainer.d.ts} +0 -0
  110. /package/dist/view/{FloatingWindow.d.ts → Overlay.d.ts} +0 -0
  111. /package/dist/view/{FloatingWindowTab.d.ts → PopoutWindow.d.ts} +0 -0
  112. /package/dist/view/{TabFloating.d.ts → PopupMenu.d.ts} +0 -0
package/README.md CHANGED
@@ -4,13 +4,17 @@
4
4
 
5
5
  FlexLayout is a layout manager that arranges React components in multiple tab sets, tabs can be resized and moved.
6
6
 
7
+ ![FlexLayout Demo Screenshot](Screenshot_light.png?raw=true "FlexLayout Demo Screenshot")
8
+
7
9
  **This is a maintenance fork of react-flexlayout. Check out the original project at the link above.**
8
10
 
9
11
  To install this fork: `yarn add @aptre/flex-layout` and use `@aptre/flex-layout` in place of `flexlayout-react`.
10
12
 
11
- [Run the Demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.7/demo/index.html)
13
+ [Run the Demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/demo/index.html)
14
+
15
+ Try it now using [JSFiddle](https://jsfiddle.net/fvd9btea/)
12
16
 
13
- [API Doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.7/typedoc/index.html)
17
+ [API Doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.8/typedoc/index.html)
14
18
 
15
19
  FlexLayout's only dependency is React.
16
20
 
@@ -18,23 +22,21 @@ Features:
18
22
  * splitters
19
23
  * tabs
20
24
  * tab dragging and ordering
21
- * tabset dragging (move all the tabs in a tabset in one operation)
22
- * dock to tabset or edge of frame
23
- * maximize tabset (double click tabset header or use icon)
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)
24
28
  * tab overflow (show menu when tabs overflow, scroll tabs using mouse wheel)
25
- * border tabsets
29
+ * border tab sets
26
30
  * popout tabs into new browser windows
27
31
  * submodels, allow layouts inside layouts
28
32
  * tab renaming (double click tab text to rename)
29
- * theming - light, underline, gray and dark
30
- * touch events - works on mobile devices (iPad, Android)
31
- * add tabs using drag, indirect drag, add to active tabset, add to tabset by id
32
- * preferred pixel size tabsets (try to keep their size when window resizes)
33
- * headed tabsets
34
- * tab and tabset attributes: enableHeader, enableTabStrip, enableDock, enableDrop...
35
- * 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
36
38
  * component state is preserved when tabs are moved
37
- * typescript type declarations included
39
+ * typescript type declarations
38
40
 
39
41
  ## Installation
40
42
 
@@ -66,7 +68,7 @@ or by adding the css to your html:
66
68
 
67
69
  ## Usage
68
70
 
69
- The `<Layout>` component renders the tabsets and splitters, it takes the following props:
71
+ The `<Layout>` component renders the tab sets and splitters, it takes the following props:
70
72
 
71
73
 
72
74
  #### Required props:
@@ -77,7 +79,7 @@ The `<Layout>` component renders the tabsets and splitters, it takes the followi
77
79
  | model | the layout model |
78
80
  | factory | a factory function for creating React components |
79
81
 
80
- Additional [optional props](#optional-props)
82
+ Additional [optional props](#optional-layout-props)
81
83
 
82
84
  The model is tree of Node objects that define the structure of the layout.
83
85
 
@@ -145,62 +147,46 @@ function App() {
145
147
  }
146
148
  ```
147
149
 
148
- 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.
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.
149
151
 
150
- Try it now using [JSFiddle](https://jsfiddle.net/10kmLzvu/)
152
+ Try it now using [JSFiddle](https://jsfiddle.net/fvd9btea/)
151
153
 
152
154
  A simple Typescript example can be found here:
153
155
 
154
156
  https://github.com/nealus/FlexLayout_cra_example
155
157
 
156
- The model is built up using 4 types of 'node':
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':
157
166
 
158
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)
159
- , child 'rows' will render in the opposite orientation to their parent.
168
+ , child 'rows' will render in the opposite orientation to their parent row.
160
169
 
161
170
  * tabset - tabsets contain a list of tabs and the index of the selected tab
162
171
 
163
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.
164
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
+
165
178
  * border - borders contain a list of tabs and the index of the selected tab, they can only be used in the borders
166
179
  top level element.
167
180
 
168
- The main layout is defined with rows within rows that contain tabsets that themselves contain tabs.
181
+ The tree structure for the JSON model is well defined as Typescript interfaces, see [JSON Model](#json-model-definition)
169
182
 
170
- The model json contains 3 top level elements:
171
-
172
- * global - where global options are defined
173
- * layout - where the main row/tabset/tabs layout hierarchy is defined
174
- * 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.
175
184
 
176
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).
177
186
 
178
- NOTE: the easiest way to create your initial layout JSON is to use the [demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.7/demo/index.html) app, modify one of the
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
179
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.
180
189
 
181
- To control where nodes can be dropped you can add a callback function to the model:
182
-
183
- ```
184
- model.setOnAllowDrop(this.allowDrop);
185
- ```
186
-
187
- example:
188
- ```javascript
189
- allowDrop(dragNode, dropInfo) {
190
- let dropNode = dropInfo.node;
191
-
192
- // prevent non-border tabs dropping into borders
193
- if (dropNode.getType() == "border" && (dragNode.getParent() == null || dragNode.getParent().getType() != "border"))
194
- return false;
195
-
196
- // prevent border tabs dropping into main layout
197
- if (dropNode.getType() != "border" && (dragNode.getParent() != null && dragNode.getParent().getType() == "border"))
198
- return false;
199
-
200
- return true;
201
- }
202
- ```
203
-
204
190
  By changing global or node attributes you can change the layout appearance and functionality, for example:
205
191
 
206
192
  Setting tabSetEnableTabStrip:false in the global options would change the layout into a multi-splitter (without
@@ -209,255 +195,28 @@ tabs or drag and drop).
209
195
  ```
210
196
  global: {tabSetEnableTabStrip:false},
211
197
  ```
212
- ## Floating Tabs (Popouts)
213
-
214
- Tabs can be rendered into external browser windows (for use in multi-monitor setups)
215
- by configuring them with the enableFloat attribute. When this attribute is present
216
- an additional icon is shown in the tab header bar allowing the tab to be popped out
217
- into an external window.
218
-
219
- For popouts to work there needs to be an additional html page 'popout.html' hosted
220
- at the same location as the main page (copy the one from examples/demo). The popout.html is the host page for the
221
- popped out tab, the styles from the main page will be copied into it at runtime.
222
-
223
- Because popouts are rendering into a different document to the main layout any code in the popped out
224
- tab that uses the global document or window objects will not work correctly (for example custom popup menus),
225
- they need to instead use the document/window of the popout. To get the document/window of the popout use the
226
- following method on one of the elements rendered in the popout (for example a ref or target in an event handler):
227
-
228
- ```
229
- const currentDocument = this.selfRef.current.ownerDocument;
230
- const currentWindow = currentDocument.defaultView!;
231
- ```
232
-
233
- In the above code selfRef is a React ref to the toplevel element in the tab being rendered.
234
-
235
- Note: some libraries support popout windows by allowing you to specify the document to use,
236
- for example see the getDocument() callback in agGrid at https://www.ag-grid.com/javascript-grid-callbacks/
237
-
238
- ## Optional Props
239
-
240
-
241
- | Prop | Description |
242
- | --------------- | ----------------- |
243
- | font | the tab font (overrides value in css). Example: font={{size:"12px", style:"italic"}}|
244
- | 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 |
245
- | 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 |
246
- | onRenderTab | function called when rendering a tab, allows leading (icon), content section, buttons and name used in overflow menu to be customized |
247
- | onRenderTabSet | function called when rendering a tabset, allows header and buttons to be customized |
248
- | onModelChange | function called when model has changed |
249
- | 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. |
250
- | classNameMapper | function called with default css class name, return value is class name that will be used. Mainly for use with css modules.|
251
- | i18nMapper | function called for each I18nLabel to allow user translation, currently used for tab and tabset move messages, return undefined to use default values |
252
- | supportsPopout | if left undefined will do simple check based on userAgent |
253
- | popoutURL | URL of popout window relative to origin, defaults to popout.html |
254
- | 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 |
255
- | 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. |
256
- | onRenderDragRect | callback for rendering the drag rectangles |
257
- | onRenderFloatingTabPlaceholder | callback for rendering the floating tab placeholder |
258
- | onContextMenu | callback for handling context actions on tabs and tabsets |
259
- | onAuxMouseClick | callback for handling mouse clicks on tabs and tabsets with alt, meta, shift keys, also handles center mouse clicks |
260
- | onShowOverflowMenu | callback for handling the display of the tab overflow menu |
261
- | onTabSetPlaceHolder | callback for rendering a placeholder when a tabset is empty |
262
- | 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 |
263
- | 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 |
264
-
265
-
266
- ## Global Config attributes
267
-
268
- Attributes allowed in the 'global' element
269
-
270
-
271
- | Attribute | Default | Description |
272
- |-------------------------------|:-------:|--------------------------------------------------------------------------------------------------------------|
273
- | splitterSize | 8 | width in pixels of all splitters between tabsets/borders |
274
- | splitterExtra | 0 | additional width in pixels of the splitter hit test area |
275
- | legacyOverflowMenu | false | use the legacy text only overflow menu |
276
- | enableEdgeDock | true | |
277
- | enableRotateBorderIcons | true | boolean indicating if tab icons should rotate with the text in the left and right borders |
278
- | tabEnableClose | true | allow user to close all tabs via close button |
279
- | tabCloseType | 1 | see values in ICloseType |
280
- | tabEnableDrag | true | allow user to drag all tabs to new location |
281
- | tabEnableRename | true | allow user to rename all tabs by double clicking |
282
- | tabEnableFloat | false | enable popouts in all tabs (in popout capable browser) |
283
- | tabClassName | null | |
284
- | tabContentClassName | null | |
285
- | tabIcon | null | |
286
- | tabEnableRenderOnDemand | true | whether to avoid rendering component until tab is visible |
287
- | tabDragSpeed | 0.3 | CSS transition speed of drag outlines (in seconds) |
288
- | tabBorderWidth | -1 | width when added to border, -1 will use border size |
289
- | tabBorderHeight | -1 | height when added to border, -1 will use border size |
290
- | tabSetEnableDeleteWhenEmpty | true | |
291
- | tabSetEnableDrop | true | allow user to drag tabs into all tabsets |
292
- | tabSetEnableDrag | true | allow user to drag tabs out of all tabsets |
293
- | tabSetEnableDivide | true | allow user to drag tabs to region of all tabsets, splitting into new tabset |
294
- | tabSetEnableMaximize | true | allow user to maximize all tabsets to fill view via maximize button |
295
- | tabSetEnableClose | false | allow user to close all tabsets via close button |
296
- | tabSetAutoSelectTab | true | whether to select new/moved tabs in all tabsets |
297
- | tabSetClassNameTabStrip | null | height in pixels of tab strips in all tabsets |
298
- | tabSetEnableSingleTabStretch | false | if a tabset has only a single tab then stretch the single tab to fill area and display in a header style |
299
- | tabSetClassNameHeader | null | |
300
- | tabSetEnableTabStrip | true | enable tab strip and allow multiple tabs in all tabsets |
301
- | tabSetHeaderHeight | 0 | height of tabset header in pixels; if left as 0 then the value will be calculated from the current fontSize |
302
- | tabSetTabStripHeight | 0 | height of tabset tab bar in pixels; if left as 0 then the value will be calculated from the current fontSize |
303
- | borderBarSize | 0 | size of the border bars in pixels; if left as 0 then the value will be calculated from the current fontSize |
304
- | borderEnableAutoHide | false | hide border if it has zero tabs |
305
- | borderEnableDrop | true | allow user to drag tabs into this border |
306
- | borderAutoSelectTabWhenOpen | true | whether to select new/moved tabs in border when the border is already open |
307
- | borderAutoSelectTabWhenClosed | false | whether to select new/moved tabs in border when the border is curently closed |
308
- | borderClassName | null | |
309
- | borderSize | 200 | initial width in pixels for left/right borders, height for top/bottom borders |
310
- | borderMinSize | 0 | minimum width in pixels for left/right borders, height for top/bottom borders |
311
- | tabSetMinHeight | 0 | minimum width (in px) for all tabsets |
312
- | tabSetMinWidth | 0 | minimum height (in px) for all tabsets |
313
- | tabSetTabLocation | top | show tabs in location top or bottom |
314
- | rootOrientationVertical | false | the top level 'row' will layout horizontally by default, set this option true to make it layout vertically |
315
-
316
-
317
- ## Row Attributes
318
-
319
- Attributes allowed in nodes of type 'row'.
320
-
321
- | Attribute | Default | Description |
322
- | ------------- |:-------------:| -----|
323
- | type | row | |
324
- | weight | 100 | |
325
- | width | null | preferred pixel width |
326
- | height | null | preferred pixel height |
327
- | children | *required* | a list of row and tabset nodes |
328
198
 
329
- ## Tab Attributes
330
-
331
- Attributes allowed in nodes of type 'tab'.
332
-
333
- Inherited defaults will take their value from the associated global attributes (see above).
199
+ ## Model Actions
334
200
 
201
+ Once the model json has been loaded all changes to the model are applied through actions.
335
202
 
336
- | Attribute | Default | Description |
337
- | ------------- |:-------------:| -----|
338
- | type | tab | |
339
- | name | *required* | name of tab to be displayed in the tab button |
340
- | altName | *optional* | if there is no name specifed then this value will be used in the overflow menu |
341
- | component | *required* | string identifying which component to run (for factory) |
342
- | config | null | a place to hold json config for the hosted component |
343
- | id | auto generated | |
344
- | helpText | *optional* | An optional help text for the tab to be displayed upon tab hover. |
345
- | enableClose | *inherited* | allow user to close tab via close button |
346
- | closeType | *inherited* | see values in ICloseType |
347
- | enableDrag | *inherited* | allow user to drag tab to new location |
348
- | enableRename | *inherited* | allow user to rename tabs by double clicking |
349
- | enableFloat | *inherited* | enable popout (in popout capable browser) |
350
- | floating | false | |
351
- | className | *inherited* | class applied to tab button |
352
- | contentClassName | *inherited* | class applied to tab content |
353
- | tabsetClassName | undefined | class applied to parent tabset when this is the only tab and it is stretched to fill the tabset |
354
- | icon | *inherited* | |
355
- | enableRenderOnDemand | *inherited* | whether to avoid rendering component until tab is visible |
356
- | borderWidth | *inherited* | width when added to border, -1 will use border size |
357
- | borderHeight | *inherited* | height when added to border, -1 will use border size |
358
-
359
- Tab nodes have a getExtraData() method that initially returns an empty object, this is the place to
360
- add extra data to a tab node that will not be saved.
361
-
362
-
363
- ## TabSet Attributes
364
-
365
- Attributes allowed in nodes of type 'tabset'.
366
-
367
- Inherited defaults will take their value from the associated global attributes (see above).
368
-
369
- Note: tabsets can be dynamically created as tabs are moved and deleted when all their tabs are removed (unless enableDeleteWhenEmpty is false).
370
-
371
- | Attribute | Default | Description |
372
- |-------------------------|:-------------:|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
373
- | type | tabset | |
374
- | weight | 100 | relative weight for sizing of this tabset in parent row |
375
- | width | null | preferred pixel width |
376
- | height | null | preferred pixel height |
377
- | name | null | named tabsets will show a header bar above the tabs |
378
- | config | null | a place to hold json config used in your own code |
379
- | selected | 0 | index of selected/visible tab in tabset |
380
- | 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 |
381
- | maximized | false | whether tabset is currently maximized to fill view |
382
- | enableClose | false | allow user to close tabset via a close button |
383
- | id | auto generated | |
384
- | children | *required* | a list of tab nodes |
385
- | enableDeleteWhenEmpty | *inherited* | |
386
- | enableDrop | *inherited* | allow user to drag tabs into this tabset |
387
- | enableDrag | *inherited* | allow user to drag tabs out this tabset |
388
- | enableDivide | *inherited* | allow user to drag tabs to region of this tabset, splitting into new tabset |
389
- | enableMaximize | *inherited* | allow user to maximize tabset to fill view via maximize button |
390
- | enableSingleTabStretch | *inherited* | if the tabset has only a single tab then stretch the single tab to fill area and display in a header style |
391
- | autoSelectTab | *inherited* | whether to select new/moved tabs in tabset |
392
- | classNameTabStrip | *inherited* | |
393
- | classNameHeader | *inherited* | |
394
- | enableTabStrip | *inherited* | enable tab strip and allow multiple tabs in this tabset |
395
- | headerHeight | *inherited* | |
396
- | tabStripHeight | *inherited* | height in pixels of tab strip |
397
- | tabLocation | *inherited* | show tabs in location top or bottom |
398
- | minHeight | *inherited* | minimum height (in px) for this tabset |
399
- | minWidth | *inherited* | minimum width (in px) for this tabset |
400
-
401
- ## Border Attributes
402
-
403
- Attributes allowed in nodes of type 'border'.
404
-
405
- Inherited defaults will take their value from the associated global attributes (see above).
406
-
407
-
408
- | Attribute | Default | Description |
409
- | ------------- |:-------------:| -----|
410
- | type | border | |
411
- | size | *inherited* | size of the tab body when selected |
412
- | minSize | *inherited* | |
413
- | selected | -1 | index of selected/visible tab in border; -1 means no tab unselected / border closed |
414
- | id | auto generated | border_ + border name e.g. border_left |
415
- | config | null | a place to hold json config used in your own code |
416
- | show | true | show/hide this border |
417
- | enableAutoHide | false | hide border if it has zero tabs |
418
- | children | *required* | a list of tab nodes |
419
- | barSize | *inherited* | size of this border's bar in pixels; if left as 0 then the value will be calculated from the current fontSize |
420
- | enableDrop | *inherited* | |
421
- | autoSelectTabWhenOpen | *inherited* | whether to select new/moved tabs in border when the border is already open |
422
- | autoSelectTabWhenClosed | *inherited* | whether to select new/moved tabs in border when the border is currently closed |
423
- | className | *inherited* | class applied to tab button |
424
203
 
425
- ## Model Actions
204
+ You apply actions using the `Model.doAction()` method.
426
205
 
427
- All changes to the model are applied through actions.
428
- You can intercept actions resulting from GUI changes before they are applied by
429
- implementing the `onAction` callback property of the `Layout`.
430
- You can also apply actions directly using the `Model.doAction()` method.
431
- 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
432
207
  generators (typically accessed as `FlexLayout.Actions.<actionName>`):
433
208
 
434
- | Action Creator | Description |
435
- | ------------- | -----|
436
- | 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` |
437
- | 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 |
438
- | Actions.deleteTab(tabNodeId) | delete the given tab |
439
- | Actions.renameTab(tabNodeId, newName) | rename the given tab |
440
- | Actions.selectTab(tabNodeId) | select the given tab |
441
- | Actions.setActiveTabset(tabsetNodeId) | set the tabset as the active tabset |
442
- | Actions.adjustSplit(splitterNodeId, value) | adjust the size of the given splitter |
443
- | Actions.adjustBorderSplit(borderNodeId, pos) | updates the size of the given border node |
444
- | Actions.maximizeToggle(tabsetNodeId) | toggles whether the given tabset node is maximized |
445
- | Actions.updateModelAttributes(attributes) | updates the global attributes |
446
- | Actions.updateNodeAttributes(nodeId, attributes) | updates the attributes of the given node |
447
- | Actions.floatTab(nodeId) | popout the tab into a floating browser window |
448
- | 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)
449
210
 
450
211
  ### Examples
451
212
 
452
213
  ```js
453
214
  model.doAction(FlexLayout.Actions.updateModelAttributes({
454
- splitterSize:40,
455
- tabSetHeaderHeight:40,
456
- tabSetTabStripHeight:40
215
+ splitterSize:40
457
216
  }));
458
217
  ```
459
218
 
460
- The above example would increase the size of the splitters, tabset headers and tabs, this could be used to make
219
+ The above example would increase the size of the splitters, this could be used to make
461
220
  adjusting the layout easier on a small device.
462
221
 
463
222
  ```js
@@ -467,64 +226,148 @@ model.doAction(FlexLayout.Actions.addNode(
467
226
  ```
468
227
 
469
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
+
470
230
  Note: you can get the id of a node (e.g., the node returned by the `addNode`
471
231
  action) using the method `node.getId()`.
472
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`).
473
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
+
474
277
 
475
278
  ## Layout Component Methods to Create New Tabs
476
279
 
477
- Methods on the Layout Component for adding tabs, the tabs are specified by their layout json.
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)
478
283
 
479
284
  Example:
480
285
 
481
286
  ```
482
- this.layoutRef.current.addTabToTabSet("NAVIGATION", {type:"tab", component:"grid", name:"a grid"});
287
+ layoutRef.current.addTabToTabSet("NAVIGATION", {type:"tab", component:"grid", name:"a grid"});
483
288
  ```
484
- This would add a new grid component to the tabset with id "NAVIGATION" (where this.layoutRef is a ref to the Layout element, see https://reactjs.org/docs/refs-and-the-dom.html ).
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 ).
485
290
 
486
291
 
487
- | Layout Method | Description |
488
- | ------------- | -----|
489
- | addTabToTabSet(tabsetId, json) | adds a new tab to the tabset with the given Id |
490
- | addTabToActiveTabSet(json) | adds a new tab to the active tabset |
491
- | 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 |
492
- | 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 |
493
- | moveTabWithDragAndDrop( node, dragText) | Move a tab/tabset using drag and drop triggered from a custom event |
494
292
 
495
293
  ## Tab Node Events
496
294
 
497
- You can handle events on nodes by adding a listener, this would typically be done
498
- in the components constructor() method.
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:
499
297
 
500
298
  Example:
501
299
  ```
502
- constructor(props) {
503
- super(props);
504
- let config = this.props.node.getConfig();
505
-
506
- // save state in flexlayout node tree
507
- this.props.node.setEventListener("save", (p) => {
508
- config.subject = this.subject;
509
- };
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
+ }, []);
510
308
  }
511
309
 
512
310
  ```
513
311
 
514
312
  | Event | parameters | Description |
515
313
  | ------------- |:-------------:| -----|
516
- | resize | | called when tab is resized during layout, called before it is rendered with the new size|
517
- | close | | called when a tab is closed |
518
- | visibility | | called when the visibility of a tab changes |
519
- | save | | called before a tabnode is serialized to json, use to save node config by adding data to the object returned by node.getConfig()|
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()|
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.
520
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
521
364
 
522
365
  ## Alternative Layout Managers
523
366
 
524
367
  | Name | Repository |
525
368
  | ------------- |:-------------|
526
- | rc-dock | https://github.com/ticlo/rc-dock |
527
- | Dockview | https://dockview.dev/ |
528
- | lumino | https://github.com/jupyterlab/lumino |
369
+ | rc-dock | https://github.com/ticlo/rc-dock |
370
+ | Dockview | https://dockview.dev/ |
371
+ | lumino | https://github.com/jupyterlab/lumino |
529
372
  | golden-layout | https://github.com/golden-layout/golden-layout |
530
373
  | react-mosaic | https://github.com/nomcopter/react-mosaic |
@@ -1,6 +1,6 @@
1
- import { Orientation } from "./Orientation.js";
1
+ import { Orientation } from "./Orientation";
2
2
  export declare class DockLocation {
3
- static values: Record<string, DockLocation>;
3
+ static values: Map<string, DockLocation>;
4
4
  static TOP: DockLocation;
5
5
  static BOTTOM: DockLocation;
6
6
  static LEFT: DockLocation;
@@ -1,7 +1,7 @@
1
- import { DockLocation } from "./DockLocation.js";
2
- import { IDropTarget } from "./model/IDropTarget.js";
3
- import { Node } from "./model/Node.js";
4
- import { Rect } from "./Rect.js";
1
+ import { DockLocation } from "./DockLocation";
2
+ import { IDropTarget } from "./model/IDropTarget";
3
+ import { Node } from "./model/Node";
4
+ import { Rect } from "./Rect";
5
5
  export declare class DropInfo {
6
6
  node: Node & IDropTarget;
7
7
  rect: Rect;
@@ -1,14 +1,12 @@
1
1
  export declare 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
  }