@aptre/flex-layout 0.4.3 → 0.5.0
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/Layout.features.e2e.test.d.ts +1 -0
- package/dist/Rect.d.ts +1 -1
- package/dist/index.mjs +168 -105
- 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/dist/view/OptimizedLayout.d.ts +1 -1
- package/package.json +5 -3
- 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/dist/Layout.test.d.ts +0 -1
- package/typedoc/classes/Action.html +0 -4
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(
|
|
@@ -4938,6 +4959,12 @@ var Tab = (props) => {
|
|
|
4938
4959
|
}
|
|
4939
4960
|
}
|
|
4940
4961
|
}, [selected]);
|
|
4962
|
+
React17.useLayoutEffect(() => {
|
|
4963
|
+
node.setRect(rect);
|
|
4964
|
+
}, [rect, node]);
|
|
4965
|
+
React17.useLayoutEffect(() => {
|
|
4966
|
+
node.setVisible(selected);
|
|
4967
|
+
}, [selected, node]);
|
|
4941
4968
|
const onPointerDown = () => {
|
|
4942
4969
|
const parent = node.getParent();
|
|
4943
4970
|
if (parent instanceof TabSetNode) {
|
|
@@ -4946,13 +4973,11 @@ var Tab = (props) => {
|
|
|
4946
4973
|
}
|
|
4947
4974
|
}
|
|
4948
4975
|
};
|
|
4949
|
-
node.setRect(rect);
|
|
4950
4976
|
const cm = layout.getClassName;
|
|
4951
4977
|
const style2 = {};
|
|
4952
4978
|
rect.styleWithPosition(style2);
|
|
4953
4979
|
let overlay = null;
|
|
4954
4980
|
if (selected) {
|
|
4955
|
-
node.setVisible(true);
|
|
4956
4981
|
if (document.hidden && node.isEnablePopoutOverlay()) {
|
|
4957
4982
|
const overlayStyle = {};
|
|
4958
4983
|
rect.styleWithPosition(overlayStyle);
|
|
@@ -4960,7 +4985,6 @@ var Tab = (props) => {
|
|
|
4960
4985
|
}
|
|
4961
4986
|
} else {
|
|
4962
4987
|
style2.display = "none";
|
|
4963
|
-
node.setVisible(false);
|
|
4964
4988
|
}
|
|
4965
4989
|
if (parentNode instanceof TabSetNode) {
|
|
4966
4990
|
if (node.getModel().getMaximizedTabset(layout.getWindowId()) !== void 0) {
|
|
@@ -4992,6 +5016,7 @@ var SizeTracker = React18.memo(
|
|
|
4992
5016
|
return prevProps.rect.equalSize(nextProps.rect) && prevProps.selected === nextProps.selected && prevProps.forceRevision === nextProps.forceRevision && prevProps.tabsRevision === nextProps.tabsRevision;
|
|
4993
5017
|
}
|
|
4994
5018
|
);
|
|
5019
|
+
SizeTracker.displayName = "SizeTracker";
|
|
4995
5020
|
|
|
4996
5021
|
// src/view/Layout.tsx
|
|
4997
5022
|
var Layout = class extends React19.Component {
|
|
@@ -5813,7 +5838,7 @@ var LayoutInternal = class _LayoutInternal extends React19.Component {
|
|
|
5813
5838
|
if (!this.isDraggingOverWindow && this.props.model.getMaximizedTabset(this.windowId) === void 0) {
|
|
5814
5839
|
this.setState({ showEdges: this.props.model.isEnableEdgeDock() });
|
|
5815
5840
|
}
|
|
5816
|
-
const clientRect = this.selfRef.current
|
|
5841
|
+
const clientRect = this.selfRef.current.getBoundingClientRect();
|
|
5817
5842
|
const r = new Rect(event.clientX - clientRect.left, event.clientY - clientRect.top, 1, 1);
|
|
5818
5843
|
r.positionElement(this.outlineDiv);
|
|
5819
5844
|
}
|
|
@@ -5897,9 +5922,24 @@ var DragState = class {
|
|
|
5897
5922
|
|
|
5898
5923
|
// src/view/OptimizedLayout.tsx
|
|
5899
5924
|
import * as React20 from "react";
|
|
5900
|
-
import { useCallback, useEffect as useEffect6,
|
|
5901
|
-
function
|
|
5925
|
+
import { useCallback, useEffect as useEffect6, useState as useState4 } from "react";
|
|
5926
|
+
function createTabInfo(node) {
|
|
5927
|
+
const parent = node.getParent();
|
|
5928
|
+
const contentRect = parent?.getContentRect() ?? Rect.empty();
|
|
5929
|
+
return {
|
|
5930
|
+
node,
|
|
5931
|
+
rect: contentRect,
|
|
5932
|
+
visible: node.isSelected()
|
|
5933
|
+
};
|
|
5934
|
+
}
|
|
5935
|
+
function TabRef({
|
|
5936
|
+
node,
|
|
5937
|
+
onTabMount,
|
|
5938
|
+
onRectChange,
|
|
5939
|
+
onVisibilityChange
|
|
5940
|
+
}) {
|
|
5902
5941
|
useEffect6(() => {
|
|
5942
|
+
onTabMount(node);
|
|
5903
5943
|
const handleResize = (params) => {
|
|
5904
5944
|
onRectChange(node.getId(), params.rect);
|
|
5905
5945
|
};
|
|
@@ -5920,7 +5960,7 @@ function TabRef({ node, onRectChange, onVisibilityChange }) {
|
|
|
5920
5960
|
node.removeEventListener("resize");
|
|
5921
5961
|
node.removeEventListener("visibility");
|
|
5922
5962
|
};
|
|
5923
|
-
}, [node, onRectChange, onVisibilityChange]);
|
|
5963
|
+
}, [node, onTabMount, onRectChange, onVisibilityChange]);
|
|
5924
5964
|
return null;
|
|
5925
5965
|
}
|
|
5926
5966
|
function TabContainer({
|
|
@@ -5980,37 +6020,43 @@ function TabContainer({
|
|
|
5980
6020
|
})
|
|
5981
6021
|
);
|
|
5982
6022
|
}
|
|
5983
|
-
function OptimizedLayout({ model, renderTab, classNameMapper, onDragStateChange, ...layoutProps }) {
|
|
6023
|
+
function OptimizedLayout({ model, renderTab, classNameMapper, onDragStateChange, onModelChange: userOnModelChange, ...layoutProps }) {
|
|
5984
6024
|
const [isDragging, setIsDragging] = useState4(false);
|
|
5985
6025
|
const [tabs, setTabs] = useState4(() => /* @__PURE__ */ new Map());
|
|
5986
|
-
const
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
tabNodesRef.current = newTabNodes;
|
|
5995
|
-
setTabs((prevTabs) => {
|
|
6026
|
+
const syncTabsWithModel = useCallback(
|
|
6027
|
+
(prevTabs) => {
|
|
6028
|
+
const modelTabNodes = /* @__PURE__ */ new Map();
|
|
6029
|
+
model.visitNodes((node) => {
|
|
6030
|
+
if (node instanceof TabNode) {
|
|
6031
|
+
modelTabNodes.set(node.getId(), node);
|
|
6032
|
+
}
|
|
6033
|
+
});
|
|
5996
6034
|
const nextTabs = /* @__PURE__ */ new Map();
|
|
5997
|
-
|
|
6035
|
+
let changed = false;
|
|
6036
|
+
for (const [nodeId, node] of modelTabNodes) {
|
|
5998
6037
|
const existing = prevTabs.get(nodeId);
|
|
5999
6038
|
if (existing) {
|
|
6000
6039
|
nextTabs.set(nodeId, { ...existing, node });
|
|
6001
6040
|
} else {
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
nextTabs.set(nodeId, {
|
|
6005
|
-
node,
|
|
6006
|
-
rect: contentRect,
|
|
6007
|
-
visible: node.isSelected()
|
|
6008
|
-
});
|
|
6041
|
+
nextTabs.set(nodeId, createTabInfo(node));
|
|
6042
|
+
changed = true;
|
|
6009
6043
|
}
|
|
6010
6044
|
}
|
|
6045
|
+
for (const nodeId of prevTabs.keys()) {
|
|
6046
|
+
if (!modelTabNodes.has(nodeId)) {
|
|
6047
|
+
changed = true;
|
|
6048
|
+
}
|
|
6049
|
+
}
|
|
6050
|
+
if (!changed && nextTabs.size === prevTabs.size) {
|
|
6051
|
+
return prevTabs;
|
|
6052
|
+
}
|
|
6011
6053
|
return nextTabs;
|
|
6012
|
-
}
|
|
6013
|
-
|
|
6054
|
+
},
|
|
6055
|
+
[model]
|
|
6056
|
+
);
|
|
6057
|
+
useEffect6(() => {
|
|
6058
|
+
setTabs((prevTabs) => syncTabsWithModel(prevTabs));
|
|
6059
|
+
}, [syncTabsWithModel]);
|
|
6014
6060
|
const handleRectChange = useCallback((nodeId, rect) => {
|
|
6015
6061
|
setTabs((prevTabs) => {
|
|
6016
6062
|
const existing = prevTabs.get(nodeId);
|
|
@@ -6033,6 +6079,16 @@ function OptimizedLayout({ model, renderTab, classNameMapper, onDragStateChange,
|
|
|
6033
6079
|
return nextTabs;
|
|
6034
6080
|
});
|
|
6035
6081
|
}, []);
|
|
6082
|
+
const handleTabMount = useCallback((node) => {
|
|
6083
|
+
setTabs((prevTabs) => {
|
|
6084
|
+
if (prevTabs.has(node.getId())) {
|
|
6085
|
+
return prevTabs;
|
|
6086
|
+
}
|
|
6087
|
+
const nextTabs = new Map(prevTabs);
|
|
6088
|
+
nextTabs.set(node.getId(), createTabInfo(node));
|
|
6089
|
+
return nextTabs;
|
|
6090
|
+
});
|
|
6091
|
+
}, []);
|
|
6036
6092
|
const handleDragStateChange = useCallback(
|
|
6037
6093
|
(dragging) => {
|
|
6038
6094
|
setIsDragging(dragging);
|
|
@@ -6040,14 +6096,20 @@ function OptimizedLayout({ model, renderTab, classNameMapper, onDragStateChange,
|
|
|
6040
6096
|
},
|
|
6041
6097
|
[onDragStateChange]
|
|
6042
6098
|
);
|
|
6099
|
+
const handleModelChange = useCallback(
|
|
6100
|
+
(changedModel, action) => {
|
|
6101
|
+
setTabs((prevTabs) => syncTabsWithModel(prevTabs));
|
|
6102
|
+
userOnModelChange?.(changedModel, action);
|
|
6103
|
+
},
|
|
6104
|
+
[syncTabsWithModel, userOnModelChange]
|
|
6105
|
+
);
|
|
6043
6106
|
const factory = useCallback(
|
|
6044
6107
|
(node) => {
|
|
6045
|
-
return /* @__PURE__ */ React20.createElement(TabRef, { key: node.getId(), node, onRectChange: handleRectChange, onVisibilityChange: handleVisibilityChange });
|
|
6108
|
+
return /* @__PURE__ */ React20.createElement(TabRef, { key: node.getId(), node, onTabMount: handleTabMount, onRectChange: handleRectChange, onVisibilityChange: handleVisibilityChange });
|
|
6046
6109
|
},
|
|
6047
|
-
[handleRectChange, handleVisibilityChange]
|
|
6110
|
+
[handleTabMount, handleRectChange, handleVisibilityChange]
|
|
6048
6111
|
);
|
|
6049
|
-
|
|
6050
|
-
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Layout, { model, factory, classNameMapper, onDragStateChange: handleDragStateChange, ...layoutProps }), /* @__PURE__ */ React20.createElement(TabContainer, { tabs: tabsForContainer, renderTab, isDragging, classNameMapper }));
|
|
6112
|
+
return /* @__PURE__ */ React20.createElement(React20.Fragment, null, /* @__PURE__ */ React20.createElement(Layout, { model, factory, classNameMapper, onDragStateChange: handleDragStateChange, onModelChange: handleModelChange, ...layoutProps }), /* @__PURE__ */ React20.createElement(TabContainer, { tabs, renderTab, isDragging, classNameMapper }));
|
|
6051
6113
|
}
|
|
6052
6114
|
|
|
6053
6115
|
// src/model/walk.ts
|
|
@@ -6092,7 +6154,7 @@ function walkJsonModel(model, visitor) {
|
|
|
6092
6154
|
}
|
|
6093
6155
|
}
|
|
6094
6156
|
export {
|
|
6095
|
-
|
|
6157
|
+
ActionType,
|
|
6096
6158
|
Actions,
|
|
6097
6159
|
BorderNode,
|
|
6098
6160
|
BorderSet,
|
|
@@ -6115,6 +6177,7 @@ export {
|
|
|
6115
6177
|
RowNode,
|
|
6116
6178
|
TabNode,
|
|
6117
6179
|
TabSetNode,
|
|
6180
|
+
createAction,
|
|
6118
6181
|
findJsonNodeById,
|
|
6119
6182
|
walkJsonModel
|
|
6120
6183
|
};
|