flexlayout-react 0.7.0 → 0.7.3
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 +37 -42
- package/declarations/model/Floating.d.ts +15 -0
- package/declarations/model/FloatingSet.d.ts +9 -0
- package/declarations/view/Layout.d.ts +7 -0
- package/dist/flexlayout.js +6 -6
- package/dist/flexlayout_min.js +1 -1
- package/lib/model/BorderNode.js +7 -1
- package/lib/model/BorderNode.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/model/TabSetNode.js +8 -1
- package/lib/model/TabSetNode.js.map +1 -1
- package/lib/view/BorderTabSet.js +3 -1
- package/lib/view/BorderTabSet.js.map +1 -1
- package/lib/view/Icons.js +15 -10
- package/lib/view/Icons.js.map +1 -1
- package/lib/view/Layout.js +26 -73
- package/lib/view/Layout.js.map +1 -1
- package/lib/view/TabSet.js +3 -1
- package/lib/view/TabSet.js.map +1 -1
- package/package.json +5 -3
- package/src/model/BorderNode.ts +6 -1
- package/src/model/TabSetNode.ts +6 -1
- package/src/view/BorderTabSet.tsx +5 -3
- package/src/view/Icons.tsx +17 -7
- package/src/view/Layout.tsx +31 -99
- package/src/view/TabSet.tsx +5 -3
- package/style/_base.scss +1 -1
- package/style/dark.css +2 -1
- package/style/dark.css.map +1 -1
- package/style/dark.scss +1 -0
- package/style/gray.css +2 -1
- package/style/gray.css.map +1 -1
- package/style/gray.scss +1 -0
- package/style/light.css +2 -1
- package/style/light.css.map +1 -1
- package/style/light.scss +1 -0
- package/style/underline.css +11 -5
- 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.3
|
|
2
|
+
Fixed right edge marker location when border enableAutoHide
|
|
3
|
+
Dragging out a selected border tab will now leave the border unselected
|
|
4
|
+
|
|
5
|
+
0.7.2
|
|
6
|
+
New Layout JSON tabs to demo
|
|
7
|
+
Added --color-icon css rootOrientationVertical
|
|
8
|
+
|
|
9
|
+
0.7.1
|
|
10
|
+
Fix for #310 - Added new layout method: moveTabWithDragAndDrop(node) to allow tab dragging to be
|
|
11
|
+
started from custom code.
|
|
12
|
+
|
|
1
13
|
0.7.0
|
|
2
14
|
Updated dependencies, in particular changed React peer dependency to React 18
|
|
3
15
|
Made changes for React 18
|
package/README.md
CHANGED
|
@@ -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
|
|
|
@@ -59,7 +57,7 @@ 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
|
|
|
@@ -185,17 +157,15 @@ class Main extends React.Component {
|
|
|
185
157
|
}
|
|
186
158
|
}
|
|
187
159
|
|
|
188
|
-
const
|
|
189
|
-
const root = createRoot(container);
|
|
160
|
+
const root = createRoot(document.getElementById("container"));
|
|
190
161
|
root.render(<Main/>);
|
|
191
162
|
```
|
|
192
|
-
(See the examples for full source code)
|
|
193
163
|
|
|
194
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.
|
|
195
165
|
|
|
196
166
|
Try it now using [JSFiddle](https://jsfiddle.net/10kmLzvu/)
|
|
197
167
|
|
|
198
|
-
A simple
|
|
168
|
+
A simple Typescript example can be found here:
|
|
199
169
|
|
|
200
170
|
https://github.com/nealus/FlexLayout_cra_example
|
|
201
171
|
|
|
@@ -306,11 +276,7 @@ tabs or drag and drop).
|
|
|
306
276
|
```
|
|
307
277
|
## Floating Tabs (Popouts)
|
|
308
278
|
|
|
309
|
-
|
|
310
|
-
NOT work for any version of IE or the previous version of Edge. For unsupported browsers the popout icons
|
|
311
|
-
will not be shown and any saved layout with popouts will show with all their tabs in the main layout.
|
|
312
|
-
|
|
313
|
-
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)
|
|
314
280
|
by configuring them with the enableFloat attribute. When this attribute is present
|
|
315
281
|
an additional icon is shown in the tab header bar allowing the tab to be popped out
|
|
316
282
|
into an external window.
|
|
@@ -331,9 +297,37 @@ following method on one of the elements rendered in the popout (for example a re
|
|
|
331
297
|
|
|
332
298
|
In the above code selfRef is a React ref to the toplevel element in the tab being rendered.
|
|
333
299
|
|
|
334
|
-
Note: some libraries
|
|
300
|
+
Note: some libraries support popout windows by allowing you to specify the document to use,
|
|
335
301
|
for example see the getDocument() callback in agGrid at https://www.ag-grid.com/javascript-grid-callbacks/
|
|
336
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
|
+
|
|
337
331
|
## Global Config attributes
|
|
338
332
|
|
|
339
333
|
Attributes allowed in the 'global' element
|
|
@@ -555,6 +549,7 @@ This would add a new grid component to the tabset with id "NAVIGATION" (where th
|
|
|
555
549
|
| addTabToActiveTabSet(json) | adds a new tab to the active tabset |
|
|
556
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 |
|
|
557
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 |
|
|
558
553
|
|
|
559
554
|
## Tab Node Events
|
|
560
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
|
+
}
|
|
@@ -92,6 +92,7 @@ export interface ILayoutState {
|
|
|
92
92
|
editingTab?: TabNode;
|
|
93
93
|
showHiddenBorder: DockLocation;
|
|
94
94
|
portal?: React.ReactPortal;
|
|
95
|
+
showEdges?: boolean;
|
|
95
96
|
}
|
|
96
97
|
export interface IIcons {
|
|
97
98
|
close?: (React.ReactNode | ((tabNode: TabNode) => React.ReactNode));
|
|
@@ -138,6 +139,12 @@ export declare class Layout extends React.Component<ILayoutProps, ILayoutState>
|
|
|
138
139
|
* @param onDrop a callback to call when the drag is complete (node and event will be undefined if the drag was cancelled)
|
|
139
140
|
*/
|
|
140
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;
|
|
141
148
|
/**
|
|
142
149
|
* Adds a new tab by dragging a labeled panel to the drop location, dragging starts when you
|
|
143
150
|
* mouse down on the panel
|