flexlayout-react 0.6.10 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChangeLog.txt +12 -0
- package/README.md +45 -48
- package/declarations/model/Floating.d.ts +15 -0
- package/declarations/model/FloatingSet.d.ts +9 -0
- package/declarations/view/Icons.d.ts +0 -1
- package/declarations/view/Layout.d.ts +12 -3
- package/dist/flexlayout.js +7 -7
- package/dist/flexlayout_min.js +1 -1
- package/lib/PopupMenu.js.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib/model/Floating.js +61 -0
- package/lib/model/Floating.js.map +1 -0
- package/lib/model/FloatingSet.js +58 -0
- package/lib/model/FloatingSet.js.map +1 -0
- package/lib/view/BorderTabSet.js +4 -2
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/ErrorBoundary.js.map +1 -1
- package/lib/view/Icons.js +15 -10
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +29 -76
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/TabSet.js +3 -1
- package/lib/view/TabSet.js.map +1 -1
- package/lib/view/Utils.js.map +1 -1
- package/package.json +20 -20
- package/src/PopupMenu.tsx +5 -5
- package/src/view/BorderButton.tsx +3 -3
- package/src/view/BorderTabSet.tsx +9 -7
- package/src/view/ErrorBoundary.tsx +1 -0
- package/src/view/Icons.tsx +17 -7
- package/src/view/Layout.tsx +38 -104
- package/src/view/TabButton.tsx +3 -3
- package/src/view/TabButtonStamp.tsx +3 -3
- package/src/view/TabSet.tsx +8 -6
- package/src/view/Utils.tsx +3 -3
- package/style/_base.scss +1 -1
- package/style/dark.css +4 -3
- package/style/dark.css.map +1 -1
- package/style/dark.scss +1 -0
- package/style/gray.css +4 -3
- package/style/gray.css.map +1 -1
- package/style/gray.scss +1 -0
- package/style/light.css +4 -3
- package/style/light.css.map +1 -1
- package/style/light.scss +1 -0
- package/style/underline.css +13 -7
- package/style/underline.css.map +1 -1
- package/style/underline.scss +11 -5
- package/dist/flexlayout.js.zip +0 -0
- package/dist/flexlayout_min.js.zip +0 -0
package/ChangeLog.txt
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
0.7.2
|
|
2
|
+
New Layout JSON tabs to demo
|
|
3
|
+
Added --color-icon css rootOrientationVertical
|
|
4
|
+
|
|
5
|
+
0.7.1
|
|
6
|
+
Fix for #310 - Added new layout method: moveTabWithDragAndDrop(node) to allow tab dragging to be
|
|
7
|
+
started from custom code.
|
|
8
|
+
|
|
9
|
+
0.7.0
|
|
10
|
+
Updated dependencies, in particular changed React peer dependency to React 18
|
|
11
|
+
Made changes for React 18
|
|
12
|
+
|
|
1
13
|
0.6.10
|
|
2
14
|
fix for #312, chrome warning for wheel event listener
|
|
3
15
|
|
package/README.md
CHANGED
|
@@ -8,11 +8,11 @@ FlexLayout is a layout manager that arranges React components in multiple tab se
|
|
|
8
8
|
|
|
9
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.7/demo/index.html)
|
|
12
12
|
|
|
13
|
-
Try it now using [JSFiddle](https://jsfiddle.net/
|
|
13
|
+
Try it now using [JSFiddle](https://jsfiddle.net/10kmLzvu/)
|
|
14
14
|
|
|
15
|
-
[API Doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.
|
|
15
|
+
[API Doc](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.7/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
|
|
|
@@ -27,19 +27,17 @@ Features:
|
|
|
27
27
|
* maximize tabset (double click tabset header or use icon)
|
|
28
28
|
* tab overflow (show menu when tabs overflow, scroll tabs using mouse wheel)
|
|
29
29
|
* border tabsets
|
|
30
|
-
* popout tabs into new browser windows
|
|
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
|
-
*
|
|
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
|
-
* supports overriding css class names via the classNameMapper prop, for use in css modules
|
|
43
41
|
|
|
44
42
|
## Installation
|
|
45
43
|
|
|
@@ -55,11 +53,11 @@ Import React and FlexLayout in your modules:
|
|
|
55
53
|
|
|
56
54
|
```
|
|
57
55
|
import * as React from "react";
|
|
58
|
-
import
|
|
56
|
+
import { createRoot } from "react-dom/client";
|
|
59
57
|
import * as FlexLayout from "flexlayout-react";
|
|
60
58
|
```
|
|
61
59
|
|
|
62
|
-
Include the light, gray or dark style in your html:
|
|
60
|
+
Include the light, underline, gray or dark style in your html:
|
|
63
61
|
|
|
64
62
|
```
|
|
65
63
|
<link rel="stylesheet" href="node_modules/flexlayout-react/style/light.css" />
|
|
@@ -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
|
-
|
|
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
|
|
|
@@ -161,7 +133,7 @@ var json = {
|
|
|
161
133
|
|
|
162
134
|
```
|
|
163
135
|
import * as React from "react";
|
|
164
|
-
import
|
|
136
|
+
import { createRoot } from "react-dom/client";
|
|
165
137
|
import * as FlexLayout from "flexlayout-react";
|
|
166
138
|
|
|
167
139
|
class Main extends React.Component {
|
|
@@ -185,15 +157,15 @@ class Main extends React.Component {
|
|
|
185
157
|
}
|
|
186
158
|
}
|
|
187
159
|
|
|
188
|
-
|
|
160
|
+
const root = createRoot(document.getElementById("container"));
|
|
161
|
+
root.render(<Main/>);
|
|
189
162
|
```
|
|
190
|
-
(See the examples for full source code)
|
|
191
163
|
|
|
192
164
|
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.
|
|
193
165
|
|
|
194
|
-
Try it now using [JSFiddle](https://jsfiddle.net/
|
|
166
|
+
Try it now using [JSFiddle](https://jsfiddle.net/10kmLzvu/)
|
|
195
167
|
|
|
196
|
-
A simple
|
|
168
|
+
A simple Typescript example can be found here:
|
|
197
169
|
|
|
198
170
|
https://github.com/nealus/FlexLayout_cra_example
|
|
199
171
|
|
|
@@ -219,7 +191,7 @@ The model json contains 3 top level elements:
|
|
|
219
191
|
|
|
220
192
|
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).
|
|
221
193
|
|
|
222
|
-
NOTE: the easiest way to create your initial layout JSON is to use the [demo](https://rawgit.com/caplin/FlexLayout/demos/demos/v0.
|
|
194
|
+
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
|
|
223
195
|
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.
|
|
224
196
|
|
|
225
197
|
|
|
@@ -304,11 +276,7 @@ tabs or drag and drop).
|
|
|
304
276
|
```
|
|
305
277
|
## Floating Tabs (Popouts)
|
|
306
278
|
|
|
307
|
-
|
|
308
|
-
NOT work for any version of IE or the previous version of Edge. For unsupported browsers the popout icons
|
|
309
|
-
will not be shown and any saved layout with popouts will show with all their tabs in the main layout.
|
|
310
|
-
|
|
311
|
-
For supported browsers tabs can be rendered into external browser windows (for use in multi-monitor setups)
|
|
279
|
+
Tabs can be rendered into external browser windows (for use in multi-monitor setups)
|
|
312
280
|
by configuring them with the enableFloat attribute. When this attribute is present
|
|
313
281
|
an additional icon is shown in the tab header bar allowing the tab to be popped out
|
|
314
282
|
into an external window.
|
|
@@ -329,9 +297,37 @@ following method on one of the elements rendered in the popout (for example a re
|
|
|
329
297
|
|
|
330
298
|
In the above code selfRef is a React ref to the toplevel element in the tab being rendered.
|
|
331
299
|
|
|
332
|
-
Note: some libraries
|
|
300
|
+
Note: some libraries support popout windows by allowing you to specify the document to use,
|
|
333
301
|
for example see the getDocument() callback in agGrid at https://www.ag-grid.com/javascript-grid-callbacks/
|
|
334
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 |
|
|
329
|
+
|
|
330
|
+
|
|
335
331
|
## Global Config attributes
|
|
336
332
|
|
|
337
333
|
Attributes allowed in the 'global' element
|
|
@@ -553,6 +549,7 @@ This would add a new grid component to the tabset with id "NAVIGATION" (where th
|
|
|
553
549
|
| addTabToActiveTabSet(json) | adds a new tab to the active tabset |
|
|
554
550
|
| 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 |
|
|
555
551
|
| 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 |
|
|
552
|
+
| moveTabWithDragAndDrop( node, dragText) | Move a tab/tabset using drag and drop triggered from a custom event |
|
|
556
553
|
|
|
557
554
|
## Tab Node Events
|
|
558
555
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Rect } from "../Rect";
|
|
2
|
+
import { IJsonFloating } from "./IJsonModel";
|
|
3
|
+
import { TabNode } from "./TabNode";
|
|
4
|
+
export declare class Floating {
|
|
5
|
+
private _rect;
|
|
6
|
+
private _parentId;
|
|
7
|
+
private _tabIndex;
|
|
8
|
+
private _tab;
|
|
9
|
+
constructor(_rect: Rect, _parentId: string, _tabIndex: number, _tab: TabNode);
|
|
10
|
+
get rect(): Rect;
|
|
11
|
+
get tabIndex(): number;
|
|
12
|
+
get parentId(): string;
|
|
13
|
+
get tab(): TabNode;
|
|
14
|
+
toJson(): IJsonFloating;
|
|
15
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Rect } from "../Rect";
|
|
2
|
+
import { Floating } from "./Floating";
|
|
3
|
+
import { TabNode } from "./TabNode";
|
|
4
|
+
export declare class FloatingSet {
|
|
5
|
+
get floatingWindows(): Floating[];
|
|
6
|
+
delete(node: TabNode): void;
|
|
7
|
+
find(node: TabNode): Floating | undefined;
|
|
8
|
+
add(r: Rect, parentId: string, tabIndex: number, node: TabNode): void;
|
|
9
|
+
}
|
|
@@ -21,13 +21,15 @@ export declare type ShowOverflowMenuCallback = (node: TabSetNode | BorderNode, m
|
|
|
21
21
|
node: TabNode;
|
|
22
22
|
}) => void) => void;
|
|
23
23
|
export declare type TabSetPlaceHolderCallback = (node: TabSetNode) => React.ReactNode;
|
|
24
|
+
export declare type IconFactory = (node: TabNode) => React.ReactNode;
|
|
25
|
+
export declare type TitleFactory = (node: TabNode) => ITitleObject | React.ReactNode;
|
|
24
26
|
export interface ILayoutProps {
|
|
25
27
|
model: Model;
|
|
26
28
|
factory: (node: TabNode) => React.ReactNode;
|
|
27
29
|
font?: IFontValues;
|
|
28
30
|
fontFamily?: string;
|
|
29
|
-
iconFactory?:
|
|
30
|
-
titleFactory?:
|
|
31
|
+
iconFactory?: IconFactory;
|
|
32
|
+
titleFactory?: TitleFactory;
|
|
31
33
|
icons?: IIcons;
|
|
32
34
|
onAction?: (action: Action) => Action | undefined;
|
|
33
35
|
onRenderTab?: (node: TabNode, renderValues: ITabRenderValues) => void;
|
|
@@ -89,7 +91,8 @@ export interface ILayoutState {
|
|
|
89
91
|
calculatedBorderBarSize: number;
|
|
90
92
|
editingTab?: TabNode;
|
|
91
93
|
showHiddenBorder: DockLocation;
|
|
92
|
-
portal?: React.
|
|
94
|
+
portal?: React.ReactPortal;
|
|
95
|
+
showEdges?: boolean;
|
|
93
96
|
}
|
|
94
97
|
export interface IIcons {
|
|
95
98
|
close?: (React.ReactNode | ((tabNode: TabNode) => React.ReactNode));
|
|
@@ -136,6 +139,12 @@ export declare class Layout extends React.Component<ILayoutProps, ILayoutState>
|
|
|
136
139
|
* @param onDrop a callback to call when the drag is complete (node and event will be undefined if the drag was cancelled)
|
|
137
140
|
*/
|
|
138
141
|
addTabWithDragAndDrop(dragText: string | undefined, json: IJsonTabNode, onDrop?: (node?: Node, event?: Event) => void): void;
|
|
142
|
+
/**
|
|
143
|
+
* Move a tab/tabset using drag and drop
|
|
144
|
+
* @param node the tab or tabset to drag
|
|
145
|
+
* @param dragText the text to show on the drag panel
|
|
146
|
+
*/
|
|
147
|
+
moveTabWithDragAndDrop(node: (TabNode | TabSetNode), dragText?: string): void;
|
|
139
148
|
/**
|
|
140
149
|
* Adds a new tab by dragging a labeled panel to the drop location, dragging starts when you
|
|
141
150
|
* mouse down on the panel
|