@tscircuit/schematic-viewer 2.0.98 → 2.0.100

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/index.js CHANGED
@@ -1,3 +1,176 @@
1
+ // lib/utils/schematic-net-registry.ts
2
+ import { su } from "@tscircuit/soup-util";
3
+ function buildNetRegistry(circuitJson) {
4
+ const cju = su(circuitJson);
5
+ const srcCompToSchComp = /* @__PURE__ */ new Map();
6
+ for (const c of cju.schematic_component.list()) {
7
+ if (c.source_component_id) {
8
+ srcCompToSchComp.set(c.source_component_id, c.schematic_component_id);
9
+ }
10
+ }
11
+ const componentIdToKeys = /* @__PURE__ */ new Map();
12
+ for (const sourceTrace of cju.source_trace.list()) {
13
+ const key = sourceTrace.subcircuit_connectivity_map_key;
14
+ if (!key) continue;
15
+ for (const portId of sourceTrace.connected_source_port_ids ?? []) {
16
+ const schCompId = srcCompToSchComp.get(
17
+ cju.source_port.get(portId)?.source_component_id ?? ""
18
+ );
19
+ if (!schCompId) continue;
20
+ if (!componentIdToKeys.has(schCompId)) {
21
+ componentIdToKeys.set(schCompId, /* @__PURE__ */ new Set());
22
+ }
23
+ componentIdToKeys.get(schCompId).add(key);
24
+ }
25
+ }
26
+ const netLabelIdToKey = /* @__PURE__ */ new Map();
27
+ for (const label of cju.schematic_net_label.list()) {
28
+ if (!label.source_net_id) continue;
29
+ const key = cju.source_net.get(label.source_net_id)?.subcircuit_connectivity_map_key ?? label.source_net_id;
30
+ netLabelIdToKey.set(label.schematic_net_label_id, key);
31
+ }
32
+ const textIdToKey = /* @__PURE__ */ new Map();
33
+ for (const text of cju.schematic_text.list()) {
34
+ if (!text.source_trace_id) continue;
35
+ const key = cju.source_trace.get(
36
+ text.source_trace_id
37
+ )?.subcircuit_connectivity_map_key;
38
+ if (key) textIdToKey.set(text.schematic_text_id, key);
39
+ }
40
+ return { componentIdToKeys, netLabelIdToKey, textIdToKey };
41
+ }
42
+
43
+ // lib/utils/get-net-locations.ts
44
+ var distance = (a, b) => Math.hypot(a.x - b.x, a.y - b.y);
45
+ var distanceToSegment = (p, a, b) => {
46
+ const dx = b.x - a.x, dy = b.y - a.y;
47
+ const lengthSquared = dx * dx + dy * dy;
48
+ const t = lengthSquared ? Math.max(
49
+ 0,
50
+ Math.min(1, ((p.x - a.x) * dx + (p.y - a.y) * dy) / lengthSquared)
51
+ ) : 0;
52
+ return distance(p, { x: a.x + t * dx, y: a.y + t * dy });
53
+ };
54
+ var onSegment = (p, a, b) => Math.abs(distance(a, p) + distance(p, b) - distance(a, b)) < 1e-5;
55
+ function getNetKeyAtElement(target, circuitJson) {
56
+ const registry = buildNetRegistry(circuitJson);
57
+ const element = target?.closest(
58
+ "[data-subcircuit-connectivity-map-key], [data-schematic-net-label-id], [data-schematic-text-id], [data-schematic-trace-id]"
59
+ );
60
+ if (!element) return void 0;
61
+ const trace = circuitJson.find(
62
+ (e) => e.type === "schematic_trace" && e.schematic_trace_id === element.getAttribute("data-schematic-trace-id")
63
+ );
64
+ return element.getAttribute("data-subcircuit-connectivity-map-key") || registry.netLabelIdToKey.get(
65
+ element.getAttribute("data-schematic-net-label-id")
66
+ ) || registry.textIdToKey.get(element.getAttribute("data-schematic-text-id")) || (trace?.type === "schematic_trace" ? trace.subcircuit_connectivity_map_key || circuitJson.filter((e) => e.type === "source_trace").find((e) => e.source_trace_id === trace.source_trace_id)?.subcircuit_connectivity_map_key : void 0);
67
+ }
68
+ function getNetLocations(circuitJson, key) {
69
+ const registry = buildNetRegistry(circuitJson);
70
+ const sources = circuitJson.filter((e) => e.type === "source_trace");
71
+ const traces = circuitJson.filter((e) => e.type === "schematic_trace");
72
+ const sheets = circuitJson.filter((e) => e.type === "schematic_sheet");
73
+ const defaultSheet = sheets[0]?.schematic_sheet_id;
74
+ const nodes = [];
75
+ for (const trace of traces) {
76
+ const traceKey = trace.subcircuit_connectivity_map_key ?? sources.find((s) => s.source_trace_id === trace.source_trace_id)?.subcircuit_connectivity_map_key;
77
+ if (traceKey !== key) continue;
78
+ for (const edge of trace.edges)
79
+ nodes.push({
80
+ a: edge.from,
81
+ b: edge.to,
82
+ sheet: trace.schematic_sheet_id ?? defaultSheet,
83
+ target: { type: "schematic_trace", id: trace.schematic_trace_id },
84
+ sourceTraceId: trace.source_trace_id,
85
+ portIds: [
86
+ edge.from_schematic_port_id,
87
+ edge.to_schematic_port_id
88
+ ].filter((id) => !!id),
89
+ junctions: trace.junctions
90
+ });
91
+ }
92
+ for (const element of circuitJson) {
93
+ if (element.type === "schematic_net_label" && registry.netLabelIdToKey.get(element.schematic_net_label_id) === key) {
94
+ const point = element.anchor_position ?? element.center;
95
+ nodes.push({
96
+ a: point,
97
+ b: point,
98
+ sheet: element.schematic_sheet_id ?? defaultSheet,
99
+ target: {
100
+ type: "schematic_net_label",
101
+ id: element.schematic_net_label_id
102
+ },
103
+ name: element.text
104
+ });
105
+ }
106
+ }
107
+ for (const element of circuitJson) {
108
+ if (element.type !== "schematic_text" || registry.textIdToKey.get(element.schematic_text_id) !== key)
109
+ continue;
110
+ const sheet = element.schematic_sheet_id ?? defaultSheet;
111
+ const nearest = nodes.filter(
112
+ (n) => n.sheet === sheet && n.sourceTraceId === element.source_trace_id
113
+ ).sort(
114
+ (a, b) => distanceToSegment(element.position, a.a, a.b) - distanceToSegment(element.position, b.a, b.b)
115
+ )[0];
116
+ const point = nearest?.a ?? element.position;
117
+ nodes.push({
118
+ a: point,
119
+ b: point,
120
+ sheet,
121
+ target: { type: "schematic_text", id: element.schematic_text_id },
122
+ name: element.text
123
+ });
124
+ }
125
+ const parents = nodes.map((_, i) => i);
126
+ const root = (i) => parents[i] === i ? i : parents[i] = root(parents[i]);
127
+ for (let i = 0; i < nodes.length; i++)
128
+ for (let j = 0; j < i; j++) {
129
+ const a = nodes[i], b = nodes[j];
130
+ if (a.sheet !== b.sheet) continue;
131
+ if (onSegment(a.a, b.a, b.b) || onSegment(a.b, b.a, b.b) || onSegment(b.a, a.a, a.b) || onSegment(b.b, a.a, a.b) || [...a.junctions ?? [], ...b.junctions ?? []].some(
132
+ (p) => onSegment(p, a.a, a.b) && onSegment(p, b.a, b.b)
133
+ ))
134
+ parents[root(i)] = root(j);
135
+ }
136
+ const groups = /* @__PURE__ */ new Map();
137
+ nodes.forEach(
138
+ (node, i) => groups.set(root(i), [...groups.get(root(i)) ?? [], node])
139
+ );
140
+ return [...groups.values()].map((island, index) => {
141
+ const representative = island.find((n) => n.target.type !== "schematic_trace") ?? island[0];
142
+ const ports = circuitJson.filter((e) => e.type === "schematic_port").filter(
143
+ (e) => (e.schematic_sheet_id ?? defaultSheet) === representative.sheet && island.some(
144
+ (n) => n.portIds?.includes(e.schematic_port_id) || onSegment(e.center, n.a, n.b)
145
+ )
146
+ );
147
+ const names = ports.map((port) => {
148
+ const sourcePort = circuitJson.find(
149
+ (e) => e.type === "source_port" && e.source_port_id === port.source_port_id
150
+ );
151
+ if (sourcePort?.type !== "source_port") return void 0;
152
+ const component = circuitJson.find(
153
+ (e) => e.type === "source_component" && e.source_component_id === sourcePort.source_component_id
154
+ );
155
+ return component?.type === "source_component" ? `${component.name}.${sourcePort.name ?? `pin${sourcePort.pin_number}`}` : void 0;
156
+ }).filter((name) => !!name).sort();
157
+ const sheetIndex = sheets.findIndex(
158
+ (s) => s.schematic_sheet_id === representative.sheet
159
+ );
160
+ const sheetName = sheets[sheetIndex]?.name ?? `Sheet ${Math.max(0, sheetIndex) + 1}`;
161
+ return {
162
+ kind: "net",
163
+ label: `${sheetName}: ${names[0] ?? representative.name ?? `Location ${index + 1}`}`,
164
+ schematicSheetId: representative.sheet,
165
+ target: representative.target,
166
+ focusPoint: {
167
+ x: (representative.a.x + representative.b.x) / 2,
168
+ y: (representative.a.y + representative.b.y) / 2
169
+ }
170
+ };
171
+ });
172
+ }
173
+
1
174
  // lib/components/StyleAnalysisDialog.tsx
2
175
  import * as Dialog from "@radix-ui/react-dialog";
3
176
 
@@ -221,7 +394,7 @@ var setStoredString = (key, value) => {
221
394
 
222
395
  // lib/hooks/useSchematicGroupsOverlay.ts
223
396
  import { useEffect as useEffect2 } from "react";
224
- import { su } from "@tscircuit/soup-util";
397
+ import { su as su2 } from "@tscircuit/soup-util";
225
398
  var GROUP_COLORS = [
226
399
  "#8B0000",
227
400
  // Dark Red
@@ -265,8 +438,8 @@ var useSchematicGroupsOverlay = (options) => {
265
438
  const existingOverlays = svg.querySelectorAll(".schematic-group-overlay");
266
439
  existingOverlays.forEach((overlay) => overlay.remove());
267
440
  try {
268
- const sourceGroups = su(circuitJson).source_group?.list().filter((x) => !!!x.is_subcircuit) || [];
269
- const schematicComponents = su(circuitJson).schematic_component?.list() || [];
441
+ const sourceGroups = su2(circuitJson).source_group?.list().filter((x) => !!!x.is_subcircuit) || [];
442
+ const schematicComponents = su2(circuitJson).schematic_component?.list() || [];
270
443
  const sourceGroupHierarchy = /* @__PURE__ */ new Map();
271
444
  sourceGroups.forEach((group) => {
272
445
  const groupWithParent = group;
@@ -304,7 +477,7 @@ var useSchematicGroupsOverlay = (options) => {
304
477
  if (hasMeaningfulGroups) {
305
478
  const groupMap = /* @__PURE__ */ new Map();
306
479
  for (const comp of schematicComponents) {
307
- const sourceComp = su(circuitJson).source_component.get(
480
+ const sourceComp = su2(circuitJson).source_component.get(
308
481
  comp.source_component_id
309
482
  );
310
483
  if (sourceComp?.source_group_id) {
@@ -488,11 +661,10 @@ function calculateGroupBounds(components, svg) {
488
661
  }
489
662
 
490
663
  // lib/hooks/useSchematicNetHover.ts
491
- import { su as su2 } from "@tscircuit/soup-util";
492
664
  import { useEffect as useEffect3 } from "react";
493
665
  var FADED_CLASS = "sch-net-faded";
494
666
  var TRACE_SELECTOR = "g.trace[data-subcircuit-connectivity-map-key], g.trace-overlays[data-subcircuit-connectivity-map-key]";
495
- var NET_LABEL_SELECTOR = "[data-schematic-net-label-id]";
667
+ var NET_LABEL_SELECTOR = "[data-schematic-net-label-id], [data-schematic-text-id]";
496
668
  var useSchematicNetHover = ({
497
669
  svgDivRef,
498
670
  circuitJson,
@@ -502,7 +674,7 @@ var useSchematicNetHover = ({
502
674
  useEffect3(() => {
503
675
  const svgDiv = svgDivRef.current;
504
676
  if (!enabled || !svgDiv) return;
505
- const { componentIdToKeys, netLabelIdToKey } = buildNetRegistry(circuitJson);
677
+ const { componentIdToKeys, netLabelIdToKey, textIdToKey } = buildNetRegistry(circuitJson);
506
678
  let netElements = [];
507
679
  const triggerNetKeys = /* @__PURE__ */ new Map();
508
680
  let hoveredNetKey = null;
@@ -531,7 +703,7 @@ var useSchematicNetHover = ({
531
703
  for (const el of Array.from(svg.querySelectorAll(NET_LABEL_SELECTOR))) {
532
704
  const key = netLabelIdToKey.get(
533
705
  el.getAttribute("data-schematic-net-label-id")
534
- );
706
+ ) ?? textIdToKey.get(el.getAttribute("data-schematic-text-id"));
535
707
  const keys = /* @__PURE__ */ new Set();
536
708
  if (key) {
537
709
  keys.add(key);
@@ -547,64 +719,41 @@ var useSchematicNetHover = ({
547
719
  el.classList.toggle(FADED_CLASS, key !== null && !keys.has(key));
548
720
  }
549
721
  };
550
- const handleMouseOver = (e) => {
722
+ const handleMouseMove = (e) => {
551
723
  const target = e.target;
552
724
  if (!(target instanceof Element)) {
553
725
  highlightNet(null);
554
726
  return;
555
727
  }
556
728
  const trigger = target.closest(`${TRACE_SELECTOR}, ${NET_LABEL_SELECTOR}`);
557
- if (!trigger) {
558
- highlightNet(null);
729
+ if (trigger && triggerNetKeys.has(trigger)) {
730
+ highlightNet(triggerNetKeys.get(trigger));
559
731
  return;
560
732
  }
561
- highlightNet(triggerNetKeys.get(trigger) ?? null);
733
+ for (const [el, key] of triggerNetKeys) {
734
+ if (!el.matches(NET_LABEL_SELECTOR)) continue;
735
+ const rect = el.getBoundingClientRect();
736
+ if (e.clientX >= rect.left - 6 && e.clientX <= rect.right + 6 && e.clientY >= rect.top - 6 && e.clientY <= rect.bottom + 6) {
737
+ highlightNet(key);
738
+ return;
739
+ }
740
+ }
741
+ highlightNet(null);
562
742
  };
563
743
  const handleMouseLeave = () => highlightNet(null);
564
744
  collectNetElements();
565
- svgDiv.addEventListener("mouseover", handleMouseOver);
745
+ svgDiv.addEventListener("mousemove", handleMouseMove);
566
746
  svgDiv.addEventListener("mouseleave", handleMouseLeave);
567
747
  const observer = new MutationObserver(collectNetElements);
568
748
  observer.observe(svgDiv, { childList: true });
569
749
  return () => {
570
750
  observer.disconnect();
571
- svgDiv.removeEventListener("mouseover", handleMouseOver);
751
+ svgDiv.removeEventListener("mousemove", handleMouseMove);
572
752
  svgDiv.removeEventListener("mouseleave", handleMouseLeave);
573
753
  for (const { el } of netElements) el.classList.remove(FADED_CLASS);
574
754
  };
575
755
  }, [svgDivRef, circuitJsonKey, enabled]);
576
756
  };
577
- function buildNetRegistry(circuitJson) {
578
- const cju = su2(circuitJson);
579
- const srcCompToSchComp = /* @__PURE__ */ new Map();
580
- for (const c of cju.schematic_component.list()) {
581
- if (c.source_component_id) {
582
- srcCompToSchComp.set(c.source_component_id, c.schematic_component_id);
583
- }
584
- }
585
- const componentIdToKeys = /* @__PURE__ */ new Map();
586
- for (const sourceTrace of cju.source_trace.list()) {
587
- const key = sourceTrace.subcircuit_connectivity_map_key;
588
- if (!key) continue;
589
- for (const portId of sourceTrace.connected_source_port_ids ?? []) {
590
- const schCompId = srcCompToSchComp.get(
591
- cju.source_port.get(portId)?.source_component_id ?? ""
592
- );
593
- if (!schCompId) continue;
594
- if (!componentIdToKeys.has(schCompId)) {
595
- componentIdToKeys.set(schCompId, /* @__PURE__ */ new Set());
596
- }
597
- componentIdToKeys.get(schCompId).add(key);
598
- }
599
- }
600
- const netLabelIdToKey = /* @__PURE__ */ new Map();
601
- for (const label of cju.schematic_net_label.list()) {
602
- if (!label.source_net_id) continue;
603
- const key = cju.source_net.get(label.source_net_id)?.subcircuit_connectivity_map_key ?? label.source_net_id;
604
- netLabelIdToKey.set(label.schematic_net_label_id, key);
605
- }
606
- return { componentIdToKeys, netLabelIdToKey };
607
- }
608
757
 
609
758
  // lib/hooks/useSchematicWarnings.ts
610
759
  import { useLayoutEffect, useRef } from "react";
@@ -716,7 +865,7 @@ var useSchematicWarnings = ({
716
865
 
717
866
  // lib/hooks/useSchematicSearch.ts
718
867
  import { useCallback as useCallback2, useEffect as useEffect4, useMemo, useRef as useRef2, useState as useState2 } from "react";
719
- import { fromString } from "transformation-matrix";
868
+ import { applyToPoint, fromString } from "transformation-matrix";
720
869
 
721
870
  // lib/utils/get-schematic-search-results.ts
722
871
  var normalize = (value) => String(value ?? "").toLocaleLowerCase();
@@ -851,7 +1000,7 @@ var getSchematicSearchResults = (circuitJson, query) => {
851
1000
  port.center.x - anchorPosition.x,
852
1001
  port.center.y - anchorPosition.y
853
1002
  )
854
- })).filter(({ distance }) => distance <= 1).sort((a, b) => a.distance - b.distance)[0]?.port;
1003
+ })).filter(({ distance: distance2 }) => distance2 <= 1).sort((a, b) => a.distance - b.distance)[0]?.port;
855
1004
  const sourcePort = nearestConnectedPort ? sourcePorts.get(nearestConnectedPort.source_port_id) : void 0;
856
1005
  const connectedComponent = sourcePort?.source_component_id ? sourceComponents.get(sourcePort.source_component_id) : void 0;
857
1006
  const connectedPinName = sourcePort?.name ?? (sourcePort?.pin_number !== void 0 ? `pin${sourcePort.pin_number}` : nearestConnectedPort?.display_pin_label);
@@ -953,18 +1102,29 @@ var useSchematicSearch = ({
953
1102
  const svgRoot = svgDivRef.current;
954
1103
  const container = containerRef.current;
955
1104
  if (!svgRoot || !container) return false;
956
- let attribute = "data-schematic-net-label-id";
957
- if (result.target.type === "schematic_component") {
958
- attribute = "data-schematic-component-id";
959
- }
960
- if (result.target.type === "schematic_text") {
961
- attribute = "data-schematic-text-id";
962
- }
1105
+ const attribute = `data-${result.target.type.replaceAll("_", "-")}-id`;
963
1106
  const target = Array.from(
964
1107
  svgRoot.querySelectorAll(`[${attribute}]`)
965
1108
  ).find((element) => element.getAttribute(attribute) === result.target.id);
966
1109
  if (!target) return false;
967
- const targetRect = target.getBoundingClientRect();
1110
+ let targetRect = target.getBoundingClientRect();
1111
+ if (result.focusPoint) {
1112
+ const svg = target.closest("svg");
1113
+ const transform = svg?.getAttribute("data-real-to-screen-transform");
1114
+ const screenMatrix = svg?.getScreenCTM?.();
1115
+ if (transform && screenMatrix) {
1116
+ const point = applyToPoint(
1117
+ screenMatrix,
1118
+ applyToPoint(fromString(transform), result.focusPoint)
1119
+ );
1120
+ targetRect = {
1121
+ left: point.x - 1,
1122
+ top: point.y - 1,
1123
+ width: 2,
1124
+ height: 2
1125
+ };
1126
+ }
1127
+ }
968
1128
  const containerRect = container.getBoundingClientRect();
969
1129
  if (!containerRect.width || !containerRect.height) return false;
970
1130
  if (!targetRect.width && !targetRect.height) return false;
@@ -1157,6 +1317,7 @@ import { useCallback as useCallback3, useEffect as useEffect6, useRef as useRef3
1157
1317
  var LONG_PRESS_DURATION_MS = 600;
1158
1318
  var MOVEMENT_THRESHOLD_PX = 10;
1159
1319
  var useContextMenu = ({ containerRef }) => {
1320
+ const [menuTarget, setMenuTarget] = useState4(null);
1160
1321
  const [menuVisible, setMenuVisible] = useState4(false);
1161
1322
  const [menuPos, setMenuPos] = useState4({ x: 0, y: 0 });
1162
1323
  const menuRef = useRef3(null);
@@ -1176,6 +1337,7 @@ var useContextMenu = ({ containerRef }) => {
1176
1337
  const movedTooFar = Math.abs(event.clientX - origin.x) > MOVEMENT_THRESHOLD_PX || Math.abs(event.clientY - origin.y) > MOVEMENT_THRESHOLD_PX;
1177
1338
  interactionOriginRef.current = null;
1178
1339
  if (movedTooFar) return;
1340
+ setMenuTarget(event.target instanceof Element ? event.target : null);
1179
1341
  setMenuPos({ x: event.clientX, y: event.clientY });
1180
1342
  setMenuVisible(true);
1181
1343
  }, []);
@@ -1188,6 +1350,7 @@ var useContextMenu = ({ containerRef }) => {
1188
1350
  }
1189
1351
  const touch = event.touches[0];
1190
1352
  if (!touch) return;
1353
+ const target = event.target instanceof Element ? event.target : null;
1191
1354
  interactionOriginRef.current = {
1192
1355
  x: touch.clientX,
1193
1356
  y: touch.clientY
@@ -1195,6 +1358,7 @@ var useContextMenu = ({ containerRef }) => {
1195
1358
  longPressTimeoutRef.current = window.setTimeout(() => {
1196
1359
  const container = containerRef.current;
1197
1360
  if (!container || !interactionOriginRef.current) return;
1361
+ setMenuTarget(target);
1198
1362
  const rect = container.getBoundingClientRect();
1199
1363
  setMenuPos({
1200
1364
  x: rect.left + rect.width / 2,
@@ -1245,6 +1409,7 @@ var useContextMenu = ({ containerRef }) => {
1245
1409
  useEffect6(() => clearLongPressTimeout, [clearLongPressTimeout]);
1246
1410
  return {
1247
1411
  menuVisible,
1412
+ menuTarget,
1248
1413
  menuPos,
1249
1414
  menuRef,
1250
1415
  setMenuVisible,
@@ -1557,10 +1722,10 @@ var MouseTrackerProvider = ({ children }) => {
1557
1722
  const { clientX, clientY } = event;
1558
1723
  const mouseDownPos = storeRef.current.mouseDownPosition;
1559
1724
  if (mouseDownPos) {
1560
- const distance = Math.sqrt(
1725
+ const distance2 = Math.sqrt(
1561
1726
  Math.pow(clientX - mouseDownPos.x, 2) + Math.pow(clientY - mouseDownPos.y, 2)
1562
1727
  );
1563
- if (distance > DRAG_THRESHOLD_PX) {
1728
+ if (distance2 > DRAG_THRESHOLD_PX) {
1564
1729
  storeRef.current.mouseDownPosition = null;
1565
1730
  return;
1566
1731
  }
@@ -1670,6 +1835,8 @@ var SchematicComponentDetailsTooltip = ({
1670
1835
  margin: 0,
1671
1836
  padding: 0,
1672
1837
  overflowY: "auto",
1838
+ overscrollBehavior: "contain",
1839
+ cursor: "auto",
1673
1840
  boxSizing: "border-box",
1674
1841
  border: "1px solid #cbd5e1",
1675
1842
  borderRadius: "4px",
@@ -1684,6 +1851,7 @@ var SchematicComponentDetailsTooltip = ({
1684
1851
  },
1685
1852
  onMouseDown: (event) => event.stopPropagation(),
1686
1853
  onClick: (event) => event.stopPropagation(),
1854
+ onWheel: (event) => event.stopPropagation(),
1687
1855
  children: [
1688
1856
  /* @__PURE__ */ jsxs2(
1689
1857
  "dl",
@@ -2945,7 +3113,7 @@ import { useMemo as useMemo5 } from "react";
2945
3113
  // package.json
2946
3114
  var package_default = {
2947
3115
  name: "@tscircuit/schematic-viewer",
2948
- version: "2.0.97",
3116
+ version: "2.0.99",
2949
3117
  repository: {
2950
3118
  type: "git",
2951
3119
  url: "https://github.com/tscircuit/schematic-viewer"
@@ -3066,6 +3234,8 @@ var CheckIcon2 = () => /* @__PURE__ */ jsx10(
3066
3234
  }
3067
3235
  );
3068
3236
  var ViewMenu = ({
3237
+ netLocations = [],
3238
+ onSelectNetLocation,
3069
3239
  circuitJson,
3070
3240
  circuitJsonKey,
3071
3241
  menuRef,
@@ -3137,6 +3307,40 @@ var ViewMenu = ({
3137
3307
  avoidCollisions: true,
3138
3308
  children: [
3139
3309
  /* @__PURE__ */ jsx10("style", { children: HIGHLIGHT_CSS }),
3310
+ netLocations.length > 0 && /* @__PURE__ */ jsxs8(DropdownMenu2.Sub, { children: [
3311
+ /* @__PURE__ */ jsxs8(
3312
+ DropdownMenu2.SubTrigger,
3313
+ {
3314
+ className: "sv-vm-item",
3315
+ style: itemStyles2,
3316
+ children: [
3317
+ "Net Locations ",
3318
+ /* @__PURE__ */ jsx10("span", { style: { marginLeft: "auto" }, children: "\u203A" })
3319
+ ]
3320
+ }
3321
+ ),
3322
+ /* @__PURE__ */ jsx10(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx10(
3323
+ DropdownMenu2.SubContent,
3324
+ {
3325
+ style: {
3326
+ ...contentStyles2,
3327
+ maxHeight: "min(400px, var(--radix-dropdown-menu-content-available-height))",
3328
+ overflowY: "auto"
3329
+ },
3330
+ collisionPadding: 10,
3331
+ children: netLocations.map((location, index) => /* @__PURE__ */ jsx10(
3332
+ DropdownMenu2.Item,
3333
+ {
3334
+ className: "sv-vm-item",
3335
+ style: itemStyles2,
3336
+ onSelect: () => onSelectNetLocation?.(location),
3337
+ children: location.label
3338
+ },
3339
+ index
3340
+ ))
3341
+ }
3342
+ ) })
3343
+ ] }),
3140
3344
  /* @__PURE__ */ jsxs8(
3141
3345
  DropdownMenu2.Item,
3142
3346
  {
@@ -3412,7 +3616,7 @@ var SchematicViewer = ({
3412
3616
  const shouldPanSchematic = useCallback7(
3413
3617
  (event) => {
3414
3618
  if (event.target instanceof Element && event.target.closest(
3415
- "[data-schematic-search], [data-schematic-warnings], .schematic-warning"
3619
+ "[data-schematic-search], [data-schematic-warnings], .schematic-warning, [data-schematic-component-details-tooltip]"
3416
3620
  )) {
3417
3621
  return false;
3418
3622
  }
@@ -3444,7 +3648,8 @@ var SchematicViewer = ({
3444
3648
  menuPos,
3445
3649
  menuRef,
3446
3650
  setMenuVisible,
3447
- contextMenuEventHandlers
3651
+ contextMenuEventHandlers,
3652
+ menuTarget
3448
3653
  } = useContextMenu({ containerRef });
3449
3654
  const { containerWidth, containerHeight } = useResizeHandling(containerRef);
3450
3655
  const selectedComponentDetails = useMemo6(
@@ -3700,6 +3905,14 @@ var SchematicViewer = ({
3700
3905
  {
3701
3906
  circuitJson,
3702
3907
  circuitJsonKey,
3908
+ netLocations: (() => {
3909
+ const key = getNetKeyAtElement(menuTarget, circuitJson);
3910
+ return key ? getNetLocations(circuitJson, key) : [];
3911
+ })(),
3912
+ onSelectNetLocation: (location) => {
3913
+ setMenuVisible(false);
3914
+ handleSearchResultSelect(location);
3915
+ },
3703
3916
  menuRef,
3704
3917
  menuPos,
3705
3918
  onOpenChange: setMenuVisible,