@tscircuit/schematic-viewer 2.0.108 → 2.0.110
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.d.ts +5 -1
- package/dist/index.js +291 -284
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -201,6 +201,7 @@ var zIndexMap = {
|
|
|
201
201
|
viewMenuIcon: 48,
|
|
202
202
|
clickToInteractOverlay: 100,
|
|
203
203
|
schematicComponentDetailsTooltip: 105,
|
|
204
|
+
schematicElementHighlight: 46,
|
|
204
205
|
schematicComponentHoverOutline: 47,
|
|
205
206
|
schematicPortHoverOutline: 48,
|
|
206
207
|
schematicSearch: 101
|
|
@@ -1283,7 +1284,7 @@ var enableDebug = () => {
|
|
|
1283
1284
|
};
|
|
1284
1285
|
|
|
1285
1286
|
// lib/components/SchematicViewer.tsx
|
|
1286
|
-
import { useCallback as
|
|
1287
|
+
import { useCallback as useCallback8, useEffect as useEffect14, useMemo as useMemo6, useRef as useRef8, useState as useState9 } from "react";
|
|
1287
1288
|
import { toString as transformToString } from "transformation-matrix";
|
|
1288
1289
|
import { useMouseMatrixTransform } from "use-mouse-matrix-transform";
|
|
1289
1290
|
|
|
@@ -2192,7 +2193,7 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
2192
2193
|
};
|
|
2193
2194
|
|
|
2194
2195
|
// lib/components/SchematicComponentMouseTarget.tsx
|
|
2195
|
-
import { useCallback as
|
|
2196
|
+
import { useCallback as useCallback6, useEffect as useEffect11 } from "react";
|
|
2196
2197
|
|
|
2197
2198
|
// lib/hooks/useMouseEventsOverBoundingBox.ts
|
|
2198
2199
|
import {
|
|
@@ -2251,23 +2252,23 @@ var useMouseEventsOverBoundingBox = (options) => {
|
|
|
2251
2252
|
return { hovering };
|
|
2252
2253
|
};
|
|
2253
2254
|
|
|
2254
|
-
// lib/
|
|
2255
|
-
import {
|
|
2255
|
+
// lib/hooks/useSvgElementMeasurement.ts
|
|
2256
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useRef as useRef6, useState as useState6 } from "react";
|
|
2256
2257
|
var areMeasurementsEqual = (a, b) => {
|
|
2257
2258
|
if (!a && !b) return true;
|
|
2258
2259
|
if (!a || !b) return false;
|
|
2259
2260
|
return Math.abs(a.bounds.minX - b.bounds.minX) < 0.5 && Math.abs(a.bounds.maxX - b.bounds.maxX) < 0.5 && Math.abs(a.bounds.minY - b.bounds.minY) < 0.5 && Math.abs(a.bounds.maxY - b.bounds.maxY) < 0.5 && Math.abs(a.rect.left - b.rect.left) < 0.5 && Math.abs(a.rect.top - b.rect.top) < 0.5 && Math.abs(a.rect.width - b.rect.width) < 0.5 && Math.abs(a.rect.height - b.rect.height) < 0.5;
|
|
2260
2261
|
};
|
|
2261
|
-
var
|
|
2262
|
-
|
|
2262
|
+
var useSvgElementMeasurement = ({
|
|
2263
|
+
selector,
|
|
2263
2264
|
svgDivRef,
|
|
2264
2265
|
containerRef,
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
showOutline,
|
|
2268
|
-
circuitJsonKey
|
|
2266
|
+
circuitJsonKey,
|
|
2267
|
+
padding = 0
|
|
2269
2268
|
}) => {
|
|
2270
|
-
const [measurement, setMeasurement] = useState6(
|
|
2269
|
+
const [measurement, setMeasurement] = useState6(
|
|
2270
|
+
null
|
|
2271
|
+
);
|
|
2271
2272
|
const frameRef = useRef6(null);
|
|
2272
2273
|
const measure = useCallback5(() => {
|
|
2273
2274
|
frameRef.current = null;
|
|
@@ -2278,7 +2279,7 @@ var SchematicComponentMouseTarget = ({
|
|
|
2278
2279
|
return;
|
|
2279
2280
|
}
|
|
2280
2281
|
const element = svgDiv.querySelector(
|
|
2281
|
-
|
|
2282
|
+
selector
|
|
2282
2283
|
);
|
|
2283
2284
|
if (!element) {
|
|
2284
2285
|
setMeasurement((prev) => prev ? null : prev);
|
|
@@ -2288,22 +2289,22 @@ var SchematicComponentMouseTarget = ({
|
|
|
2288
2289
|
const containerRect = container.getBoundingClientRect();
|
|
2289
2290
|
const nextMeasurement = {
|
|
2290
2291
|
bounds: {
|
|
2291
|
-
minX: elementRect.left,
|
|
2292
|
-
maxX: elementRect.right,
|
|
2293
|
-
minY: elementRect.top,
|
|
2294
|
-
maxY: elementRect.bottom
|
|
2292
|
+
minX: elementRect.left - padding,
|
|
2293
|
+
maxX: elementRect.right + padding,
|
|
2294
|
+
minY: elementRect.top - padding,
|
|
2295
|
+
maxY: elementRect.bottom + padding
|
|
2295
2296
|
},
|
|
2296
2297
|
rect: {
|
|
2297
|
-
left: elementRect.left - containerRect.left,
|
|
2298
|
-
top: elementRect.top - containerRect.top,
|
|
2299
|
-
width: elementRect.width,
|
|
2300
|
-
height: elementRect.height
|
|
2298
|
+
left: elementRect.left - containerRect.left - padding,
|
|
2299
|
+
top: elementRect.top - containerRect.top - padding,
|
|
2300
|
+
width: elementRect.width + padding * 2,
|
|
2301
|
+
height: elementRect.height + padding * 2
|
|
2301
2302
|
}
|
|
2302
2303
|
};
|
|
2303
2304
|
setMeasurement(
|
|
2304
2305
|
(prev) => areMeasurementsEqual(prev, nextMeasurement) ? prev : nextMeasurement
|
|
2305
2306
|
);
|
|
2306
|
-
}, [
|
|
2307
|
+
}, [selector, padding, containerRef, svgDivRef]);
|
|
2307
2308
|
const scheduleMeasure = useCallback5(() => {
|
|
2308
2309
|
if (frameRef.current !== null) return;
|
|
2309
2310
|
frameRef.current = window.requestAnimationFrame(measure);
|
|
@@ -2343,7 +2344,27 @@ var SchematicComponentMouseTarget = ({
|
|
|
2343
2344
|
}
|
|
2344
2345
|
};
|
|
2345
2346
|
}, [scheduleMeasure, svgDivRef, containerRef]);
|
|
2346
|
-
|
|
2347
|
+
return measurement;
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2350
|
+
// lib/components/SchematicComponentMouseTarget.tsx
|
|
2351
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2352
|
+
var SchematicComponentMouseTarget = ({
|
|
2353
|
+
componentId,
|
|
2354
|
+
svgDivRef,
|
|
2355
|
+
containerRef,
|
|
2356
|
+
onComponentClick,
|
|
2357
|
+
onHoverChange,
|
|
2358
|
+
showOutline,
|
|
2359
|
+
circuitJsonKey
|
|
2360
|
+
}) => {
|
|
2361
|
+
const measurement = useSvgElementMeasurement({
|
|
2362
|
+
selector: `[data-schematic-component-id="${componentId}"]`,
|
|
2363
|
+
svgDivRef,
|
|
2364
|
+
containerRef,
|
|
2365
|
+
circuitJsonKey
|
|
2366
|
+
});
|
|
2367
|
+
const handleClick = useCallback6(
|
|
2347
2368
|
(event) => {
|
|
2348
2369
|
if (onComponentClick) {
|
|
2349
2370
|
onComponentClick(componentId, event);
|
|
@@ -2356,7 +2377,7 @@ var SchematicComponentMouseTarget = ({
|
|
|
2356
2377
|
bounds,
|
|
2357
2378
|
onClick: onComponentClick ? handleClick : void 0
|
|
2358
2379
|
});
|
|
2359
|
-
|
|
2380
|
+
useEffect11(() => {
|
|
2360
2381
|
if (onHoverChange) {
|
|
2361
2382
|
onHoverChange(componentId, hovering);
|
|
2362
2383
|
}
|
|
@@ -2382,14 +2403,44 @@ var SchematicComponentMouseTarget = ({
|
|
|
2382
2403
|
);
|
|
2383
2404
|
};
|
|
2384
2405
|
|
|
2385
|
-
// lib/components/
|
|
2386
|
-
import {
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2406
|
+
// lib/components/SchematicElementHighlight.tsx
|
|
2407
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
2408
|
+
var SchematicElementHighlight = ({
|
|
2409
|
+
selector,
|
|
2410
|
+
svgDivRef,
|
|
2411
|
+
containerRef,
|
|
2412
|
+
circuitJsonKey
|
|
2413
|
+
}) => {
|
|
2414
|
+
const measurement = useSvgElementMeasurement({
|
|
2415
|
+
selector,
|
|
2416
|
+
svgDivRef,
|
|
2417
|
+
containerRef,
|
|
2418
|
+
circuitJsonKey,
|
|
2419
|
+
padding: 4
|
|
2420
|
+
});
|
|
2421
|
+
if (!measurement) return null;
|
|
2422
|
+
return /* @__PURE__ */ jsx6(
|
|
2423
|
+
"div",
|
|
2424
|
+
{
|
|
2425
|
+
"data-schematic-element-highlight": true,
|
|
2426
|
+
style: {
|
|
2427
|
+
position: "absolute",
|
|
2428
|
+
left: measurement.rect.left,
|
|
2429
|
+
top: measurement.rect.top,
|
|
2430
|
+
width: measurement.rect.width,
|
|
2431
|
+
height: measurement.rect.height,
|
|
2432
|
+
border: "1.5px dashed #3b82f6",
|
|
2433
|
+
boxSizing: "border-box",
|
|
2434
|
+
pointerEvents: "none",
|
|
2435
|
+
zIndex: zIndexMap.schematicElementHighlight
|
|
2436
|
+
}
|
|
2437
|
+
}
|
|
2438
|
+
);
|
|
2392
2439
|
};
|
|
2440
|
+
|
|
2441
|
+
// lib/components/SchematicPortMouseTarget.tsx
|
|
2442
|
+
import { useCallback as useCallback7, useEffect as useEffect12 } from "react";
|
|
2443
|
+
import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2393
2444
|
var SchematicPortMouseTarget = ({
|
|
2394
2445
|
portId,
|
|
2395
2446
|
portLabel,
|
|
@@ -2400,84 +2451,15 @@ var SchematicPortMouseTarget = ({
|
|
|
2400
2451
|
showOutline,
|
|
2401
2452
|
circuitJsonKey
|
|
2402
2453
|
}) => {
|
|
2403
|
-
const
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
}
|
|
2413
|
-
const element = svgDiv.querySelector(
|
|
2414
|
-
`[data-schematic-port-id="${portId}"]`
|
|
2415
|
-
);
|
|
2416
|
-
if (!element) {
|
|
2417
|
-
setMeasurement((prev) => prev ? null : prev);
|
|
2418
|
-
return;
|
|
2419
|
-
}
|
|
2420
|
-
const elementRect = element.getBoundingClientRect();
|
|
2421
|
-
const containerRect = container.getBoundingClientRect();
|
|
2422
|
-
const padding = 4;
|
|
2423
|
-
const nextMeasurement = {
|
|
2424
|
-
bounds: {
|
|
2425
|
-
minX: elementRect.left - padding,
|
|
2426
|
-
maxX: elementRect.right + padding,
|
|
2427
|
-
minY: elementRect.top - padding,
|
|
2428
|
-
maxY: elementRect.bottom + padding
|
|
2429
|
-
},
|
|
2430
|
-
rect: {
|
|
2431
|
-
left: elementRect.left - containerRect.left - padding,
|
|
2432
|
-
top: elementRect.top - containerRect.top - padding,
|
|
2433
|
-
width: elementRect.width + padding * 2,
|
|
2434
|
-
height: elementRect.height + padding * 2
|
|
2435
|
-
}
|
|
2436
|
-
};
|
|
2437
|
-
setMeasurement(
|
|
2438
|
-
(prev) => areMeasurementsEqual2(prev, nextMeasurement) ? prev : nextMeasurement
|
|
2439
|
-
);
|
|
2440
|
-
}, [portId, containerRef, svgDivRef]);
|
|
2441
|
-
const scheduleMeasure = useCallback6(() => {
|
|
2442
|
-
if (frameRef.current !== null) return;
|
|
2443
|
-
frameRef.current = window.requestAnimationFrame(measure);
|
|
2444
|
-
}, [measure]);
|
|
2445
|
-
useEffect11(() => {
|
|
2446
|
-
scheduleMeasure();
|
|
2447
|
-
}, [scheduleMeasure, circuitJsonKey]);
|
|
2448
|
-
useEffect11(() => {
|
|
2449
|
-
scheduleMeasure();
|
|
2450
|
-
const svgDiv = svgDivRef.current;
|
|
2451
|
-
const container = containerRef.current;
|
|
2452
|
-
if (!svgDiv || !container) return;
|
|
2453
|
-
const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => {
|
|
2454
|
-
scheduleMeasure();
|
|
2455
|
-
}) : null;
|
|
2456
|
-
resizeObserver?.observe(container);
|
|
2457
|
-
resizeObserver?.observe(svgDiv);
|
|
2458
|
-
const mutationObserver = typeof MutationObserver !== "undefined" ? new MutationObserver(() => {
|
|
2459
|
-
scheduleMeasure();
|
|
2460
|
-
}) : null;
|
|
2461
|
-
mutationObserver?.observe(svgDiv, {
|
|
2462
|
-
attributes: true,
|
|
2463
|
-
attributeFilter: ["style", "transform"],
|
|
2464
|
-
subtree: true,
|
|
2465
|
-
childList: true
|
|
2466
|
-
});
|
|
2467
|
-
window.addEventListener("scroll", scheduleMeasure, true);
|
|
2468
|
-
window.addEventListener("resize", scheduleMeasure);
|
|
2469
|
-
return () => {
|
|
2470
|
-
resizeObserver?.disconnect();
|
|
2471
|
-
mutationObserver?.disconnect();
|
|
2472
|
-
window.removeEventListener("scroll", scheduleMeasure, true);
|
|
2473
|
-
window.removeEventListener("resize", scheduleMeasure);
|
|
2474
|
-
if (frameRef.current !== null) {
|
|
2475
|
-
cancelAnimationFrame(frameRef.current);
|
|
2476
|
-
frameRef.current = null;
|
|
2477
|
-
}
|
|
2478
|
-
};
|
|
2479
|
-
}, [scheduleMeasure, svgDivRef, containerRef]);
|
|
2480
|
-
const handleClick = useCallback6(
|
|
2454
|
+
const measurement = useSvgElementMeasurement({
|
|
2455
|
+
selector: `[data-schematic-port-id="${portId}"]`,
|
|
2456
|
+
svgDivRef,
|
|
2457
|
+
containerRef,
|
|
2458
|
+
circuitJsonKey,
|
|
2459
|
+
// Add some padding around the port for easier interaction
|
|
2460
|
+
padding: 4
|
|
2461
|
+
});
|
|
2462
|
+
const handleClick = useCallback7(
|
|
2481
2463
|
(event) => {
|
|
2482
2464
|
if (onPortClick) {
|
|
2483
2465
|
onPortClick(portId, event);
|
|
@@ -2490,7 +2472,7 @@ var SchematicPortMouseTarget = ({
|
|
|
2490
2472
|
bounds,
|
|
2491
2473
|
onClick: onPortClick ? handleClick : void 0
|
|
2492
2474
|
});
|
|
2493
|
-
|
|
2475
|
+
useEffect12(() => {
|
|
2494
2476
|
if (onHoverChange) {
|
|
2495
2477
|
onHoverChange(portId, hovering);
|
|
2496
2478
|
}
|
|
@@ -2500,7 +2482,7 @@ var SchematicPortMouseTarget = ({
|
|
|
2500
2482
|
}
|
|
2501
2483
|
const rect = measurement.rect;
|
|
2502
2484
|
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
2503
|
-
/* @__PURE__ */
|
|
2485
|
+
/* @__PURE__ */ jsx7(
|
|
2504
2486
|
"div",
|
|
2505
2487
|
{
|
|
2506
2488
|
style: {
|
|
@@ -2518,7 +2500,7 @@ var SchematicPortMouseTarget = ({
|
|
|
2518
2500
|
}
|
|
2519
2501
|
}
|
|
2520
2502
|
),
|
|
2521
|
-
hovering && portLabel && /* @__PURE__ */
|
|
2503
|
+
hovering && portLabel && /* @__PURE__ */ jsx7(
|
|
2522
2504
|
"div",
|
|
2523
2505
|
{
|
|
2524
2506
|
style: {
|
|
@@ -2543,15 +2525,15 @@ var SchematicPortMouseTarget = ({
|
|
|
2543
2525
|
};
|
|
2544
2526
|
|
|
2545
2527
|
// lib/components/SchematicSearch.tsx
|
|
2546
|
-
import { useEffect as
|
|
2528
|
+
import { useEffect as useEffect13, useRef as useRef7, useState as useState7 } from "react";
|
|
2547
2529
|
|
|
2548
2530
|
// lib/components/SchematicSearchIcons.tsx
|
|
2549
|
-
import { jsx as
|
|
2531
|
+
import { jsx as jsx8, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2550
2532
|
var Icon = ({
|
|
2551
2533
|
children,
|
|
2552
2534
|
size,
|
|
2553
2535
|
strokeWidth
|
|
2554
|
-
}) => /* @__PURE__ */
|
|
2536
|
+
}) => /* @__PURE__ */ jsx8(
|
|
2555
2537
|
"svg",
|
|
2556
2538
|
{
|
|
2557
2539
|
width: size,
|
|
@@ -2567,30 +2549,30 @@ var Icon = ({
|
|
|
2567
2549
|
}
|
|
2568
2550
|
);
|
|
2569
2551
|
var SearchIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2570
|
-
/* @__PURE__ */
|
|
2571
|
-
/* @__PURE__ */
|
|
2552
|
+
/* @__PURE__ */ jsx8("circle", { cx: "11", cy: "11", r: "8" }),
|
|
2553
|
+
/* @__PURE__ */ jsx8("path", { d: "m21 21-4.34-4.34" })
|
|
2572
2554
|
] });
|
|
2573
2555
|
var CloseIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2574
|
-
/* @__PURE__ */
|
|
2575
|
-
/* @__PURE__ */
|
|
2556
|
+
/* @__PURE__ */ jsx8("path", { d: "M18 6 6 18" }),
|
|
2557
|
+
/* @__PURE__ */ jsx8("path", { d: "m6 6 12 12" })
|
|
2576
2558
|
] });
|
|
2577
2559
|
var ComponentIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2578
|
-
/* @__PURE__ */
|
|
2579
|
-
/* @__PURE__ */
|
|
2580
|
-
/* @__PURE__ */
|
|
2560
|
+
/* @__PURE__ */ jsx8("rect", { x: "4", y: "4", width: "16", height: "16", rx: "2" }),
|
|
2561
|
+
/* @__PURE__ */ jsx8("rect", { x: "8", y: "8", width: "8", height: "8", rx: "1" }),
|
|
2562
|
+
/* @__PURE__ */ jsx8("path", { d: "M7 2v2M12 2v2M17 2v2M7 20v2M12 20v2M17 20v2M2 7h2M2 12h2M2 17h2M20 7h2M20 12h2M20 17h2" })
|
|
2581
2563
|
] });
|
|
2582
2564
|
var NetIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2583
|
-
/* @__PURE__ */
|
|
2584
|
-
/* @__PURE__ */
|
|
2585
|
-
/* @__PURE__ */
|
|
2565
|
+
/* @__PURE__ */ jsx8("path", { d: "M15 6a9 9 0 0 0-9 9V3" }),
|
|
2566
|
+
/* @__PURE__ */ jsx8("circle", { cx: "18", cy: "6", r: "3" }),
|
|
2567
|
+
/* @__PURE__ */ jsx8("circle", { cx: "6", cy: "18", r: "3" })
|
|
2586
2568
|
] });
|
|
2587
2569
|
var EnterIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2588
|
-
/* @__PURE__ */
|
|
2589
|
-
/* @__PURE__ */
|
|
2570
|
+
/* @__PURE__ */ jsx8("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" }),
|
|
2571
|
+
/* @__PURE__ */ jsx8("path", { d: "m9 10-5 5 5 5" })
|
|
2590
2572
|
] });
|
|
2591
2573
|
|
|
2592
2574
|
// lib/components/SchematicSearch.tsx
|
|
2593
|
-
import { Fragment as Fragment5, jsx as
|
|
2575
|
+
import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2594
2576
|
var HighlightedSearchText = ({
|
|
2595
2577
|
text,
|
|
2596
2578
|
query
|
|
@@ -2606,7 +2588,7 @@ var HighlightedSearchText = ({
|
|
|
2606
2588
|
parts.push(text.slice(cursor, matchIndex));
|
|
2607
2589
|
}
|
|
2608
2590
|
parts.push(
|
|
2609
|
-
/* @__PURE__ */
|
|
2591
|
+
/* @__PURE__ */ jsx9("strong", { style: { fontWeight: 700 }, children: text.slice(matchIndex, matchIndex + normalizedQuery.length) }, `${matchIndex}-${cursor}`)
|
|
2610
2592
|
);
|
|
2611
2593
|
cursor = matchIndex + normalizedQuery.length;
|
|
2612
2594
|
matchIndex = normalizedText.indexOf(normalizedQuery, cursor);
|
|
@@ -2628,13 +2610,13 @@ var SchematicSearch = ({
|
|
|
2628
2610
|
onSelect,
|
|
2629
2611
|
viewerContainerRef
|
|
2630
2612
|
}) => {
|
|
2631
|
-
const [isOpen, setIsOpen] =
|
|
2632
|
-
const [activeResultId, setActiveResultId] =
|
|
2633
|
-
const [hoveredResultId, setHoveredResultId] =
|
|
2634
|
-
const inputRef =
|
|
2635
|
-
const resultsListRef =
|
|
2613
|
+
const [isOpen, setIsOpen] = useState7(false);
|
|
2614
|
+
const [activeResultId, setActiveResultId] = useState7(null);
|
|
2615
|
+
const [hoveredResultId, setHoveredResultId] = useState7(null);
|
|
2616
|
+
const inputRef = useRef7(null);
|
|
2617
|
+
const resultsListRef = useRef7(null);
|
|
2636
2618
|
const shortcutLabel = getShortcutLabel();
|
|
2637
|
-
|
|
2619
|
+
useEffect13(() => {
|
|
2638
2620
|
setActiveResultId((currentId) => {
|
|
2639
2621
|
if (results.some((result) => result.target.id === currentId)) {
|
|
2640
2622
|
return currentId;
|
|
@@ -2642,11 +2624,11 @@ var SchematicSearch = ({
|
|
|
2642
2624
|
return results.find((result) => result.kind === "component")?.target.id ?? results[0]?.target.id ?? null;
|
|
2643
2625
|
});
|
|
2644
2626
|
}, [results]);
|
|
2645
|
-
|
|
2627
|
+
useEffect13(() => {
|
|
2646
2628
|
if (!activeResultId) return;
|
|
2647
2629
|
resultsListRef.current?.querySelector(`[data-search-result-id="${activeResultId}"]`)?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
2648
2630
|
}, [activeResultId]);
|
|
2649
|
-
|
|
2631
|
+
useEffect13(() => {
|
|
2650
2632
|
const handleSearchShortcut = (event) => {
|
|
2651
2633
|
if (event.key === "Escape" && isOpen) {
|
|
2652
2634
|
event.preventDefault();
|
|
@@ -2748,7 +2730,7 @@ var SchematicSearch = ({
|
|
|
2748
2730
|
const renderResultSection = (title, sectionResults) => {
|
|
2749
2731
|
if (sectionResults.length === 0) return null;
|
|
2750
2732
|
return /* @__PURE__ */ jsxs6("section", { children: [
|
|
2751
|
-
/* @__PURE__ */
|
|
2733
|
+
/* @__PURE__ */ jsx9(
|
|
2752
2734
|
"div",
|
|
2753
2735
|
{
|
|
2754
2736
|
style: {
|
|
@@ -2768,9 +2750,9 @@ var SchematicSearch = ({
|
|
|
2768
2750
|
const hovering = result.target.id === hoveredResultId;
|
|
2769
2751
|
let resultBackground = "#ffffff";
|
|
2770
2752
|
if (hovering || active) resultBackground = "#f1f3f5";
|
|
2771
|
-
let resultIcon = /* @__PURE__ */
|
|
2753
|
+
let resultIcon = /* @__PURE__ */ jsx9(NetIcon, { size: 15, strokeWidth: 1.8 });
|
|
2772
2754
|
if (result.kind === "component") {
|
|
2773
|
-
resultIcon = /* @__PURE__ */
|
|
2755
|
+
resultIcon = /* @__PURE__ */ jsx9(ComponentIcon, { size: 15, strokeWidth: 1.8 });
|
|
2774
2756
|
}
|
|
2775
2757
|
const selectResult = () => {
|
|
2776
2758
|
inputRef.current?.blur();
|
|
@@ -2803,7 +2785,7 @@ var SchematicSearch = ({
|
|
|
2803
2785
|
textAlign: "left"
|
|
2804
2786
|
},
|
|
2805
2787
|
children: [
|
|
2806
|
-
/* @__PURE__ */
|
|
2788
|
+
/* @__PURE__ */ jsx9(
|
|
2807
2789
|
"span",
|
|
2808
2790
|
{
|
|
2809
2791
|
style: {
|
|
@@ -2821,7 +2803,7 @@ var SchematicSearch = ({
|
|
|
2821
2803
|
}
|
|
2822
2804
|
),
|
|
2823
2805
|
/* @__PURE__ */ jsxs6("span", { style: { minWidth: 0, flex: 1 }, children: [
|
|
2824
|
-
/* @__PURE__ */
|
|
2806
|
+
/* @__PURE__ */ jsx9(
|
|
2825
2807
|
"span",
|
|
2826
2808
|
{
|
|
2827
2809
|
style: {
|
|
@@ -2833,10 +2815,10 @@ var SchematicSearch = ({
|
|
|
2833
2815
|
textOverflow: "ellipsis",
|
|
2834
2816
|
whiteSpace: "nowrap"
|
|
2835
2817
|
},
|
|
2836
|
-
children: /* @__PURE__ */
|
|
2818
|
+
children: /* @__PURE__ */ jsx9(HighlightedSearchText, { text: result.label, query })
|
|
2837
2819
|
}
|
|
2838
2820
|
),
|
|
2839
|
-
result.detail && /* @__PURE__ */
|
|
2821
|
+
result.detail && /* @__PURE__ */ jsx9(
|
|
2840
2822
|
"span",
|
|
2841
2823
|
{
|
|
2842
2824
|
style: {
|
|
@@ -2872,7 +2854,7 @@ var SchematicSearch = ({
|
|
|
2872
2854
|
}
|
|
2873
2855
|
)
|
|
2874
2856
|
] }),
|
|
2875
|
-
active && /* @__PURE__ */
|
|
2857
|
+
active && /* @__PURE__ */ jsx9(
|
|
2876
2858
|
"span",
|
|
2877
2859
|
{
|
|
2878
2860
|
title: "Press Enter to open",
|
|
@@ -2882,7 +2864,7 @@ var SchematicSearch = ({
|
|
|
2882
2864
|
fontSize: "17px",
|
|
2883
2865
|
lineHeight: 1
|
|
2884
2866
|
},
|
|
2885
|
-
children: /* @__PURE__ */
|
|
2867
|
+
children: /* @__PURE__ */ jsx9(EnterIcon, { size: 14, strokeWidth: 1.8 })
|
|
2886
2868
|
}
|
|
2887
2869
|
)
|
|
2888
2870
|
]
|
|
@@ -2892,7 +2874,7 @@ var SchematicSearch = ({
|
|
|
2892
2874
|
})
|
|
2893
2875
|
] });
|
|
2894
2876
|
};
|
|
2895
|
-
return /* @__PURE__ */
|
|
2877
|
+
return /* @__PURE__ */ jsx9(
|
|
2896
2878
|
"div",
|
|
2897
2879
|
{
|
|
2898
2880
|
"data-schematic-search": true,
|
|
@@ -2905,7 +2887,7 @@ var SchematicSearch = ({
|
|
|
2905
2887
|
zIndex: zIndexMap.schematicSearch,
|
|
2906
2888
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
|
|
2907
2889
|
},
|
|
2908
|
-
children: !isOpen ? /* @__PURE__ */
|
|
2890
|
+
children: !isOpen ? /* @__PURE__ */ jsx9(
|
|
2909
2891
|
"button",
|
|
2910
2892
|
{
|
|
2911
2893
|
type: "button",
|
|
@@ -2936,7 +2918,7 @@ var SchematicSearch = ({
|
|
|
2936
2918
|
cursor: "pointer",
|
|
2937
2919
|
boxShadow: "0 2px 4px rgba(0,0,0,0.1)"
|
|
2938
2920
|
},
|
|
2939
|
-
children: /* @__PURE__ */
|
|
2921
|
+
children: /* @__PURE__ */ jsx9(SearchIcon, { size: 16, strokeWidth: 2 })
|
|
2940
2922
|
}
|
|
2941
2923
|
) : /* @__PURE__ */ jsxs6(
|
|
2942
2924
|
"div",
|
|
@@ -2964,8 +2946,8 @@ var SchematicSearch = ({
|
|
|
2964
2946
|
borderBottom: searchHeaderBorder
|
|
2965
2947
|
},
|
|
2966
2948
|
children: [
|
|
2967
|
-
/* @__PURE__ */
|
|
2968
|
-
/* @__PURE__ */
|
|
2949
|
+
/* @__PURE__ */ jsx9(SearchIcon, { size: 15, strokeWidth: 2 }),
|
|
2950
|
+
/* @__PURE__ */ jsx9(
|
|
2969
2951
|
"input",
|
|
2970
2952
|
{
|
|
2971
2953
|
ref: inputRef,
|
|
@@ -2985,7 +2967,7 @@ var SchematicSearch = ({
|
|
|
2985
2967
|
}
|
|
2986
2968
|
}
|
|
2987
2969
|
),
|
|
2988
|
-
query && results.length > 0 ? /* @__PURE__ */
|
|
2970
|
+
query && results.length > 0 ? /* @__PURE__ */ jsx9(
|
|
2989
2971
|
"span",
|
|
2990
2972
|
{
|
|
2991
2973
|
style: {
|
|
@@ -2996,7 +2978,7 @@ var SchematicSearch = ({
|
|
|
2996
2978
|
},
|
|
2997
2979
|
children: resultCountLabel
|
|
2998
2980
|
}
|
|
2999
|
-
) : /* @__PURE__ */
|
|
2981
|
+
) : /* @__PURE__ */ jsx9(
|
|
3000
2982
|
"kbd",
|
|
3001
2983
|
{
|
|
3002
2984
|
style: {
|
|
@@ -3013,7 +2995,7 @@ var SchematicSearch = ({
|
|
|
3013
2995
|
children: shortcutLabel
|
|
3014
2996
|
}
|
|
3015
2997
|
),
|
|
3016
|
-
isOpen && /* @__PURE__ */
|
|
2998
|
+
isOpen && /* @__PURE__ */ jsx9(
|
|
3017
2999
|
"button",
|
|
3018
3000
|
{
|
|
3019
3001
|
type: "button",
|
|
@@ -3036,13 +3018,13 @@ var SchematicSearch = ({
|
|
|
3036
3018
|
padding: 0,
|
|
3037
3019
|
lineHeight: 1
|
|
3038
3020
|
},
|
|
3039
|
-
children: /* @__PURE__ */
|
|
3021
|
+
children: /* @__PURE__ */ jsx9(CloseIcon, { size: 16, strokeWidth: 2 })
|
|
3040
3022
|
}
|
|
3041
3023
|
)
|
|
3042
3024
|
]
|
|
3043
3025
|
}
|
|
3044
3026
|
),
|
|
3045
|
-
query && /* @__PURE__ */
|
|
3027
|
+
query && /* @__PURE__ */ jsx9(
|
|
3046
3028
|
"div",
|
|
3047
3029
|
{
|
|
3048
3030
|
ref: resultsListRef,
|
|
@@ -3057,7 +3039,7 @@ var SchematicSearch = ({
|
|
|
3057
3039
|
},
|
|
3058
3040
|
onWheel: (event) => event.stopPropagation(),
|
|
3059
3041
|
onTouchMove: (event) => event.stopPropagation(),
|
|
3060
|
-
children: results.length === 0 ? /* @__PURE__ */
|
|
3042
|
+
children: results.length === 0 ? /* @__PURE__ */ jsx9(
|
|
3061
3043
|
"div",
|
|
3062
3044
|
{
|
|
3063
3045
|
style: {
|
|
@@ -3081,9 +3063,9 @@ var SchematicSearch = ({
|
|
|
3081
3063
|
};
|
|
3082
3064
|
|
|
3083
3065
|
// lib/components/SchematicSheetSelector.tsx
|
|
3084
|
-
import { useState as
|
|
3066
|
+
import { useState as useState8 } from "react";
|
|
3085
3067
|
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
3086
|
-
import { Fragment as Fragment6, jsx as
|
|
3068
|
+
import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
3087
3069
|
var FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
3088
3070
|
var contentStyles = {
|
|
3089
3071
|
backgroundColor: "#ffffff",
|
|
@@ -3133,7 +3115,7 @@ var MENU_CSS = `
|
|
|
3133
3115
|
.sv-sheet-chevron { transition: transform 0.2s ease; }
|
|
3134
3116
|
[data-state="open"] > .sv-sheet-chevron { transform: rotate(180deg); }
|
|
3135
3117
|
`;
|
|
3136
|
-
var CheckIcon = () => /* @__PURE__ */
|
|
3118
|
+
var CheckIcon = () => /* @__PURE__ */ jsx10(
|
|
3137
3119
|
"svg",
|
|
3138
3120
|
{
|
|
3139
3121
|
width: "14",
|
|
@@ -3145,10 +3127,10 @@ var CheckIcon = () => /* @__PURE__ */ jsx9(
|
|
|
3145
3127
|
strokeLinecap: "round",
|
|
3146
3128
|
strokeLinejoin: "round",
|
|
3147
3129
|
"aria-hidden": "true",
|
|
3148
|
-
children: /* @__PURE__ */
|
|
3130
|
+
children: /* @__PURE__ */ jsx10("path", { d: "M20 6 9 17l-5-5" })
|
|
3149
3131
|
}
|
|
3150
3132
|
);
|
|
3151
|
-
var ChevronDownIcon = ({ className }) => /* @__PURE__ */
|
|
3133
|
+
var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx10(
|
|
3152
3134
|
"svg",
|
|
3153
3135
|
{
|
|
3154
3136
|
className,
|
|
@@ -3162,7 +3144,7 @@ var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx9(
|
|
|
3162
3144
|
strokeLinejoin: "round",
|
|
3163
3145
|
style: { opacity: 0.6, flexShrink: 0 },
|
|
3164
3146
|
"aria-hidden": "true",
|
|
3165
|
-
children: /* @__PURE__ */
|
|
3147
|
+
children: /* @__PURE__ */ jsx10("path", { d: "m6 9 6 6 6-6" })
|
|
3166
3148
|
}
|
|
3167
3149
|
);
|
|
3168
3150
|
var SchematicSheetSelector = ({
|
|
@@ -3170,16 +3152,16 @@ var SchematicSheetSelector = ({
|
|
|
3170
3152
|
selectedSheetId,
|
|
3171
3153
|
onSelectSheet
|
|
3172
3154
|
}) => {
|
|
3173
|
-
const [open, setOpen] =
|
|
3155
|
+
const [open, setOpen] = useState8(false);
|
|
3174
3156
|
if (sheets.length <= 1) return null;
|
|
3175
3157
|
const selectedSheet = sheets.find(
|
|
3176
3158
|
(s) => s.schematic_sheet_id === selectedSheetId
|
|
3177
3159
|
);
|
|
3178
3160
|
const selectedLabel = selectedSheet?.name ?? "Select sheet";
|
|
3179
3161
|
return /* @__PURE__ */ jsxs7(Fragment6, { children: [
|
|
3180
|
-
/* @__PURE__ */
|
|
3162
|
+
/* @__PURE__ */ jsx10("style", { children: MENU_CSS }),
|
|
3181
3163
|
/* @__PURE__ */ jsxs7(DropdownMenu.Root, { open, onOpenChange: setOpen, modal: false, children: [
|
|
3182
|
-
/* @__PURE__ */
|
|
3164
|
+
/* @__PURE__ */ jsx10(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs7(
|
|
3183
3165
|
"button",
|
|
3184
3166
|
{
|
|
3185
3167
|
type: "button",
|
|
@@ -3204,13 +3186,13 @@ var SchematicSheetSelector = ({
|
|
|
3204
3186
|
fontFamily: FONT_FAMILY
|
|
3205
3187
|
},
|
|
3206
3188
|
children: [
|
|
3207
|
-
/* @__PURE__ */
|
|
3208
|
-
/* @__PURE__ */
|
|
3209
|
-
/* @__PURE__ */
|
|
3189
|
+
/* @__PURE__ */ jsx10("span", { style: { color: "#888888", flexShrink: 0 }, children: "Sheet:" }),
|
|
3190
|
+
/* @__PURE__ */ jsx10("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: selectedLabel }),
|
|
3191
|
+
/* @__PURE__ */ jsx10(ChevronDownIcon, { className: "sv-sheet-chevron" })
|
|
3210
3192
|
]
|
|
3211
3193
|
}
|
|
3212
3194
|
) }),
|
|
3213
|
-
/* @__PURE__ */
|
|
3195
|
+
/* @__PURE__ */ jsx10(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx10(
|
|
3214
3196
|
DropdownMenu.Content,
|
|
3215
3197
|
{
|
|
3216
3198
|
style: contentStyles,
|
|
@@ -3232,8 +3214,8 @@ var SchematicSheetSelector = ({
|
|
|
3232
3214
|
setOpen(false);
|
|
3233
3215
|
},
|
|
3234
3216
|
children: [
|
|
3235
|
-
/* @__PURE__ */
|
|
3236
|
-
/* @__PURE__ */
|
|
3217
|
+
/* @__PURE__ */ jsx10("span", { style: iconSlotStyles, children: selected && /* @__PURE__ */ jsx10(CheckIcon, {}) }),
|
|
3218
|
+
/* @__PURE__ */ jsx10("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: sheet.name })
|
|
3237
3219
|
]
|
|
3238
3220
|
},
|
|
3239
3221
|
sheet.schematic_sheet_id
|
|
@@ -3246,7 +3228,7 @@ var SchematicSheetSelector = ({
|
|
|
3246
3228
|
};
|
|
3247
3229
|
|
|
3248
3230
|
// lib/components/SchematicWarningsButton.tsx
|
|
3249
|
-
import { jsx as
|
|
3231
|
+
import { jsx as jsx11, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3250
3232
|
var SchematicWarningsButton = ({
|
|
3251
3233
|
count,
|
|
3252
3234
|
showWarnings,
|
|
@@ -3296,12 +3278,12 @@ var SchematicWarningsButton = ({
|
|
|
3296
3278
|
strokeLinejoin: "round",
|
|
3297
3279
|
"aria-hidden": "true",
|
|
3298
3280
|
children: [
|
|
3299
|
-
/* @__PURE__ */
|
|
3300
|
-
/* @__PURE__ */
|
|
3281
|
+
/* @__PURE__ */ jsx11("path", { d: "M10.3 3.9 1.8 18.1A2 2 0 0 0 3.5 21h17a2 2 0 0 0 1.7-2.9L13.7 3.9a2 2 0 0 0-3.4 0Z" }),
|
|
3282
|
+
/* @__PURE__ */ jsx11("path", { d: "M12 9v4m0 4h.01" })
|
|
3301
3283
|
]
|
|
3302
3284
|
}
|
|
3303
3285
|
),
|
|
3304
|
-
/* @__PURE__ */
|
|
3286
|
+
/* @__PURE__ */ jsx11("span", { children: count })
|
|
3305
3287
|
]
|
|
3306
3288
|
}
|
|
3307
3289
|
);
|
|
@@ -3315,7 +3297,7 @@ import { useMemo as useMemo5 } from "react";
|
|
|
3315
3297
|
// package.json
|
|
3316
3298
|
var package_default = {
|
|
3317
3299
|
name: "@tscircuit/schematic-viewer",
|
|
3318
|
-
version: "2.0.
|
|
3300
|
+
version: "2.0.109",
|
|
3319
3301
|
repository: {
|
|
3320
3302
|
type: "git",
|
|
3321
3303
|
url: "https://github.com/tscircuit/schematic-viewer"
|
|
@@ -3372,7 +3354,7 @@ var package_default = {
|
|
|
3372
3354
|
"@tscircuit/props": "^0.0.697",
|
|
3373
3355
|
"@tscircuit/soup-util": "^0.0.41",
|
|
3374
3356
|
"circuit-json": "^0.0.479",
|
|
3375
|
-
"circuit-to-svg": "
|
|
3357
|
+
"circuit-to-svg": "0.0.445",
|
|
3376
3358
|
debug: "^4.4.0",
|
|
3377
3359
|
"performance-now": "^2.1.0",
|
|
3378
3360
|
"transformation-matrix": "^2.16.1",
|
|
@@ -3381,7 +3363,7 @@ var package_default = {
|
|
|
3381
3363
|
};
|
|
3382
3364
|
|
|
3383
3365
|
// lib/components/ViewMenu.tsx
|
|
3384
|
-
import { Fragment as Fragment7, jsx as
|
|
3366
|
+
import { Fragment as Fragment7, jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3385
3367
|
var FONT_FAMILY2 = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
3386
3368
|
var contentStyles2 = {
|
|
3387
3369
|
backgroundColor: "#262626",
|
|
@@ -3430,7 +3412,7 @@ var HIGHLIGHT_CSS = `
|
|
|
3430
3412
|
.sv-vm-item:hover:not([data-disabled]) { background-color: #404040; }
|
|
3431
3413
|
.sv-vm-item[data-disabled] { opacity: 0.45; cursor: not-allowed; }
|
|
3432
3414
|
`;
|
|
3433
|
-
var CheckIcon2 = () => /* @__PURE__ */
|
|
3415
|
+
var CheckIcon2 = () => /* @__PURE__ */ jsx12(
|
|
3434
3416
|
"svg",
|
|
3435
3417
|
{
|
|
3436
3418
|
width: "14",
|
|
@@ -3442,7 +3424,7 @@ var CheckIcon2 = () => /* @__PURE__ */ jsx11(
|
|
|
3442
3424
|
strokeLinecap: "round",
|
|
3443
3425
|
strokeLinejoin: "round",
|
|
3444
3426
|
"aria-hidden": "true",
|
|
3445
|
-
children: /* @__PURE__ */
|
|
3427
|
+
children: /* @__PURE__ */ jsx12("path", { d: "M20 6 9 17l-5-5" })
|
|
3446
3428
|
}
|
|
3447
3429
|
);
|
|
3448
3430
|
var ViewMenu = ({
|
|
@@ -3500,7 +3482,7 @@ var ViewMenu = ({
|
|
|
3500
3482
|
}
|
|
3501
3483
|
}, [circuitJsonKey]);
|
|
3502
3484
|
if (isComponentMenu && (!pcbComponent || !onViewPcbComponent)) return null;
|
|
3503
|
-
return /* @__PURE__ */
|
|
3485
|
+
return /* @__PURE__ */ jsx12(
|
|
3504
3486
|
"div",
|
|
3505
3487
|
{
|
|
3506
3488
|
ref: menuRef,
|
|
@@ -3512,8 +3494,8 @@ var ViewMenu = ({
|
|
|
3512
3494
|
height: 0
|
|
3513
3495
|
},
|
|
3514
3496
|
children: /* @__PURE__ */ jsxs9(DropdownMenu2.Root, { open: true, onOpenChange, modal: false, children: [
|
|
3515
|
-
/* @__PURE__ */
|
|
3516
|
-
/* @__PURE__ */
|
|
3497
|
+
/* @__PURE__ */ jsx12(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx12("div", { style: { position: "absolute", width: 1, height: 1 } }) }),
|
|
3498
|
+
/* @__PURE__ */ jsx12(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsxs9(
|
|
3517
3499
|
DropdownMenu2.Content,
|
|
3518
3500
|
{
|
|
3519
3501
|
style: contentStyles2,
|
|
@@ -3522,8 +3504,8 @@ var ViewMenu = ({
|
|
|
3522
3504
|
collisionPadding: 10,
|
|
3523
3505
|
avoidCollisions: true,
|
|
3524
3506
|
children: [
|
|
3525
|
-
/* @__PURE__ */
|
|
3526
|
-
pcbComponent && onViewPcbComponent && /* @__PURE__ */
|
|
3507
|
+
/* @__PURE__ */ jsx12("style", { children: HIGHLIGHT_CSS }),
|
|
3508
|
+
pcbComponent && onViewPcbComponent && /* @__PURE__ */ jsx12(Fragment7, { children: /* @__PURE__ */ jsxs9(
|
|
3527
3509
|
DropdownMenu2.Item,
|
|
3528
3510
|
{
|
|
3529
3511
|
className: "sv-vm-item",
|
|
@@ -3533,8 +3515,8 @@ var ViewMenu = ({
|
|
|
3533
3515
|
onViewPcbComponent(pcbComponent);
|
|
3534
3516
|
},
|
|
3535
3517
|
children: [
|
|
3536
|
-
/* @__PURE__ */
|
|
3537
|
-
/* @__PURE__ */
|
|
3518
|
+
/* @__PURE__ */ jsx12("span", { style: iconSlotStyles2, children: "\u2197" }),
|
|
3519
|
+
/* @__PURE__ */ jsx12("span", { children: "Show on PCB" })
|
|
3538
3520
|
]
|
|
3539
3521
|
}
|
|
3540
3522
|
) }),
|
|
@@ -3546,11 +3528,11 @@ var ViewMenu = ({
|
|
|
3546
3528
|
style: itemStyles2,
|
|
3547
3529
|
children: [
|
|
3548
3530
|
"Net Locations ",
|
|
3549
|
-
/* @__PURE__ */
|
|
3531
|
+
/* @__PURE__ */ jsx12("span", { style: { marginLeft: "auto" }, children: "\u203A" })
|
|
3550
3532
|
]
|
|
3551
3533
|
}
|
|
3552
3534
|
),
|
|
3553
|
-
/* @__PURE__ */
|
|
3535
|
+
/* @__PURE__ */ jsx12(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx12(
|
|
3554
3536
|
DropdownMenu2.SubContent,
|
|
3555
3537
|
{
|
|
3556
3538
|
style: {
|
|
@@ -3559,7 +3541,7 @@ var ViewMenu = ({
|
|
|
3559
3541
|
overflowY: "auto"
|
|
3560
3542
|
},
|
|
3561
3543
|
collisionPadding: 10,
|
|
3562
|
-
children: netLocations.map((location, index) => /* @__PURE__ */
|
|
3544
|
+
children: netLocations.map((location, index) => /* @__PURE__ */ jsx12(
|
|
3563
3545
|
DropdownMenu2.Item,
|
|
3564
3546
|
{
|
|
3565
3547
|
className: "sv-vm-item",
|
|
@@ -3586,8 +3568,8 @@ var ViewMenu = ({
|
|
|
3586
3568
|
if (hasPorts) onTogglePorts(!showPorts);
|
|
3587
3569
|
},
|
|
3588
3570
|
children: [
|
|
3589
|
-
/* @__PURE__ */
|
|
3590
|
-
/* @__PURE__ */
|
|
3571
|
+
/* @__PURE__ */ jsx12("span", { style: iconSlotStyles2, children: showPorts && /* @__PURE__ */ jsx12(CheckIcon2, {}) }),
|
|
3572
|
+
/* @__PURE__ */ jsx12("span", { children: "Show Schematic Ports" })
|
|
3591
3573
|
]
|
|
3592
3574
|
}
|
|
3593
3575
|
),
|
|
@@ -3604,8 +3586,8 @@ var ViewMenu = ({
|
|
|
3604
3586
|
if (hasGroups) onToggleGroups(!showGroups);
|
|
3605
3587
|
},
|
|
3606
3588
|
children: [
|
|
3607
|
-
/* @__PURE__ */
|
|
3608
|
-
/* @__PURE__ */
|
|
3589
|
+
/* @__PURE__ */ jsx12("span", { style: iconSlotStyles2, children: showGroups && /* @__PURE__ */ jsx12(CheckIcon2, {}) }),
|
|
3590
|
+
/* @__PURE__ */ jsx12("span", { children: "View Schematic Groups" })
|
|
3609
3591
|
]
|
|
3610
3592
|
}
|
|
3611
3593
|
),
|
|
@@ -3620,8 +3602,8 @@ var ViewMenu = ({
|
|
|
3620
3602
|
onToggleGrid(!showGrid);
|
|
3621
3603
|
},
|
|
3622
3604
|
children: [
|
|
3623
|
-
/* @__PURE__ */
|
|
3624
|
-
/* @__PURE__ */
|
|
3605
|
+
/* @__PURE__ */ jsx12("span", { style: iconSlotStyles2, children: showGrid && /* @__PURE__ */ jsx12(CheckIcon2, {}) }),
|
|
3606
|
+
/* @__PURE__ */ jsx12("span", { children: "Show Grid" })
|
|
3625
3607
|
]
|
|
3626
3608
|
}
|
|
3627
3609
|
),
|
|
@@ -3634,12 +3616,12 @@ var ViewMenu = ({
|
|
|
3634
3616
|
onCheckedChange: onToggleWarnings,
|
|
3635
3617
|
onSelect: (event) => event.preventDefault(),
|
|
3636
3618
|
children: [
|
|
3637
|
-
/* @__PURE__ */
|
|
3638
|
-
/* @__PURE__ */
|
|
3619
|
+
/* @__PURE__ */ jsx12("span", { style: iconSlotStyles2, children: /* @__PURE__ */ jsx12(DropdownMenu2.ItemIndicator, { children: /* @__PURE__ */ jsx12(CheckIcon2, {}) }) }),
|
|
3620
|
+
/* @__PURE__ */ jsx12("span", { children: "Show Warnings" })
|
|
3639
3621
|
]
|
|
3640
3622
|
}
|
|
3641
3623
|
),
|
|
3642
|
-
/* @__PURE__ */
|
|
3624
|
+
/* @__PURE__ */ jsx12(DropdownMenu2.Separator, { style: separatorStyles }),
|
|
3643
3625
|
/* @__PURE__ */ jsxs9(
|
|
3644
3626
|
DropdownMenu2.Item,
|
|
3645
3627
|
{
|
|
@@ -3647,12 +3629,12 @@ var ViewMenu = ({
|
|
|
3647
3629
|
style: itemStyles2,
|
|
3648
3630
|
onSelect: onRunStyleAnalysis,
|
|
3649
3631
|
children: [
|
|
3650
|
-
/* @__PURE__ */
|
|
3651
|
-
/* @__PURE__ */
|
|
3632
|
+
/* @__PURE__ */ jsx12("span", { style: iconSlotStyles2 }),
|
|
3633
|
+
/* @__PURE__ */ jsx12("span", { children: "Run Style Analysis" })
|
|
3652
3634
|
]
|
|
3653
3635
|
}
|
|
3654
3636
|
),
|
|
3655
|
-
/* @__PURE__ */
|
|
3637
|
+
/* @__PURE__ */ jsx12(DropdownMenu2.Separator, { style: separatorStyles }),
|
|
3656
3638
|
/* @__PURE__ */ jsxs9(
|
|
3657
3639
|
"div",
|
|
3658
3640
|
{
|
|
@@ -3680,7 +3662,7 @@ var ViewMenu = ({
|
|
|
3680
3662
|
};
|
|
3681
3663
|
|
|
3682
3664
|
// lib/components/SchematicViewer.tsx
|
|
3683
|
-
import { jsx as
|
|
3665
|
+
import { jsx as jsx13, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3684
3666
|
var SchematicViewer = ({
|
|
3685
3667
|
circuitJson,
|
|
3686
3668
|
platformConfig,
|
|
@@ -3698,6 +3680,8 @@ var SchematicViewer = ({
|
|
|
3698
3680
|
searchEnabled = true,
|
|
3699
3681
|
controller,
|
|
3700
3682
|
onViewPcbComponent,
|
|
3683
|
+
highlightedSchematicComponentIds,
|
|
3684
|
+
highlightedSchematicTextIds,
|
|
3701
3685
|
css,
|
|
3702
3686
|
className
|
|
3703
3687
|
}) => {
|
|
@@ -3721,7 +3705,7 @@ var SchematicViewer = ({
|
|
|
3721
3705
|
}, [circuitJsonKey]);
|
|
3722
3706
|
const hasMultipleSheets = schematicSheets.length > 1;
|
|
3723
3707
|
const defaultSheetId = schematicSheets[0]?.schematic_sheet_id;
|
|
3724
|
-
const [selectedSheetId, setSelectedSheetId] =
|
|
3708
|
+
const [selectedSheetId, setSelectedSheetId] = useState9(
|
|
3725
3709
|
() => {
|
|
3726
3710
|
const stored = getStoredString(STORAGE_KEYS.SELECTED_SCHEMATIC_SHEET);
|
|
3727
3711
|
if (stored && schematicSheets.some((s) => s.schematic_sheet_id === stored)) {
|
|
@@ -3730,14 +3714,14 @@ var SchematicViewer = ({
|
|
|
3730
3714
|
return defaultSheetId;
|
|
3731
3715
|
}
|
|
3732
3716
|
);
|
|
3733
|
-
|
|
3717
|
+
useEffect14(() => {
|
|
3734
3718
|
const stillExists = selectedSheetId !== void 0 && schematicSheets.some((s) => s.schematic_sheet_id === selectedSheetId);
|
|
3735
3719
|
if (!stillExists) {
|
|
3736
3720
|
setSelectedSheetId(defaultSheetId);
|
|
3737
3721
|
}
|
|
3738
3722
|
}, [circuitJsonKey]);
|
|
3739
3723
|
const activeSheetId = hasMultipleSheets ? selectedSheetId ?? defaultSheetId : void 0;
|
|
3740
|
-
const handleSelectSheet =
|
|
3724
|
+
const handleSelectSheet = useCallback8(
|
|
3741
3725
|
(sheetId) => {
|
|
3742
3726
|
setSelectedSheetId(sheetId);
|
|
3743
3727
|
setStoredString(STORAGE_KEYS.SELECTED_SCHEMATIC_SHEET, sheetId);
|
|
@@ -3745,32 +3729,32 @@ var SchematicViewer = ({
|
|
|
3745
3729
|
},
|
|
3746
3730
|
[onSchematicSheetChange]
|
|
3747
3731
|
);
|
|
3748
|
-
const [showGridInternal, setShowGridInternal] =
|
|
3749
|
-
const [analysisCircuitJson, setAnalysisCircuitJson] =
|
|
3750
|
-
const [showWarnings, setShowWarnings] =
|
|
3732
|
+
const [showGridInternal, setShowGridInternal] = useState9(false);
|
|
3733
|
+
const [analysisCircuitJson, setAnalysisCircuitJson] = useState9(null);
|
|
3734
|
+
const [showWarnings, setShowWarnings] = useState9(false);
|
|
3751
3735
|
const warningCount = circuitJson.filter(
|
|
3752
3736
|
(element) => element.type.startsWith("schematic_") && element.type.endsWith("_warning")
|
|
3753
3737
|
).length;
|
|
3754
3738
|
const showGrid = debugGrid || showGridInternal;
|
|
3755
|
-
const [isInteractionEnabled, setIsInteractionEnabled] =
|
|
3739
|
+
const [isInteractionEnabled, setIsInteractionEnabled] = useState9(
|
|
3756
3740
|
!clickToInteractEnabled
|
|
3757
3741
|
);
|
|
3758
|
-
const [showSchematicGroups, setShowSchematicGroups] =
|
|
3742
|
+
const [showSchematicGroups, setShowSchematicGroups] = useState9(() => {
|
|
3759
3743
|
if (disableGroups) return false;
|
|
3760
3744
|
return getStoredBoolean(STORAGE_KEYS.IS_SHOWING_SCHEMATIC_GROUPS, false);
|
|
3761
3745
|
});
|
|
3762
|
-
const [showSchematicPortsInternal, setShowSchematicPortsInternal] =
|
|
3746
|
+
const [showSchematicPortsInternal, setShowSchematicPortsInternal] = useState9(
|
|
3763
3747
|
() => showSchematicPorts ?? getStoredBoolean(STORAGE_KEYS.IS_SHOWING_SCHEMATIC_PORTS, false)
|
|
3764
3748
|
);
|
|
3765
|
-
|
|
3749
|
+
useEffect14(() => {
|
|
3766
3750
|
if (showSchematicPorts !== void 0) {
|
|
3767
3751
|
setShowSchematicPortsInternal(showSchematicPorts);
|
|
3768
3752
|
}
|
|
3769
3753
|
}, [showSchematicPorts]);
|
|
3770
|
-
const [isHoveringClickableComponent, setIsHoveringClickableComponent] =
|
|
3771
|
-
const hoveringComponentsRef =
|
|
3772
|
-
const [selectedSchematicComponent, setSelectedSchematicComponent] =
|
|
3773
|
-
const handleComponentHoverChange =
|
|
3754
|
+
const [isHoveringClickableComponent, setIsHoveringClickableComponent] = useState9(false);
|
|
3755
|
+
const hoveringComponentsRef = useRef8(/* @__PURE__ */ new Set());
|
|
3756
|
+
const [selectedSchematicComponent, setSelectedSchematicComponent] = useState9(null);
|
|
3757
|
+
const handleComponentHoverChange = useCallback8(
|
|
3774
3758
|
(componentId, isHovering) => {
|
|
3775
3759
|
if (isHovering) {
|
|
3776
3760
|
hoveringComponentsRef.current.add(componentId);
|
|
@@ -3781,9 +3765,9 @@ var SchematicViewer = ({
|
|
|
3781
3765
|
},
|
|
3782
3766
|
[]
|
|
3783
3767
|
);
|
|
3784
|
-
const [isHoveringClickablePort, setIsHoveringClickablePort] =
|
|
3785
|
-
const hoveringPortsRef =
|
|
3786
|
-
const handlePortHoverChange =
|
|
3768
|
+
const [isHoveringClickablePort, setIsHoveringClickablePort] = useState9(false);
|
|
3769
|
+
const hoveringPortsRef = useRef8(/* @__PURE__ */ new Set());
|
|
3770
|
+
const handlePortHoverChange = useCallback8(
|
|
3787
3771
|
(portId, isHovering) => {
|
|
3788
3772
|
if (isHovering) {
|
|
3789
3773
|
hoveringPortsRef.current.add(portId);
|
|
@@ -3794,9 +3778,9 @@ var SchematicViewer = ({
|
|
|
3794
3778
|
},
|
|
3795
3779
|
[]
|
|
3796
3780
|
);
|
|
3797
|
-
const svgDivRef =
|
|
3798
|
-
const touchStartRef =
|
|
3799
|
-
const zoomScaleRef =
|
|
3781
|
+
const svgDivRef = useRef8(null);
|
|
3782
|
+
const touchStartRef = useRef8(null);
|
|
3783
|
+
const zoomScaleRef = useRef8({ x: 1, y: 1 });
|
|
3800
3784
|
const schematicComponentIds = useMemo6(() => {
|
|
3801
3785
|
try {
|
|
3802
3786
|
const components = su4(circuitJson).schematic_component?.list() ?? [];
|
|
@@ -3848,7 +3832,7 @@ var SchematicViewer = ({
|
|
|
3848
3832
|
}
|
|
3849
3833
|
touchStartRef.current = null;
|
|
3850
3834
|
};
|
|
3851
|
-
const shouldPanSchematic =
|
|
3835
|
+
const shouldPanSchematic = useCallback8(
|
|
3852
3836
|
(event) => {
|
|
3853
3837
|
if (event.target instanceof Element && event.target.closest(
|
|
3854
3838
|
"[data-schematic-search], [data-schematic-warnings], .schematic-warning, [data-schematic-component-details-tooltip]"
|
|
@@ -3915,7 +3899,7 @@ var SchematicViewer = ({
|
|
|
3915
3899
|
);
|
|
3916
3900
|
return { left, top, width, maxHeight };
|
|
3917
3901
|
}, [selectedSchematicComponent, containerWidth, containerHeight]);
|
|
3918
|
-
const handleSchematicComponentClick =
|
|
3902
|
+
const handleSchematicComponentClick = useCallback8(
|
|
3919
3903
|
(schematicComponentId, event) => {
|
|
3920
3904
|
if (event.target instanceof Element && event.target.closest("[data-schematic-component-details-tooltip]")) {
|
|
3921
3905
|
return;
|
|
@@ -3934,10 +3918,10 @@ var SchematicViewer = ({
|
|
|
3934
3918
|
},
|
|
3935
3919
|
[containerRef, onSchematicComponentClicked]
|
|
3936
3920
|
);
|
|
3937
|
-
|
|
3921
|
+
useEffect14(() => {
|
|
3938
3922
|
setSelectedSchematicComponent(null);
|
|
3939
3923
|
}, [circuitJsonKey, activeSheetId]);
|
|
3940
|
-
|
|
3924
|
+
useEffect14(() => {
|
|
3941
3925
|
if (!selectedSchematicComponent) return;
|
|
3942
3926
|
const handleKeyDown = (event) => {
|
|
3943
3927
|
if (event.key === "Escape") {
|
|
@@ -4021,7 +4005,7 @@ var SchematicViewer = ({
|
|
|
4021
4005
|
enabled: netHoverHighlightEnabled
|
|
4022
4006
|
});
|
|
4023
4007
|
const svgDiv = useMemo6(
|
|
4024
|
-
() => /* @__PURE__ */
|
|
4008
|
+
() => /* @__PURE__ */ jsx13(
|
|
4025
4009
|
"div",
|
|
4026
4010
|
{
|
|
4027
4011
|
ref: svgDivRef,
|
|
@@ -4037,9 +4021,9 @@ var SchematicViewer = ({
|
|
|
4037
4021
|
);
|
|
4038
4022
|
useSchematicWarnings({ svgDivRef, svgContent: svgDiv, circuitJsonKey });
|
|
4039
4023
|
return /* @__PURE__ */ jsxs10(MouseTracker, { children: [
|
|
4040
|
-
netHoverHighlightEnabled && /* @__PURE__ */
|
|
4024
|
+
netHoverHighlightEnabled && /* @__PURE__ */ jsx13("style", { children: `.sch-net-faded { opacity: 0.35; }
|
|
4041
4025
|
svg :is(g.trace, g.trace-overlays, g[data-schematic-component-id], [data-schematic-net-label-id]) { transition: opacity 0.12s ease-in-out; }` }),
|
|
4042
|
-
searchEnabled && /* @__PURE__ */
|
|
4026
|
+
searchEnabled && /* @__PURE__ */ jsx13("style", { children: `.schematic-search-match text,
|
|
4043
4027
|
text.schematic-search-match {
|
|
4044
4028
|
fill: #ff00d4 !important;
|
|
4045
4029
|
}
|
|
@@ -4055,8 +4039,11 @@ var SchematicViewer = ({
|
|
|
4055
4039
|
flex-direction: column;
|
|
4056
4040
|
}
|
|
4057
4041
|
}` }),
|
|
4058
|
-
/* @__PURE__ */
|
|
4059
|
-
|
|
4042
|
+
/* @__PURE__ */ jsx13("style", { children: `
|
|
4043
|
+
.schematic-component-clickable > svg { overflow: visible; }
|
|
4044
|
+
.schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }
|
|
4045
|
+
` }),
|
|
4046
|
+
onSchematicPortClicked && /* @__PURE__ */ jsx13("style", { children: "[data-schematic-port-id]:hover { cursor: pointer !important; }" }),
|
|
4060
4047
|
/* @__PURE__ */ jsxs10(
|
|
4061
4048
|
"div",
|
|
4062
4049
|
{
|
|
@@ -4092,7 +4079,7 @@ var SchematicViewer = ({
|
|
|
4092
4079
|
},
|
|
4093
4080
|
onTouchCancel: contextMenuEventHandlers.onTouchCancel,
|
|
4094
4081
|
children: [
|
|
4095
|
-
!isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */
|
|
4082
|
+
!isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */ jsx13(
|
|
4096
4083
|
"div",
|
|
4097
4084
|
{
|
|
4098
4085
|
onClick: (e) => {
|
|
@@ -4111,7 +4098,7 @@ var SchematicViewer = ({
|
|
|
4111
4098
|
pointerEvents: "all",
|
|
4112
4099
|
touchAction: "pan-x pan-y pinch-zoom"
|
|
4113
4100
|
},
|
|
4114
|
-
children: /* @__PURE__ */
|
|
4101
|
+
children: /* @__PURE__ */ jsx13(
|
|
4115
4102
|
"div",
|
|
4116
4103
|
{
|
|
4117
4104
|
style: {
|
|
@@ -4128,14 +4115,14 @@ var SchematicViewer = ({
|
|
|
4128
4115
|
)
|
|
4129
4116
|
}
|
|
4130
4117
|
),
|
|
4131
|
-
analysisCircuitJson && /* @__PURE__ */
|
|
4118
|
+
analysisCircuitJson && /* @__PURE__ */ jsx13(
|
|
4132
4119
|
StyleAnalysisDialog,
|
|
4133
4120
|
{
|
|
4134
4121
|
circuitJson: analysisCircuitJson,
|
|
4135
4122
|
onClose: () => setAnalysisCircuitJson(null)
|
|
4136
4123
|
}
|
|
4137
4124
|
),
|
|
4138
|
-
menuVisible && /* @__PURE__ */
|
|
4125
|
+
menuVisible && /* @__PURE__ */ jsx13(
|
|
4139
4126
|
ViewMenu,
|
|
4140
4127
|
{
|
|
4141
4128
|
isComponentMenu: !!getSchematicComponentAtElement(menuTarget, circuitJson),
|
|
@@ -4193,7 +4180,7 @@ var SchematicViewer = ({
|
|
|
4193
4180
|
zIndex: zIndexMap.schematicSearch
|
|
4194
4181
|
},
|
|
4195
4182
|
children: [
|
|
4196
|
-
/* @__PURE__ */
|
|
4183
|
+
/* @__PURE__ */ jsx13(
|
|
4197
4184
|
SchematicSheetSelector,
|
|
4198
4185
|
{
|
|
4199
4186
|
sheets: schematicSheets,
|
|
@@ -4201,7 +4188,7 @@ var SchematicViewer = ({
|
|
|
4201
4188
|
onSelectSheet: handleSelectSheet
|
|
4202
4189
|
}
|
|
4203
4190
|
),
|
|
4204
|
-
searchEnabled && /* @__PURE__ */
|
|
4191
|
+
searchEnabled && /* @__PURE__ */ jsx13(
|
|
4205
4192
|
SchematicSearch,
|
|
4206
4193
|
{
|
|
4207
4194
|
query: searchQuery,
|
|
@@ -4212,7 +4199,7 @@ var SchematicViewer = ({
|
|
|
4212
4199
|
viewerContainerRef: containerRef
|
|
4213
4200
|
}
|
|
4214
4201
|
),
|
|
4215
|
-
warningCount > 0 && /* @__PURE__ */
|
|
4202
|
+
warningCount > 0 && /* @__PURE__ */ jsx13(
|
|
4216
4203
|
SchematicWarningsButton,
|
|
4217
4204
|
{
|
|
4218
4205
|
count: warningCount,
|
|
@@ -4223,7 +4210,7 @@ var SchematicViewer = ({
|
|
|
4223
4210
|
]
|
|
4224
4211
|
}
|
|
4225
4212
|
),
|
|
4226
|
-
schematicComponentIds.map((componentId) => /* @__PURE__ */
|
|
4213
|
+
schematicComponentIds.map((componentId) => /* @__PURE__ */ jsx13(
|
|
4227
4214
|
SchematicComponentMouseTarget,
|
|
4228
4215
|
{
|
|
4229
4216
|
componentId,
|
|
@@ -4236,8 +4223,28 @@ var SchematicViewer = ({
|
|
|
4236
4223
|
},
|
|
4237
4224
|
componentId
|
|
4238
4225
|
)),
|
|
4226
|
+
highlightedSchematicComponentIds?.map((componentId) => /* @__PURE__ */ jsx13(
|
|
4227
|
+
SchematicElementHighlight,
|
|
4228
|
+
{
|
|
4229
|
+
selector: `[data-schematic-component-id="${componentId}"]`,
|
|
4230
|
+
svgDivRef,
|
|
4231
|
+
containerRef,
|
|
4232
|
+
circuitJsonKey
|
|
4233
|
+
},
|
|
4234
|
+
`component-${componentId}`
|
|
4235
|
+
)),
|
|
4236
|
+
highlightedSchematicTextIds?.map((textId) => /* @__PURE__ */ jsx13(
|
|
4237
|
+
SchematicElementHighlight,
|
|
4238
|
+
{
|
|
4239
|
+
selector: `[data-schematic-text-id="${textId}"]`,
|
|
4240
|
+
svgDivRef,
|
|
4241
|
+
containerRef,
|
|
4242
|
+
circuitJsonKey
|
|
4243
|
+
},
|
|
4244
|
+
`text-${textId}`
|
|
4245
|
+
)),
|
|
4239
4246
|
svgDiv,
|
|
4240
|
-
selectedComponentDetails && componentTooltipLayout && /* @__PURE__ */
|
|
4247
|
+
selectedComponentDetails && componentTooltipLayout && /* @__PURE__ */ jsx13(
|
|
4241
4248
|
SchematicComponentDetailsTooltip,
|
|
4242
4249
|
{
|
|
4243
4250
|
platformConfig,
|
|
@@ -4249,7 +4256,7 @@ var SchematicViewer = ({
|
|
|
4249
4256
|
...componentTooltipLayout
|
|
4250
4257
|
}
|
|
4251
4258
|
),
|
|
4252
|
-
showSchematicPortsInternal && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */
|
|
4259
|
+
showSchematicPortsInternal && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */ jsx13(
|
|
4253
4260
|
SchematicPortMouseTarget,
|
|
4254
4261
|
{
|
|
4255
4262
|
portId,
|
|
@@ -4279,7 +4286,7 @@ import {
|
|
|
4279
4286
|
convertCircuitJsonToSchematicSimulationSvg,
|
|
4280
4287
|
convertCircuitJsonToSimulationGraphSvg
|
|
4281
4288
|
} from "circuit-to-svg";
|
|
4282
|
-
import { useEffect as
|
|
4289
|
+
import { useEffect as useEffect15, useMemo as useMemo7, useRef as useRef9, useState as useState11 } from "react";
|
|
4283
4290
|
import { toString as transformToString2 } from "transformation-matrix";
|
|
4284
4291
|
import { useMouseMatrixTransform as useMouseMatrixTransform2 } from "use-mouse-matrix-transform";
|
|
4285
4292
|
|
|
@@ -4297,8 +4304,8 @@ var getAnalogSimulationBackgroundColor = (simulationSvg, colorOverrides) => getR
|
|
|
4297
4304
|
|
|
4298
4305
|
// lib/components/AnalogSimulationSelector.tsx
|
|
4299
4306
|
import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
|
|
4300
|
-
import { useState as
|
|
4301
|
-
import { Fragment as Fragment8, jsx as
|
|
4307
|
+
import { useState as useState10 } from "react";
|
|
4308
|
+
import { Fragment as Fragment8, jsx as jsx14, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4302
4309
|
var FONT_FAMILY3 = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
4303
4310
|
var contentStyles3 = {
|
|
4304
4311
|
backgroundColor: "#ffffff",
|
|
@@ -4348,7 +4355,7 @@ var MENU_CSS2 = `
|
|
|
4348
4355
|
.sv-simulation-chevron { transition: transform 0.2s ease; }
|
|
4349
4356
|
[data-state="open"] > .sv-simulation-chevron { transform: rotate(180deg); }
|
|
4350
4357
|
`;
|
|
4351
|
-
var CheckIcon3 = () => /* @__PURE__ */
|
|
4358
|
+
var CheckIcon3 = () => /* @__PURE__ */ jsx14(
|
|
4352
4359
|
"svg",
|
|
4353
4360
|
{
|
|
4354
4361
|
width: "14",
|
|
@@ -4360,10 +4367,10 @@ var CheckIcon3 = () => /* @__PURE__ */ jsx13(
|
|
|
4360
4367
|
strokeLinecap: "round",
|
|
4361
4368
|
strokeLinejoin: "round",
|
|
4362
4369
|
"aria-hidden": "true",
|
|
4363
|
-
children: /* @__PURE__ */
|
|
4370
|
+
children: /* @__PURE__ */ jsx14("path", { d: "M20 6 9 17l-5-5" })
|
|
4364
4371
|
}
|
|
4365
4372
|
);
|
|
4366
|
-
var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */
|
|
4373
|
+
var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */ jsx14(
|
|
4367
4374
|
"svg",
|
|
4368
4375
|
{
|
|
4369
4376
|
className,
|
|
@@ -4377,7 +4384,7 @@ var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */ jsx13(
|
|
|
4377
4384
|
strokeLinejoin: "round",
|
|
4378
4385
|
style: { opacity: 0.6, flexShrink: 0 },
|
|
4379
4386
|
"aria-hidden": "true",
|
|
4380
|
-
children: /* @__PURE__ */
|
|
4387
|
+
children: /* @__PURE__ */ jsx14("path", { d: "m6 9 6 6 6-6" })
|
|
4381
4388
|
}
|
|
4382
4389
|
);
|
|
4383
4390
|
var getSimulationLabels = (simulations) => {
|
|
@@ -4396,7 +4403,7 @@ var AnalogSimulationSelector = ({
|
|
|
4396
4403
|
selectedSimulationExperimentId,
|
|
4397
4404
|
onSelectSimulation
|
|
4398
4405
|
}) => {
|
|
4399
|
-
const [open, setOpen] =
|
|
4406
|
+
const [open, setOpen] = useState10(false);
|
|
4400
4407
|
if (simulations.length <= 1) return null;
|
|
4401
4408
|
const simulationLabels = getSimulationLabels(simulations);
|
|
4402
4409
|
const selectedSimulation = simulationLabels.find(
|
|
@@ -4404,9 +4411,9 @@ var AnalogSimulationSelector = ({
|
|
|
4404
4411
|
);
|
|
4405
4412
|
const selectedLabel = selectedSimulation?.label ?? "Select simulation";
|
|
4406
4413
|
return /* @__PURE__ */ jsxs11(Fragment8, { children: [
|
|
4407
|
-
/* @__PURE__ */
|
|
4414
|
+
/* @__PURE__ */ jsx14("style", { children: MENU_CSS2 }),
|
|
4408
4415
|
/* @__PURE__ */ jsxs11(DropdownMenu3.Root, { open, onOpenChange: setOpen, modal: false, children: [
|
|
4409
|
-
/* @__PURE__ */
|
|
4416
|
+
/* @__PURE__ */ jsx14(DropdownMenu3.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs11(
|
|
4410
4417
|
"button",
|
|
4411
4418
|
{
|
|
4412
4419
|
type: "button",
|
|
@@ -4433,13 +4440,13 @@ var AnalogSimulationSelector = ({
|
|
|
4433
4440
|
zIndex: zIndexMap.viewMenuIcon
|
|
4434
4441
|
},
|
|
4435
4442
|
children: [
|
|
4436
|
-
/* @__PURE__ */
|
|
4437
|
-
/* @__PURE__ */
|
|
4438
|
-
/* @__PURE__ */
|
|
4443
|
+
/* @__PURE__ */ jsx14("span", { style: { color: "#888888", flexShrink: 0 }, children: "Simulation:" }),
|
|
4444
|
+
/* @__PURE__ */ jsx14("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: selectedLabel }),
|
|
4445
|
+
/* @__PURE__ */ jsx14(ChevronDownIcon2, { className: "sv-simulation-chevron" })
|
|
4439
4446
|
]
|
|
4440
4447
|
}
|
|
4441
4448
|
) }),
|
|
4442
|
-
/* @__PURE__ */
|
|
4449
|
+
/* @__PURE__ */ jsx14(DropdownMenu3.Portal, { children: /* @__PURE__ */ jsx14(
|
|
4443
4450
|
DropdownMenu3.Content,
|
|
4444
4451
|
{
|
|
4445
4452
|
style: contentStyles3,
|
|
@@ -4461,8 +4468,8 @@ var AnalogSimulationSelector = ({
|
|
|
4461
4468
|
setOpen(false);
|
|
4462
4469
|
},
|
|
4463
4470
|
children: [
|
|
4464
|
-
/* @__PURE__ */
|
|
4465
|
-
/* @__PURE__ */
|
|
4471
|
+
/* @__PURE__ */ jsx14("span", { style: iconSlotStyles3, children: selected && /* @__PURE__ */ jsx14(CheckIcon3, {}) }),
|
|
4472
|
+
/* @__PURE__ */ jsx14("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: label })
|
|
4466
4473
|
]
|
|
4467
4474
|
},
|
|
4468
4475
|
simulation.simulation_experiment_id
|
|
@@ -4475,7 +4482,7 @@ var AnalogSimulationSelector = ({
|
|
|
4475
4482
|
};
|
|
4476
4483
|
|
|
4477
4484
|
// lib/components/AnalogSimulationViewer.tsx
|
|
4478
|
-
import { jsx as
|
|
4485
|
+
import { jsx as jsx15, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4479
4486
|
var DEFAULT_RENDER_WIDTH = 1200;
|
|
4480
4487
|
var DEFAULT_COMBINED_RENDER_ASPECT_RATIO = 1;
|
|
4481
4488
|
var DEFAULT_GRAPH_ONLY_RENDER_ASPECT_RATIO = 2;
|
|
@@ -4490,16 +4497,16 @@ var AnalogSimulationViewer = ({
|
|
|
4490
4497
|
onSimulationChange,
|
|
4491
4498
|
acSweepView = "magnitude"
|
|
4492
4499
|
}) => {
|
|
4493
|
-
const [circuitJson, setCircuitJson] =
|
|
4494
|
-
const [isLoading, setIsLoading] =
|
|
4495
|
-
const [error, setError] =
|
|
4496
|
-
const [svgObjectUrl, setSvgObjectUrl] =
|
|
4497
|
-
const containerRef =
|
|
4498
|
-
const imgRef =
|
|
4500
|
+
const [circuitJson, setCircuitJson] = useState11(null);
|
|
4501
|
+
const [isLoading, setIsLoading] = useState11(true);
|
|
4502
|
+
const [error, setError] = useState11(null);
|
|
4503
|
+
const [svgObjectUrl, setSvgObjectUrl] = useState11(null);
|
|
4504
|
+
const containerRef = useRef9(null);
|
|
4505
|
+
const imgRef = useRef9(null);
|
|
4499
4506
|
const { containerWidth } = useResizeHandling(
|
|
4500
4507
|
containerRef
|
|
4501
4508
|
);
|
|
4502
|
-
const [isDragging, setIsDragging] =
|
|
4509
|
+
const [isDragging, setIsDragging] = useState11(false);
|
|
4503
4510
|
const {
|
|
4504
4511
|
ref: transformRef,
|
|
4505
4512
|
cancelDrag: _cancelDrag,
|
|
@@ -4515,7 +4522,7 @@ var AnalogSimulationViewer = ({
|
|
|
4515
4522
|
const renderAspectRatio = width && height ? width / height : defaultRenderAspectRatio;
|
|
4516
4523
|
const effectiveWidth = width || (height ? height * renderAspectRatio : containerWidth) || DEFAULT_RENDER_WIDTH;
|
|
4517
4524
|
const effectiveHeight = height || effectiveWidth / renderAspectRatio;
|
|
4518
|
-
|
|
4525
|
+
useEffect15(() => {
|
|
4519
4526
|
setIsLoading(true);
|
|
4520
4527
|
setError(null);
|
|
4521
4528
|
setCircuitJson(inputCircuitJson);
|
|
@@ -4527,11 +4534,11 @@ var AnalogSimulationViewer = ({
|
|
|
4527
4534
|
(element) => element.type === "simulation_experiment"
|
|
4528
4535
|
);
|
|
4529
4536
|
}, [circuitJson]);
|
|
4530
|
-
const [selectedSimulationExperimentId, setSelectedSimulationExperimentId] =
|
|
4537
|
+
const [selectedSimulationExperimentId, setSelectedSimulationExperimentId] = useState11(null);
|
|
4531
4538
|
const simulationExperimentId = (selectedSimulationExperimentId && simulationExperiments.some(
|
|
4532
4539
|
(simulation) => simulation.simulation_experiment_id === selectedSimulationExperimentId
|
|
4533
4540
|
) ? selectedSimulationExperimentId : simulationExperiments[0]?.simulation_experiment_id) ?? null;
|
|
4534
|
-
|
|
4541
|
+
useEffect15(() => {
|
|
4535
4542
|
if (simulationExperimentId !== selectedSimulationExperimentId) {
|
|
4536
4543
|
setSelectedSimulationExperimentId(simulationExperimentId);
|
|
4537
4544
|
}
|
|
@@ -4568,7 +4575,7 @@ var AnalogSimulationViewer = ({
|
|
|
4568
4575
|
simulationExperimentId,
|
|
4569
4576
|
acSweepView
|
|
4570
4577
|
]);
|
|
4571
|
-
|
|
4578
|
+
useEffect15(() => {
|
|
4572
4579
|
if (!simulationSvg) {
|
|
4573
4580
|
setSvgObjectUrl(null);
|
|
4574
4581
|
return;
|
|
@@ -4594,7 +4601,7 @@ var AnalogSimulationViewer = ({
|
|
|
4594
4601
|
const handleTouchStart = (_e) => {
|
|
4595
4602
|
setIsDragging(true);
|
|
4596
4603
|
};
|
|
4597
|
-
|
|
4604
|
+
useEffect15(() => {
|
|
4598
4605
|
const handleMouseUp = () => {
|
|
4599
4606
|
setIsDragging(false);
|
|
4600
4607
|
};
|
|
@@ -4609,7 +4616,7 @@ var AnalogSimulationViewer = ({
|
|
|
4609
4616
|
};
|
|
4610
4617
|
}, []);
|
|
4611
4618
|
if (isLoading) {
|
|
4612
|
-
return /* @__PURE__ */
|
|
4619
|
+
return /* @__PURE__ */ jsx15(
|
|
4613
4620
|
"div",
|
|
4614
4621
|
{
|
|
4615
4622
|
style: {
|
|
@@ -4629,7 +4636,7 @@ var AnalogSimulationViewer = ({
|
|
|
4629
4636
|
);
|
|
4630
4637
|
}
|
|
4631
4638
|
if (error) {
|
|
4632
|
-
return /* @__PURE__ */
|
|
4639
|
+
return /* @__PURE__ */ jsx15(
|
|
4633
4640
|
"div",
|
|
4634
4641
|
{
|
|
4635
4642
|
style: {
|
|
@@ -4645,8 +4652,8 @@ var AnalogSimulationViewer = ({
|
|
|
4645
4652
|
},
|
|
4646
4653
|
className,
|
|
4647
4654
|
children: /* @__PURE__ */ jsxs12("div", { style: { textAlign: "center", padding: "20px" }, children: [
|
|
4648
|
-
/* @__PURE__ */
|
|
4649
|
-
/* @__PURE__ */
|
|
4655
|
+
/* @__PURE__ */ jsx15("div", { style: { fontWeight: "bold", marginBottom: "8px" }, children: "Circuit Conversion Error" }),
|
|
4656
|
+
/* @__PURE__ */ jsx15("div", { style: { fontSize: "14px" }, children: error })
|
|
4650
4657
|
] })
|
|
4651
4658
|
}
|
|
4652
4659
|
);
|
|
@@ -4668,11 +4675,11 @@ var AnalogSimulationViewer = ({
|
|
|
4668
4675
|
},
|
|
4669
4676
|
className,
|
|
4670
4677
|
children: [
|
|
4671
|
-
/* @__PURE__ */
|
|
4678
|
+
/* @__PURE__ */ jsx15("div", { style: { fontSize: "16px", color: "#475569", fontWeight: 500 }, children: "No Simulation Found" }),
|
|
4672
4679
|
/* @__PURE__ */ jsxs12("div", { style: { fontSize: "14px", color: "#64748b" }, children: [
|
|
4673
4680
|
"Use",
|
|
4674
4681
|
" ",
|
|
4675
|
-
/* @__PURE__ */
|
|
4682
|
+
/* @__PURE__ */ jsx15(
|
|
4676
4683
|
"code",
|
|
4677
4684
|
{
|
|
4678
4685
|
style: {
|
|
@@ -4711,7 +4718,7 @@ var AnalogSimulationViewer = ({
|
|
|
4711
4718
|
onMouseDown: handleMouseDown,
|
|
4712
4719
|
onTouchStart: handleTouchStart,
|
|
4713
4720
|
children: [
|
|
4714
|
-
/* @__PURE__ */
|
|
4721
|
+
/* @__PURE__ */ jsx15(
|
|
4715
4722
|
AnalogSimulationSelector,
|
|
4716
4723
|
{
|
|
4717
4724
|
simulations: simulationExperiments,
|
|
@@ -4719,7 +4726,7 @@ var AnalogSimulationViewer = ({
|
|
|
4719
4726
|
onSelectSimulation: handleSelectSimulation
|
|
4720
4727
|
}
|
|
4721
4728
|
),
|
|
4722
|
-
svgObjectUrl ? /* @__PURE__ */
|
|
4729
|
+
svgObjectUrl ? /* @__PURE__ */ jsx15(
|
|
4723
4730
|
"img",
|
|
4724
4731
|
{
|
|
4725
4732
|
ref: imgRef,
|
|
@@ -4733,7 +4740,7 @@ var AnalogSimulationViewer = ({
|
|
|
4733
4740
|
objectFit: "contain"
|
|
4734
4741
|
}
|
|
4735
4742
|
}
|
|
4736
|
-
) : /* @__PURE__ */
|
|
4743
|
+
) : /* @__PURE__ */ jsx15(
|
|
4737
4744
|
"div",
|
|
4738
4745
|
{
|
|
4739
4746
|
style: {
|
|
@@ -4754,16 +4761,16 @@ var AnalogSimulationViewer = ({
|
|
|
4754
4761
|
};
|
|
4755
4762
|
|
|
4756
4763
|
// lib/hooks/useSchematicViewerController.ts
|
|
4757
|
-
import { useCallback as
|
|
4764
|
+
import { useCallback as useCallback9, useMemo as useMemo8, useState as useState12 } from "react";
|
|
4758
4765
|
var useSchematicViewerController = () => {
|
|
4759
|
-
const [focusRequest, setFocusRequest] =
|
|
4760
|
-
const focusSchematicComponent =
|
|
4766
|
+
const [focusRequest, setFocusRequest] = useState12(null);
|
|
4767
|
+
const focusSchematicComponent = useCallback9(
|
|
4761
4768
|
(schematicComponentId) => {
|
|
4762
4769
|
setFocusRequest({ schematicComponentId });
|
|
4763
4770
|
},
|
|
4764
4771
|
[]
|
|
4765
4772
|
);
|
|
4766
|
-
const onFocusRequestHandled =
|
|
4773
|
+
const onFocusRequestHandled = useCallback9(
|
|
4767
4774
|
(request) => {
|
|
4768
4775
|
setFocusRequest((current) => current === request ? null : current);
|
|
4769
4776
|
},
|