@aptre/flex-layout 0.4.4 → 0.5.1
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/dist/Attribute.d.ts +3 -1
- package/dist/AttributeDefinitions.d.ts +5 -1
- package/dist/Rect.d.ts +1 -1
- package/dist/index.mjs +102 -74
- package/dist/model/Action.d.ts +158 -4
- package/dist/model/Actions.d.ts +23 -23
- package/dist/model/BorderNode.d.ts +2 -2
- package/dist/model/BorderSet.d.ts +2 -1
- package/dist/model/Model.d.ts +1 -1
- package/dist/model/Node.d.ts +15 -1
- package/dist/model/TabNode.d.ts +4 -3
- package/dist/model/TabSetNode.d.ts +1 -1
- package/dist/view/Layout.d.ts +1 -1
- package/package.json +2 -1
- package/typedoc/assets/hierarchy.js +1 -1
- package/typedoc/assets/navigation.js +1 -1
- package/typedoc/assets/search.js +1 -1
- package/typedoc/classes/Actions.html +29 -29
- package/typedoc/classes/BorderNode.html +3 -3
- package/typedoc/classes/Model.html +4 -4
- package/typedoc/classes/Node.html +2 -2
- package/typedoc/classes/Rect.html +1 -1
- package/typedoc/classes/RowNode.html +2 -2
- package/typedoc/classes/TabNode.html +4 -4
- package/typedoc/classes/TabSetNode.html +3 -3
- package/typedoc/functions/createAction.html +2 -0
- package/typedoc/hierarchy.html +1 -1
- package/typedoc/index.html +1 -1
- package/typedoc/interfaces/ActionDataMap.html +18 -0
- package/typedoc/interfaces/AddNodeData.html +7 -0
- package/typedoc/interfaces/AdjustBorderSplitData.html +3 -0
- package/typedoc/interfaces/AdjustWeightsData.html +3 -0
- package/typedoc/interfaces/CloseWindowData.html +2 -0
- package/typedoc/interfaces/CreateWindowData.html +3 -0
- package/typedoc/interfaces/DeleteTabData.html +2 -0
- package/typedoc/interfaces/DeleteTabsetData.html +2 -0
- package/typedoc/interfaces/IBorderAttributes.html +1 -1
- package/typedoc/interfaces/IJsonBorderNode.html +1 -1
- package/typedoc/interfaces/IJsonRowNode.html +1 -1
- package/typedoc/interfaces/IJsonTabNode.html +1 -1
- package/typedoc/interfaces/IJsonTabSetNode.html +1 -1
- package/typedoc/interfaces/ILayoutProps.html +4 -4
- package/typedoc/interfaces/IOptimizedLayoutProps.html +4 -4
- package/typedoc/interfaces/IRowAttributes.html +1 -1
- package/typedoc/interfaces/ITabAttributes.html +1 -1
- package/typedoc/interfaces/ITabSetAttributes.html +1 -1
- package/typedoc/interfaces/MaximizeToggleData.html +3 -0
- package/typedoc/interfaces/MoveNodeData.html +6 -0
- package/typedoc/interfaces/PopoutTabData.html +2 -0
- package/typedoc/interfaces/PopoutTabsetData.html +2 -0
- package/typedoc/interfaces/RenameTabData.html +3 -0
- package/typedoc/interfaces/ResizeEventParams.html +3 -0
- package/typedoc/interfaces/SelectTabData.html +3 -0
- package/typedoc/interfaces/SetActiveTabsetData.html +3 -0
- package/typedoc/interfaces/UpdateModelAttributesData.html +2 -0
- package/typedoc/interfaces/UpdateNodeAttributesData.html +3 -0
- package/typedoc/interfaces/VisibilityEventParams.html +3 -0
- package/typedoc/types/Action.html +2 -0
- package/typedoc/types/ActionTypeValue.html +1 -0
- package/typedoc/types/EmptyEventParams.html +2 -0
- package/typedoc/types/NodeAttributes.html +2 -0
- package/typedoc/types/NodeEventCallback.html +2 -0
- package/typedoc/types/NodeEventParams.html +2 -0
- package/typedoc/variables/ActionType.html +2 -0
- package/typedoc/classes/Action.html +0 -4
package/dist/Attribute.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { AttributeValue } from "./Attribute";
|
|
2
|
+
/** Record type for node attributes - used internally for attribute storage */
|
|
3
|
+
export type AttributeRecord = Record<string, AttributeValue>;
|
|
4
|
+
/** Input type for JSON objects being read - accepts any object with string keys */
|
|
5
|
+
export type JsonInput = Record<string, unknown>;
|
package/dist/Rect.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare class Rect {
|
|
|
28
28
|
y: number;
|
|
29
29
|
};
|
|
30
30
|
positionElement(element: HTMLElement, position?: string): void;
|
|
31
|
-
styleWithPosition(style: Record<string,
|
|
31
|
+
styleWithPosition(style: CSSStyleDeclaration | Record<string, string | number>, position?: string): CSSStyleDeclaration | Record<string, string | number>;
|
|
32
32
|
contains(x: number, y: number): boolean;
|
|
33
33
|
removeInsets(insets: {
|
|
34
34
|
top: number;
|
package/dist/index.mjs
CHANGED
|
@@ -232,7 +232,7 @@ var DockLocation = class _DockLocation {
|
|
|
232
232
|
}
|
|
233
233
|
}
|
|
234
234
|
toString() {
|
|
235
|
-
return "(DockLocation: name=" + this.name + ", orientation=" + this.orientation + ")";
|
|
235
|
+
return "(DockLocation: name=" + this.name + ", orientation=" + this.orientation.toString() + ")";
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
|
|
@@ -350,33 +350,46 @@ var CLASSES = /* @__PURE__ */ ((CLASSES2) => {
|
|
|
350
350
|
})(CLASSES || {});
|
|
351
351
|
|
|
352
352
|
// src/model/Action.ts
|
|
353
|
-
var
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
353
|
+
var ActionType = {
|
|
354
|
+
ADD_NODE: "FlexLayout_AddNode",
|
|
355
|
+
MOVE_NODE: "FlexLayout_MoveNode",
|
|
356
|
+
DELETE_TAB: "FlexLayout_DeleteTab",
|
|
357
|
+
DELETE_TABSET: "FlexLayout_DeleteTabset",
|
|
358
|
+
RENAME_TAB: "FlexLayout_RenameTab",
|
|
359
|
+
SELECT_TAB: "FlexLayout_SelectTab",
|
|
360
|
+
SET_ACTIVE_TABSET: "FlexLayout_SetActiveTabset",
|
|
361
|
+
ADJUST_WEIGHTS: "FlexLayout_AdjustWeights",
|
|
362
|
+
ADJUST_BORDER_SPLIT: "FlexLayout_AdjustBorderSplit",
|
|
363
|
+
MAXIMIZE_TOGGLE: "FlexLayout_MaximizeToggle",
|
|
364
|
+
UPDATE_MODEL_ATTRIBUTES: "FlexLayout_UpdateModelAttributes",
|
|
365
|
+
UPDATE_NODE_ATTRIBUTES: "FlexLayout_UpdateNodeAttributes",
|
|
366
|
+
POPOUT_TAB: "FlexLayout_PopoutTab",
|
|
367
|
+
POPOUT_TABSET: "FlexLayout_PopoutTabset",
|
|
368
|
+
CLOSE_WINDOW: "FlexLayout_CloseWindow",
|
|
369
|
+
CREATE_WINDOW: "FlexLayout_CreateWindow"
|
|
360
370
|
};
|
|
371
|
+
function createAction(type, data) {
|
|
372
|
+
return { type, data };
|
|
373
|
+
}
|
|
361
374
|
|
|
362
375
|
// src/model/Actions.ts
|
|
363
|
-
var Actions = class
|
|
364
|
-
static ADD_NODE =
|
|
365
|
-
static MOVE_NODE =
|
|
366
|
-
static DELETE_TAB =
|
|
367
|
-
static DELETE_TABSET =
|
|
368
|
-
static RENAME_TAB =
|
|
369
|
-
static SELECT_TAB =
|
|
370
|
-
static SET_ACTIVE_TABSET =
|
|
371
|
-
static ADJUST_WEIGHTS =
|
|
372
|
-
static ADJUST_BORDER_SPLIT =
|
|
373
|
-
static MAXIMIZE_TOGGLE =
|
|
374
|
-
static UPDATE_MODEL_ATTRIBUTES =
|
|
375
|
-
static UPDATE_NODE_ATTRIBUTES =
|
|
376
|
-
static POPOUT_TAB =
|
|
377
|
-
static POPOUT_TABSET =
|
|
378
|
-
static CLOSE_WINDOW =
|
|
379
|
-
static CREATE_WINDOW =
|
|
376
|
+
var Actions = class {
|
|
377
|
+
static ADD_NODE = ActionType.ADD_NODE;
|
|
378
|
+
static MOVE_NODE = ActionType.MOVE_NODE;
|
|
379
|
+
static DELETE_TAB = ActionType.DELETE_TAB;
|
|
380
|
+
static DELETE_TABSET = ActionType.DELETE_TABSET;
|
|
381
|
+
static RENAME_TAB = ActionType.RENAME_TAB;
|
|
382
|
+
static SELECT_TAB = ActionType.SELECT_TAB;
|
|
383
|
+
static SET_ACTIVE_TABSET = ActionType.SET_ACTIVE_TABSET;
|
|
384
|
+
static ADJUST_WEIGHTS = ActionType.ADJUST_WEIGHTS;
|
|
385
|
+
static ADJUST_BORDER_SPLIT = ActionType.ADJUST_BORDER_SPLIT;
|
|
386
|
+
static MAXIMIZE_TOGGLE = ActionType.MAXIMIZE_TOGGLE;
|
|
387
|
+
static UPDATE_MODEL_ATTRIBUTES = ActionType.UPDATE_MODEL_ATTRIBUTES;
|
|
388
|
+
static UPDATE_NODE_ATTRIBUTES = ActionType.UPDATE_NODE_ATTRIBUTES;
|
|
389
|
+
static POPOUT_TAB = ActionType.POPOUT_TAB;
|
|
390
|
+
static POPOUT_TABSET = ActionType.POPOUT_TABSET;
|
|
391
|
+
static CLOSE_WINDOW = ActionType.CLOSE_WINDOW;
|
|
392
|
+
static CREATE_WINDOW = ActionType.CREATE_WINDOW;
|
|
380
393
|
/**
|
|
381
394
|
* Adds a tab node to the given tabset node
|
|
382
395
|
* @param json the json for the new tab node e.g {type:"tab", component:"table"}
|
|
@@ -387,7 +400,7 @@ var Actions = class _Actions {
|
|
|
387
400
|
* @returns {Action} the action
|
|
388
401
|
*/
|
|
389
402
|
static addNode(json, toNodeId, location, index, select) {
|
|
390
|
-
return
|
|
403
|
+
return createAction(ActionType.ADD_NODE, {
|
|
391
404
|
json,
|
|
392
405
|
toNode: toNodeId,
|
|
393
406
|
location: location.getName(),
|
|
@@ -405,7 +418,7 @@ var Actions = class _Actions {
|
|
|
405
418
|
* @returns {Action} the action
|
|
406
419
|
*/
|
|
407
420
|
static moveNode(fromNodeId, toNodeId, location, index, select) {
|
|
408
|
-
return
|
|
421
|
+
return createAction(ActionType.MOVE_NODE, {
|
|
409
422
|
fromNode: fromNodeId,
|
|
410
423
|
toNode: toNodeId,
|
|
411
424
|
location: location.getName(),
|
|
@@ -419,7 +432,7 @@ var Actions = class _Actions {
|
|
|
419
432
|
* @returns {Action} the action
|
|
420
433
|
*/
|
|
421
434
|
static deleteTab(tabNodeId) {
|
|
422
|
-
return
|
|
435
|
+
return createAction(ActionType.DELETE_TAB, { node: tabNodeId });
|
|
423
436
|
}
|
|
424
437
|
/**
|
|
425
438
|
* Deletes a tabset node and all it's child tab nodes from the layout
|
|
@@ -427,7 +440,7 @@ var Actions = class _Actions {
|
|
|
427
440
|
* @returns {Action} the action
|
|
428
441
|
*/
|
|
429
442
|
static deleteTabset(tabsetNodeId) {
|
|
430
|
-
return
|
|
443
|
+
return createAction(ActionType.DELETE_TABSET, { node: tabsetNodeId });
|
|
431
444
|
}
|
|
432
445
|
/**
|
|
433
446
|
* Change the given nodes tab text
|
|
@@ -436,7 +449,7 @@ var Actions = class _Actions {
|
|
|
436
449
|
* @returns {Action} the action
|
|
437
450
|
*/
|
|
438
451
|
static renameTab(tabNodeId, text) {
|
|
439
|
-
return
|
|
452
|
+
return createAction(ActionType.RENAME_TAB, { node: tabNodeId, text });
|
|
440
453
|
}
|
|
441
454
|
/**
|
|
442
455
|
* Selects the given tab in its parent tabset
|
|
@@ -444,7 +457,7 @@ var Actions = class _Actions {
|
|
|
444
457
|
* @returns {Action} the action
|
|
445
458
|
*/
|
|
446
459
|
static selectTab(tabNodeId) {
|
|
447
|
-
return
|
|
460
|
+
return createAction(ActionType.SELECT_TAB, { tabNode: tabNodeId });
|
|
448
461
|
}
|
|
449
462
|
/**
|
|
450
463
|
* Set the given tabset node as the active tabset
|
|
@@ -452,7 +465,7 @@ var Actions = class _Actions {
|
|
|
452
465
|
* @returns {Action} the action
|
|
453
466
|
*/
|
|
454
467
|
static setActiveTabset(tabsetNodeId, windowId) {
|
|
455
|
-
return
|
|
468
|
+
return createAction(ActionType.SET_ACTIVE_TABSET, { tabsetNode: tabsetNodeId, windowId });
|
|
456
469
|
}
|
|
457
470
|
/**
|
|
458
471
|
* Adjust the weights of a row, used when the splitter is moved
|
|
@@ -461,10 +474,10 @@ var Actions = class _Actions {
|
|
|
461
474
|
* @returns {Action} the action
|
|
462
475
|
*/
|
|
463
476
|
static adjustWeights(nodeId, weights) {
|
|
464
|
-
return
|
|
477
|
+
return createAction(ActionType.ADJUST_WEIGHTS, { nodeId, weights });
|
|
465
478
|
}
|
|
466
479
|
static adjustBorderSplit(nodeId, pos) {
|
|
467
|
-
return
|
|
480
|
+
return createAction(ActionType.ADJUST_BORDER_SPLIT, { node: nodeId, pos });
|
|
468
481
|
}
|
|
469
482
|
/**
|
|
470
483
|
* Maximizes the given tabset
|
|
@@ -472,7 +485,7 @@ var Actions = class _Actions {
|
|
|
472
485
|
* @returns {Action} the action
|
|
473
486
|
*/
|
|
474
487
|
static maximizeToggle(tabsetNodeId, windowId) {
|
|
475
|
-
return
|
|
488
|
+
return createAction(ActionType.MAXIMIZE_TOGGLE, { node: tabsetNodeId, windowId });
|
|
476
489
|
}
|
|
477
490
|
/**
|
|
478
491
|
* Updates the global model jsone attributes
|
|
@@ -480,7 +493,7 @@ var Actions = class _Actions {
|
|
|
480
493
|
* @returns {Action} the action
|
|
481
494
|
*/
|
|
482
495
|
static updateModelAttributes(attributes) {
|
|
483
|
-
return
|
|
496
|
+
return createAction(ActionType.UPDATE_MODEL_ATTRIBUTES, { json: attributes });
|
|
484
497
|
}
|
|
485
498
|
/**
|
|
486
499
|
* Updates the given nodes json attributes
|
|
@@ -489,7 +502,7 @@ var Actions = class _Actions {
|
|
|
489
502
|
* @returns {Action} the action
|
|
490
503
|
*/
|
|
491
504
|
static updateNodeAttributes(nodeId, attributes) {
|
|
492
|
-
return
|
|
505
|
+
return createAction(ActionType.UPDATE_NODE_ATTRIBUTES, { node: nodeId, json: attributes });
|
|
493
506
|
}
|
|
494
507
|
/**
|
|
495
508
|
* Pops out the given tab node into a new browser window
|
|
@@ -497,7 +510,7 @@ var Actions = class _Actions {
|
|
|
497
510
|
* @returns
|
|
498
511
|
*/
|
|
499
512
|
static popoutTab(nodeId) {
|
|
500
|
-
return
|
|
513
|
+
return createAction(ActionType.POPOUT_TAB, { node: nodeId });
|
|
501
514
|
}
|
|
502
515
|
/**
|
|
503
516
|
* Pops out the given tab set node into a new browser window
|
|
@@ -505,7 +518,7 @@ var Actions = class _Actions {
|
|
|
505
518
|
* @returns
|
|
506
519
|
*/
|
|
507
520
|
static popoutTabset(nodeId) {
|
|
508
|
-
return
|
|
521
|
+
return createAction(ActionType.POPOUT_TABSET, { node: nodeId });
|
|
509
522
|
}
|
|
510
523
|
/**
|
|
511
524
|
* Closes the popout window
|
|
@@ -513,7 +526,7 @@ var Actions = class _Actions {
|
|
|
513
526
|
* @returns
|
|
514
527
|
*/
|
|
515
528
|
static closeWindow(windowId) {
|
|
516
|
-
return
|
|
529
|
+
return createAction(ActionType.CLOSE_WINDOW, { windowId });
|
|
517
530
|
}
|
|
518
531
|
/**
|
|
519
532
|
* Creates a new empty popout window with the given layout
|
|
@@ -522,7 +535,7 @@ var Actions = class _Actions {
|
|
|
522
535
|
* @returns
|
|
523
536
|
*/
|
|
524
537
|
static createWindow(layout, rect) {
|
|
525
|
-
return
|
|
538
|
+
return createAction(ActionType.CREATE_WINDOW, { layout, rect });
|
|
526
539
|
}
|
|
527
540
|
};
|
|
528
541
|
|
|
@@ -633,7 +646,7 @@ var AttributeDefinitions = class {
|
|
|
633
646
|
}
|
|
634
647
|
update(jsonObj, obj) {
|
|
635
648
|
for (const attr of this.attributes) {
|
|
636
|
-
if (
|
|
649
|
+
if (Object.prototype.hasOwnProperty.call(jsonObj, attr.name)) {
|
|
637
650
|
const fromValue = jsonObj[attr.name];
|
|
638
651
|
if (fromValue === void 0) {
|
|
639
652
|
delete obj[attr.name];
|
|
@@ -818,13 +831,13 @@ var Node = class {
|
|
|
818
831
|
this.path = "";
|
|
819
832
|
}
|
|
820
833
|
getId() {
|
|
821
|
-
|
|
822
|
-
if (id
|
|
834
|
+
const id = this.attributes.id;
|
|
835
|
+
if (typeof id === "string") {
|
|
823
836
|
return id;
|
|
824
837
|
}
|
|
825
|
-
|
|
826
|
-
this.setId(
|
|
827
|
-
return
|
|
838
|
+
const newId = this.model.nextUniqueId();
|
|
839
|
+
this.setId(newId);
|
|
840
|
+
return newId;
|
|
828
841
|
}
|
|
829
842
|
getModel() {
|
|
830
843
|
return this.model;
|
|
@@ -951,7 +964,7 @@ var Node = class {
|
|
|
951
964
|
return rtn;
|
|
952
965
|
}
|
|
953
966
|
/** @internal */
|
|
954
|
-
canDrop(
|
|
967
|
+
canDrop(_dragNode, _x, _y) {
|
|
955
968
|
return void 0;
|
|
956
969
|
}
|
|
957
970
|
/** @internal */
|
|
@@ -1463,7 +1476,7 @@ function adjustSelectedIndex(parent, removedIndex) {
|
|
|
1463
1476
|
}
|
|
1464
1477
|
}
|
|
1465
1478
|
function randomUUID() {
|
|
1466
|
-
return (
|
|
1479
|
+
return (String([1e7]) + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) => (c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16));
|
|
1467
1480
|
}
|
|
1468
1481
|
|
|
1469
1482
|
// src/model/TabSetNode.ts
|
|
@@ -1800,7 +1813,7 @@ var TabSetNode = class _TabSetNode extends Node {
|
|
|
1800
1813
|
this.setSelected(insertPos);
|
|
1801
1814
|
}
|
|
1802
1815
|
} else if (dragNode instanceof RowNode) {
|
|
1803
|
-
dragNode.forEachNode((child,
|
|
1816
|
+
dragNode.forEachNode((child, _level) => {
|
|
1804
1817
|
if (child instanceof TabNode) {
|
|
1805
1818
|
this.addChild(child, insertPos);
|
|
1806
1819
|
insertPos++;
|
|
@@ -1821,7 +1834,8 @@ var TabSetNode = class _TabSetNode extends Node {
|
|
|
1821
1834
|
let moveNode = dragNode;
|
|
1822
1835
|
if (dragNode instanceof TabNode) {
|
|
1823
1836
|
const callback = this.model.getOnCreateTabSet();
|
|
1824
|
-
|
|
1837
|
+
const attrs = callback ? callback(dragNode) : {};
|
|
1838
|
+
moveNode = new _TabSetNode(this.model, attrs);
|
|
1825
1839
|
moveNode.addChild(dragNode);
|
|
1826
1840
|
dragParent = moveNode;
|
|
1827
1841
|
} else if (dragNode instanceof RowNode) {
|
|
@@ -2192,8 +2206,8 @@ var RowNode = class _RowNode extends Node {
|
|
|
2192
2206
|
}
|
|
2193
2207
|
if (this === this.model.getRoot(this.windowId) && this.children.length === 0) {
|
|
2194
2208
|
const callback = this.model.getOnCreateTabSet();
|
|
2195
|
-
|
|
2196
|
-
attrs = { ...
|
|
2209
|
+
const baseAttrs = callback ? callback() : {};
|
|
2210
|
+
const attrs = { ...baseAttrs, selected: -1 };
|
|
2197
2211
|
const child = new TabSetNode(this.model, attrs);
|
|
2198
2212
|
this.model.setActiveTabset(child, this.windowId);
|
|
2199
2213
|
this.addChild(child);
|
|
@@ -2265,7 +2279,8 @@ var RowNode = class _RowNode extends Node {
|
|
|
2265
2279
|
}
|
|
2266
2280
|
} else {
|
|
2267
2281
|
const callback = this.model.getOnCreateTabSet();
|
|
2268
|
-
|
|
2282
|
+
const attrs = callback ? callback(dragNode) : {};
|
|
2283
|
+
node = new TabSetNode(this.model, attrs);
|
|
2269
2284
|
node.addChild(dragNode);
|
|
2270
2285
|
}
|
|
2271
2286
|
let size = this.children.reduce((sum, child) => {
|
|
@@ -2576,7 +2591,7 @@ var Model = class _Model {
|
|
|
2576
2591
|
const tabsetId = randomUUID();
|
|
2577
2592
|
const json = {
|
|
2578
2593
|
type: "row",
|
|
2579
|
-
children: [{ type: "tabset", id: tabsetId }]
|
|
2594
|
+
children: [{ type: "tabset", id: tabsetId, children: [] }]
|
|
2580
2595
|
};
|
|
2581
2596
|
const row = RowNode.fromJson(json, this, layoutWindow);
|
|
2582
2597
|
layoutWindow.root = row;
|
|
@@ -2590,8 +2605,8 @@ var Model = class _Model {
|
|
|
2590
2605
|
case Actions.CLOSE_WINDOW: {
|
|
2591
2606
|
const window2 = this.windows.get(action.data.windowId);
|
|
2592
2607
|
if (window2) {
|
|
2593
|
-
this.rootWindow.root?.drop(window2
|
|
2594
|
-
this.rootWindow.visitNodes((node,
|
|
2608
|
+
this.rootWindow.root?.drop(window2.root, DockLocation.CENTER, -1);
|
|
2609
|
+
this.rootWindow.visitNodes((node, _level) => {
|
|
2595
2610
|
if (node instanceof RowNode) {
|
|
2596
2611
|
node.setWindowId(_Model.MAIN_WINDOW_ID);
|
|
2597
2612
|
}
|
|
@@ -2784,7 +2799,7 @@ var Model = class _Model {
|
|
|
2784
2799
|
*/
|
|
2785
2800
|
static fromJson(json) {
|
|
2786
2801
|
const model = new _Model();
|
|
2787
|
-
_Model.attributeDefinitions.fromJson(json.global, model.attributes);
|
|
2802
|
+
_Model.attributeDefinitions.fromJson(json.global ?? {}, model.attributes);
|
|
2788
2803
|
if (json.borders) {
|
|
2789
2804
|
model.borders = BorderSet.fromJson(json.borders, model);
|
|
2790
2805
|
}
|
|
@@ -3450,6 +3465,9 @@ var Splitter = (props) => {
|
|
|
3450
3465
|
outlineDiv.current.appendChild(handleDiv.current);
|
|
3451
3466
|
}
|
|
3452
3467
|
const r = selfRef.current?.getBoundingClientRect();
|
|
3468
|
+
if (!r) {
|
|
3469
|
+
return;
|
|
3470
|
+
}
|
|
3453
3471
|
const rect = new Rect(r.x - layout.getDomRect().x, r.y - layout.getDomRect().y, r.width, r.height);
|
|
3454
3472
|
dragStartX.current = event.clientX - r.x;
|
|
3455
3473
|
dragStartY.current = event.clientY - r.y;
|
|
@@ -3495,7 +3513,8 @@ var Splitter = (props) => {
|
|
|
3495
3513
|
enablePointerOnIFrames(true, layout.getCurrentDocument());
|
|
3496
3514
|
setDragging(false);
|
|
3497
3515
|
};
|
|
3498
|
-
const updateLayout = (
|
|
3516
|
+
const updateLayout = (_realtime) => {
|
|
3517
|
+
void _realtime;
|
|
3499
3518
|
const redraw = () => {
|
|
3500
3519
|
if (outlineDiv.current) {
|
|
3501
3520
|
let value = 0;
|
|
@@ -3641,13 +3660,13 @@ var BorderButton = (props) => {
|
|
|
3641
3660
|
const onClick = () => {
|
|
3642
3661
|
layout.doAction(Actions.selectTab(node.getId()));
|
|
3643
3662
|
};
|
|
3644
|
-
const
|
|
3663
|
+
const _onEndEdit = (event) => {
|
|
3645
3664
|
if (event.target !== contentRef.current) {
|
|
3646
|
-
layout.getCurrentDocument().body.removeEventListener("pointerdown",
|
|
3665
|
+
layout.getCurrentDocument().body.removeEventListener("pointerdown", _onEndEdit);
|
|
3647
3666
|
layout.setEditingTab(void 0);
|
|
3648
3667
|
}
|
|
3649
3668
|
};
|
|
3650
|
-
const onClose = (
|
|
3669
|
+
const onClose = (_event) => {
|
|
3651
3670
|
if (isTabClosable(node, selected)) {
|
|
3652
3671
|
layout.doAction(Actions.deleteTab(node.getId()));
|
|
3653
3672
|
} else {
|
|
@@ -3818,7 +3837,7 @@ var PopupMenu = (props) => {
|
|
|
3818
3837
|
onHide();
|
|
3819
3838
|
}, 0);
|
|
3820
3839
|
};
|
|
3821
|
-
const onDragEnd = (
|
|
3840
|
+
const onDragEnd = (_event) => {
|
|
3822
3841
|
layout.clearDragMain();
|
|
3823
3842
|
};
|
|
3824
3843
|
const itemElements = items.map((item, i) => /* @__PURE__ */ React6.createElement(
|
|
@@ -4067,7 +4086,7 @@ var BorderTabSet = (props) => {
|
|
|
4067
4086
|
} else {
|
|
4068
4087
|
overflowContent = /* @__PURE__ */ React8.createElement(React8.Fragment, null, icons.more, /* @__PURE__ */ React8.createElement("div", { className: cm("flexlayout__tab_button_overflow_count" /* FLEXLAYOUT__TAB_BUTTON_OVERFLOW_COUNT */) }, hiddenTabs.length));
|
|
4069
4088
|
}
|
|
4070
|
-
buttons.splice(
|
|
4089
|
+
void buttons.splice(
|
|
4071
4090
|
Math.min(renderState.overflowPosition, buttons.length),
|
|
4072
4091
|
0,
|
|
4073
4092
|
/* @__PURE__ */ React8.createElement(
|
|
@@ -4158,7 +4177,7 @@ var ErrorBoundary = class extends React10.Component {
|
|
|
4158
4177
|
super(props);
|
|
4159
4178
|
this.state = { hasError: false };
|
|
4160
4179
|
}
|
|
4161
|
-
static getDerivedStateFromError(
|
|
4180
|
+
static getDerivedStateFromError(_error) {
|
|
4162
4181
|
return { hasError: true };
|
|
4163
4182
|
}
|
|
4164
4183
|
componentDidCatch(error, errorInfo) {
|
|
@@ -4206,7 +4225,7 @@ var PopoutWindow = (props) => {
|
|
|
4206
4225
|
const popoutContent = popoutDocument.createElement("div");
|
|
4207
4226
|
popoutContent.className = "flexlayout__floating_window_content" /* FLEXLAYOUT__FLOATING_WINDOW_CONTENT */;
|
|
4208
4227
|
popoutDocument.body.appendChild(popoutContent);
|
|
4209
|
-
copyStyles(popoutDocument, styleMap).then(() => {
|
|
4228
|
+
void copyStyles(popoutDocument, styleMap).then(() => {
|
|
4210
4229
|
setContent(popoutContent);
|
|
4211
4230
|
});
|
|
4212
4231
|
const observer = new MutationObserver((mutationsList) => handleStyleMutations(mutationsList, popoutDocument, styleMap));
|
|
@@ -4261,7 +4280,9 @@ function copyStyles(popoutDoc, styleMap) {
|
|
|
4261
4280
|
const promises = [];
|
|
4262
4281
|
const styleElements = document.querySelectorAll('style, link[rel="stylesheet"]');
|
|
4263
4282
|
for (const element of styleElements) {
|
|
4264
|
-
|
|
4283
|
+
if (element instanceof HTMLElement) {
|
|
4284
|
+
copyStyle(popoutDoc, element, styleMap, promises);
|
|
4285
|
+
}
|
|
4265
4286
|
}
|
|
4266
4287
|
return Promise.all(promises);
|
|
4267
4288
|
}
|
|
@@ -4282,7 +4303,7 @@ function copyStyle(popoutDoc, element, styleMap, promises) {
|
|
|
4282
4303
|
const styleElement = element.cloneNode(true);
|
|
4283
4304
|
popoutDoc.head.appendChild(styleElement);
|
|
4284
4305
|
styleMap.set(element, styleElement);
|
|
4285
|
-
} catch
|
|
4306
|
+
} catch {
|
|
4286
4307
|
}
|
|
4287
4308
|
}
|
|
4288
4309
|
}
|
|
@@ -4359,7 +4380,7 @@ var TabButton = (props) => {
|
|
|
4359
4380
|
event.preventDefault();
|
|
4360
4381
|
}
|
|
4361
4382
|
};
|
|
4362
|
-
const onDragEnd = (
|
|
4383
|
+
const onDragEnd = (_event) => {
|
|
4363
4384
|
layout.clearDragMain();
|
|
4364
4385
|
};
|
|
4365
4386
|
const onAuxMouseClick = (event) => {
|
|
@@ -4521,7 +4542,7 @@ var TabSet = (props) => {
|
|
|
4521
4542
|
const oldWasEmpty = oldContentRect.width === 0 && oldContentRect.height === 0;
|
|
4522
4543
|
const shouldRedraw = !isFirstRender.current || oldWasEmpty;
|
|
4523
4544
|
if (shouldRedraw) {
|
|
4524
|
-
layout.redrawInternal("tabset content rect " + newContentRect);
|
|
4545
|
+
layout.redrawInternal("tabset content rect " + newContentRect.toString());
|
|
4525
4546
|
}
|
|
4526
4547
|
}
|
|
4527
4548
|
isFirstRender.current = false;
|
|
@@ -4595,7 +4616,7 @@ var TabSet = (props) => {
|
|
|
4595
4616
|
}
|
|
4596
4617
|
event.stopPropagation();
|
|
4597
4618
|
};
|
|
4598
|
-
const onDoubleClick = (
|
|
4619
|
+
const onDoubleClick = (_event) => {
|
|
4599
4620
|
if (node.canMaximize()) {
|
|
4600
4621
|
layout.maximize(node);
|
|
4601
4622
|
}
|
|
@@ -4658,7 +4679,7 @@ var TabSet = (props) => {
|
|
|
4658
4679
|
} else {
|
|
4659
4680
|
overflowContent = /* @__PURE__ */ React15.createElement(React15.Fragment, null, icons.more, /* @__PURE__ */ React15.createElement("div", { className: cm("flexlayout__tab_button_overflow_count" /* FLEXLAYOUT__TAB_BUTTON_OVERFLOW_COUNT */) }, hiddenTabs.length));
|
|
4660
4681
|
}
|
|
4661
|
-
buttons.splice(
|
|
4682
|
+
void buttons.splice(
|
|
4662
4683
|
Math.min(renderState.overflowPosition, buttons.length),
|
|
4663
4684
|
0,
|
|
4664
4685
|
/* @__PURE__ */ React15.createElement(
|
|
@@ -4995,6 +5016,7 @@ var SizeTracker = React18.memo(
|
|
|
4995
5016
|
return prevProps.rect.equalSize(nextProps.rect) && prevProps.selected === nextProps.selected && prevProps.forceRevision === nextProps.forceRevision && prevProps.tabsRevision === nextProps.tabsRevision;
|
|
4996
5017
|
}
|
|
4997
5018
|
);
|
|
5019
|
+
SizeTracker.displayName = "SizeTracker";
|
|
4998
5020
|
|
|
4999
5021
|
// src/view/Layout.tsx
|
|
5000
5022
|
var Layout = class extends React19.Component {
|
|
@@ -5763,6 +5785,11 @@ var LayoutInternal = class _LayoutInternal extends React19.Component {
|
|
|
5763
5785
|
onDragLeaveRaw = (event) => {
|
|
5764
5786
|
this.dragEnterCount--;
|
|
5765
5787
|
if (this.dragEnterCount === 0) {
|
|
5788
|
+
const relatedTarget = event.relatedTarget;
|
|
5789
|
+
if (relatedTarget && this.selfRef.current?.contains(relatedTarget)) {
|
|
5790
|
+
this.dragEnterCount = 1;
|
|
5791
|
+
return;
|
|
5792
|
+
}
|
|
5766
5793
|
this.onDragLeave(event);
|
|
5767
5794
|
}
|
|
5768
5795
|
};
|
|
@@ -5816,7 +5843,7 @@ var LayoutInternal = class _LayoutInternal extends React19.Component {
|
|
|
5816
5843
|
if (!this.isDraggingOverWindow && this.props.model.getMaximizedTabset(this.windowId) === void 0) {
|
|
5817
5844
|
this.setState({ showEdges: this.props.model.isEnableEdgeDock() });
|
|
5818
5845
|
}
|
|
5819
|
-
const clientRect = this.selfRef.current
|
|
5846
|
+
const clientRect = this.selfRef.current.getBoundingClientRect();
|
|
5820
5847
|
const r = new Rect(event.clientX - clientRect.left, event.clientY - clientRect.top, 1, 1);
|
|
5821
5848
|
r.positionElement(this.outlineDiv);
|
|
5822
5849
|
}
|
|
@@ -6132,7 +6159,7 @@ function walkJsonModel(model, visitor) {
|
|
|
6132
6159
|
}
|
|
6133
6160
|
}
|
|
6134
6161
|
export {
|
|
6135
|
-
|
|
6162
|
+
ActionType,
|
|
6136
6163
|
Actions,
|
|
6137
6164
|
BorderNode,
|
|
6138
6165
|
BorderSet,
|
|
@@ -6155,6 +6182,7 @@ export {
|
|
|
6155
6182
|
RowNode,
|
|
6156
6183
|
TabNode,
|
|
6157
6184
|
TabSetNode,
|
|
6185
|
+
createAction,
|
|
6158
6186
|
findJsonNodeById,
|
|
6159
6187
|
walkJsonModel
|
|
6160
6188
|
};
|
package/dist/model/Action.d.ts
CHANGED
|
@@ -1,5 +1,159 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { IJsonRect, IJsonRowNode, IJsonTabNode, IGlobalAttributes, ITabAttributes, ITabSetAttributes, IRowAttributes, IBorderAttributes } from "./IJsonModel";
|
|
2
|
+
/** Action type constants */
|
|
3
|
+
export declare const ActionType: {
|
|
4
|
+
readonly ADD_NODE: "FlexLayout_AddNode";
|
|
5
|
+
readonly MOVE_NODE: "FlexLayout_MoveNode";
|
|
6
|
+
readonly DELETE_TAB: "FlexLayout_DeleteTab";
|
|
7
|
+
readonly DELETE_TABSET: "FlexLayout_DeleteTabset";
|
|
8
|
+
readonly RENAME_TAB: "FlexLayout_RenameTab";
|
|
9
|
+
readonly SELECT_TAB: "FlexLayout_SelectTab";
|
|
10
|
+
readonly SET_ACTIVE_TABSET: "FlexLayout_SetActiveTabset";
|
|
11
|
+
readonly ADJUST_WEIGHTS: "FlexLayout_AdjustWeights";
|
|
12
|
+
readonly ADJUST_BORDER_SPLIT: "FlexLayout_AdjustBorderSplit";
|
|
13
|
+
readonly MAXIMIZE_TOGGLE: "FlexLayout_MaximizeToggle";
|
|
14
|
+
readonly UPDATE_MODEL_ATTRIBUTES: "FlexLayout_UpdateModelAttributes";
|
|
15
|
+
readonly UPDATE_NODE_ATTRIBUTES: "FlexLayout_UpdateNodeAttributes";
|
|
16
|
+
readonly POPOUT_TAB: "FlexLayout_PopoutTab";
|
|
17
|
+
readonly POPOUT_TABSET: "FlexLayout_PopoutTabset";
|
|
18
|
+
readonly CLOSE_WINDOW: "FlexLayout_CloseWindow";
|
|
19
|
+
readonly CREATE_WINDOW: "FlexLayout_CreateWindow";
|
|
20
|
+
};
|
|
21
|
+
export type ActionTypeValue = (typeof ActionType)[keyof typeof ActionType];
|
|
22
|
+
/** Data types for each action */
|
|
23
|
+
export interface AddNodeData {
|
|
24
|
+
json: IJsonTabNode;
|
|
25
|
+
toNode: string;
|
|
26
|
+
location: string;
|
|
27
|
+
index: number;
|
|
28
|
+
select?: boolean;
|
|
5
29
|
}
|
|
30
|
+
export interface MoveNodeData {
|
|
31
|
+
fromNode: string;
|
|
32
|
+
toNode: string;
|
|
33
|
+
location: string;
|
|
34
|
+
index: number;
|
|
35
|
+
select?: boolean;
|
|
36
|
+
}
|
|
37
|
+
export interface DeleteTabData {
|
|
38
|
+
node: string;
|
|
39
|
+
}
|
|
40
|
+
export interface DeleteTabsetData {
|
|
41
|
+
node: string;
|
|
42
|
+
}
|
|
43
|
+
export interface RenameTabData {
|
|
44
|
+
node: string;
|
|
45
|
+
text: string;
|
|
46
|
+
}
|
|
47
|
+
export interface SelectTabData {
|
|
48
|
+
tabNode: string;
|
|
49
|
+
windowId?: string;
|
|
50
|
+
}
|
|
51
|
+
export interface SetActiveTabsetData {
|
|
52
|
+
tabsetNode: string | undefined;
|
|
53
|
+
windowId?: string;
|
|
54
|
+
}
|
|
55
|
+
export interface AdjustWeightsData {
|
|
56
|
+
nodeId: string;
|
|
57
|
+
weights: number[];
|
|
58
|
+
}
|
|
59
|
+
export interface AdjustBorderSplitData {
|
|
60
|
+
node: string;
|
|
61
|
+
pos: number;
|
|
62
|
+
}
|
|
63
|
+
export interface MaximizeToggleData {
|
|
64
|
+
node: string;
|
|
65
|
+
windowId?: string;
|
|
66
|
+
}
|
|
67
|
+
/** Union type for node attributes that can be updated */
|
|
68
|
+
export type NodeAttributes = Partial<ITabAttributes> | Partial<ITabSetAttributes> | Partial<IRowAttributes> | Partial<IBorderAttributes>;
|
|
69
|
+
export interface UpdateModelAttributesData {
|
|
70
|
+
json: Partial<IGlobalAttributes>;
|
|
71
|
+
}
|
|
72
|
+
export interface UpdateNodeAttributesData {
|
|
73
|
+
node: string;
|
|
74
|
+
json: NodeAttributes;
|
|
75
|
+
}
|
|
76
|
+
export interface PopoutTabData {
|
|
77
|
+
node: string;
|
|
78
|
+
}
|
|
79
|
+
export interface PopoutTabsetData {
|
|
80
|
+
node: string;
|
|
81
|
+
}
|
|
82
|
+
export interface CloseWindowData {
|
|
83
|
+
windowId: string;
|
|
84
|
+
}
|
|
85
|
+
export interface CreateWindowData {
|
|
86
|
+
layout: IJsonRowNode;
|
|
87
|
+
rect: IJsonRect;
|
|
88
|
+
}
|
|
89
|
+
/** Map from action type to its data type */
|
|
90
|
+
export interface ActionDataMap {
|
|
91
|
+
[ActionType.ADD_NODE]: AddNodeData;
|
|
92
|
+
[ActionType.MOVE_NODE]: MoveNodeData;
|
|
93
|
+
[ActionType.DELETE_TAB]: DeleteTabData;
|
|
94
|
+
[ActionType.DELETE_TABSET]: DeleteTabsetData;
|
|
95
|
+
[ActionType.RENAME_TAB]: RenameTabData;
|
|
96
|
+
[ActionType.SELECT_TAB]: SelectTabData;
|
|
97
|
+
[ActionType.SET_ACTIVE_TABSET]: SetActiveTabsetData;
|
|
98
|
+
[ActionType.ADJUST_WEIGHTS]: AdjustWeightsData;
|
|
99
|
+
[ActionType.ADJUST_BORDER_SPLIT]: AdjustBorderSplitData;
|
|
100
|
+
[ActionType.MAXIMIZE_TOGGLE]: MaximizeToggleData;
|
|
101
|
+
[ActionType.UPDATE_MODEL_ATTRIBUTES]: UpdateModelAttributesData;
|
|
102
|
+
[ActionType.UPDATE_NODE_ATTRIBUTES]: UpdateNodeAttributesData;
|
|
103
|
+
[ActionType.POPOUT_TAB]: PopoutTabData;
|
|
104
|
+
[ActionType.POPOUT_TABSET]: PopoutTabsetData;
|
|
105
|
+
[ActionType.CLOSE_WINDOW]: CloseWindowData;
|
|
106
|
+
[ActionType.CREATE_WINDOW]: CreateWindowData;
|
|
107
|
+
}
|
|
108
|
+
/** Discriminated union of all Action types */
|
|
109
|
+
export type Action = {
|
|
110
|
+
type: typeof ActionType.ADD_NODE;
|
|
111
|
+
data: AddNodeData;
|
|
112
|
+
} | {
|
|
113
|
+
type: typeof ActionType.MOVE_NODE;
|
|
114
|
+
data: MoveNodeData;
|
|
115
|
+
} | {
|
|
116
|
+
type: typeof ActionType.DELETE_TAB;
|
|
117
|
+
data: DeleteTabData;
|
|
118
|
+
} | {
|
|
119
|
+
type: typeof ActionType.DELETE_TABSET;
|
|
120
|
+
data: DeleteTabsetData;
|
|
121
|
+
} | {
|
|
122
|
+
type: typeof ActionType.RENAME_TAB;
|
|
123
|
+
data: RenameTabData;
|
|
124
|
+
} | {
|
|
125
|
+
type: typeof ActionType.SELECT_TAB;
|
|
126
|
+
data: SelectTabData;
|
|
127
|
+
} | {
|
|
128
|
+
type: typeof ActionType.SET_ACTIVE_TABSET;
|
|
129
|
+
data: SetActiveTabsetData;
|
|
130
|
+
} | {
|
|
131
|
+
type: typeof ActionType.ADJUST_WEIGHTS;
|
|
132
|
+
data: AdjustWeightsData;
|
|
133
|
+
} | {
|
|
134
|
+
type: typeof ActionType.ADJUST_BORDER_SPLIT;
|
|
135
|
+
data: AdjustBorderSplitData;
|
|
136
|
+
} | {
|
|
137
|
+
type: typeof ActionType.MAXIMIZE_TOGGLE;
|
|
138
|
+
data: MaximizeToggleData;
|
|
139
|
+
} | {
|
|
140
|
+
type: typeof ActionType.UPDATE_MODEL_ATTRIBUTES;
|
|
141
|
+
data: UpdateModelAttributesData;
|
|
142
|
+
} | {
|
|
143
|
+
type: typeof ActionType.UPDATE_NODE_ATTRIBUTES;
|
|
144
|
+
data: UpdateNodeAttributesData;
|
|
145
|
+
} | {
|
|
146
|
+
type: typeof ActionType.POPOUT_TAB;
|
|
147
|
+
data: PopoutTabData;
|
|
148
|
+
} | {
|
|
149
|
+
type: typeof ActionType.POPOUT_TABSET;
|
|
150
|
+
data: PopoutTabsetData;
|
|
151
|
+
} | {
|
|
152
|
+
type: typeof ActionType.CLOSE_WINDOW;
|
|
153
|
+
data: CloseWindowData;
|
|
154
|
+
} | {
|
|
155
|
+
type: typeof ActionType.CREATE_WINDOW;
|
|
156
|
+
data: CreateWindowData;
|
|
157
|
+
};
|
|
158
|
+
/** Factory function for creating typed actions */
|
|
159
|
+
export declare function createAction<T extends ActionTypeValue>(type: T, data: ActionDataMap[T]): Action;
|