flexlayout-react 0.7.11 → 0.7.13

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 (73) hide show
  1. package/ChangeLog.txt +12 -0
  2. package/README.md +21 -90
  3. package/declarations/Rect.d.ts +1 -1
  4. package/declarations/Types.d.ts +1 -0
  5. package/declarations/model/Actions.d.ts +1 -1
  6. package/declarations/model/IJsonModel.d.ts +5 -1
  7. package/declarations/model/TabNode.d.ts +1 -0
  8. package/declarations/model/TabSetNode.d.ts +1 -0
  9. package/declarations/view/Layout.d.ts +4 -2
  10. package/dist/flexlayout.js +15 -15
  11. package/dist/flexlayout_min.js +1 -1
  12. package/lib/DragDrop.js +1 -1
  13. package/lib/DragDrop.js.map +1 -1
  14. package/lib/PopupMenu.js +9 -4
  15. package/lib/PopupMenu.js.map +1 -1
  16. package/lib/Rect.js +1 -6
  17. package/lib/Rect.js.map +1 -1
  18. package/lib/Types.js +1 -0
  19. package/lib/Types.js.map +1 -1
  20. package/lib/model/Actions.js.map +1 -1
  21. package/lib/model/Model.js +10 -3
  22. package/lib/model/Model.js.map +1 -1
  23. package/lib/model/TabNode.js +4 -0
  24. package/lib/model/TabNode.js.map +1 -1
  25. package/lib/model/TabSetNode.js +4 -0
  26. package/lib/model/TabSetNode.js.map +1 -1
  27. package/lib/view/BorderButton.js +7 -5
  28. package/lib/view/BorderButton.js.map +1 -1
  29. package/lib/view/FloatingWindow.js +3 -2
  30. package/lib/view/FloatingWindow.js.map +1 -1
  31. package/lib/view/Layout.js +117 -57
  32. package/lib/view/Layout.js.map +1 -1
  33. package/lib/view/Splitter.js +18 -6
  34. package/lib/view/Splitter.js.map +1 -1
  35. package/lib/view/Tab.js +3 -0
  36. package/lib/view/Tab.js.map +1 -1
  37. package/lib/view/TabButton.js +17 -12
  38. package/lib/view/TabButton.js.map +1 -1
  39. package/lib/view/TabOverflowHook.js +7 -4
  40. package/lib/view/TabOverflowHook.js.map +1 -1
  41. package/lib/view/TabSet.js +11 -5
  42. package/lib/view/TabSet.js.map +1 -1
  43. package/package.json +1 -1
  44. package/src/DragDrop.ts +2 -2
  45. package/src/PopupMenu.tsx +8 -4
  46. package/src/Rect.ts +2 -6
  47. package/src/Types.ts +1 -0
  48. package/src/model/Actions.ts +1 -1
  49. package/src/model/IJsonModel.ts +6 -2
  50. package/src/model/Model.ts +9 -3
  51. package/src/model/TabNode.ts +5 -0
  52. package/src/model/TabSetNode.ts +6 -0
  53. package/src/view/BorderButton.tsx +13 -5
  54. package/src/view/FloatingWindow.tsx +3 -3
  55. package/src/view/Layout.tsx +145 -69
  56. package/src/view/Splitter.tsx +36 -7
  57. package/src/view/Tab.tsx +4 -0
  58. package/src/view/TabButton.tsx +22 -11
  59. package/src/view/TabOverflowHook.tsx +8 -5
  60. package/src/view/TabSet.tsx +13 -5
  61. package/style/_base.scss +21 -0
  62. package/style/dark.css +17 -0
  63. package/style/dark.css.map +1 -1
  64. package/style/dark.scss +6 -0
  65. package/style/gray.css +17 -0
  66. package/style/gray.css.map +1 -1
  67. package/style/gray.scss +6 -0
  68. package/style/light.css +561 -544
  69. package/style/light.css.map +1 -1
  70. package/style/light.scss +6 -0
  71. package/style/underline.css +17 -0
  72. package/style/underline.css.map +1 -1
  73. package/style/underline.scss +6 -0
package/ChangeLog.txt CHANGED
@@ -1,3 +1,15 @@
1
+ 0.7.13
2
+ New attribute on tabset: enableSingleTabStretch will stretch a single tab to take up
3
+ all the remaining space and change the style to look like a header, combined with enableDrop
4
+ this can be used to create a Mosaic style layout (headed panels without tabs), see the new
5
+ Mosaic Style layout in the Demo.
6
+ The layout methods addTabToTabSet and addTabToActiveTabSet now return the added TabNode.
7
+ Fixed #352 - Layout.getDomRect returning null.
8
+
9
+ 0.7.12
10
+ Action.setActiveTabset can now take undefined to unset the active tabset.
11
+ Added Tab attribute contentClassName to add a class to the tab content.
12
+
1
13
  0.7.11
2
14
  Added ITabSetRenderValues.overflowPosition to allow overflow button position to be
3
15
  specified, if left undefined, position will be after sticky buttons as before.
package/README.md CHANGED
@@ -42,20 +42,16 @@ Features:
42
42
 
43
43
  ## Installation
44
44
 
45
- FlexLayout is in the npm repository. Simply install React and FlexLayout from npm:
45
+ FlexLayout is in the npm repository. install using:
46
46
 
47
47
  ```
48
- npm install react
49
- npm install react-dom
50
48
  npm install flexlayout-react
51
49
  ```
52
50
 
53
- Import React and FlexLayout in your modules:
51
+ Import FlexLayout in your modules:
54
52
 
55
53
  ```
56
- import * as React from "react";
57
- import { createRoot } from "react-dom/client";
58
- import * as FlexLayout from "flexlayout-react";
54
+ import {Layout, Model} from 'flexlayout-react';
59
55
  ```
60
56
 
61
57
  Include the light, underline, gray or dark theme by either:
@@ -93,14 +89,6 @@ The factory is a function that takes a Node object and returns a React component
93
89
 
94
90
  The model can be created using the Model.fromJson(jsonObject) static method, and can be saved using the model.toJson() method.
95
91
 
96
- ```javascript
97
- this.state = {model: FlexLayout.Model.fromJson(json)};
98
-
99
- render() {
100
- <FlexLayout.Layout model={this.state.model} factory={factory}/>
101
- }
102
- ```
103
-
104
92
  ## Example Configuration:
105
93
 
106
94
  ```javascript
@@ -140,34 +128,25 @@ var json = {
140
128
 
141
129
  ## Example Code
142
130
 
143
- ```
144
- import * as React from "react";
145
- import { createRoot } from "react-dom/client";
146
- import * as FlexLayout from "flexlayout-react";
131
+ ```javascript
132
+ const model = Model.fromJson(json);
147
133
 
148
- class Main extends React.Component {
134
+ function App() {
149
135
 
150
- constructor(props) {
151
- super(props);
152
- this.state = {model: FlexLayout.Model.fromJson(json)};
153
- }
136
+ const factory = (node) => {
137
+ var component = node.getComponent();
154
138
 
155
- factory = (node) => {
156
- var component = node.getComponent();
157
- if (component === "button") {
158
- return <button>{node.getName()}</button>;
159
- }
139
+ if (component === "button") {
140
+ return <button>{node.getName()}</button>;
160
141
  }
142
+ }
161
143
 
162
- render() {
163
- return (
164
- <FlexLayout.Layout model={this.state.model} factory={this.factory}/>
165
- )
166
- }
144
+ return (
145
+ <Layout
146
+ model={model}
147
+ factory={factory} />
148
+ );
167
149
  }
168
-
169
- const root = createRoot(document.getElementById("container"));
170
- root.render(<Main/>);
171
150
  ```
172
151
 
173
152
  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.
@@ -203,55 +182,6 @@ Weights on rows and tabsets specify the relative weight of these nodes within th
203
182
  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
204
183
  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.
205
184
 
206
-
207
- example borders section:
208
- ```
209
- borders: [
210
- {
211
- type: "border",
212
- location: "left",
213
- children: [
214
- {
215
- type: "tab",
216
- enableClose: false,
217
- name: "Navigation",
218
- component: "grid",
219
- }
220
- ]
221
- },
222
- {
223
- type: "border",
224
- location: "right",
225
- children: [
226
- {
227
- type: "tab",
228
- enableClose: false,
229
- name: "Options",
230
- component: "grid",
231
- }
232
- ]
233
- },
234
- {
235
- type: "border",
236
- location: "bottom",
237
- children: [
238
- {
239
- type: "tab",
240
- enableClose: false,
241
- name: "Activity Blotter",
242
- component: "grid",
243
- },
244
- {
245
- type: "tab",
246
- enableClose: false,
247
- name: "Execution Blotter",
248
- component: "grid",
249
- }
250
- ]
251
- }
252
- ]
253
- ```
254
-
255
185
  To control where nodes can be dropped you can add a callback function to the model:
256
186
 
257
187
  ```
@@ -259,7 +189,7 @@ model.setOnAllowDrop(this.allowDrop);
259
189
  ```
260
190
 
261
191
  example:
262
- ```
192
+ ```javascript
263
193
  allowDrop(dragNode, dropInfo) {
264
194
  let dropNode = dropInfo.node;
265
195
 
@@ -355,6 +285,7 @@ Attributes allowed in the 'global' element
355
285
  | tabEnableRename | true | allow user to rename all tabs by double clicking |
356
286
  | tabEnableFloat | false | enable popouts in all tabs (in popout capable browser) |
357
287
  | tabClassName | null | |
288
+ | tabContentClassName | null | |
358
289
  | tabIcon | null | |
359
290
  | tabEnableRenderOnDemand | true | whether to avoid rendering component until tab is visible |
360
291
  | tabDragSpeed | 0.3 | CSS transition speed of drag outlines (in seconds) |
@@ -420,7 +351,8 @@ Inherited defaults will take their value from the associated global attributes (
420
351
  | enableRename | *inherited* | allow user to rename tabs by double clicking |
421
352
  | enableFloat | *inherited* | enable popout (in popout capable browser) |
422
353
  | floating | false | |
423
- | className | *inherited* | |
354
+ | className | *inherited* | class applied to tab button |
355
+ | contentClassName | *inherited* | class applied to tab content |
424
356
  | icon | *inherited* | |
425
357
  | enableRenderOnDemand | *inherited* | whether to avoid rendering component until tab is visible |
426
358
  | borderWidth | *inherited* | width when added to border, -1 will use border size |
@@ -489,8 +421,7 @@ Inherited defaults will take their value from the associated global attributes (
489
421
  | enableDrop | *inherited* | |
490
422
  | autoSelectTabWhenOpen | *inherited* | whether to select new/moved tabs in border when the border is already open |
491
423
  | autoSelectTabWhenClosed | *inherited* | whether to select new/moved tabs in border when the border is currently closed |
492
- | className | *inherited* | |
493
-
424
+ | className | *inherited* | class applied to tab button |
494
425
 
495
426
  ## Model Actions
496
427
 
@@ -7,7 +7,7 @@ export declare class Rect {
7
7
  constructor(x: number, y: number, width: number, height: number);
8
8
  static fromElement(element: Element): Rect;
9
9
  clone(): Rect;
10
- equals(rect: Rect): boolean;
10
+ equals(rect: Rect | null | undefined): boolean;
11
11
  getBottom(): number;
12
12
  getRight(): number;
13
13
  getCenter(): {
@@ -57,6 +57,7 @@ export declare enum CLASSES {
57
57
  FLEXLAYOUT__TAB_BORDER = "flexlayout__tab_border",
58
58
  FLEXLAYOUT__TAB_BORDER_ = "flexlayout__tab_border_",
59
59
  FLEXLAYOUT__TAB_BUTTON = "flexlayout__tab_button",
60
+ FLEXLAYOUT__TAB_BUTTON_STRETCH = "flexlayout__tab_button_stretch",
60
61
  FLEXLAYOUT__TAB_BUTTON_CONTENT = "flexlayout__tab_button_content",
61
62
  FLEXLAYOUT__TAB_BUTTON_LEADING = "flexlayout__tab_button_leading",
62
63
  FLEXLAYOUT__TAB_BUTTON_OVERFLOW = "flexlayout__tab_button_overflow",
@@ -68,7 +68,7 @@ export declare class Actions {
68
68
  * @param tabsetNodeId the id of the tabset node to set as active
69
69
  * @returns {Action} the action
70
70
  */
71
- static setActiveTabset(tabsetNodeId: string): Action;
71
+ static setActiveTabset(tabsetNodeId: string | undefined): Action;
72
72
  /**
73
73
  * Adjust the splitter between two tabsets
74
74
  * @example
@@ -36,8 +36,8 @@ export interface IGlobalAttributes {
36
36
  borderMinSize?: number;
37
37
  borderSize?: number;
38
38
  enableEdgeDock?: boolean;
39
- enableUseVisibility?: boolean;
40
39
  enableRotateBorderIcons?: boolean;
40
+ enableUseVisibility?: boolean;
41
41
  legacyOverflowMenu?: boolean;
42
42
  marginInsets?: IInsets;
43
43
  rootOrientationVertical?: boolean;
@@ -47,6 +47,7 @@ export interface IGlobalAttributes {
47
47
  tabBorderWidth?: number;
48
48
  tabClassName?: string;
49
49
  tabCloseType?: ICloseType;
50
+ tabContentClassName?: string;
50
51
  tabDragSpeed?: number;
51
52
  tabEnableClose?: boolean;
52
53
  tabEnableDrag?: boolean;
@@ -64,6 +65,7 @@ export interface IGlobalAttributes {
64
65
  tabSetEnableDrag?: boolean;
65
66
  tabSetEnableDrop?: boolean;
66
67
  tabSetEnableMaximize?: boolean;
68
+ tabSetEnableSingleTabStretch?: boolean;
67
69
  tabSetEnableTabStrip?: boolean;
68
70
  tabSetHeaderHeight?: number;
69
71
  tabSetMarginInsets?: IInsets;
@@ -91,6 +93,7 @@ export interface ITabSetAttributes {
91
93
  enableDrag?: boolean;
92
94
  enableDrop?: boolean;
93
95
  enableMaximize?: boolean;
96
+ enableSingleTabStretch?: boolean;
94
97
  enableTabStrip?: boolean;
95
98
  headerHeight?: number;
96
99
  height?: number;
@@ -116,6 +119,7 @@ export interface ITabAttributes {
116
119
  closeType?: ICloseType;
117
120
  component?: string;
118
121
  config?: any;
122
+ contentClassName?: string;
119
123
  enableClose?: boolean;
120
124
  enableDrag?: boolean;
121
125
  enableFloat?: boolean;
@@ -30,6 +30,7 @@ export declare class TabNode extends Node implements IDraggable {
30
30
  isEnableDrag(): boolean;
31
31
  isEnableRename(): boolean;
32
32
  getClassName(): string | undefined;
33
+ getContentClassName(): string | undefined;
33
34
  isEnableRenderOnDemand(): boolean;
34
35
  toJson(): IJsonTabNode;
35
36
  }
@@ -28,6 +28,7 @@ export declare class TabSetNode extends Node implements IDraggable, IDropTarget
28
28
  isEnableDivide(): boolean;
29
29
  isEnableMaximize(): boolean;
30
30
  isEnableClose(): boolean;
31
+ isEnableSingleTabStretch(): boolean;
31
32
  canMaximize(): boolean;
32
33
  isEnableTabStrip(): boolean;
33
34
  isAutoSelectTab(): boolean;
@@ -126,13 +126,15 @@ export declare class Layout extends React.Component<ILayoutProps, ILayoutState>
126
126
  * Adds a new tab to the given tabset
127
127
  * @param tabsetId the id of the tabset where the new tab will be added
128
128
  * @param json the json for the new tab node
129
+ * @returns the added tab node or undefined
129
130
  */
130
- addTabToTabSet(tabsetId: string, json: IJsonTabNode): void;
131
+ addTabToTabSet(tabsetId: string, json: IJsonTabNode): TabNode | undefined;
131
132
  /**
132
133
  * Adds a new tab to the active tabset (if there is one)
133
134
  * @param json the json for the new tab node
135
+ * @returns the added tab node or undefined
134
136
  */
135
- addTabToActiveTabSet(json: IJsonTabNode): void;
137
+ addTabToActiveTabSet(json: IJsonTabNode): TabNode | undefined;
136
138
  /**
137
139
  * Adds a new tab by dragging a labeled panel to the drop location, dragging starts immediatelly
138
140
  * @param dragText the text to show on the drag panel