flexlayout-react 0.5.18 → 0.5.19

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 (53) hide show
  1. package/ChangeLog.txt +8 -0
  2. package/README.md +109 -96
  3. package/declarations/Types.d.ts +7 -1
  4. package/declarations/view/Layout.d.ts +5 -0
  5. package/dist/flexlayout.js +12 -12
  6. package/dist/flexlayout_min.js +1 -1
  7. package/lib/PopupMenu.js +14 -9
  8. package/lib/PopupMenu.js.map +1 -1
  9. package/lib/Types.js +6 -0
  10. package/lib/Types.js.map +1 -1
  11. package/lib/model/BorderNode.js +8 -7
  12. package/lib/model/BorderNode.js.map +1 -1
  13. package/lib/model/Model.js +7 -3
  14. package/lib/model/Model.js.map +1 -1
  15. package/lib/model/RowNode.js +19 -5
  16. package/lib/model/RowNode.js.map +1 -1
  17. package/lib/model/TabSetNode.js +8 -4
  18. package/lib/model/TabSetNode.js.map +1 -1
  19. package/lib/view/BorderButton.js +14 -3
  20. package/lib/view/BorderButton.js.map +1 -1
  21. package/lib/view/BorderTabSet.js +15 -4
  22. package/lib/view/BorderTabSet.js.map +1 -1
  23. package/lib/view/Layout.js +81 -48
  24. package/lib/view/Layout.js.map +1 -1
  25. package/lib/view/TabButton.js +11 -2
  26. package/lib/view/TabButton.js.map +1 -1
  27. package/lib/view/TabFloating.js +23 -11
  28. package/lib/view/TabFloating.js.map +1 -1
  29. package/lib/view/TabSet.js +43 -18
  30. package/lib/view/TabSet.js.map +1 -1
  31. package/package.json +1 -1
  32. package/src/PopupMenu.tsx +28 -10
  33. package/src/Types.ts +6 -0
  34. package/src/model/BorderNode.ts +8 -7
  35. package/src/model/Model.ts +7 -3
  36. package/src/model/RowNode.ts +8 -5
  37. package/src/model/TabSetNode.ts +8 -4
  38. package/src/view/BorderButton.tsx +22 -3
  39. package/src/view/BorderTabSet.tsx +21 -4
  40. package/src/view/Layout.tsx +100 -58
  41. package/src/view/TabButton.tsx +16 -1
  42. package/src/view/TabFloating.tsx +36 -19
  43. package/src/view/TabSet.tsx +56 -17
  44. package/style/_base.scss +65 -41
  45. package/style/dark.css +81 -59
  46. package/style/dark.css.map +1 -1
  47. package/style/dark.scss +20 -20
  48. package/style/gray.css +81 -59
  49. package/style/gray.css.map +1 -1
  50. package/style/gray.scss +20 -20
  51. package/style/light.css +81 -59
  52. package/style/light.css.map +1 -1
  53. package/style/light.scss +18 -18
package/ChangeLog.txt CHANGED
@@ -1,3 +1,11 @@
1
+ 0.5.19
2
+ Added onRenderFloatingTabPlaceholder callback prop for rendering the floating tab placeholder.
3
+ Changed style sheets to use CSS custom properties (variables) for several values.
4
+ Fix selected index in single empty tabset.
5
+ Added onContextMenu callback prop for handling context menus on tabs and tabsets.
6
+ Added onAuxMouseClick callback prop for handling mouse clicks on tabs and tabsets
7
+ with alt, meta, shift keys, also handles center mouse clicks
8
+
1
9
  0.5.18
2
10
  Added onRenderDragRect callback prop for rendering the drag rectangles
3
11
  New border attribute: enableAutoHide, to hide border if it has zero tabs
package/README.md CHANGED
@@ -66,26 +66,39 @@ Include the light, gray or dark style in your html:
66
66
  The `<Layout>` component renders the tabsets and splitters, it takes the following props:
67
67
 
68
68
 
69
- | Prop | Required/Optional | Description |
70
- | --------------- |:-----------------:| ----------------- |
71
- | model | required | the layout model |
72
- | factory | required | a factory function for creating React components |
73
- | font | optional | the tab font (overrides value in css). Example: font={{size:"12px", style:"italic"}}|
74
- | iconFactory | optional | a factory function for creating icon components for tab bar buttons |
75
- | titleFactory | optional | a factory function for creating title components for tab bar buttons |
76
- | icons | optional | object mapping keys among `close`, `maximize`, `restore`, `more`, `popout` to React nodes to use in place of the default icons |
77
- | onAction | optional | 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 |
78
- | onRenderTab | optional | function called when rendering a tab, allows leading (icon), content section, buttons and name used in overflow menu to be customized |
79
- | onRenderTabSet | optional | function called when rendering a tabset, allows header and buttons to be customized |
80
- | onModelChange | optional | function called when model has changed |
81
- | onExternalDrag | optional | 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`, and optionally `onDrop`, 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. |
82
- | classNameMapper | optional | function called with default css class name, return value is class name that will be used. Mainly for use with css modules.|
83
- | i18nMapper | optional | function called for each I18nLabel to allow user translation, currently used for tab and tabset move messages, return undefined to use default values |
84
- | supportsPopout | optional | if left undefined will do simple check based on userAgent |
85
- | popoutURL | optional | URL of popout window relative to origin, defaults to popout.html |
86
- | realtimeResize | optional | 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 |
87
- | onTabDrag | optional | 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. |
88
- | onRenderDragRect | optional | callback for rendering the drag rectangles |
69
+ #### Required props:
70
+
71
+
72
+ | Prop | Description |
73
+ | --------------- | ----------------- |
74
+ | model | the layout model |
75
+ | factory | a factory function for creating React components |
76
+
77
+ #### Optional props:
78
+
79
+
80
+ | Prop | Description |
81
+ | --------------- | ----------------- |
82
+ | font | the tab font (overrides value in css). Example: font={{size:"12px", style:"italic"}}|
83
+ | icons | object mapping keys among `close`, `maximize`, `restore`, `more`, `popout` to React nodes to use in place of the default icons |
84
+ | 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 |
85
+ | onRenderTab | function called when rendering a tab, allows leading (icon), content section, buttons and name used in overflow menu to be customized |
86
+ | onRenderTabSet | function called when rendering a tabset, allows header and buttons to be customized |
87
+ | onModelChange | function called when model has changed |
88
+ | 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. |
89
+ | classNameMapper | function called with default css class name, return value is class name that will be used. Mainly for use with css modules.|
90
+ | i18nMapper | function called for each I18nLabel to allow user translation, currently used for tab and tabset move messages, return undefined to use default values |
91
+ | supportsPopout | if left undefined will do simple check based on userAgent |
92
+ | popoutURL | URL of popout window relative to origin, defaults to popout.html |
93
+ | 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 |
94
+ | 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. |
95
+ | onRenderDragRect | callback for rendering the drag rectangles |
96
+ | onRenderFloatingTabPlaceholder | callback for rendering the floating tab placeholder |
97
+ | onContextMenu | callback for handling context actions on tabs and tabsets |
98
+ | onAuxMouseClick | callback for handling mouse clicks on tabs and tabsets with alt, meta, shift keys, also handles center mouse clicks |
99
+ | 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 |
100
+ | 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 |
101
+
89
102
 
90
103
  The model is tree of Node objects that define the structure of the layout.
91
104
 
@@ -105,38 +118,38 @@ render() {
105
118
 
106
119
  ```javascript
107
120
  var json = {
108
- global: {},
109
- borders: [],
110
- layout:{
111
- "type": "row",
112
- "weight": 100,
113
- "children": [
114
- {
115
- "type": "tabset",
116
- "weight": 50,
117
- "selected": 0,
118
- "children": [
119
- {
120
- "type": "tab",
121
- "name": "FX",
122
- "component":"grid",
123
- }
124
- ]
125
- },
126
- {
127
- "type": "tabset",
128
- "weight": 50,
129
- "selected": 0,
130
- "children": [
131
- {
132
- "type": "tab",
133
- "name": "FI",
134
- "component":"grid",
135
- }
136
- ]
137
- }
138
- ]
139
- }
121
+ global: {},
122
+ borders: [],
123
+ layout:{
124
+ "type": "row",
125
+ "weight": 100,
126
+ "children": [
127
+ {
128
+ "type": "tabset",
129
+ "weight": 50,
130
+ "selected": 0,
131
+ "children": [
132
+ {
133
+ "type": "tab",
134
+ "name": "FX",
135
+ "component":"grid",
136
+ }
137
+ ]
138
+ },
139
+ {
140
+ "type": "tabset",
141
+ "weight": 50,
142
+ "selected": 0,
143
+ "children": [
144
+ {
145
+ "type": "tab",
146
+ "name": "FI",
147
+ "component":"grid",
148
+ }
149
+ ]
150
+ }
151
+ ]
152
+ }
140
153
  };
141
154
  ```
142
155
 
@@ -208,50 +221,50 @@ existing layouts by dragging/dropping and adding nodes then press the 'Show Layo
208
221
 
209
222
  example borders section:
210
223
  ```
211
- "borders": [
212
- {
213
- "type":"border",
214
- "location": "left",
215
- "children": [
216
- {
217
- "type": "tab",
218
- "enableClose":false,
219
- "name": "Navigation",
220
- "component": "grid",
221
- }
222
- ]
223
- },
224
- {
225
- "type":"border",
226
- "location": "right",
227
- "children": [
228
- {
229
- "type": "tab",
230
- "enableClose":false,
231
- "name": "Options",
232
- "component": "grid",
233
- }
234
- ]
235
- },
236
- {
237
- "type":"border",
238
- "location": "bottom",
239
- "children": [
240
- {
241
- "type": "tab",
242
- "enableClose":false,
243
- "name": "Activity Blotter",
244
- "component": "grid",
245
- },
246
- {
247
- "type": "tab",
248
- "enableClose":false,
249
- "name": "Execution Blotter",
250
- "component": "grid",
251
- }
252
- ]
253
- }
254
- ]
224
+ "borders": [
225
+ {
226
+ "type":"border",
227
+ "location": "left",
228
+ "children": [
229
+ {
230
+ "type": "tab",
231
+ "enableClose":false,
232
+ "name": "Navigation",
233
+ "component": "grid",
234
+ }
235
+ ]
236
+ },
237
+ {
238
+ "type":"border",
239
+ "location": "right",
240
+ "children": [
241
+ {
242
+ "type": "tab",
243
+ "enableClose":false,
244
+ "name": "Options",
245
+ "component": "grid",
246
+ }
247
+ ]
248
+ },
249
+ {
250
+ "type":"border",
251
+ "location": "bottom",
252
+ "children": [
253
+ {
254
+ "type": "tab",
255
+ "enableClose":false,
256
+ "name": "Activity Blotter",
257
+ "component": "grid",
258
+ },
259
+ {
260
+ "type": "tab",
261
+ "enableClose":false,
262
+ "name": "Execution Blotter",
263
+ "component": "grid",
264
+ }
265
+ ]
266
+ }
267
+ ]
255
268
  ```
256
269
 
257
270
  To control where nodes can be dropped you can add a callback function to the model:
@@ -8,6 +8,8 @@ export declare enum CLASSES {
8
8
  FLEXLAYOUT__BORDER_BUTTON_TRAILING = "flexlayout__border_button_trailing",
9
9
  FLEXLAYOUT__BORDER_BUTTON__SELECTED = "flexlayout__border_button--selected",
10
10
  FLEXLAYOUT__BORDER_BUTTON__UNSELECTED = "flexlayout__border_button--unselected",
11
+ FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW = "flexlayout__border_toolbar_button_overflow",
12
+ FLEXLAYOUT__BORDER_TOOLBAR_BUTTON_OVERFLOW_ = "flexlayout__border_toolbar_button_overflow_",
11
13
  FLEXLAYOUT__BORDER_INNER = "flexlayout__border_inner",
12
14
  FLEXLAYOUT__BORDER_INNER_ = "flexlayout__border_inner_",
13
15
  FLEXLAYOUT__BORDER_INNER_TAB_CONTAINER = "flexlayout__border_inner_tab_container",
@@ -25,6 +27,7 @@ export declare enum CLASSES {
25
27
  FLEXLAYOUT__FLOATING_WINDOW_TAB = "flexlayout__floating_window_tab",
26
28
  FLEXLAYOUT__LAYOUT = "flexlayout__layout",
27
29
  FLEXLAYOUT__OUTLINE_RECT = "flexlayout__outline_rect",
30
+ FLEXLAYOUT__OUTLINE_RECT_EDGE = "flexlayout__outline_rect_edge",
28
31
  FLEXLAYOUT__SPLITTER = "flexlayout__splitter",
29
32
  FLEXLAYOUT__SPLITTER_EXTRA = "flexlayout__splitter_extra",
30
33
  FLEXLAYOUT__SPLITTER_ = "flexlayout__splitter_",
@@ -59,5 +62,8 @@ export declare enum CLASSES {
59
62
  FLEXLAYOUT__TAB_TOOLBAR_BUTTON_ = "flexlayout__tab_toolbar_button-",
60
63
  FLEXLAYOUT__TAB_TOOLBAR_BUTTON_FLOAT = "flexlayout__tab_toolbar_button-float",
61
64
  FLEXLAYOUT__TAB_TOOLBAR_STICKY_BUTTONS_CONTAINER = "flexlayout__tab_toolbar_sticky_buttons_container",
62
- FLEXLAYOUT__TAB_TOOLBAR_BUTTON_CLOSE = "flexlayout__tab_toolbar_button-close"
65
+ FLEXLAYOUT__TAB_TOOLBAR_BUTTON_CLOSE = "flexlayout__tab_toolbar_button-close",
66
+ FLEXLAYOUT__POPUP_MENU_CONTAINER = "flexlayout__popup_menu_container",
67
+ FLEXLAYOUT__POPUP_MENU_ITEM = "flexlayout__popup_menu_item",
68
+ FLEXLAYOUT__POPUP_MENU = "flexlayout__popup_menu"
63
69
  }
@@ -11,6 +11,8 @@ import Rect from "../Rect";
11
11
  import { IJsonTabNode } from "../model/IJsonModel";
12
12
  export declare type CustomDragCallback = (dragging: TabNode | IJsonTabNode, over: TabNode, x: number, y: number, location: DockLocation) => void;
13
13
  export declare type DragRectRenderCallback = (text: String, node?: Node, json?: IJsonTabNode) => React.ReactElement | undefined;
14
+ export declare type FloatingTabPlaceholderRenderCallback = (dockPopout: () => void, showPopout: () => void) => React.ReactElement | undefined;
15
+ export declare type NodeMouseEvent = (node: TabNode | TabSetNode | BorderNode, event: React.MouseEvent<HTMLElement, MouseEvent>) => void;
14
16
  export interface ILayoutProps {
15
17
  model: Model;
16
18
  factory: (node: TabNode) => React.ReactNode;
@@ -44,6 +46,9 @@ export interface ILayoutProps {
44
46
  cursor?: string | undefined;
45
47
  };
46
48
  onRenderDragRect?: DragRectRenderCallback;
49
+ onRenderFloatingTabPlaceholder?: FloatingTabPlaceholderRenderCallback;
50
+ onContextMenu?: NodeMouseEvent;
51
+ onAuxMouseClick?: NodeMouseEvent;
47
52
  }
48
53
  export interface IFontValues {
49
54
  size?: string;