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/examples.js
CHANGED
|
@@ -1144,6 +1144,128 @@ var selectionDemoConfig = ({
|
|
|
1144
1144
|
],
|
|
1145
1145
|
});
|
|
1146
1146
|
|
|
1147
|
+
var createElementVisibilitySelectionState = function () { return ({
|
|
1148
|
+
elements: [
|
|
1149
|
+
{
|
|
1150
|
+
id: 'policy-normal',
|
|
1151
|
+
position: { x: 120, y: 160 },
|
|
1152
|
+
size: { width: 180, height: 120 },
|
|
1153
|
+
shapeId: 'default',
|
|
1154
|
+
style: { fill: '#dbeafe', stroke: '#1d4ed8', strokeWidth: 2 },
|
|
1155
|
+
},
|
|
1156
|
+
{
|
|
1157
|
+
id: 'policy-unselectable',
|
|
1158
|
+
position: { x: 410, y: 160 },
|
|
1159
|
+
size: { width: 180, height: 120 },
|
|
1160
|
+
shapeId: 'default',
|
|
1161
|
+
selectable: false,
|
|
1162
|
+
style: { fill: '#e2e8f0', stroke: '#334155', strokeWidth: 2 },
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
id: 'policy-hidden',
|
|
1166
|
+
position: { x: 700, y: 140 },
|
|
1167
|
+
size: { width: 180, height: 120 },
|
|
1168
|
+
shapeId: 'default',
|
|
1169
|
+
visible: false,
|
|
1170
|
+
style: { fill: '#fee2e2', stroke: '#dc2626', strokeWidth: 2 },
|
|
1171
|
+
},
|
|
1172
|
+
],
|
|
1173
|
+
ports: [
|
|
1174
|
+
{
|
|
1175
|
+
id: 'policy-normal-port',
|
|
1176
|
+
elementId: 'policy-normal',
|
|
1177
|
+
position: { x: 180, y: 60 },
|
|
1178
|
+
shapeId: 'port-circle',
|
|
1179
|
+
},
|
|
1180
|
+
{
|
|
1181
|
+
id: 'policy-unselectable-port',
|
|
1182
|
+
elementId: 'policy-unselectable',
|
|
1183
|
+
position: { x: 0, y: 60 },
|
|
1184
|
+
shapeId: 'port-circle',
|
|
1185
|
+
},
|
|
1186
|
+
{
|
|
1187
|
+
id: 'policy-hidden-port',
|
|
1188
|
+
elementId: 'policy-hidden',
|
|
1189
|
+
position: { x: 0, y: 60 },
|
|
1190
|
+
shapeId: 'port-circle',
|
|
1191
|
+
},
|
|
1192
|
+
],
|
|
1193
|
+
links: [
|
|
1194
|
+
{
|
|
1195
|
+
id: 'policy-visible-link',
|
|
1196
|
+
sourcePortId: 'policy-normal-port',
|
|
1197
|
+
targetPortId: 'policy-unselectable-port',
|
|
1198
|
+
points: [
|
|
1199
|
+
{ x: 300, y: 220 },
|
|
1200
|
+
{ x: 410, y: 220 },
|
|
1201
|
+
],
|
|
1202
|
+
style: { stroke: '#2563eb', strokeWidth: 3 },
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
id: 'policy-hidden-link',
|
|
1206
|
+
sourcePortId: 'policy-normal-port',
|
|
1207
|
+
targetPortId: 'policy-hidden-port',
|
|
1208
|
+
points: [
|
|
1209
|
+
{ x: 300, y: 220 },
|
|
1210
|
+
{ x: 700, y: 200 },
|
|
1211
|
+
],
|
|
1212
|
+
style: { stroke: '#dc2626', strokeWidth: 3 },
|
|
1213
|
+
},
|
|
1214
|
+
],
|
|
1215
|
+
texts: [
|
|
1216
|
+
{
|
|
1217
|
+
id: 'policy-tip',
|
|
1218
|
+
content: 'Blue node is normal. Slate node is visible but its body ignores click and marquee. Its port stays interactive. Hidden node, its port, and its attached red link stay in state but are suppressed from scene, selection, zoom-to-fit, and fit-to-content export.',
|
|
1219
|
+
position: { x: 80, y: 72 },
|
|
1220
|
+
size: { width: 760, height: 44 },
|
|
1221
|
+
style: { fontSize: 14, fill: '#0f172a' },
|
|
1222
|
+
},
|
|
1223
|
+
{
|
|
1224
|
+
id: 'policy-normal-label',
|
|
1225
|
+
content: 'Normal selectable element',
|
|
1226
|
+
position: { x: 16, y: 14 },
|
|
1227
|
+
ownerId: 'policy-normal',
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
id: 'policy-unselectable-label',
|
|
1231
|
+
content: 'Visible but body is unselectable',
|
|
1232
|
+
position: { x: 16, y: 14 },
|
|
1233
|
+
ownerId: 'policy-unselectable',
|
|
1234
|
+
},
|
|
1235
|
+
{
|
|
1236
|
+
id: 'policy-hidden-label',
|
|
1237
|
+
content: 'Hidden in state',
|
|
1238
|
+
position: { x: 16, y: 14 },
|
|
1239
|
+
ownerId: 'policy-hidden',
|
|
1240
|
+
},
|
|
1241
|
+
],
|
|
1242
|
+
}); };
|
|
1243
|
+
var elementVisibilitySelectionDemoConfig = {
|
|
1244
|
+
id: 'element-visibility-selection',
|
|
1245
|
+
title: 'Element Visibility + Selectability',
|
|
1246
|
+
description: 'QA scene for visible-but-unselectable element bodies, hidden-in-state elements, and port/link propagation. Shift + drag marquee to confirm only eligible items are collected.',
|
|
1247
|
+
createState: createElementVisibilitySelectionState,
|
|
1248
|
+
elementShapes: baseElementShapes,
|
|
1249
|
+
portShapes: basePortShapes,
|
|
1250
|
+
defaultElementShapeId: 'default',
|
|
1251
|
+
defaultPortShapeId: 'port-circle',
|
|
1252
|
+
actions: [
|
|
1253
|
+
{
|
|
1254
|
+
id: 'policy-filtered-selection',
|
|
1255
|
+
label: 'Try filtered API selection',
|
|
1256
|
+
run: function (editor) {
|
|
1257
|
+
editor.setSelection([
|
|
1258
|
+
'policy-normal',
|
|
1259
|
+
'policy-unselectable',
|
|
1260
|
+
'policy-hidden',
|
|
1261
|
+
'policy-unselectable-port',
|
|
1262
|
+
'policy-hidden-link',
|
|
1263
|
+
]);
|
|
1264
|
+
},
|
|
1265
|
+
},
|
|
1266
|
+
],
|
|
1267
|
+
};
|
|
1268
|
+
|
|
1147
1269
|
var createEventHandlersState = function () { return ({
|
|
1148
1270
|
elements: [
|
|
1149
1271
|
{
|
|
@@ -4610,6 +4732,8 @@ var ElementModel = /** @class */ (function () {
|
|
|
4610
4732
|
this.style = data.style;
|
|
4611
4733
|
this.portIds = data.portIds ? __spreadArray([], data.portIds, true) : [];
|
|
4612
4734
|
this.textIds = data.textIds ? __spreadArray([], data.textIds, true) : [];
|
|
4735
|
+
this.visible = data.visible;
|
|
4736
|
+
this.selectable = data.selectable;
|
|
4613
4737
|
this.parentId = (_a = data.parentId) !== null && _a !== void 0 ? _a : null;
|
|
4614
4738
|
this.moveMode = data.moveMode;
|
|
4615
4739
|
this.anchorCenter = data.anchorCenter;
|
|
@@ -4648,6 +4772,8 @@ var ElementModel = /** @class */ (function () {
|
|
|
4648
4772
|
style: this.style,
|
|
4649
4773
|
portIds: __spreadArray([], this.portIds, true),
|
|
4650
4774
|
textIds: __spreadArray([], this.textIds, true),
|
|
4775
|
+
visible: this.visible,
|
|
4776
|
+
selectable: this.selectable,
|
|
4651
4777
|
parentId: this.parentId,
|
|
4652
4778
|
moveMode: this.moveMode,
|
|
4653
4779
|
anchorCenter: this.anchorCenter,
|
|
@@ -5051,6 +5177,29 @@ var DiagramModel = /** @class */ (function () {
|
|
|
5051
5177
|
DiagramModel.prototype.getElement = function (id) {
|
|
5052
5178
|
return this.elements.get(id);
|
|
5053
5179
|
};
|
|
5180
|
+
DiagramModel.prototype.isElementVisible = function (id) {
|
|
5181
|
+
var element = this.elements.get(id);
|
|
5182
|
+
if (!element)
|
|
5183
|
+
return false;
|
|
5184
|
+
if (element.visible === false)
|
|
5185
|
+
return false;
|
|
5186
|
+
var currentParentId = element.parentId;
|
|
5187
|
+
while (currentParentId) {
|
|
5188
|
+
var parent_1 = this.elements.get(currentParentId);
|
|
5189
|
+
if (!parent_1)
|
|
5190
|
+
break;
|
|
5191
|
+
if (parent_1.visible === false)
|
|
5192
|
+
return false;
|
|
5193
|
+
currentParentId = parent_1.parentId;
|
|
5194
|
+
}
|
|
5195
|
+
return true;
|
|
5196
|
+
};
|
|
5197
|
+
DiagramModel.prototype.isElementSelectable = function (id) {
|
|
5198
|
+
var element = this.elements.get(id);
|
|
5199
|
+
if (!element)
|
|
5200
|
+
return false;
|
|
5201
|
+
return this.isElementVisible(id) && element.selectable !== false;
|
|
5202
|
+
};
|
|
5054
5203
|
DiagramModel.prototype.setElementLayout = function (id, layout) {
|
|
5055
5204
|
var element = this.elements.get(id);
|
|
5056
5205
|
if (!element)
|
|
@@ -5069,6 +5218,12 @@ var DiagramModel = /** @class */ (function () {
|
|
|
5069
5218
|
DiagramModel.prototype.getPort = function (id) {
|
|
5070
5219
|
return this.ports.get(id);
|
|
5071
5220
|
};
|
|
5221
|
+
DiagramModel.prototype.isPortVisible = function (id) {
|
|
5222
|
+
var port = this.ports.get(id);
|
|
5223
|
+
if (!port)
|
|
5224
|
+
return false;
|
|
5225
|
+
return this.isElementVisible(port.elementId);
|
|
5226
|
+
};
|
|
5072
5227
|
DiagramModel.prototype.getPortWorldPosition = function (id) {
|
|
5073
5228
|
var port = this.ports.get(id);
|
|
5074
5229
|
if (!port)
|
|
@@ -5084,6 +5239,16 @@ var DiagramModel = /** @class */ (function () {
|
|
|
5084
5239
|
DiagramModel.prototype.getLink = function (id) {
|
|
5085
5240
|
return this.links.get(id);
|
|
5086
5241
|
};
|
|
5242
|
+
DiagramModel.prototype.isLinkVisible = function (id) {
|
|
5243
|
+
var link = this.links.get(id);
|
|
5244
|
+
if (!link)
|
|
5245
|
+
return false;
|
|
5246
|
+
var sourcePort = this.ports.get(link.sourcePortId);
|
|
5247
|
+
var targetPort = this.ports.get(link.targetPortId);
|
|
5248
|
+
var sourceVisible = sourcePort ? this.isPortVisible(sourcePort.id) : true;
|
|
5249
|
+
var targetVisible = targetPort ? this.isPortVisible(targetPort.id) : true;
|
|
5250
|
+
return sourceVisible && targetVisible;
|
|
5251
|
+
};
|
|
5087
5252
|
DiagramModel.prototype.getLinkMidpoint = function (id) {
|
|
5088
5253
|
var link = this.links.get(id);
|
|
5089
5254
|
if (!link)
|
|
@@ -5093,6 +5258,23 @@ var DiagramModel = /** @class */ (function () {
|
|
|
5093
5258
|
DiagramModel.prototype.getText = function (id) {
|
|
5094
5259
|
return this.texts.get(id);
|
|
5095
5260
|
};
|
|
5261
|
+
DiagramModel.prototype.isTextVisible = function (id) {
|
|
5262
|
+
var text = this.texts.get(id);
|
|
5263
|
+
if (!text)
|
|
5264
|
+
return false;
|
|
5265
|
+
if (!text.ownerId)
|
|
5266
|
+
return true;
|
|
5267
|
+
if (this.elements.has(text.ownerId)) {
|
|
5268
|
+
return this.isElementVisible(text.ownerId);
|
|
5269
|
+
}
|
|
5270
|
+
if (this.ports.has(text.ownerId)) {
|
|
5271
|
+
return this.isPortVisible(text.ownerId);
|
|
5272
|
+
}
|
|
5273
|
+
if (this.links.has(text.ownerId)) {
|
|
5274
|
+
return this.isLinkVisible(text.ownerId);
|
|
5275
|
+
}
|
|
5276
|
+
return true;
|
|
5277
|
+
};
|
|
5096
5278
|
DiagramModel.prototype.getTextWorldPosition = function (id) {
|
|
5097
5279
|
var text = this.texts.get(id);
|
|
5098
5280
|
if (!text)
|
|
@@ -5281,18 +5463,18 @@ var DiagramModel = /** @class */ (function () {
|
|
|
5281
5463
|
}
|
|
5282
5464
|
var current = element;
|
|
5283
5465
|
while (current === null || current === void 0 ? void 0 : current.parentId) {
|
|
5284
|
-
var
|
|
5285
|
-
if (!
|
|
5466
|
+
var parent_2 = this.elements.get(current.parentId);
|
|
5467
|
+
if (!parent_2)
|
|
5286
5468
|
break;
|
|
5287
|
-
var parentX =
|
|
5288
|
-
var parentY =
|
|
5289
|
-
if (
|
|
5290
|
-
parentX -=
|
|
5291
|
-
parentY -=
|
|
5469
|
+
var parentX = parent_2.position.x;
|
|
5470
|
+
var parentY = parent_2.position.y;
|
|
5471
|
+
if (parent_2.anchorCenter) {
|
|
5472
|
+
parentX -= parent_2.size.width / 2;
|
|
5473
|
+
parentY -= parent_2.size.height / 2;
|
|
5292
5474
|
}
|
|
5293
5475
|
x += parentX;
|
|
5294
5476
|
y += parentY;
|
|
5295
|
-
current =
|
|
5477
|
+
current = parent_2;
|
|
5296
5478
|
}
|
|
5297
5479
|
return { x: x, y: y };
|
|
5298
5480
|
};
|
|
@@ -8407,16 +8589,38 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
8407
8589
|
this.emitEntityDeletionEvents(removal.removed);
|
|
8408
8590
|
};
|
|
8409
8591
|
DiagramEngine.prototype.setSelection = function (ids) {
|
|
8410
|
-
this.selection.set(ids);
|
|
8592
|
+
this.selection.set(this.normalizeSelectionIds(ids));
|
|
8411
8593
|
this.emitSelection();
|
|
8412
8594
|
};
|
|
8413
8595
|
DiagramEngine.prototype.toggleSelection = function (id) {
|
|
8414
|
-
this.selection.
|
|
8596
|
+
var current = new Set(this.selection.get());
|
|
8597
|
+
if (current.has(id)) {
|
|
8598
|
+
current.delete(id);
|
|
8599
|
+
}
|
|
8600
|
+
else if (this.isSelectableId(id)) {
|
|
8601
|
+
current.add(id);
|
|
8602
|
+
}
|
|
8603
|
+
this.selection.set(Array.from(current));
|
|
8415
8604
|
this.emitSelection();
|
|
8416
8605
|
};
|
|
8417
8606
|
DiagramEngine.prototype.getSelection = function () {
|
|
8418
8607
|
return this.selection.get();
|
|
8419
8608
|
};
|
|
8609
|
+
DiagramEngine.prototype.isElementVisible = function (id) {
|
|
8610
|
+
return this.model.isElementVisible(id);
|
|
8611
|
+
};
|
|
8612
|
+
DiagramEngine.prototype.isElementSelectable = function (id) {
|
|
8613
|
+
return this.model.isElementSelectable(id);
|
|
8614
|
+
};
|
|
8615
|
+
DiagramEngine.prototype.isPortVisible = function (id) {
|
|
8616
|
+
return this.model.isPortVisible(id);
|
|
8617
|
+
};
|
|
8618
|
+
DiagramEngine.prototype.isLinkVisible = function (id) {
|
|
8619
|
+
return this.model.isLinkVisible(id);
|
|
8620
|
+
};
|
|
8621
|
+
DiagramEngine.prototype.isTextVisible = function (id) {
|
|
8622
|
+
return this.model.isTextVisible(id);
|
|
8623
|
+
};
|
|
8420
8624
|
DiagramEngine.prototype.getElementWorldPosition = function (id) {
|
|
8421
8625
|
return this.model.getElementWorldPosition(id);
|
|
8422
8626
|
};
|
|
@@ -8678,11 +8882,15 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
8678
8882
|
var _this = this;
|
|
8679
8883
|
var _a;
|
|
8680
8884
|
var allPatches = this.appendTextLayoutPatches(patches, (_a = options === null || options === void 0 ? void 0 : options.emitTextUpdated) !== null && _a !== void 0 ? _a : true);
|
|
8885
|
+
var selectionChanged = this.syncSelectionToPolicies();
|
|
8681
8886
|
var state = this.model.toState();
|
|
8682
8887
|
this.events.emit('change', { patches: allPatches, state: state });
|
|
8683
|
-
if ((options === null || options === void 0 ? void 0 : options.render)
|
|
8684
|
-
return;
|
|
8685
|
-
|
|
8888
|
+
if ((options === null || options === void 0 ? void 0 : options.render) !== false) {
|
|
8889
|
+
this.scheduler.requestRender(function () { return _this.renderer.render(_this.model); });
|
|
8890
|
+
}
|
|
8891
|
+
if (selectionChanged) {
|
|
8892
|
+
this.emitSelection();
|
|
8893
|
+
}
|
|
8686
8894
|
};
|
|
8687
8895
|
DiagramEngine.prototype.appendTextLayoutPatches = function (patches, emitTextUpdated) {
|
|
8688
8896
|
var _this = this;
|
|
@@ -9128,6 +9336,31 @@ var DiagramEngine = /** @class */ (function () {
|
|
|
9128
9336
|
});
|
|
9129
9337
|
this.renderer.renderSelection(selectedIds);
|
|
9130
9338
|
};
|
|
9339
|
+
DiagramEngine.prototype.normalizeSelectionIds = function (ids) {
|
|
9340
|
+
var _this = this;
|
|
9341
|
+
return ids.filter(function (id, index) { return ids.indexOf(id) === index && _this.isSelectableId(id); });
|
|
9342
|
+
};
|
|
9343
|
+
DiagramEngine.prototype.isSelectableId = function (id) {
|
|
9344
|
+
if (this.model.getElement(id))
|
|
9345
|
+
return this.model.isElementSelectable(id);
|
|
9346
|
+
if (this.model.getPort(id))
|
|
9347
|
+
return this.model.isPortVisible(id);
|
|
9348
|
+
if (this.model.getLink(id))
|
|
9349
|
+
return this.model.isLinkVisible(id);
|
|
9350
|
+
if (this.model.getText(id))
|
|
9351
|
+
return this.model.isTextVisible(id);
|
|
9352
|
+
return false;
|
|
9353
|
+
};
|
|
9354
|
+
DiagramEngine.prototype.syncSelectionToPolicies = function () {
|
|
9355
|
+
var current = this.selection.get();
|
|
9356
|
+
var normalized = this.normalizeSelectionIds(current);
|
|
9357
|
+
if (current.length === normalized.length &&
|
|
9358
|
+
current.every(function (id, index) { return id === normalized[index]; })) {
|
|
9359
|
+
return false;
|
|
9360
|
+
}
|
|
9361
|
+
this.selection.set(normalized);
|
|
9362
|
+
return true;
|
|
9363
|
+
};
|
|
9131
9364
|
DiagramEngine.prototype.applyLayoutForParent = function (parentId, options) {
|
|
9132
9365
|
return this.autoLayoutService.applyLayoutForParent(parentId, options);
|
|
9133
9366
|
};
|
|
@@ -10045,7 +10278,9 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10045
10278
|
};
|
|
10046
10279
|
KonvaRenderer.prototype.syncElements = function (model) {
|
|
10047
10280
|
var _this = this;
|
|
10048
|
-
var elements = Array.from(model.elements.values())
|
|
10281
|
+
var elements = Array.from(model.elements.values())
|
|
10282
|
+
.filter(function (element) { return model.isElementVisible(element.id); })
|
|
10283
|
+
.map(function (element, index) { return ({
|
|
10049
10284
|
element: element,
|
|
10050
10285
|
depth: _this.getElementDepth(model, element),
|
|
10051
10286
|
order: index,
|
|
@@ -10078,6 +10313,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10078
10313
|
node.setAttrs({ __depth: depth });
|
|
10079
10314
|
}
|
|
10080
10315
|
});
|
|
10316
|
+
var visibleElementIds = new Set(elements.map(function (_a) {
|
|
10317
|
+
var element = _a.element;
|
|
10318
|
+
return element.id;
|
|
10319
|
+
}));
|
|
10081
10320
|
elements.forEach(function (_a) {
|
|
10082
10321
|
var _b;
|
|
10083
10322
|
var element = _a.element;
|
|
@@ -10086,7 +10325,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10086
10325
|
});
|
|
10087
10326
|
Array.from(this.elementNodes.keys()).forEach(function (id) {
|
|
10088
10327
|
var _a;
|
|
10089
|
-
if (!
|
|
10328
|
+
if (!visibleElementIds.has(id)) {
|
|
10090
10329
|
var node = _this.elementNodes.get(id);
|
|
10091
10330
|
(_a = node === null || node === void 0 ? void 0 : node.destroy) === null || _a === void 0 ? void 0 : _a.call(node);
|
|
10092
10331
|
_this.elementNodes.delete(id);
|
|
@@ -10109,7 +10348,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10109
10348
|
};
|
|
10110
10349
|
KonvaRenderer.prototype.syncPorts = function (model) {
|
|
10111
10350
|
var _this = this;
|
|
10112
|
-
var ports = Array.from(model.ports.values());
|
|
10351
|
+
var ports = Array.from(model.ports.values()).filter(function (port) { return model.isPortVisible(port.id); });
|
|
10113
10352
|
ports.forEach(function (port) {
|
|
10114
10353
|
var _a, _b, _c, _d, _e;
|
|
10115
10354
|
var data = port.toData();
|
|
@@ -10127,9 +10366,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10127
10366
|
_this.updatePosition(node, position);
|
|
10128
10367
|
_this.applyPortOrientation(node, data, position, model);
|
|
10129
10368
|
});
|
|
10369
|
+
var visiblePortIds = new Set(ports.map(function (port) { return port.id; }));
|
|
10130
10370
|
Array.from(this.portNodes.keys()).forEach(function (id) {
|
|
10131
10371
|
var _a;
|
|
10132
|
-
if (!
|
|
10372
|
+
if (!visiblePortIds.has(id)) {
|
|
10133
10373
|
var node = _this.portNodes.get(id);
|
|
10134
10374
|
(_a = node === null || node === void 0 ? void 0 : node.destroy) === null || _a === void 0 ? void 0 : _a.call(node);
|
|
10135
10375
|
_this.portNodes.delete(id);
|
|
@@ -10140,7 +10380,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10140
10380
|
};
|
|
10141
10381
|
KonvaRenderer.prototype.syncLinks = function (model) {
|
|
10142
10382
|
var _this = this;
|
|
10143
|
-
var links = Array.from(model.links.values());
|
|
10383
|
+
var links = Array.from(model.links.values()).filter(function (link) { return model.isLinkVisible(link.id); });
|
|
10144
10384
|
links.forEach(function (link) {
|
|
10145
10385
|
var _a, _b;
|
|
10146
10386
|
var node = _this.linkNodes.get(link.id);
|
|
@@ -10151,9 +10391,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10151
10391
|
}
|
|
10152
10392
|
_this.updateLine(node, link.toData());
|
|
10153
10393
|
});
|
|
10394
|
+
var visibleLinkIds = new Set(links.map(function (link) { return link.id; }));
|
|
10154
10395
|
Array.from(this.linkNodes.keys()).forEach(function (id) {
|
|
10155
10396
|
var _a;
|
|
10156
|
-
if (!
|
|
10397
|
+
if (!visibleLinkIds.has(id)) {
|
|
10157
10398
|
var node = _this.linkNodes.get(id);
|
|
10158
10399
|
(_a = node === null || node === void 0 ? void 0 : node.destroy) === null || _a === void 0 ? void 0 : _a.call(node);
|
|
10159
10400
|
_this.linkNodes.delete(id);
|
|
@@ -10164,7 +10405,7 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10164
10405
|
};
|
|
10165
10406
|
KonvaRenderer.prototype.syncTexts = function (model) {
|
|
10166
10407
|
var _this = this;
|
|
10167
|
-
var texts = Array.from(model.texts.values());
|
|
10408
|
+
var texts = Array.from(model.texts.values()).filter(function (text) { return model.isTextVisible(text.id); });
|
|
10168
10409
|
texts.forEach(function (text) {
|
|
10169
10410
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
10170
10411
|
var node = _this.textNodes.get(text.id);
|
|
@@ -10253,9 +10494,10 @@ var KonvaRenderer = /** @class */ (function () {
|
|
|
10253
10494
|
_this.textBackgroundNodes.delete(text.id);
|
|
10254
10495
|
}
|
|
10255
10496
|
});
|
|
10497
|
+
var visibleTextIds = new Set(texts.map(function (text) { return text.id; }));
|
|
10256
10498
|
Array.from(this.textNodes.keys()).forEach(function (id) {
|
|
10257
10499
|
var _a, _b;
|
|
10258
|
-
if (!
|
|
10500
|
+
if (!visibleTextIds.has(id)) {
|
|
10259
10501
|
var backgroundNode = _this.textBackgroundNodes.get(id);
|
|
10260
10502
|
(_a = backgroundNode === null || backgroundNode === void 0 ? void 0 : backgroundNode.destroy) === null || _a === void 0 ? void 0 : _a.call(backgroundNode);
|
|
10261
10503
|
_this.textBackgroundNodes.delete(id);
|
|
@@ -11247,15 +11489,21 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
11247
11489
|
KonvaInteraction.prototype.normalizeHit = function (hit) {
|
|
11248
11490
|
if (!hit || hit.type === 'none')
|
|
11249
11491
|
return null;
|
|
11250
|
-
if (hit.type === 'port'
|
|
11251
|
-
hit.
|
|
11252
|
-
|
|
11253
|
-
|
|
11492
|
+
if (hit.type === 'port') {
|
|
11493
|
+
return this.engine.isPortVisible(hit.id) ? hit : null;
|
|
11494
|
+
}
|
|
11495
|
+
if (hit.type === 'link') {
|
|
11496
|
+
return this.engine.isLinkVisible(hit.id) ? hit : null;
|
|
11497
|
+
}
|
|
11498
|
+
if (hit.type === 'text') {
|
|
11499
|
+
return this.engine.isTextVisible(hit.id) ? hit : null;
|
|
11500
|
+
}
|
|
11501
|
+
if (hit.type === 'resize-handle' ||
|
|
11254
11502
|
hit.type === 'link-handle' ||
|
|
11255
11503
|
hit.type === 'shape-hover-control') {
|
|
11256
11504
|
return hit;
|
|
11257
11505
|
}
|
|
11258
|
-
return __assign(__assign({}, hit), { type: 'element' });
|
|
11506
|
+
return this.engine.isElementSelectable(hit.id) ? __assign(__assign({}, hit), { type: 'element' }) : null;
|
|
11259
11507
|
};
|
|
11260
11508
|
KonvaInteraction.prototype.resolveHit = function (point) {
|
|
11261
11509
|
var _this = this;
|
|
@@ -11321,6 +11569,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
11321
11569
|
var best = null;
|
|
11322
11570
|
state.elements.forEach(function (element) {
|
|
11323
11571
|
var _a, _b, _c;
|
|
11572
|
+
if (!_this.engine.isElementSelectable(element.id))
|
|
11573
|
+
return;
|
|
11324
11574
|
var world = (_a = _this.engine.getElementWorldPosition(element.id)) !== null && _a !== void 0 ? _a : element.position;
|
|
11325
11575
|
var rotation = _this.engine.getElementRotation(element.id);
|
|
11326
11576
|
if (!pointInRotatedRect(point, world, element.size, rotation, (_b = element.anchorCenter) !== null && _b !== void 0 ? _b : false))
|
|
@@ -11350,6 +11600,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
11350
11600
|
var bestDistance = Number.POSITIVE_INFINITY;
|
|
11351
11601
|
links.forEach(function (link) {
|
|
11352
11602
|
var _a, _b;
|
|
11603
|
+
if (!_this.engine.isLinkVisible(link.id))
|
|
11604
|
+
return;
|
|
11353
11605
|
if (link.points.length < 2)
|
|
11354
11606
|
return;
|
|
11355
11607
|
var tolerance = ((_b = (_a = link.style) === null || _a === void 0 ? void 0 : _a.hitStrokeWidth) !== null && _b !== void 0 ? _b : 15) / 2;
|
|
@@ -12364,6 +12616,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
12364
12616
|
};
|
|
12365
12617
|
state.elements.forEach(function (element) {
|
|
12366
12618
|
var _a, _b;
|
|
12619
|
+
if (!_this.engine.isElementSelectable(element.id))
|
|
12620
|
+
return;
|
|
12367
12621
|
var position = (_a = _this.engine.getElementWorldPosition(element.id)) !== null && _a !== void 0 ? _a : element.position;
|
|
12368
12622
|
var rotation = _this.engine.getElementRotation(element.id);
|
|
12369
12623
|
var anchorCenter = (_b = element.anchorCenter) !== null && _b !== void 0 ? _b : false;
|
|
@@ -12381,6 +12635,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
12381
12635
|
});
|
|
12382
12636
|
state.ports.forEach(function (port) {
|
|
12383
12637
|
var _a;
|
|
12638
|
+
if (!_this.engine.isPortVisible(port.id))
|
|
12639
|
+
return;
|
|
12384
12640
|
var position = (_a = _this.engine.getPortWorldPosition(port.id)) !== null && _a !== void 0 ? _a : port.position;
|
|
12385
12641
|
if (containsPoint(position)) {
|
|
12386
12642
|
selected.add(port.id);
|
|
@@ -12388,6 +12644,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
12388
12644
|
});
|
|
12389
12645
|
state.texts.forEach(function (text) {
|
|
12390
12646
|
var _a, _b, _c, _d, _e;
|
|
12647
|
+
if (!_this.engine.isTextVisible(text.id))
|
|
12648
|
+
return;
|
|
12391
12649
|
var position = (_a = _this.engine.getTextWorldPosition(text.id)) !== null && _a !== void 0 ? _a : text.position;
|
|
12392
12650
|
var width = (_c = (_b = text.size) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 0;
|
|
12393
12651
|
var height = (_e = (_d = text.size) === null || _d === void 0 ? void 0 : _d.height) !== null && _e !== void 0 ? _e : 0;
|
|
@@ -12397,6 +12655,8 @@ var KonvaInteraction = /** @class */ (function () {
|
|
|
12397
12655
|
}
|
|
12398
12656
|
});
|
|
12399
12657
|
state.links.forEach(function (link) {
|
|
12658
|
+
if (!_this.engine.isLinkVisible(link.id))
|
|
12659
|
+
return;
|
|
12400
12660
|
if (link.points.length === 0)
|
|
12401
12661
|
return;
|
|
12402
12662
|
var xs = link.points.map(function (point) { return point.x; });
|
|
@@ -13328,13 +13588,65 @@ var resolveViewportFitOptions = function (options) {
|
|
|
13328
13588
|
return { padding: padding, minZoom: minZoom, maxZoom: maxZoom };
|
|
13329
13589
|
};
|
|
13330
13590
|
var clamp = function (value, min, max) { return Math.max(min, Math.min(max, value)); };
|
|
13591
|
+
var isElementVisibleInState = function (elementId, elementsById) {
|
|
13592
|
+
var _a, _b;
|
|
13593
|
+
var element = elementsById.get(elementId);
|
|
13594
|
+
if (!element)
|
|
13595
|
+
return false;
|
|
13596
|
+
if (element.visible === false)
|
|
13597
|
+
return false;
|
|
13598
|
+
var currentParentId = (_a = element.parentId) !== null && _a !== void 0 ? _a : null;
|
|
13599
|
+
while (currentParentId) {
|
|
13600
|
+
var parent_1 = elementsById.get(currentParentId);
|
|
13601
|
+
if (!parent_1)
|
|
13602
|
+
break;
|
|
13603
|
+
if (parent_1.visible === false)
|
|
13604
|
+
return false;
|
|
13605
|
+
currentParentId = (_b = parent_1.parentId) !== null && _b !== void 0 ? _b : null;
|
|
13606
|
+
}
|
|
13607
|
+
return true;
|
|
13608
|
+
};
|
|
13609
|
+
var isPortVisibleInState = function (portId, portsById, elementsById) {
|
|
13610
|
+
var port = portsById.get(portId);
|
|
13611
|
+
if (!port)
|
|
13612
|
+
return false;
|
|
13613
|
+
return isElementVisibleInState(port.elementId, elementsById);
|
|
13614
|
+
};
|
|
13615
|
+
var isLinkVisibleInState = function (linkId, linksById, portsById, elementsById) {
|
|
13616
|
+
var link = linksById.get(linkId);
|
|
13617
|
+
if (!link)
|
|
13618
|
+
return false;
|
|
13619
|
+
var sourcePort = portsById.get(link.sourcePortId);
|
|
13620
|
+
var targetPort = portsById.get(link.targetPortId);
|
|
13621
|
+
var sourceVisible = sourcePort ? isPortVisibleInState(sourcePort.id, portsById, elementsById) : true;
|
|
13622
|
+
var targetVisible = targetPort ? isPortVisibleInState(targetPort.id, portsById, elementsById) : true;
|
|
13623
|
+
return sourceVisible && targetVisible;
|
|
13624
|
+
};
|
|
13625
|
+
var isTextVisibleInState = function (text, elementsById, portsById, linksById) {
|
|
13626
|
+
if (!text.ownerId)
|
|
13627
|
+
return true;
|
|
13628
|
+
if (elementsById.has(text.ownerId))
|
|
13629
|
+
return isElementVisibleInState(text.ownerId, elementsById);
|
|
13630
|
+
if (portsById.has(text.ownerId))
|
|
13631
|
+
return isPortVisibleInState(text.ownerId, portsById, elementsById);
|
|
13632
|
+
if (linksById.has(text.ownerId))
|
|
13633
|
+
return isLinkVisibleInState(text.ownerId, linksById, portsById, elementsById);
|
|
13634
|
+
return true;
|
|
13635
|
+
};
|
|
13331
13636
|
var resolveStateWorldBounds = function (state) {
|
|
13332
13637
|
var bounds = createBounds();
|
|
13638
|
+
var elementsById = new Map(state.elements.map(function (element) { return [element.id, element]; }));
|
|
13639
|
+
var portsById = new Map(state.ports.map(function (port) { return [port.id, port]; }));
|
|
13640
|
+
var linksById = new Map(state.links.map(function (link) { return [link.id, link]; }));
|
|
13333
13641
|
state.elements.forEach(function (element) {
|
|
13642
|
+
if (!isElementVisibleInState(element.id, elementsById))
|
|
13643
|
+
return;
|
|
13334
13644
|
includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
|
|
13335
13645
|
});
|
|
13336
13646
|
state.ports.forEach(function (port) {
|
|
13337
13647
|
var _a;
|
|
13648
|
+
if (!isPortVisibleInState(port.id, portsById, elementsById))
|
|
13649
|
+
return;
|
|
13338
13650
|
var size = port.size;
|
|
13339
13651
|
if (!size) {
|
|
13340
13652
|
expandBounds(bounds, port.position.x, port.position.y);
|
|
@@ -13346,12 +13658,16 @@ var resolveStateWorldBounds = function (state) {
|
|
|
13346
13658
|
includeRect(bounds, x, y, size.width, size.height);
|
|
13347
13659
|
});
|
|
13348
13660
|
state.links.forEach(function (link) {
|
|
13661
|
+
if (!isLinkVisibleInState(link.id, linksById, portsById, elementsById))
|
|
13662
|
+
return;
|
|
13349
13663
|
link.points.forEach(function (point) {
|
|
13350
13664
|
expandBounds(bounds, point.x, point.y);
|
|
13351
13665
|
});
|
|
13352
13666
|
});
|
|
13353
13667
|
state.texts.forEach(function (text) {
|
|
13354
13668
|
var _a;
|
|
13669
|
+
if (!isTextVisibleInState(text, elementsById, portsById, linksById))
|
|
13670
|
+
return;
|
|
13355
13671
|
var offset = (_a = text.displayOffset) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
|
|
13356
13672
|
var position = { x: text.position.x + offset.x, y: text.position.y + offset.y };
|
|
13357
13673
|
var clipSize = text.displayClipSize;
|
|
@@ -13366,7 +13682,10 @@ var resolveStateWorldBounds = function (state) {
|
|
|
13366
13682
|
};
|
|
13367
13683
|
var resolveElementWorldBounds = function (state) {
|
|
13368
13684
|
var bounds = createBounds();
|
|
13685
|
+
var elementsById = new Map(state.elements.map(function (element) { return [element.id, element]; }));
|
|
13369
13686
|
state.elements.forEach(function (element) {
|
|
13687
|
+
if (!isElementVisibleInState(element.id, elementsById))
|
|
13688
|
+
return;
|
|
13370
13689
|
includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
|
|
13371
13690
|
});
|
|
13372
13691
|
return hasBounds(bounds) ? bounds : null;
|
|
@@ -16518,6 +16837,12 @@ var demoTabs = [
|
|
|
16518
16837
|
description: selectionDemoConfig.description,
|
|
16519
16838
|
Component: wrapSimpleDemo(selectionDemoConfig),
|
|
16520
16839
|
},
|
|
16840
|
+
{
|
|
16841
|
+
id: elementVisibilitySelectionDemoConfig.id,
|
|
16842
|
+
title: elementVisibilitySelectionDemoConfig.title,
|
|
16843
|
+
description: elementVisibilitySelectionDemoConfig.description,
|
|
16844
|
+
Component: wrapSimpleDemo(elementVisibilitySelectionDemoConfig),
|
|
16845
|
+
},
|
|
16521
16846
|
{
|
|
16522
16847
|
id: eventHandlersDemoConfig.id,
|
|
16523
16848
|
title: eventHandlersDemoConfig.title,
|