orcasvn-react-diagrams 0.2.9 → 0.2.10

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.
@@ -1162,13 +1162,21 @@ var createElementVisibilitySelectionState = function () { return ({
1162
1162
  style: { fill: '#e2e8f0', stroke: '#334155', strokeWidth: 2 },
1163
1163
  },
1164
1164
  {
1165
- id: 'policy-hidden',
1166
- position: { x: 700, y: 140 },
1167
- size: { width: 180, height: 120 },
1165
+ id: 'policy-hidden-parent',
1166
+ position: { x: 660, y: 110 },
1167
+ size: { width: 220, height: 170 },
1168
1168
  shapeId: 'default',
1169
1169
  visible: false,
1170
1170
  style: { fill: '#fee2e2', stroke: '#dc2626', strokeWidth: 2 },
1171
1171
  },
1172
+ {
1173
+ id: 'policy-hidden-child',
1174
+ parentId: 'policy-hidden-parent',
1175
+ position: { x: 50, y: 58 },
1176
+ size: { width: 120, height: 72 },
1177
+ shapeId: 'default',
1178
+ style: { fill: '#dcfce7', stroke: '#16a34a', strokeWidth: 2 },
1179
+ },
1172
1180
  ],
1173
1181
  ports: [
1174
1182
  {
@@ -1184,9 +1192,15 @@ var createElementVisibilitySelectionState = function () { return ({
1184
1192
  shapeId: 'port-circle',
1185
1193
  },
1186
1194
  {
1187
- id: 'policy-hidden-port',
1188
- elementId: 'policy-hidden',
1189
- position: { x: 0, y: 60 },
1195
+ id: 'policy-hidden-parent-port',
1196
+ elementId: 'policy-hidden-parent',
1197
+ position: { x: 0, y: 85 },
1198
+ shapeId: 'port-circle',
1199
+ },
1200
+ {
1201
+ id: 'policy-hidden-child-port',
1202
+ elementId: 'policy-hidden-child',
1203
+ position: { x: 120, y: 36 },
1190
1204
  shapeId: 'port-circle',
1191
1205
  },
1192
1206
  ],
@@ -1202,22 +1216,32 @@ var createElementVisibilitySelectionState = function () { return ({
1202
1216
  style: { stroke: '#2563eb', strokeWidth: 3 },
1203
1217
  },
1204
1218
  {
1205
- id: 'policy-hidden-link',
1219
+ id: 'policy-hidden-parent-link',
1206
1220
  sourcePortId: 'policy-normal-port',
1207
- targetPortId: 'policy-hidden-port',
1221
+ targetPortId: 'policy-hidden-parent-port',
1208
1222
  points: [
1209
1223
  { x: 300, y: 220 },
1210
- { x: 700, y: 200 },
1224
+ { x: 660, y: 195 },
1211
1225
  ],
1212
1226
  style: { stroke: '#dc2626', strokeWidth: 3 },
1213
1227
  },
1228
+ {
1229
+ id: 'policy-visible-child-link',
1230
+ sourcePortId: 'policy-normal-port',
1231
+ targetPortId: 'policy-hidden-child-port',
1232
+ points: [
1233
+ { x: 300, y: 220 },
1234
+ { x: 830, y: 204 },
1235
+ ],
1236
+ style: { stroke: '#16a34a', strokeWidth: 3 },
1237
+ },
1214
1238
  ],
1215
1239
  texts: [
1216
1240
  {
1217
1241
  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.',
1242
+ content: 'Blue node is normal. Slate node is visible but its body ignores click and marquee. Its port stays interactive. Red parent container is hidden, but its green child stays visible and interactive. Parent-owned port/text and the red parent link stay suppressed, while the green child link remains in scene, selection, zoom-to-fit, and fit-to-content export.',
1219
1243
  position: { x: 80, y: 72 },
1220
- size: { width: 760, height: 44 },
1244
+ size: { width: 810, height: 60 },
1221
1245
  style: { fontSize: 14, fill: '#0f172a' },
1222
1246
  },
1223
1247
  {
@@ -1234,16 +1258,22 @@ var createElementVisibilitySelectionState = function () { return ({
1234
1258
  },
1235
1259
  {
1236
1260
  id: 'policy-hidden-label',
1237
- content: 'Hidden in state',
1261
+ content: 'Hidden parent body',
1238
1262
  position: { x: 16, y: 14 },
1239
- ownerId: 'policy-hidden',
1263
+ ownerId: 'policy-hidden-parent',
1264
+ },
1265
+ {
1266
+ id: 'policy-hidden-child-label',
1267
+ content: 'Visible child inside hidden parent',
1268
+ position: { x: 10, y: 12 },
1269
+ ownerId: 'policy-hidden-child',
1240
1270
  },
1241
1271
  ],
1242
1272
  }); };
1243
1273
  var elementVisibilitySelectionDemoConfig = {
1244
1274
  id: 'element-visibility-selection',
1245
1275
  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.',
1276
+ description: 'QA scene for visible-but-unselectable bodies, hidden parent containers, and visible descendants that survive hidden ancestors. Shift + drag marquee to confirm only eligible items are collected.',
1247
1277
  createState: createElementVisibilitySelectionState,
1248
1278
  elementShapes: baseElementShapes,
1249
1279
  portShapes: basePortShapes,
@@ -1257,9 +1287,14 @@ var elementVisibilitySelectionDemoConfig = {
1257
1287
  editor.setSelection([
1258
1288
  'policy-normal',
1259
1289
  'policy-unselectable',
1260
- 'policy-hidden',
1290
+ 'policy-hidden-parent',
1291
+ 'policy-hidden-child',
1261
1292
  'policy-unselectable-port',
1262
- 'policy-hidden-link',
1293
+ 'policy-hidden-parent-port',
1294
+ 'policy-hidden-child-port',
1295
+ 'policy-hidden-parent-link',
1296
+ 'policy-visible-child-link',
1297
+ 'policy-hidden-child-label',
1263
1298
  ]);
1264
1299
  },
1265
1300
  },
@@ -5181,18 +5216,7 @@ var DiagramModel = /** @class */ (function () {
5181
5216
  var element = this.elements.get(id);
5182
5217
  if (!element)
5183
5218
  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;
5219
+ return element.visible !== false;
5196
5220
  };
5197
5221
  DiagramModel.prototype.isElementSelectable = function (id) {
5198
5222
  var element = this.elements.get(id);
@@ -5463,18 +5487,18 @@ var DiagramModel = /** @class */ (function () {
5463
5487
  }
5464
5488
  var current = element;
5465
5489
  while (current === null || current === void 0 ? void 0 : current.parentId) {
5466
- var parent_2 = this.elements.get(current.parentId);
5467
- if (!parent_2)
5490
+ var parent_1 = this.elements.get(current.parentId);
5491
+ if (!parent_1)
5468
5492
  break;
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;
5493
+ var parentX = parent_1.position.x;
5494
+ var parentY = parent_1.position.y;
5495
+ if (parent_1.anchorCenter) {
5496
+ parentX -= parent_1.size.width / 2;
5497
+ parentY -= parent_1.size.height / 2;
5474
5498
  }
5475
5499
  x += parentX;
5476
5500
  y += parentY;
5477
- current = parent_2;
5501
+ current = parent_1;
5478
5502
  }
5479
5503
  return { x: x, y: y };
5480
5504
  };
@@ -13589,22 +13613,10 @@ var resolveViewportFitOptions = function (options) {
13589
13613
  };
13590
13614
  var clamp = function (value, min, max) { return Math.max(min, Math.min(max, value)); };
13591
13615
  var isElementVisibleInState = function (elementId, elementsById) {
13592
- var _a, _b;
13593
13616
  var element = elementsById.get(elementId);
13594
13617
  if (!element)
13595
13618
  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;
13619
+ return element.visible !== false;
13608
13620
  };
13609
13621
  var isPortVisibleInState = function (portId, portsById, elementsById) {
13610
13622
  var port = portsById.get(portId);
@@ -13633,6 +13645,103 @@ var isTextVisibleInState = function (text, elementsById, portsById, linksById) {
13633
13645
  return isLinkVisibleInState(text.ownerId, linksById, portsById, elementsById);
13634
13646
  return true;
13635
13647
  };
13648
+ var resolveElementWorldPositionInState = function (elementId, elementsById) {
13649
+ var element = elementsById.get(elementId);
13650
+ if (!element)
13651
+ return null;
13652
+ var x = element.position.x;
13653
+ var y = element.position.y;
13654
+ if (element.anchorCenter) {
13655
+ x -= element.size.width / 2;
13656
+ y -= element.size.height / 2;
13657
+ }
13658
+ var current = element;
13659
+ while (current.parentId) {
13660
+ var parent_1 = elementsById.get(current.parentId);
13661
+ if (!parent_1)
13662
+ break;
13663
+ var parentX = parent_1.position.x;
13664
+ var parentY = parent_1.position.y;
13665
+ if (parent_1.anchorCenter) {
13666
+ parentX -= parent_1.size.width / 2;
13667
+ parentY -= parent_1.size.height / 2;
13668
+ }
13669
+ x += parentX;
13670
+ y += parentY;
13671
+ current = parent_1;
13672
+ }
13673
+ return { x: x, y: y };
13674
+ };
13675
+ var resolvePortWorldPositionInState = function (portId, portsById, elementsById) {
13676
+ var port = portsById.get(portId);
13677
+ if (!port)
13678
+ return null;
13679
+ var elementPosition = resolveElementWorldPositionInState(port.elementId, elementsById);
13680
+ if (!elementPosition)
13681
+ return __assign({}, port.position);
13682
+ return {
13683
+ x: elementPosition.x + port.position.x,
13684
+ y: elementPosition.y + port.position.y,
13685
+ };
13686
+ };
13687
+ var resolveLinkMidpointInState = function (link) {
13688
+ var points = link.points;
13689
+ if (points.length === 0)
13690
+ return { x: 0, y: 0 };
13691
+ if (points.length === 1)
13692
+ return __assign({}, points[0]);
13693
+ var total = 0;
13694
+ for (var i = 1; i < points.length; i += 1) {
13695
+ total += distance(points[i - 1], points[i]);
13696
+ }
13697
+ var halfway = total / 2;
13698
+ var traveled = 0;
13699
+ for (var i = 1; i < points.length; i += 1) {
13700
+ var segment = distance(points[i - 1], points[i]);
13701
+ if (traveled + segment >= halfway) {
13702
+ var ratio = segment === 0 ? 0 : (halfway - traveled) / segment;
13703
+ return {
13704
+ x: points[i - 1].x + (points[i].x - points[i - 1].x) * ratio,
13705
+ y: points[i - 1].y + (points[i].y - points[i - 1].y) * ratio,
13706
+ };
13707
+ }
13708
+ traveled += segment;
13709
+ }
13710
+ return __assign({}, points[points.length - 1]);
13711
+ };
13712
+ var resolveTextWorldPositionInState = function (text, elementsById, portsById, linksById) {
13713
+ if (!text.ownerId)
13714
+ return __assign({}, text.position);
13715
+ if (elementsById.has(text.ownerId)) {
13716
+ var elementPosition = resolveElementWorldPositionInState(text.ownerId, elementsById);
13717
+ if (!elementPosition)
13718
+ return __assign({}, text.position);
13719
+ return {
13720
+ x: elementPosition.x + text.position.x,
13721
+ y: elementPosition.y + text.position.y,
13722
+ };
13723
+ }
13724
+ if (portsById.has(text.ownerId)) {
13725
+ var portPosition = resolvePortWorldPositionInState(text.ownerId, portsById, elementsById);
13726
+ if (!portPosition)
13727
+ return __assign({}, text.position);
13728
+ return {
13729
+ x: portPosition.x + text.position.x,
13730
+ y: portPosition.y + text.position.y,
13731
+ };
13732
+ }
13733
+ if (linksById.has(text.ownerId)) {
13734
+ var link = linksById.get(text.ownerId);
13735
+ if (!link)
13736
+ return __assign({}, text.position);
13737
+ var midpoint = resolveLinkMidpointInState(link);
13738
+ return {
13739
+ x: midpoint.x + text.position.x,
13740
+ y: midpoint.y + text.position.y,
13741
+ };
13742
+ }
13743
+ return __assign({}, text.position);
13744
+ };
13636
13745
  var resolveStateWorldBounds = function (state) {
13637
13746
  var bounds = createBounds();
13638
13747
  var elementsById = new Map(state.elements.map(function (element) { return [element.id, element]; }));
@@ -13641,20 +13750,26 @@ var resolveStateWorldBounds = function (state) {
13641
13750
  state.elements.forEach(function (element) {
13642
13751
  if (!isElementVisibleInState(element.id, elementsById))
13643
13752
  return;
13644
- includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
13753
+ var position = resolveElementWorldPositionInState(element.id, elementsById);
13754
+ if (!position)
13755
+ return;
13756
+ includeRect(bounds, position.x, position.y, element.size.width, element.size.height);
13645
13757
  });
13646
13758
  state.ports.forEach(function (port) {
13647
13759
  var _a;
13648
13760
  if (!isPortVisibleInState(port.id, portsById, elementsById))
13649
13761
  return;
13762
+ var position = resolvePortWorldPositionInState(port.id, portsById, elementsById);
13763
+ if (!position)
13764
+ return;
13650
13765
  var size = port.size;
13651
13766
  if (!size) {
13652
- expandBounds(bounds, port.position.x, port.position.y);
13767
+ expandBounds(bounds, position.x, position.y);
13653
13768
  return;
13654
13769
  }
13655
13770
  var anchorCenter = (_a = port.anchorCenter) !== null && _a !== void 0 ? _a : true;
13656
- var x = anchorCenter ? port.position.x - size.width / 2 : port.position.x;
13657
- var y = anchorCenter ? port.position.y - size.height / 2 : port.position.y;
13771
+ var x = anchorCenter ? position.x - size.width / 2 : position.x;
13772
+ var y = anchorCenter ? position.y - size.height / 2 : position.y;
13658
13773
  includeRect(bounds, x, y, size.width, size.height);
13659
13774
  });
13660
13775
  state.links.forEach(function (link) {
@@ -13669,7 +13784,8 @@ var resolveStateWorldBounds = function (state) {
13669
13784
  if (!isTextVisibleInState(text, elementsById, portsById, linksById))
13670
13785
  return;
13671
13786
  var offset = (_a = text.displayOffset) !== null && _a !== void 0 ? _a : { x: 0, y: 0 };
13672
- var position = { x: text.position.x + offset.x, y: text.position.y + offset.y };
13787
+ var worldPosition = resolveTextWorldPositionInState(text, elementsById, portsById, linksById);
13788
+ var position = { x: worldPosition.x + offset.x, y: worldPosition.y + offset.y };
13673
13789
  var clipSize = text.displayClipSize;
13674
13790
  var size = clipSize !== null && clipSize !== void 0 ? clipSize : text.size;
13675
13791
  if (size) {
@@ -13686,7 +13802,10 @@ var resolveElementWorldBounds = function (state) {
13686
13802
  state.elements.forEach(function (element) {
13687
13803
  if (!isElementVisibleInState(element.id, elementsById))
13688
13804
  return;
13689
- includeRect(bounds, element.position.x, element.position.y, element.size.width, element.size.height);
13805
+ var position = resolveElementWorldPositionInState(element.id, elementsById);
13806
+ if (!position)
13807
+ return;
13808
+ includeRect(bounds, position.x, position.y, element.size.width, element.size.height);
13690
13809
  });
13691
13810
  return hasBounds(bounds) ? bounds : null;
13692
13811
  };