orcasvn-react-diagrams 0.2.8 → 0.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +6 -5
- package/ai/api-contract.json +16 -0
- package/ai/invariants.json +8 -0
- package/ai/manifest.json +1 -1
- package/dist/cjs/examples.js +351 -26
- package/dist/cjs/index.js +223 -26
- package/dist/cjs/types/api/types.d.ts +2 -0
- package/dist/cjs/types/displaybox/demos/elementVisibilitySelectionDemo.d.ts +4 -0
- package/dist/cjs/types/engine/DiagramEngine.d.ts +8 -0
- package/dist/cjs/types/models/DiagramModel.d.ts +5 -0
- package/dist/cjs/types/models/ElementModel.d.ts +2 -0
- package/dist/esm/examples.js +351 -26
- package/dist/esm/examples.js.map +1 -1
- package/dist/esm/index.js +223 -26
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/api/types.d.ts +2 -0
- package/dist/esm/types/displaybox/demos/elementVisibilitySelectionDemo.d.ts +4 -0
- package/dist/esm/types/engine/DiagramEngine.d.ts +8 -0
- package/dist/esm/types/models/DiagramModel.d.ts +5 -0
- package/dist/esm/types/models/ElementModel.d.ts +2 -0
- package/dist/examples.d.ts +2 -0
- package/dist/index.d.ts +9 -0
- package/docs/API_CONTRACT.md +16 -1
- package/docs/CAPABILITIES.md +1 -0
- package/docs/COMMANDS_EVENTS.md +3 -1
- package/docs/DOCUMENTATION_WORKFLOW.md +2 -1
- package/docs/INTEGRATION_PLAYBOOK.md +1 -0
- package/docs/PORTING_CHECKLIST.md +1 -0
- package/docs/STATE_INVARIANTS.md +9 -1
- package/package.json +1 -1
- package/src/displaybox/demos/elementVisibilitySelectionDemo.ts +128 -0
- package/src/displaybox/demos/index.tsx +14 -7
package/dist/esm/index.js
CHANGED
|
@@ -85,6 +85,8 @@ var ElementModel = /** @class */ (function () {
|
|
|
85
85
|
this.style = data.style;
|
|
86
86
|
this.portIds = data.portIds ? __spreadArray([], data.portIds, true) : [];
|
|
87
87
|
this.textIds = data.textIds ? __spreadArray([], data.textIds, true) : [];
|
|
88
|
+
this.visible = data.visible;
|
|
89
|
+
this.selectable = data.selectable;
|
|
88
90
|
this.parentId = (_a = data.parentId) !== null && _a !== void 0 ? _a : null;
|
|
89
91
|
this.moveMode = data.moveMode;
|
|
90
92
|
this.anchorCenter = data.anchorCenter;
|
|
@@ -123,6 +125,8 @@ var ElementModel = /** @class */ (function () {
|
|
|
123
125
|
style: this.style,
|
|
124
126
|
portIds: __spreadArray([], this.portIds, true),
|
|
125
127
|
textIds: __spreadArray([], this.textIds, true),
|
|
128
|
+
visible: this.visible,
|
|
129
|
+
selectable: this.selectable,
|
|
126
130
|
parentId: this.parentId,
|
|
127
131
|
moveMode: this.moveMode,
|
|
128
132
|
anchorCenter: this.anchorCenter,
|
|
@@ -526,6 +530,29 @@ var DiagramModel = /** @class */ (function () {
|
|
|
526
530
|
DiagramModel.prototype.getElement = function (id) {
|
|
527
531
|
return this.elements.get(id);
|
|
528
532
|
};
|
|
533
|
+
DiagramModel.prototype.isElementVisible = function (id) {
|
|
534
|
+
var element = this.elements.get(id);
|
|
535
|
+
if (!element)
|
|
536
|
+
return false;
|
|
537
|
+
if (element.visible === false)
|
|
538
|
+
return false;
|
|
539
|
+
var currentParentId = element.parentId;
|
|
540
|
+
while (currentParentId) {
|
|
541
|
+
var parent_1 = this.elements.get(currentParentId);
|
|
542
|
+
if (!parent_1)
|
|
543
|
+
break;
|
|
544
|
+
if (parent_1.visible === false)
|
|
545
|
+
return false;
|
|
546
|
+
currentParentId = parent_1.parentId;
|
|
547
|
+
}
|
|
548
|
+
return true;
|
|
549
|
+
};
|
|
550
|
+
DiagramModel.prototype.isElementSelectable = function (id) {
|
|
551
|
+
var element = this.elements.get(id);
|
|
552
|
+
if (!element)
|
|
553
|
+
return false;
|
|
554
|
+
return this.isElementVisible(id) && element.selectable !== false;
|
|
555
|
+
};
|
|
529
556
|
DiagramModel.prototype.setElementLayout = function (id, layout) {
|
|
530
557
|
var element = this.elements.get(id);
|
|
531
558
|
if (!element)
|
|
@@ -544,6 +571,12 @@ var DiagramModel = /** @class */ (function () {
|
|
|
544
571
|
DiagramModel.prototype.getPort = function (id) {
|
|
545
572
|
return this.ports.get(id);
|
|
546
573
|
};
|
|
574
|
+
DiagramModel.prototype.isPortVisible = function (id) {
|
|
575
|
+
var port = this.ports.get(id);
|
|
576
|
+
if (!port)
|
|
577
|
+
return false;
|
|
578
|
+
return this.isElementVisible(port.elementId);
|
|
579
|
+
};
|
|
547
580
|
DiagramModel.prototype.getPortWorldPosition = function (id) {
|
|
548
581
|
var port = this.ports.get(id);
|
|
549
582
|
if (!port)
|
|
@@ -559,6 +592,16 @@ var DiagramModel = /** @class */ (function () {
|
|
|
559
592
|
DiagramModel.prototype.getLink = function (id) {
|
|
560
593
|
return this.links.get(id);
|
|
561
594
|
};
|
|
595
|
+
DiagramModel.prototype.isLinkVisible = function (id) {
|
|
596
|
+
var link = this.links.get(id);
|
|
597
|
+
if (!link)
|
|
598
|
+
return false;
|
|
599
|
+
var sourcePort = this.ports.get(link.sourcePortId);
|
|
600
|
+
var targetPort = this.ports.get(link.targetPortId);
|
|
601
|
+
var sourceVisible = sourcePort ? this.isPortVisible(sourcePort.id) : true;
|
|
602
|
+
var targetVisible = targetPort ? this.isPortVisible(targetPort.id) : true;
|
|
603
|
+
return sourceVisible && targetVisible;
|
|
604
|
+
};
|
|
562
605
|
DiagramModel.prototype.getLinkMidpoint = function (id) {
|
|
563
606
|
var link = this.links.get(id);
|
|
564
607
|
if (!link)
|
|
@@ -568,6 +611,23 @@ var DiagramModel = /** @class */ (function () {
|
|
|
568
611
|
DiagramModel.prototype.getText = function (id) {
|
|
569
612
|
return this.texts.get(id);
|
|
570
613
|
};
|
|
614
|
+
DiagramModel.prototype.isTextVisible = function (id) {
|
|
615
|
+
var text = this.texts.get(id);
|
|
616
|
+
if (!text)
|
|
617
|
+
return false;
|
|
618
|
+
if (!text.ownerId)
|
|
619
|
+
return true;
|
|
620
|
+
if (this.elements.has(text.ownerId)) {
|
|
621
|
+
return this.isElementVisible(text.ownerId);
|
|
622
|
+
}
|
|
623
|
+
if (this.ports.has(text.ownerId)) {
|
|
624
|
+
return this.isPortVisible(text.ownerId);
|
|
625
|
+
}
|
|
626
|
+
if (this.links.has(text.ownerId)) {
|
|
627
|
+
return this.isLinkVisible(text.ownerId);
|
|
628
|
+
}
|
|
629
|
+
return true;
|
|
630
|
+
};
|
|
571
631
|
DiagramModel.prototype.getTextWorldPosition = function (id) {
|
|
572
632
|
var text = this.texts.get(id);
|
|
573
633
|
if (!text)
|
|
@@ -756,18 +816,18 @@ var DiagramModel = /** @class */ (function () {
|
|
|
756
816
|
}
|
|
757
817
|
var current = element;
|
|
758
818
|
while (current === null || current === void 0 ? void 0 : current.parentId) {
|
|
759
|
-
var
|
|
760
|
-
if (!
|
|
819
|
+
var parent_2 = this.elements.get(current.parentId);
|
|
820
|
+
if (!parent_2)
|
|
761
821
|
break;
|
|
762
|
-
var parentX =
|
|
763
|
-
var parentY =
|
|
764
|
-
if (
|
|
765
|
-
parentX -=
|
|
766
|
-
parentY -=
|
|
822
|
+
var parentX = parent_2.position.x;
|
|
823
|
+
var parentY = parent_2.position.y;
|
|
824
|
+
if (parent_2.anchorCenter) {
|
|
825
|
+
parentX -= parent_2.size.width / 2;
|
|
826
|
+
parentY -= parent_2.size.height / 2;
|
|
767
827
|
}
|
|
768
828
|
x += parentX;
|
|
769
829
|
y += parentY;
|
|
770
|
-
current =
|
|
830
|
+
current = parent_2;
|
|
771
831
|
}
|
|
772
832
|
return { x: x, y: y };
|
|
773
833
|
};
|
|
@@ -4330,16 +4390,38 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
4330
4390
|
this.emitEntityDeletionEvents(removal.removed);
|
|
4331
4391
|
};
|
|
4332
4392
|
DiagramEngine.prototype.setSelection = function (ids) {
|
|
4333
|
-
this.selection.set(ids);
|
|
4393
|
+
this.selection.set(this.normalizeSelectionIds(ids));
|
|
4334
4394
|
this.emitSelection();
|
|
4335
4395
|
};
|
|
4336
4396
|
DiagramEngine.prototype.toggleSelection = function (id) {
|
|
4337
|
-
this.selection.
|
|
4397
|
+
var current = new Set(this.selection.get());
|
|
4398
|
+
if (current.has(id)) {
|
|
4399
|
+
current.delete(id);
|
|
4400
|
+
}
|
|
4401
|
+
else if (this.isSelectableId(id)) {
|
|
4402
|
+
current.add(id);
|
|
4403
|
+
}
|
|
4404
|
+
this.selection.set(Array.from(current));
|
|
4338
4405
|
this.emitSelection();
|
|
4339
4406
|
};
|
|
4340
4407
|
DiagramEngine.prototype.getSelection = function () {
|
|
4341
4408
|
return this.selection.get();
|
|
4342
4409
|
};
|
|
4410
|
+
DiagramEngine.prototype.isElementVisible = function (id) {
|
|
4411
|
+
return this.model.isElementVisible(id);
|
|
4412
|
+
};
|
|
4413
|
+
DiagramEngine.prototype.isElementSelectable = function (id) {
|
|
4414
|
+
return this.model.isElementSelectable(id);
|
|
4415
|
+
};
|
|
4416
|
+
DiagramEngine.prototype.isPortVisible = function (id) {
|
|
4417
|
+
return this.model.isPortVisible(id);
|
|
4418
|
+
};
|
|
4419
|
+
DiagramEngine.prototype.isLinkVisible = function (id) {
|
|
4420
|
+
return this.model.isLinkVisible(id);
|
|
4421
|
+
};
|
|
4422
|
+
DiagramEngine.prototype.isTextVisible = function (id) {
|
|
4423
|
+
return this.model.isTextVisible(id);
|
|
4424
|
+
};
|
|
4343
4425
|
DiagramEngine.prototype.getElementWorldPosition = function (id) {
|
|
4344
4426
|
return this.model.getElementWorldPosition(id);
|
|
4345
4427
|
};
|
|
@@ -4601,11 +4683,15 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
4601
4683
|
var _this = this;
|
|
4602
4684
|
var _a;
|
|
4603
4685
|
var allPatches = this.appendTextLayoutPatches(patches, (_a = options === null || options === void 0 ? void 0 : options.emitTextUpdated) !== null && _a !== void 0 ? _a : true);
|
|
4686
|
+
var selectionChanged = this.syncSelectionToPolicies();
|
|
4604
4687
|
var state = this.model.toState();
|
|
4605
4688
|
this.events.emit('change', { patches: allPatches, state: state });
|
|
4606
|
-
if ((options === null || options === void 0 ? void 0 : options.render)
|
|
4607
|
-
return;
|
|
4608
|
-
|
|
4689
|
+
if ((options === null || options === void 0 ? void 0 : options.render) !== false) {
|
|
4690
|
+
this.scheduler.requestRender(function () { return _this.renderer.render(_this.model); });
|
|
4691
|
+
}
|
|
4692
|
+
if (selectionChanged) {
|
|
4693
|
+
this.emitSelection();
|
|
4694
|
+
}
|
|
4609
4695
|
};
|
|
4610
4696
|
DiagramEngine.prototype.appendTextLayoutPatches = function (patches, emitTextUpdated) {
|
|
4611
4697
|
var _this = this;
|
|
@@ -5051,6 +5137,31 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
5051
5137
|
});
|
|
5052
5138
|
this.renderer.renderSelection(selectedIds);
|
|
5053
5139
|
};
|
|
5140
|
+
DiagramEngine.prototype.normalizeSelectionIds = function (ids) {
|
|
5141
|
+
var _this = this;
|
|
5142
|
+
return ids.filter(function (id, index) { return ids.indexOf(id) === index && _this.isSelectableId(id); });
|
|
5143
|
+
};
|
|
5144
|
+
DiagramEngine.prototype.isSelectableId = function (id) {
|
|
5145
|
+
if (this.model.getElement(id))
|
|
5146
|
+
return this.model.isElementSelectable(id);
|
|
5147
|
+
if (this.model.getPort(id))
|
|
5148
|
+
return this.model.isPortVisible(id);
|
|
5149
|
+
if (this.model.getLink(id))
|
|
5150
|
+
return this.model.isLinkVisible(id);
|
|
5151
|
+
if (this.model.getText(id))
|
|
5152
|
+
return this.model.isTextVisible(id);
|
|
5153
|
+
return false;
|
|
5154
|
+
};
|
|
5155
|
+
DiagramEngine.prototype.syncSelectionToPolicies = function () {
|
|
5156
|
+
var current = this.selection.get();
|
|
5157
|
+
var normalized = this.normalizeSelectionIds(current);
|
|
5158
|
+
if (current.length === normalized.length &&
|
|
5159
|
+
current.every(function (id, index) { return id === normalized[index]; })) {
|
|
5160
|
+
return false;
|
|
5161
|
+
}
|
|
5162
|
+
this.selection.set(normalized);
|
|
5163
|
+
return true;
|
|
5164
|
+
};
|
|
5054
5165
|
DiagramEngine.prototype.applyLayoutForParent = function (parentId, options) {
|
|
5055
5166
|
return this.autoLayoutService.applyLayoutForParent(parentId, options);
|
|
5056
5167
|
};
|
|
@@ -6003,7 +6114,9 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6003
6114
|
};
|
|
6004
6115
|
KonvaRenderer.prototype.syncElements = function (model) {
|
|
6005
6116
|
var _this = this;
|
|
6006
|
-
var elements = Array.from(model.elements.values())
|
|
6117
|
+
var elements = Array.from(model.elements.values())
|
|
6118
|
+
.filter(function (element) { return model.isElementVisible(element.id); })
|
|
6119
|
+
.map(function (element, index) { return ({
|
|
6007
6120
|
element: element,
|
|
6008
6121
|
depth: _this.getElementDepth(model, element),
|
|
6009
6122
|
order: index,
|
|
@@ -6036,6 +6149,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6036
6149
|
node.setAttrs({ __depth: depth });
|
|
6037
6150
|
}
|
|
6038
6151
|
});
|
|
6152
|
+
var visibleElementIds = new Set(elements.map(function (_a) {
|
|
6153
|
+
var element = _a.element;
|
|
6154
|
+
return element.id;
|
|
6155
|
+
}));
|
|
6039
6156
|
elements.forEach(function (_a) {
|
|
6040
6157
|
var _b;
|
|
6041
6158
|
var element = _a.element;
|
|
@@ -6044,7 +6161,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6044
6161
|
});
|
|
6045
6162
|
Array.from(this.elementNodes.keys()).forEach(function (id) {
|
|
6046
6163
|
var _a;
|
|
6047
|
-
if (!
|
|
6164
|
+
if (!visibleElementIds.has(id)) {
|
|
6048
6165
|
var node = _this.elementNodes.get(id);
|
|
6049
6166
|
(_a = node === null || node === void 0 ? void 0 : node.destroy) === null || _a === void 0 ? void 0 : _a.call(node);
|
|
6050
6167
|
_this.elementNodes.delete(id);
|
|
@@ -6067,7 +6184,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6067
6184
|
};
|
|
6068
6185
|
KonvaRenderer.prototype.syncPorts = function (model) {
|
|
6069
6186
|
var _this = this;
|
|
6070
|
-
var ports = Array.from(model.ports.values());
|
|
6187
|
+
var ports = Array.from(model.ports.values()).filter(function (port) { return model.isPortVisible(port.id); });
|
|
6071
6188
|
ports.forEach(function (port) {
|
|
6072
6189
|
var _a, _b, _c, _d, _e;
|
|
6073
6190
|
var data = port.toData();
|
|
@@ -6085,9 +6202,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6085
6202
|
_this.updatePosition(node, position);
|
|
6086
6203
|
_this.applyPortOrientation(node, data, position, model);
|
|
6087
6204
|
});
|
|
6205
|
+
var visiblePortIds = new Set(ports.map(function (port) { return port.id; }));
|
|
6088
6206
|
Array.from(this.portNodes.keys()).forEach(function (id) {
|
|
6089
6207
|
var _a;
|
|
6090
|
-
if (!
|
|
6208
|
+
if (!visiblePortIds.has(id)) {
|
|
6091
6209
|
var node = _this.portNodes.get(id);
|
|
6092
6210
|
(_a = node === null || node === void 0 ? void 0 : node.destroy) === null || _a === void 0 ? void 0 : _a.call(node);
|
|
6093
6211
|
_this.portNodes.delete(id);
|
|
@@ -6098,7 +6216,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6098
6216
|
};
|
|
6099
6217
|
KonvaRenderer.prototype.syncLinks = function (model) {
|
|
6100
6218
|
var _this = this;
|
|
6101
|
-
var links = Array.from(model.links.values());
|
|
6219
|
+
var links = Array.from(model.links.values()).filter(function (link) { return model.isLinkVisible(link.id); });
|
|
6102
6220
|
links.forEach(function (link) {
|
|
6103
6221
|
var _a, _b;
|
|
6104
6222
|
var node = _this.linkNodes.get(link.id);
|
|
@@ -6109,9 +6227,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6109
6227
|
}
|
|
6110
6228
|
_this.updateLine(node, link.toData());
|
|
6111
6229
|
});
|
|
6230
|
+
var visibleLinkIds = new Set(links.map(function (link) { return link.id; }));
|
|
6112
6231
|
Array.from(this.linkNodes.keys()).forEach(function (id) {
|
|
6113
6232
|
var _a;
|
|
6114
|
-
if (!
|
|
6233
|
+
if (!visibleLinkIds.has(id)) {
|
|
6115
6234
|
var node = _this.linkNodes.get(id);
|
|
6116
6235
|
(_a = node === null || node === void 0 ? void 0 : node.destroy) === null || _a === void 0 ? void 0 : _a.call(node);
|
|
6117
6236
|
_this.linkNodes.delete(id);
|
|
@@ -6122,7 +6241,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6122
6241
|
};
|
|
6123
6242
|
KonvaRenderer.prototype.syncTexts = function (model) {
|
|
6124
6243
|
var _this = this;
|
|
6125
|
-
var texts = Array.from(model.texts.values());
|
|
6244
|
+
var texts = Array.from(model.texts.values()).filter(function (text) { return model.isTextVisible(text.id); });
|
|
6126
6245
|
texts.forEach(function (text) {
|
|
6127
6246
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
6128
6247
|
var node = _this.textNodes.get(text.id);
|
|
@@ -6211,9 +6330,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
6211
6330
|
_this.textBackgroundNodes.delete(text.id);
|
|
6212
6331
|
}
|
|
6213
6332
|
});
|
|
6333
|
+
var visibleTextIds = new Set(texts.map(function (text) { return text.id; }));
|
|
6214
6334
|
Array.from(this.textNodes.keys()).forEach(function (id) {
|
|
6215
6335
|
var _a, _b;
|
|
6216
|
-
if (!
|
|
6336
|
+
if (!visibleTextIds.has(id)) {
|
|
6217
6337
|
var backgroundNode = _this.textBackgroundNodes.get(id);
|
|
6218
6338
|
(_a = backgroundNode === null || backgroundNode === void 0 ? void 0 : backgroundNode.destroy) === null || _a === void 0 ? void 0 : _a.call(backgroundNode);
|
|
6219
6339
|
_this.textBackgroundNodes.delete(id);
|
|
@@ -7216,15 +7336,21 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
7216
7336
|
KonvaInteraction.prototype.normalizeHit = function (hit) {
|
|
7217
7337
|
if (!hit || hit.type === 'none')
|
|
7218
7338
|
return null;
|
|
7219
|
-
if (hit.type === 'port'
|
|
7220
|
-
hit.
|
|
7221
|
-
|
|
7222
|
-
|
|
7339
|
+
if (hit.type === 'port') {
|
|
7340
|
+
return this.engine.isPortVisible(hit.id) ? hit : null;
|
|
7341
|
+
}
|
|
7342
|
+
if (hit.type === 'link') {
|
|
7343
|
+
return this.engine.isLinkVisible(hit.id) ? hit : null;
|
|
7344
|
+
}
|
|
7345
|
+
if (hit.type === 'text') {
|
|
7346
|
+
return this.engine.isTextVisible(hit.id) ? hit : null;
|
|
7347
|
+
}
|
|
7348
|
+
if (hit.type === 'resize-handle' ||
|
|
7223
7349
|
hit.type === 'link-handle' ||
|
|
7224
7350
|
hit.type === 'shape-hover-control') {
|
|
7225
7351
|
return hit;
|
|
7226
7352
|
}
|
|
7227
|
-
return __assign(__assign({}, hit), { type: 'element' });
|
|
7353
|
+
return this.engine.isElementSelectable(hit.id) ? __assign(__assign({}, hit), { type: 'element' }) : null;
|
|
7228
7354
|
};
|
|
7229
7355
|
KonvaInteraction.prototype.resolveHit = function (point) {
|
|
7230
7356
|
var _this = this;
|
|
@@ -7290,6 +7416,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
7290
7416
|
var best = null;
|
|
7291
7417
|
state.elements.forEach(function (element) {
|
|
7292
7418
|
var _a, _b, _c;
|
|
7419
|
+
if (!_this.engine.isElementSelectable(element.id))
|
|
7420
|
+
return;
|
|
7293
7421
|
var world = (_a = _this.engine.getElementWorldPosition(element.id)) !== null && _a !== void 0 ? _a : element.position;
|
|
7294
7422
|
var rotation = _this.engine.getElementRotation(element.id);
|
|
7295
7423
|
if (!pointInRotatedRect(point, world, element.size, rotation, (_b = element.anchorCenter) !== null && _b !== void 0 ? _b : false))
|
|
@@ -7319,6 +7447,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
7319
7447
|
var bestDistance = Number.POSITIVE_INFINITY;
|
|
7320
7448
|
links.forEach(function (link) {
|
|
7321
7449
|
var _a, _b;
|
|
7450
|
+
if (!_this.engine.isLinkVisible(link.id))
|
|
7451
|
+
return;
|
|
7322
7452
|
if (link.points.length < 2)
|
|
7323
7453
|
return;
|
|
7324
7454
|
var tolerance = ((_b = (_a = link.style) === null || _a === void 0 ? void 0 : _a.hitStrokeWidth) !== null && _b !== void 0 ? _b : 15) / 2;
|
|
@@ -8333,6 +8463,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
8333
8463
|
};
|
|
8334
8464
|
state.elements.forEach(function (element) {
|
|
8335
8465
|
var _a, _b;
|
|
8466
|
+
if (!_this.engine.isElementSelectable(element.id))
|
|
8467
|
+
return;
|
|
8336
8468
|
var position = (_a = _this.engine.getElementWorldPosition(element.id)) !== null && _a !== void 0 ? _a : element.position;
|
|
8337
8469
|
var rotation = _this.engine.getElementRotation(element.id);
|
|
8338
8470
|
var anchorCenter = (_b = element.anchorCenter) !== null && _b !== void 0 ? _b : false;
|
|
@@ -8350,6 +8482,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
8350
8482
|
});
|
|
8351
8483
|
state.ports.forEach(function (port) {
|
|
8352
8484
|
var _a;
|
|
8485
|
+
if (!_this.engine.isPortVisible(port.id))
|
|
8486
|
+
return;
|
|
8353
8487
|
var position = (_a = _this.engine.getPortWorldPosition(port.id)) !== null && _a !== void 0 ? _a : port.position;
|
|
8354
8488
|
if (containsPoint(position)) {
|
|
8355
8489
|
selected.add(port.id);
|
|
@@ -8357,6 +8491,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
8357
8491
|
});
|
|
8358
8492
|
state.texts.forEach(function (text) {
|
|
8359
8493
|
var _a, _b, _c, _d, _e;
|
|
8494
|
+
if (!_this.engine.isTextVisible(text.id))
|
|
8495
|
+
return;
|
|
8360
8496
|
var position = (_a = _this.engine.getTextWorldPosition(text.id)) !== null && _a !== void 0 ? _a : text.position;
|
|
8361
8497
|
var width = (_c = (_b = text.size) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0;
|
|
8362
8498
|
var height = (_e = (_d = text.size) === null || _d === void 0 ? void 0 : _d.height) !== null && _e !== void 0 ? _e : 0;
|
|
@@ -8366,6 +8502,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
8366
8502
|
}
|
|
8367
8503
|
});
|
|
8368
8504
|
state.links.forEach(function (link) {
|
|
8505
|
+
if (!_this.engine.isLinkVisible(link.id))
|
|
8506
|
+
return;
|
|
8369
8507
|
if (link.points.length === 0)
|
|
8370
8508
|
return;
|
|
8371
8509
|
var xs = link.points.map(function (point) { return point.x; });
|
|
@@ -9297,13 +9435,65 @@ var resolveViewportFitOptions = function (options) {
|
|
|
9297
9435
|
return { padding: padding, minZoom: minZoom, maxZoom: maxZoom };
|
|
9298
9436
|
};
|
|
9299
9437
|
var clamp = function (value, min, max) { return Math.max(min, Math.min(max, value)); };
|
|
9438
|
+
var isElementVisibleInState = function (elementId, elementsById) {
|
|
9439
|
+
var _a, _b;
|
|
9440
|
+
var element = elementsById.get(elementId);
|
|
9441
|
+
if (!element)
|
|
9442
|
+
return false;
|
|
9443
|
+
if (element.visible === false)
|
|
9444
|
+
return false;
|
|
9445
|
+
var currentParentId = (_a = element.parentId) !== null && _a !== void 0 ? _a : null;
|
|
9446
|
+
while (currentParentId) {
|
|
9447
|
+
var parent_1 = elementsById.get(currentParentId);
|
|
9448
|
+
if (!parent_1)
|
|
9449
|
+
break;
|
|
9450
|
+
if (parent_1.visible === false)
|
|
9451
|
+
return false;
|
|
9452
|
+
currentParentId = (_b = parent_1.parentId) !== null && _b !== void 0 ? _b : null;
|
|
9453
|
+
}
|
|
9454
|
+
return true;
|
|
9455
|
+
};
|
|
9456
|
+
var isPortVisibleInState = function (portId, portsById, elementsById) {
|
|
9457
|
+
var port = portsById.get(portId);
|
|
9458
|
+
if (!port)
|
|
9459
|
+
return false;
|
|
9460
|
+
return isElementVisibleInState(port.elementId, elementsById);
|
|
9461
|
+
};
|
|
9462
|
+
var isLinkVisibleInState = function (linkId, linksById, portsById, elementsById) {
|
|
9463
|
+
var link = linksById.get(linkId);
|
|
9464
|
+
if (!link)
|
|
9465
|
+
return false;
|
|
9466
|
+
var sourcePort = portsById.get(link.sourcePortId);
|
|
9467
|
+
var targetPort = portsById.get(link.targetPortId);
|
|
9468
|
+
var sourceVisible = sourcePort ? isPortVisibleInState(sourcePort.id, portsById, elementsById) : true;
|
|
9469
|
+
var targetVisible = targetPort ? isPortVisibleInState(targetPort.id, portsById, elementsById) : true;
|
|
9470
|
+
return sourceVisible && targetVisible;
|
|
9471
|
+
};
|
|
9472
|
+
var isTextVisibleInState = function (text, elementsById, portsById, linksById) {
|
|
9473
|
+
if (!text.ownerId)
|
|
9474
|
+
return true;
|
|
9475
|
+
if (elementsById.has(text.ownerId))
|
|
9476
|
+
return isElementVisibleInState(text.ownerId, elementsById);
|
|
9477
|
+
if (portsById.has(text.ownerId))
|
|
9478
|
+
return isPortVisibleInState(text.ownerId, portsById, elementsById);
|
|
9479
|
+
if (linksById.has(text.ownerId))
|
|
9480
|
+
return isLinkVisibleInState(text.ownerId, linksById, portsById, elementsById);
|
|
9481
|
+
return true;
|
|
9482
|
+
};
|
|
9300
9483
|
var resolveStateWorldBounds = function (state) {
|
|
9301
9484
|
var bounds = createBounds();
|
|
9485
|
+
var elementsById = new Map(state.elements.map(function (element) { return [element.id, element]; }));
|
|
9486
|
+
var portsById = new Map(state.ports.map(function (port) { return [port.id, port]; }));
|
|
9487
|
+
var linksById = new Map(state.links.map(function (link) { return [link.id, link]; }));
|
|
9302
9488
|
state.elements.forEach(function (element) {
|
|
9489
|
+
if (!isElementVisibleInState(element.id, elementsById))
|
|
9490
|
+
return;
|
|
9303
9491
|
includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
|
|
9304
9492
|
});
|
|
9305
9493
|
state.ports.forEach(function (port) {
|
|
9306
9494
|
var _a;
|
|
9495
|
+
if (!isPortVisibleInState(port.id, portsById, elementsById))
|
|
9496
|
+
return;
|
|
9307
9497
|
var size = port.size;
|
|
9308
9498
|
if (!size) {
|
|
9309
9499
|
expandBounds(bounds, port.position.x, port.position.y);
|
|
@@ -9315,12 +9505,16 @@ var resolveStateWorldBounds = function (state) {
|
|
|
9315
9505
|
includeRect(bounds, x, y, size.width, size.height);
|
|
9316
9506
|
});
|
|
9317
9507
|
state.links.forEach(function (link) {
|
|
9508
|
+
if (!isLinkVisibleInState(link.id, linksById, portsById, elementsById))
|
|
9509
|
+
return;
|
|
9318
9510
|
link.points.forEach(function (point) {
|
|
9319
9511
|
expandBounds(bounds, point.x, point.y);
|
|
9320
9512
|
});
|
|
9321
9513
|
});
|
|
9322
9514
|
state.texts.forEach(function (text) {
|
|
9323
9515
|
var _a;
|
|
9516
|
+
if (!isTextVisibleInState(text, elementsById, portsById, linksById))
|
|
9517
|
+
return;
|
|
9324
9518
|
var offset = (_a = text.displayOffset) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
|
|
9325
9519
|
var position = { x: text.position.x + offset.x, y: text.position.y + offset.y };
|
|
9326
9520
|
var clipSize = text.displayClipSize;
|
|
@@ -9335,7 +9529,10 @@ var resolveStateWorldBounds = function (state) {
|
|
|
9335
9529
|
};
|
|
9336
9530
|
var resolveElementWorldBounds = function (state) {
|
|
9337
9531
|
var bounds = createBounds();
|
|
9532
|
+
var elementsById = new Map(state.elements.map(function (element) { return [element.id, element]; }));
|
|
9338
9533
|
state.elements.forEach(function (element) {
|
|
9534
|
+
if (!isElementVisibleInState(element.id, elementsById))
|
|
9535
|
+
return;
|
|
9339
9536
|
includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
|
|
9340
9537
|
});
|
|
9341
9538
|
return hasBounds(bounds) ? bounds : null;
|