You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+32-34Lines changed: 32 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,17 +30,15 @@ Features:
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, gray and dark
33
+
* theming - light, underline, gray and dark
34
34
* touch events - works on mobile devices (iPad, Android)
35
35
* add tabs using drag, indirect drag, add to active tabset, add to tabset by id
36
36
* preferred pixel size tabsets (try to keep their size when window resizes)
37
37
* headed tabsets
38
38
* tab and tabset attributes: enableHeader, enableTabStrip, enableDock, enableDrop...
39
39
* customizable tabs and tabset header rendering
40
-
* esc cancels drag
41
40
* typescript type declarations included
42
41
43
-
44
42
## Installation
45
43
46
44
FlexLayout is in the npm repository. Simply install React and FlexLayout from npm:
@@ -78,33 +76,7 @@ The `<Layout>` component renders the tabsets and splitters, it takes the followi
78
76
| model | the layout model |
79
77
| factory | a factory function for creating React components |
80
78
81
-
#### Optional props:
82
-
83
-
84
-
| Prop | Description |
85
-
| --------------- | ----------------- |
86
-
| font | the tab font (overrides value in css). Example: font={{size:"12px", style:"italic"}}|
87
-
| 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 |
88
-
| 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 |
89
-
| onRenderTab | function called when rendering a tab, allows leading (icon), content section, buttons and name used in overflow menu to be customized |
90
-
| onRenderTabSet | function called when rendering a tabset, allows header and buttons to be customized |
91
-
| onModelChange | function called when model has changed |
92
-
| 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. |
93
-
| classNameMapper | function called with default css class name, return value is class name that will be used. Mainly for use with css modules.|
94
-
| i18nMapper | function called for each I18nLabel to allow user translation, currently used for tab and tabset move messages, return undefined to use default values |
95
-
| supportsPopout | if left undefined will do simple check based on userAgent |
96
-
| popoutURL | URL of popout window relative to origin, defaults to popout.html |
97
-
| 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 |
98
-
| 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. |
99
-
| onRenderDragRect | callback for rendering the drag rectangles |
100
-
| onRenderFloatingTabPlaceholder | callback for rendering the floating tab placeholder |
101
-
| onContextMenu | callback for handling context actions on tabs and tabsets |
102
-
| onAuxMouseClick | callback for handling mouse clicks on tabs and tabsets with alt, meta, shift keys, also handles center mouse clicks |
103
-
| onShowOverflowMenu | callback for handling the display of the tab overflow menu |
104
-
| onTabSetPlaceHolder | callback for rendering a placeholder when a tabset is empty |
105
-
| 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 |
106
-
| 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 |
107
-
79
+
Additional [optional props](#optional-props)
108
80
109
81
The model is tree of Node objects that define the structure of the layout.
110
82
@@ -185,17 +157,15 @@ class Main extends React.Component {
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.
195
165
196
166
Try it now using [JSFiddle](https://jsfiddle.net/10kmLzvu/)
197
167
198
-
A simple Create React App (CRA) example (using typescript) can be found here:
168
+
A simple Typescript example can be found here:
199
169
200
170
https://github.com/nealus/FlexLayout_cra_example
201
171
@@ -330,6 +300,34 @@ In the above code selfRef is a React ref to the toplevel element in the tab bein
330
300
Note: some libraries support popout windows by allowing you to specify the document to use,
331
301
for example see the getDocument() callback in agGrid at https://www.ag-grid.com/javascript-grid-callbacks/
332
302
303
+
## Optional Props
304
+
305
+
306
+
| Prop | Description |
307
+
| --------------- | ----------------- |
308
+
| font | the tab font (overrides value in css). Example: font={{size:"12px", style:"italic"}}|
309
+
| 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 |
310
+
| 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 |
311
+
| onRenderTab | function called when rendering a tab, allows leading (icon), content section, buttons and name used in overflow menu to be customized |
312
+
| onRenderTabSet | function called when rendering a tabset, allows header and buttons to be customized |
313
+
| onModelChange | function called when model has changed |
314
+
| 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. |
315
+
| classNameMapper | function called with default css class name, return value is class name that will be used. Mainly for use with css modules.|
316
+
| i18nMapper | function called for each I18nLabel to allow user translation, currently used for tab and tabset move messages, return undefined to use default values |
317
+
| supportsPopout | if left undefined will do simple check based on userAgent |
318
+
| popoutURL | URL of popout window relative to origin, defaults to popout.html |
319
+
| 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 |
320
+
| 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. |
321
+
| onRenderDragRect | callback for rendering the drag rectangles |
322
+
| onRenderFloatingTabPlaceholder | callback for rendering the floating tab placeholder |
323
+
| onContextMenu | callback for handling context actions on tabs and tabsets |
324
+
| onAuxMouseClick | callback for handling mouse clicks on tabs and tabsets with alt, meta, shift keys, also handles center mouse clicks |
325
+
| onShowOverflowMenu | callback for handling the display of the tab overflow menu |
326
+
| onTabSetPlaceHolder | callback for rendering a placeholder when a tabset is empty |
327
+
| 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 |
328
+
| 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 |
0 commit comments