@tscircuit/schematic-viewer 2.0.100 → 2.0.102
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 +12 -2
- package/dist/index.js +514 -318
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1284,7 +1284,7 @@ var enableDebug = () => {
|
|
|
1284
1284
|
};
|
|
1285
1285
|
|
|
1286
1286
|
// lib/components/SchematicViewer.tsx
|
|
1287
|
-
import { useCallback as useCallback7, useEffect as
|
|
1287
|
+
import { useCallback as useCallback7, useEffect as useEffect13, useMemo as useMemo6, useRef as useRef9, useState as useState10 } from "react";
|
|
1288
1288
|
import { toString as transformToString } from "transformation-matrix";
|
|
1289
1289
|
import { useMouseMatrixTransform } from "use-mouse-matrix-transform";
|
|
1290
1290
|
|
|
@@ -1604,6 +1604,45 @@ var getFootprintPreviewUrl = (footprintPreviewCircuitJson, viewBox) => {
|
|
|
1604
1604
|
return url.toString();
|
|
1605
1605
|
};
|
|
1606
1606
|
|
|
1607
|
+
// lib/utils/get-pcb-component-at-element.ts
|
|
1608
|
+
var getSchematicComponentAtElement = (target, circuitJson) => {
|
|
1609
|
+
const componentId = target?.closest("[data-schematic-component-id]")?.getAttribute("data-schematic-component-id");
|
|
1610
|
+
const textId = target?.closest("[data-schematic-text-id]")?.getAttribute("data-schematic-text-id");
|
|
1611
|
+
const portId = target?.closest("[data-schematic-port-id]")?.getAttribute("data-schematic-port-id");
|
|
1612
|
+
if (!componentId && !textId && !portId) return;
|
|
1613
|
+
const text = circuitJson.find(
|
|
1614
|
+
(element) => element.type === "schematic_text" && element.schematic_text_id === textId
|
|
1615
|
+
);
|
|
1616
|
+
const port = circuitJson.find(
|
|
1617
|
+
(element) => element.type === "schematic_port" && !!portId && (element.schematic_port_id === portId || element.source_port_id === portId)
|
|
1618
|
+
);
|
|
1619
|
+
const schematicComponentId = componentId ?? (text?.type === "schematic_text" ? text.schematic_component_id : void 0) ?? (port?.type === "schematic_port" ? port.schematic_component_id : void 0);
|
|
1620
|
+
if (!schematicComponentId) return;
|
|
1621
|
+
const schematicComponent = circuitJson.find(
|
|
1622
|
+
(element) => element.type === "schematic_component" && element.schematic_component_id === schematicComponentId
|
|
1623
|
+
);
|
|
1624
|
+
if (schematicComponent?.type !== "schematic_component") return;
|
|
1625
|
+
return schematicComponent;
|
|
1626
|
+
};
|
|
1627
|
+
var getPcbComponentAtElement = (target, circuitJson) => {
|
|
1628
|
+
const schematicComponent = getSchematicComponentAtElement(target, circuitJson);
|
|
1629
|
+
if (!schematicComponent) return;
|
|
1630
|
+
const sourceComponent = circuitJson.find(
|
|
1631
|
+
(element) => element.type === "source_component" && element.source_component_id === schematicComponent.source_component_id
|
|
1632
|
+
);
|
|
1633
|
+
const pcbComponent = circuitJson.find(
|
|
1634
|
+
(element) => element.type === "pcb_component" && element.source_component_id === schematicComponent.source_component_id
|
|
1635
|
+
);
|
|
1636
|
+
if (sourceComponent?.type !== "source_component" || pcbComponent?.type !== "pcb_component")
|
|
1637
|
+
return;
|
|
1638
|
+
return {
|
|
1639
|
+
source_component_id: sourceComponent.source_component_id,
|
|
1640
|
+
schematic_component_id: schematicComponent.schematic_component_id,
|
|
1641
|
+
pcb_component_id: pcbComponent.pcb_component_id,
|
|
1642
|
+
refdes: sourceComponent.name
|
|
1643
|
+
};
|
|
1644
|
+
};
|
|
1645
|
+
|
|
1607
1646
|
// lib/components/MouseTracker.tsx
|
|
1608
1647
|
import {
|
|
1609
1648
|
createContext,
|
|
@@ -1785,7 +1824,125 @@ var MouseTrackerProvider = ({ children }) => {
|
|
|
1785
1824
|
|
|
1786
1825
|
// lib/components/SchematicComponentDetailsTooltip.tsx
|
|
1787
1826
|
import { useMemo as useMemo3 } from "react";
|
|
1788
|
-
|
|
1827
|
+
|
|
1828
|
+
// lib/components/JlcPartAvailability.tsx
|
|
1829
|
+
import { useEffect as useEffect8, useState as useState5 } from "react";
|
|
1830
|
+
|
|
1831
|
+
// lib/utils/jlc-part-availability.ts
|
|
1832
|
+
var nonNegativeNumber = (value) => {
|
|
1833
|
+
if (typeof value !== "number" && typeof value !== "string") return null;
|
|
1834
|
+
if (typeof value === "string" && !value.trim()) return null;
|
|
1835
|
+
const number = Number(value);
|
|
1836
|
+
return Number.isFinite(number) && number >= 0 ? number : null;
|
|
1837
|
+
};
|
|
1838
|
+
var getPrice = (value) => {
|
|
1839
|
+
const number = nonNegativeNumber(value);
|
|
1840
|
+
if (number !== null) return number;
|
|
1841
|
+
if (typeof value !== "string") return null;
|
|
1842
|
+
try {
|
|
1843
|
+
const tiers = JSON.parse(value);
|
|
1844
|
+
if (Array.isArray(tiers)) {
|
|
1845
|
+
return nonNegativeNumber(tiers[0]?.price);
|
|
1846
|
+
}
|
|
1847
|
+
} catch {
|
|
1848
|
+
const tiers = value.split(",").map((tier) => {
|
|
1849
|
+
const [quantity, price] = tier.split(":");
|
|
1850
|
+
return {
|
|
1851
|
+
quantity: nonNegativeNumber(quantity?.split("-")[0]),
|
|
1852
|
+
price: nonNegativeNumber(price)
|
|
1853
|
+
};
|
|
1854
|
+
}).filter((tier) => tier.quantity !== null && tier.price !== null).sort((a, b) => a.quantity - b.quantity);
|
|
1855
|
+
return tiers[0]?.price ?? null;
|
|
1856
|
+
}
|
|
1857
|
+
return null;
|
|
1858
|
+
};
|
|
1859
|
+
var fetchJlcPartAvailability = async (partNumber, signal) => {
|
|
1860
|
+
const response = await fetch(
|
|
1861
|
+
`https://jlcsearch.tscircuit.com/api/search?q=${encodeURIComponent(partNumber)}&limit=1`,
|
|
1862
|
+
{ signal, cache: "no-store" }
|
|
1863
|
+
);
|
|
1864
|
+
if (!response.ok) throw new Error("JLC part lookup failed");
|
|
1865
|
+
const data = await response.json();
|
|
1866
|
+
if (!Array.isArray(data?.components)) return null;
|
|
1867
|
+
const part = data.components.find(
|
|
1868
|
+
(component) => component && String(component.lcsc).replace(/^c/i, "") === partNumber.replace(/^c/i, "")
|
|
1869
|
+
);
|
|
1870
|
+
if (!part) return null;
|
|
1871
|
+
return {
|
|
1872
|
+
price: nonNegativeNumber(part.price1) ?? getPrice(part.price),
|
|
1873
|
+
stock: nonNegativeNumber(part.stock)
|
|
1874
|
+
};
|
|
1875
|
+
};
|
|
1876
|
+
|
|
1877
|
+
// lib/components/JlcPartAvailability.tsx
|
|
1878
|
+
import { Fragment as Fragment3, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
1879
|
+
var JlcPartAvailability = ({ partNumber }) => {
|
|
1880
|
+
const [result, setResult] = useState5(null);
|
|
1881
|
+
const [loading, setLoading] = useState5(true);
|
|
1882
|
+
useEffect8(() => {
|
|
1883
|
+
const controller = new AbortController();
|
|
1884
|
+
let active = true;
|
|
1885
|
+
setLoading(true);
|
|
1886
|
+
setResult(null);
|
|
1887
|
+
const timeout = setTimeout(() => {
|
|
1888
|
+
controller.abort();
|
|
1889
|
+
if (active) setLoading(false);
|
|
1890
|
+
}, 1e4);
|
|
1891
|
+
fetchJlcPartAvailability(partNumber, controller.signal).then((availability) => {
|
|
1892
|
+
if (active) setResult(availability);
|
|
1893
|
+
}).catch(() => {
|
|
1894
|
+
}).finally(() => {
|
|
1895
|
+
clearTimeout(timeout);
|
|
1896
|
+
if (active) setLoading(false);
|
|
1897
|
+
});
|
|
1898
|
+
return () => {
|
|
1899
|
+
active = false;
|
|
1900
|
+
clearTimeout(timeout);
|
|
1901
|
+
controller.abort();
|
|
1902
|
+
};
|
|
1903
|
+
}, [partNumber]);
|
|
1904
|
+
return /* @__PURE__ */ jsx3(
|
|
1905
|
+
"span",
|
|
1906
|
+
{
|
|
1907
|
+
role: "status",
|
|
1908
|
+
"aria-label": `${partNumber} price and stock`,
|
|
1909
|
+
"aria-busy": loading,
|
|
1910
|
+
style: { display: "block", color: "#64748b", marginTop: "2px" },
|
|
1911
|
+
children: loading ? /* @__PURE__ */ jsxs2("span", { style: { display: "inline-flex", alignItems: "center", gap: 4 }, children: [
|
|
1912
|
+
/* @__PURE__ */ jsx3("svg", { width: "12", height: "12", viewBox: "0 0 12 12", "aria-hidden": "true", children: /* @__PURE__ */ jsx3(
|
|
1913
|
+
"circle",
|
|
1914
|
+
{
|
|
1915
|
+
cx: "6",
|
|
1916
|
+
cy: "6",
|
|
1917
|
+
r: "4",
|
|
1918
|
+
fill: "none",
|
|
1919
|
+
stroke: "currentColor",
|
|
1920
|
+
strokeWidth: "2",
|
|
1921
|
+
strokeDasharray: "18 8",
|
|
1922
|
+
children: /* @__PURE__ */ jsx3(
|
|
1923
|
+
"animateTransform",
|
|
1924
|
+
{
|
|
1925
|
+
attributeName: "transform",
|
|
1926
|
+
type: "rotate",
|
|
1927
|
+
from: "0 6 6",
|
|
1928
|
+
to: "360 6 6",
|
|
1929
|
+
dur: "1s",
|
|
1930
|
+
repeatCount: "indefinite"
|
|
1931
|
+
}
|
|
1932
|
+
)
|
|
1933
|
+
}
|
|
1934
|
+
) }),
|
|
1935
|
+
"Loading price and stock\u2026"
|
|
1936
|
+
] }) : /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
1937
|
+
/* @__PURE__ */ jsx3("span", { style: { display: "block" }, children: result?.price != null ? `$${result.price.toLocaleString("en-US", { minimumFractionDigits: 2, maximumFractionDigits: 6 })}` : "Price unavailable" }),
|
|
1938
|
+
/* @__PURE__ */ jsx3("span", { style: { display: "block" }, children: result?.stock != null ? `${result.stock.toLocaleString("en-US")} in stock` : "Stock unavailable" })
|
|
1939
|
+
] })
|
|
1940
|
+
}
|
|
1941
|
+
);
|
|
1942
|
+
};
|
|
1943
|
+
|
|
1944
|
+
// lib/components/SchematicComponentDetailsTooltip.tsx
|
|
1945
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
1789
1946
|
var detailLabelStyle = {
|
|
1790
1947
|
color: "#64748b",
|
|
1791
1948
|
fontFamily: 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace',
|
|
@@ -1818,7 +1975,7 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1818
1975
|
) : void 0,
|
|
1819
1976
|
[footprintPreviewCircuitJson, footprintPreviewViewBox]
|
|
1820
1977
|
);
|
|
1821
|
-
return /* @__PURE__ */
|
|
1978
|
+
return /* @__PURE__ */ jsxs3(
|
|
1822
1979
|
"dialog",
|
|
1823
1980
|
{
|
|
1824
1981
|
open: true,
|
|
@@ -1853,7 +2010,7 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1853
2010
|
onClick: (event) => event.stopPropagation(),
|
|
1854
2011
|
onWheel: (event) => event.stopPropagation(),
|
|
1855
2012
|
children: [
|
|
1856
|
-
/* @__PURE__ */
|
|
2013
|
+
/* @__PURE__ */ jsxs3(
|
|
1857
2014
|
"dl",
|
|
1858
2015
|
{
|
|
1859
2016
|
style: {
|
|
@@ -1864,9 +2021,9 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1864
2021
|
padding: "8px"
|
|
1865
2022
|
},
|
|
1866
2023
|
children: [
|
|
1867
|
-
infoEntries.map((entry) => /* @__PURE__ */
|
|
1868
|
-
/* @__PURE__ */
|
|
1869
|
-
/* @__PURE__ */
|
|
2024
|
+
infoEntries.map((entry) => /* @__PURE__ */ jsxs3("div", { style: { display: "contents" }, children: [
|
|
2025
|
+
/* @__PURE__ */ jsx4("dt", { style: detailLabelStyle, children: entry.label }),
|
|
2026
|
+
/* @__PURE__ */ jsx4(
|
|
1870
2027
|
"dd",
|
|
1871
2028
|
{
|
|
1872
2029
|
style: {
|
|
@@ -1882,9 +2039,9 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1882
2039
|
}
|
|
1883
2040
|
)
|
|
1884
2041
|
] }, entry.key)),
|
|
1885
|
-
supplierPartNumberEntries.map((entry) => /* @__PURE__ */
|
|
1886
|
-
/* @__PURE__ */
|
|
1887
|
-
/* @__PURE__ */
|
|
2042
|
+
supplierPartNumberEntries.map((entry) => /* @__PURE__ */ jsxs3("div", { style: { display: "contents" }, children: [
|
|
2043
|
+
/* @__PURE__ */ jsx4("dt", { style: detailLabelStyle, children: entry.label }),
|
|
2044
|
+
/* @__PURE__ */ jsx4(
|
|
1888
2045
|
"dd",
|
|
1889
2046
|
{
|
|
1890
2047
|
style: {
|
|
@@ -1895,25 +2052,39 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1895
2052
|
lineHeight: 1.45,
|
|
1896
2053
|
overflowWrap: "anywhere"
|
|
1897
2054
|
},
|
|
1898
|
-
children: entry.links.map((link, index) => /* @__PURE__ */
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
"
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
2055
|
+
children: entry.links.map((link, index) => /* @__PURE__ */ jsxs3(
|
|
2056
|
+
"span",
|
|
2057
|
+
{
|
|
2058
|
+
style: entry.label === "jlcpcb" ? { display: "block", marginTop: index > 0 ? 6 : 0 } : void 0,
|
|
2059
|
+
children: [
|
|
2060
|
+
entry.label !== "jlcpcb" && index > 0 && ", ",
|
|
2061
|
+
/* @__PURE__ */ jsx4(
|
|
2062
|
+
"a",
|
|
2063
|
+
{
|
|
2064
|
+
href: link.href,
|
|
2065
|
+
target: "_blank",
|
|
2066
|
+
rel: "noreferrer noopener",
|
|
2067
|
+
style: { color: "#2563eb", textDecoration: "underline" },
|
|
2068
|
+
children: link.partNumber
|
|
2069
|
+
}
|
|
2070
|
+
),
|
|
2071
|
+
entry.label === "jlcpcb" && /* @__PURE__ */ jsx4(
|
|
2072
|
+
JlcPartAvailability,
|
|
2073
|
+
{
|
|
2074
|
+
partNumber: link.partNumber
|
|
2075
|
+
},
|
|
2076
|
+
`${sourceComponent.source_component_id}-${link.partNumber}`
|
|
2077
|
+
)
|
|
2078
|
+
]
|
|
2079
|
+
},
|
|
2080
|
+
link.href
|
|
2081
|
+
))
|
|
1911
2082
|
}
|
|
1912
2083
|
)
|
|
1913
2084
|
] }, entry.key)),
|
|
1914
|
-
footprinterString && /* @__PURE__ */
|
|
1915
|
-
/* @__PURE__ */
|
|
1916
|
-
/* @__PURE__ */
|
|
2085
|
+
footprinterString && /* @__PURE__ */ jsxs3("div", { style: { display: "contents" }, children: [
|
|
2086
|
+
/* @__PURE__ */ jsx4("dt", { style: detailLabelStyle, children: "footprint" }),
|
|
2087
|
+
/* @__PURE__ */ jsx4(
|
|
1917
2088
|
"dd",
|
|
1918
2089
|
{
|
|
1919
2090
|
style: {
|
|
@@ -1932,7 +2103,7 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1932
2103
|
]
|
|
1933
2104
|
}
|
|
1934
2105
|
),
|
|
1935
|
-
warnings.length > 0 && /* @__PURE__ */
|
|
2106
|
+
warnings.length > 0 && /* @__PURE__ */ jsxs3(
|
|
1936
2107
|
"section",
|
|
1937
2108
|
{
|
|
1938
2109
|
"aria-label": "Component warnings",
|
|
@@ -1948,16 +2119,16 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1948
2119
|
overflowWrap: "anywhere"
|
|
1949
2120
|
},
|
|
1950
2121
|
children: [
|
|
1951
|
-
/* @__PURE__ */
|
|
2122
|
+
/* @__PURE__ */ jsxs3("strong", { children: [
|
|
1952
2123
|
"Warnings (",
|
|
1953
2124
|
warnings.length,
|
|
1954
2125
|
")"
|
|
1955
2126
|
] }),
|
|
1956
|
-
/* @__PURE__ */
|
|
2127
|
+
/* @__PURE__ */ jsx4("ul", { style: { margin: "4px 0 0", paddingLeft: "18px" }, children: warnings.map((warning, index) => /* @__PURE__ */ jsx4("li", { children: warning.message }, `${warning.type}-${index}`)) })
|
|
1957
2128
|
]
|
|
1958
2129
|
}
|
|
1959
2130
|
),
|
|
1960
|
-
footprintPreviewUrl && /* @__PURE__ */
|
|
2131
|
+
footprintPreviewUrl && /* @__PURE__ */ jsx4("div", { style: { padding: "0 4px 4px" }, children: /* @__PURE__ */ jsx4(
|
|
1961
2132
|
"div",
|
|
1962
2133
|
{
|
|
1963
2134
|
style: {
|
|
@@ -1967,7 +2138,7 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1967
2138
|
borderRadius: "2px",
|
|
1968
2139
|
background: "#f8fafc"
|
|
1969
2140
|
},
|
|
1970
|
-
children: /* @__PURE__ */
|
|
2141
|
+
children: /* @__PURE__ */ jsx4(
|
|
1971
2142
|
"img",
|
|
1972
2143
|
{
|
|
1973
2144
|
src: footprintPreviewUrl,
|
|
@@ -1990,12 +2161,12 @@ var SchematicComponentDetailsTooltip = ({
|
|
|
1990
2161
|
};
|
|
1991
2162
|
|
|
1992
2163
|
// lib/components/SchematicComponentMouseTarget.tsx
|
|
1993
|
-
import { useCallback as useCallback5, useEffect as
|
|
2164
|
+
import { useCallback as useCallback5, useEffect as useEffect10, useRef as useRef6, useState as useState6 } from "react";
|
|
1994
2165
|
|
|
1995
2166
|
// lib/hooks/useMouseEventsOverBoundingBox.ts
|
|
1996
2167
|
import {
|
|
1997
2168
|
useContext as useContext2,
|
|
1998
|
-
useEffect as
|
|
2169
|
+
useEffect as useEffect9,
|
|
1999
2170
|
useId,
|
|
2000
2171
|
useMemo as useMemo4,
|
|
2001
2172
|
useRef as useRef5,
|
|
@@ -2017,7 +2188,7 @@ var useMouseEventsOverBoundingBox = (options) => {
|
|
|
2017
2188
|
},
|
|
2018
2189
|
[]
|
|
2019
2190
|
);
|
|
2020
|
-
|
|
2191
|
+
useEffect9(() => {
|
|
2021
2192
|
context.registerBoundingBox(id, {
|
|
2022
2193
|
bounds: latestOptionsRef.current.bounds,
|
|
2023
2194
|
onClick: latestOptionsRef.current.onClick ? handleClick : void 0
|
|
@@ -2026,7 +2197,7 @@ var useMouseEventsOverBoundingBox = (options) => {
|
|
|
2026
2197
|
context.unregisterBoundingBox(id);
|
|
2027
2198
|
};
|
|
2028
2199
|
}, [context, handleClick, id]);
|
|
2029
|
-
|
|
2200
|
+
useEffect9(() => {
|
|
2030
2201
|
context.updateBoundingBox(id, {
|
|
2031
2202
|
bounds: latestOptionsRef.current.bounds,
|
|
2032
2203
|
onClick: latestOptionsRef.current.onClick ? handleClick : void 0
|
|
@@ -2050,7 +2221,7 @@ var useMouseEventsOverBoundingBox = (options) => {
|
|
|
2050
2221
|
};
|
|
2051
2222
|
|
|
2052
2223
|
// lib/components/SchematicComponentMouseTarget.tsx
|
|
2053
|
-
import { jsx as
|
|
2224
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2054
2225
|
var areMeasurementsEqual = (a, b) => {
|
|
2055
2226
|
if (!a && !b) return true;
|
|
2056
2227
|
if (!a || !b) return false;
|
|
@@ -2065,7 +2236,7 @@ var SchematicComponentMouseTarget = ({
|
|
|
2065
2236
|
showOutline,
|
|
2066
2237
|
circuitJsonKey
|
|
2067
2238
|
}) => {
|
|
2068
|
-
const [measurement, setMeasurement] =
|
|
2239
|
+
const [measurement, setMeasurement] = useState6(null);
|
|
2069
2240
|
const frameRef = useRef6(null);
|
|
2070
2241
|
const measure = useCallback5(() => {
|
|
2071
2242
|
frameRef.current = null;
|
|
@@ -2106,10 +2277,10 @@ var SchematicComponentMouseTarget = ({
|
|
|
2106
2277
|
if (frameRef.current !== null) return;
|
|
2107
2278
|
frameRef.current = window.requestAnimationFrame(measure);
|
|
2108
2279
|
}, [measure]);
|
|
2109
|
-
|
|
2280
|
+
useEffect10(() => {
|
|
2110
2281
|
scheduleMeasure();
|
|
2111
2282
|
}, [scheduleMeasure, circuitJsonKey]);
|
|
2112
|
-
|
|
2283
|
+
useEffect10(() => {
|
|
2113
2284
|
scheduleMeasure();
|
|
2114
2285
|
const svgDiv = svgDivRef.current;
|
|
2115
2286
|
const container = containerRef.current;
|
|
@@ -2154,7 +2325,7 @@ var SchematicComponentMouseTarget = ({
|
|
|
2154
2325
|
bounds,
|
|
2155
2326
|
onClick: onComponentClick ? handleClick : void 0
|
|
2156
2327
|
});
|
|
2157
|
-
|
|
2328
|
+
useEffect10(() => {
|
|
2158
2329
|
if (onHoverChange) {
|
|
2159
2330
|
onHoverChange(componentId, hovering);
|
|
2160
2331
|
}
|
|
@@ -2163,7 +2334,7 @@ var SchematicComponentMouseTarget = ({
|
|
|
2163
2334
|
return null;
|
|
2164
2335
|
}
|
|
2165
2336
|
const rect = measurement.rect;
|
|
2166
|
-
return /* @__PURE__ */
|
|
2337
|
+
return /* @__PURE__ */ jsx5(
|
|
2167
2338
|
"div",
|
|
2168
2339
|
{
|
|
2169
2340
|
style: {
|
|
@@ -2181,8 +2352,8 @@ var SchematicComponentMouseTarget = ({
|
|
|
2181
2352
|
};
|
|
2182
2353
|
|
|
2183
2354
|
// lib/components/SchematicPortMouseTarget.tsx
|
|
2184
|
-
import { useCallback as useCallback6, useEffect as
|
|
2185
|
-
import { Fragment as
|
|
2355
|
+
import { useCallback as useCallback6, useEffect as useEffect11, useRef as useRef7, useState as useState7 } from "react";
|
|
2356
|
+
import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2186
2357
|
var areMeasurementsEqual2 = (a, b) => {
|
|
2187
2358
|
if (!a && !b) return true;
|
|
2188
2359
|
if (!a || !b) return false;
|
|
@@ -2198,7 +2369,7 @@ var SchematicPortMouseTarget = ({
|
|
|
2198
2369
|
showOutline,
|
|
2199
2370
|
circuitJsonKey
|
|
2200
2371
|
}) => {
|
|
2201
|
-
const [measurement, setMeasurement] =
|
|
2372
|
+
const [measurement, setMeasurement] = useState7(null);
|
|
2202
2373
|
const frameRef = useRef7(null);
|
|
2203
2374
|
const measure = useCallback6(() => {
|
|
2204
2375
|
frameRef.current = null;
|
|
@@ -2240,10 +2411,10 @@ var SchematicPortMouseTarget = ({
|
|
|
2240
2411
|
if (frameRef.current !== null) return;
|
|
2241
2412
|
frameRef.current = window.requestAnimationFrame(measure);
|
|
2242
2413
|
}, [measure]);
|
|
2243
|
-
|
|
2414
|
+
useEffect11(() => {
|
|
2244
2415
|
scheduleMeasure();
|
|
2245
2416
|
}, [scheduleMeasure, circuitJsonKey]);
|
|
2246
|
-
|
|
2417
|
+
useEffect11(() => {
|
|
2247
2418
|
scheduleMeasure();
|
|
2248
2419
|
const svgDiv = svgDivRef.current;
|
|
2249
2420
|
const container = containerRef.current;
|
|
@@ -2288,7 +2459,7 @@ var SchematicPortMouseTarget = ({
|
|
|
2288
2459
|
bounds,
|
|
2289
2460
|
onClick: onPortClick ? handleClick : void 0
|
|
2290
2461
|
});
|
|
2291
|
-
|
|
2462
|
+
useEffect11(() => {
|
|
2292
2463
|
if (onHoverChange) {
|
|
2293
2464
|
onHoverChange(portId, hovering);
|
|
2294
2465
|
}
|
|
@@ -2297,8 +2468,8 @@ var SchematicPortMouseTarget = ({
|
|
|
2297
2468
|
return null;
|
|
2298
2469
|
}
|
|
2299
2470
|
const rect = measurement.rect;
|
|
2300
|
-
return /* @__PURE__ */
|
|
2301
|
-
/* @__PURE__ */
|
|
2471
|
+
return /* @__PURE__ */ jsxs4(Fragment4, { children: [
|
|
2472
|
+
/* @__PURE__ */ jsx6(
|
|
2302
2473
|
"div",
|
|
2303
2474
|
{
|
|
2304
2475
|
style: {
|
|
@@ -2316,7 +2487,7 @@ var SchematicPortMouseTarget = ({
|
|
|
2316
2487
|
}
|
|
2317
2488
|
}
|
|
2318
2489
|
),
|
|
2319
|
-
hovering && portLabel && /* @__PURE__ */
|
|
2490
|
+
hovering && portLabel && /* @__PURE__ */ jsx6(
|
|
2320
2491
|
"div",
|
|
2321
2492
|
{
|
|
2322
2493
|
style: {
|
|
@@ -2341,15 +2512,15 @@ var SchematicPortMouseTarget = ({
|
|
|
2341
2512
|
};
|
|
2342
2513
|
|
|
2343
2514
|
// lib/components/SchematicSearch.tsx
|
|
2344
|
-
import { useEffect as
|
|
2515
|
+
import { useEffect as useEffect12, useRef as useRef8, useState as useState8 } from "react";
|
|
2345
2516
|
|
|
2346
2517
|
// lib/components/SchematicSearchIcons.tsx
|
|
2347
|
-
import { jsx as
|
|
2518
|
+
import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2348
2519
|
var Icon = ({
|
|
2349
2520
|
children,
|
|
2350
2521
|
size,
|
|
2351
2522
|
strokeWidth
|
|
2352
|
-
}) => /* @__PURE__ */
|
|
2523
|
+
}) => /* @__PURE__ */ jsx7(
|
|
2353
2524
|
"svg",
|
|
2354
2525
|
{
|
|
2355
2526
|
width: size,
|
|
@@ -2364,31 +2535,31 @@ var Icon = ({
|
|
|
2364
2535
|
children
|
|
2365
2536
|
}
|
|
2366
2537
|
);
|
|
2367
|
-
var SearchIcon = (props) => /* @__PURE__ */
|
|
2368
|
-
/* @__PURE__ */
|
|
2369
|
-
/* @__PURE__ */
|
|
2538
|
+
var SearchIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2539
|
+
/* @__PURE__ */ jsx7("circle", { cx: "11", cy: "11", r: "8" }),
|
|
2540
|
+
/* @__PURE__ */ jsx7("path", { d: "m21 21-4.34-4.34" })
|
|
2370
2541
|
] });
|
|
2371
|
-
var CloseIcon = (props) => /* @__PURE__ */
|
|
2372
|
-
/* @__PURE__ */
|
|
2373
|
-
/* @__PURE__ */
|
|
2542
|
+
var CloseIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2543
|
+
/* @__PURE__ */ jsx7("path", { d: "M18 6 6 18" }),
|
|
2544
|
+
/* @__PURE__ */ jsx7("path", { d: "m6 6 12 12" })
|
|
2374
2545
|
] });
|
|
2375
|
-
var ComponentIcon = (props) => /* @__PURE__ */
|
|
2376
|
-
/* @__PURE__ */
|
|
2377
|
-
/* @__PURE__ */
|
|
2378
|
-
/* @__PURE__ */
|
|
2546
|
+
var ComponentIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2547
|
+
/* @__PURE__ */ jsx7("rect", { x: "4", y: "4", width: "16", height: "16", rx: "2" }),
|
|
2548
|
+
/* @__PURE__ */ jsx7("rect", { x: "8", y: "8", width: "8", height: "8", rx: "1" }),
|
|
2549
|
+
/* @__PURE__ */ jsx7("path", { d: "M7 2v2M12 2v2M17 2v2M7 20v2M12 20v2M17 20v2M2 7h2M2 12h2M2 17h2M20 7h2M20 12h2M20 17h2" })
|
|
2379
2550
|
] });
|
|
2380
|
-
var NetIcon = (props) => /* @__PURE__ */
|
|
2381
|
-
/* @__PURE__ */
|
|
2382
|
-
/* @__PURE__ */
|
|
2383
|
-
/* @__PURE__ */
|
|
2551
|
+
var NetIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2552
|
+
/* @__PURE__ */ jsx7("path", { d: "M15 6a9 9 0 0 0-9 9V3" }),
|
|
2553
|
+
/* @__PURE__ */ jsx7("circle", { cx: "18", cy: "6", r: "3" }),
|
|
2554
|
+
/* @__PURE__ */ jsx7("circle", { cx: "6", cy: "18", r: "3" })
|
|
2384
2555
|
] });
|
|
2385
|
-
var EnterIcon = (props) => /* @__PURE__ */
|
|
2386
|
-
/* @__PURE__ */
|
|
2387
|
-
/* @__PURE__ */
|
|
2556
|
+
var EnterIcon = (props) => /* @__PURE__ */ jsxs5(Icon, { ...props, children: [
|
|
2557
|
+
/* @__PURE__ */ jsx7("path", { d: "M20 4v7a4 4 0 0 1-4 4H4" }),
|
|
2558
|
+
/* @__PURE__ */ jsx7("path", { d: "m9 10-5 5 5 5" })
|
|
2388
2559
|
] });
|
|
2389
2560
|
|
|
2390
2561
|
// lib/components/SchematicSearch.tsx
|
|
2391
|
-
import { Fragment as
|
|
2562
|
+
import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2392
2563
|
var HighlightedSearchText = ({
|
|
2393
2564
|
text,
|
|
2394
2565
|
query
|
|
@@ -2404,7 +2575,7 @@ var HighlightedSearchText = ({
|
|
|
2404
2575
|
parts.push(text.slice(cursor, matchIndex));
|
|
2405
2576
|
}
|
|
2406
2577
|
parts.push(
|
|
2407
|
-
/* @__PURE__ */
|
|
2578
|
+
/* @__PURE__ */ jsx8("strong", { style: { fontWeight: 700 }, children: text.slice(matchIndex, matchIndex + normalizedQuery.length) }, `${matchIndex}-${cursor}`)
|
|
2408
2579
|
);
|
|
2409
2580
|
cursor = matchIndex + normalizedQuery.length;
|
|
2410
2581
|
matchIndex = normalizedText.indexOf(normalizedQuery, cursor);
|
|
@@ -2426,13 +2597,13 @@ var SchematicSearch = ({
|
|
|
2426
2597
|
onSelect,
|
|
2427
2598
|
viewerContainerRef
|
|
2428
2599
|
}) => {
|
|
2429
|
-
const [isOpen, setIsOpen] =
|
|
2430
|
-
const [activeResultId, setActiveResultId] =
|
|
2431
|
-
const [hoveredResultId, setHoveredResultId] =
|
|
2600
|
+
const [isOpen, setIsOpen] = useState8(false);
|
|
2601
|
+
const [activeResultId, setActiveResultId] = useState8(null);
|
|
2602
|
+
const [hoveredResultId, setHoveredResultId] = useState8(null);
|
|
2432
2603
|
const inputRef = useRef8(null);
|
|
2433
2604
|
const resultsListRef = useRef8(null);
|
|
2434
2605
|
const shortcutLabel = getShortcutLabel();
|
|
2435
|
-
|
|
2606
|
+
useEffect12(() => {
|
|
2436
2607
|
setActiveResultId((currentId) => {
|
|
2437
2608
|
if (results.some((result) => result.target.id === currentId)) {
|
|
2438
2609
|
return currentId;
|
|
@@ -2440,11 +2611,11 @@ var SchematicSearch = ({
|
|
|
2440
2611
|
return results.find((result) => result.kind === "component")?.target.id ?? results[0]?.target.id ?? null;
|
|
2441
2612
|
});
|
|
2442
2613
|
}, [results]);
|
|
2443
|
-
|
|
2614
|
+
useEffect12(() => {
|
|
2444
2615
|
if (!activeResultId) return;
|
|
2445
2616
|
resultsListRef.current?.querySelector(`[data-search-result-id="${activeResultId}"]`)?.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
2446
2617
|
}, [activeResultId]);
|
|
2447
|
-
|
|
2618
|
+
useEffect12(() => {
|
|
2448
2619
|
const handleSearchShortcut = (event) => {
|
|
2449
2620
|
if (event.key === "Escape" && isOpen) {
|
|
2450
2621
|
event.preventDefault();
|
|
@@ -2545,8 +2716,8 @@ var SchematicSearch = ({
|
|
|
2545
2716
|
};
|
|
2546
2717
|
const renderResultSection = (title, sectionResults) => {
|
|
2547
2718
|
if (sectionResults.length === 0) return null;
|
|
2548
|
-
return /* @__PURE__ */
|
|
2549
|
-
/* @__PURE__ */
|
|
2719
|
+
return /* @__PURE__ */ jsxs6("section", { children: [
|
|
2720
|
+
/* @__PURE__ */ jsx8(
|
|
2550
2721
|
"div",
|
|
2551
2722
|
{
|
|
2552
2723
|
style: {
|
|
@@ -2566,16 +2737,16 @@ var SchematicSearch = ({
|
|
|
2566
2737
|
const hovering = result.target.id === hoveredResultId;
|
|
2567
2738
|
let resultBackground = "#ffffff";
|
|
2568
2739
|
if (hovering || active) resultBackground = "#f1f3f5";
|
|
2569
|
-
let resultIcon = /* @__PURE__ */
|
|
2740
|
+
let resultIcon = /* @__PURE__ */ jsx8(NetIcon, { size: 15, strokeWidth: 1.8 });
|
|
2570
2741
|
if (result.kind === "component") {
|
|
2571
|
-
resultIcon = /* @__PURE__ */
|
|
2742
|
+
resultIcon = /* @__PURE__ */ jsx8(ComponentIcon, { size: 15, strokeWidth: 1.8 });
|
|
2572
2743
|
}
|
|
2573
2744
|
const selectResult = () => {
|
|
2574
2745
|
inputRef.current?.blur();
|
|
2575
2746
|
setActiveResultId(result.target.id);
|
|
2576
2747
|
onSelect(result);
|
|
2577
2748
|
};
|
|
2578
|
-
return /* @__PURE__ */
|
|
2749
|
+
return /* @__PURE__ */ jsxs6(
|
|
2579
2750
|
"button",
|
|
2580
2751
|
{
|
|
2581
2752
|
type: "button",
|
|
@@ -2601,7 +2772,7 @@ var SchematicSearch = ({
|
|
|
2601
2772
|
textAlign: "left"
|
|
2602
2773
|
},
|
|
2603
2774
|
children: [
|
|
2604
|
-
/* @__PURE__ */
|
|
2775
|
+
/* @__PURE__ */ jsx8(
|
|
2605
2776
|
"span",
|
|
2606
2777
|
{
|
|
2607
2778
|
style: {
|
|
@@ -2618,8 +2789,8 @@ var SchematicSearch = ({
|
|
|
2618
2789
|
children: resultIcon
|
|
2619
2790
|
}
|
|
2620
2791
|
),
|
|
2621
|
-
/* @__PURE__ */
|
|
2622
|
-
/* @__PURE__ */
|
|
2792
|
+
/* @__PURE__ */ jsxs6("span", { style: { minWidth: 0, flex: 1 }, children: [
|
|
2793
|
+
/* @__PURE__ */ jsx8(
|
|
2623
2794
|
"span",
|
|
2624
2795
|
{
|
|
2625
2796
|
style: {
|
|
@@ -2631,10 +2802,10 @@ var SchematicSearch = ({
|
|
|
2631
2802
|
textOverflow: "ellipsis",
|
|
2632
2803
|
whiteSpace: "nowrap"
|
|
2633
2804
|
},
|
|
2634
|
-
children: /* @__PURE__ */
|
|
2805
|
+
children: /* @__PURE__ */ jsx8(HighlightedSearchText, { text: result.label, query })
|
|
2635
2806
|
}
|
|
2636
2807
|
),
|
|
2637
|
-
result.detail && /* @__PURE__ */
|
|
2808
|
+
result.detail && /* @__PURE__ */ jsx8(
|
|
2638
2809
|
"span",
|
|
2639
2810
|
{
|
|
2640
2811
|
style: {
|
|
@@ -2650,7 +2821,7 @@ var SchematicSearch = ({
|
|
|
2650
2821
|
children: result.detail
|
|
2651
2822
|
}
|
|
2652
2823
|
),
|
|
2653
|
-
result.schematicSheetName && /* @__PURE__ */
|
|
2824
|
+
result.schematicSheetName && /* @__PURE__ */ jsxs6(
|
|
2654
2825
|
"span",
|
|
2655
2826
|
{
|
|
2656
2827
|
style: {
|
|
@@ -2670,7 +2841,7 @@ var SchematicSearch = ({
|
|
|
2670
2841
|
}
|
|
2671
2842
|
)
|
|
2672
2843
|
] }),
|
|
2673
|
-
active && /* @__PURE__ */
|
|
2844
|
+
active && /* @__PURE__ */ jsx8(
|
|
2674
2845
|
"span",
|
|
2675
2846
|
{
|
|
2676
2847
|
title: "Press Enter to open",
|
|
@@ -2680,7 +2851,7 @@ var SchematicSearch = ({
|
|
|
2680
2851
|
fontSize: "17px",
|
|
2681
2852
|
lineHeight: 1
|
|
2682
2853
|
},
|
|
2683
|
-
children: /* @__PURE__ */
|
|
2854
|
+
children: /* @__PURE__ */ jsx8(EnterIcon, { size: 14, strokeWidth: 1.8 })
|
|
2684
2855
|
}
|
|
2685
2856
|
)
|
|
2686
2857
|
]
|
|
@@ -2690,7 +2861,7 @@ var SchematicSearch = ({
|
|
|
2690
2861
|
})
|
|
2691
2862
|
] });
|
|
2692
2863
|
};
|
|
2693
|
-
return /* @__PURE__ */
|
|
2864
|
+
return /* @__PURE__ */ jsx8(
|
|
2694
2865
|
"div",
|
|
2695
2866
|
{
|
|
2696
2867
|
"data-schematic-search": true,
|
|
@@ -2703,7 +2874,7 @@ var SchematicSearch = ({
|
|
|
2703
2874
|
zIndex: zIndexMap.schematicSearch,
|
|
2704
2875
|
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'
|
|
2705
2876
|
},
|
|
2706
|
-
children: !isOpen ? /* @__PURE__ */
|
|
2877
|
+
children: !isOpen ? /* @__PURE__ */ jsx8(
|
|
2707
2878
|
"button",
|
|
2708
2879
|
{
|
|
2709
2880
|
type: "button",
|
|
@@ -2734,9 +2905,9 @@ var SchematicSearch = ({
|
|
|
2734
2905
|
cursor: "pointer",
|
|
2735
2906
|
boxShadow: "0 2px 4px rgba(0,0,0,0.1)"
|
|
2736
2907
|
},
|
|
2737
|
-
children: /* @__PURE__ */
|
|
2908
|
+
children: /* @__PURE__ */ jsx8(SearchIcon, { size: 16, strokeWidth: 2 })
|
|
2738
2909
|
}
|
|
2739
|
-
) : /* @__PURE__ */
|
|
2910
|
+
) : /* @__PURE__ */ jsxs6(
|
|
2740
2911
|
"div",
|
|
2741
2912
|
{
|
|
2742
2913
|
onKeyDown: handleSearchKeyDown,
|
|
@@ -2749,7 +2920,7 @@ var SchematicSearch = ({
|
|
|
2749
2920
|
boxShadow: "0 2px 4px rgba(0,0,0,0.1)"
|
|
2750
2921
|
},
|
|
2751
2922
|
children: [
|
|
2752
|
-
/* @__PURE__ */
|
|
2923
|
+
/* @__PURE__ */ jsxs6(
|
|
2753
2924
|
"div",
|
|
2754
2925
|
{
|
|
2755
2926
|
style: {
|
|
@@ -2762,8 +2933,8 @@ var SchematicSearch = ({
|
|
|
2762
2933
|
borderBottom: searchHeaderBorder
|
|
2763
2934
|
},
|
|
2764
2935
|
children: [
|
|
2765
|
-
/* @__PURE__ */
|
|
2766
|
-
/* @__PURE__ */
|
|
2936
|
+
/* @__PURE__ */ jsx8(SearchIcon, { size: 15, strokeWidth: 2 }),
|
|
2937
|
+
/* @__PURE__ */ jsx8(
|
|
2767
2938
|
"input",
|
|
2768
2939
|
{
|
|
2769
2940
|
ref: inputRef,
|
|
@@ -2783,7 +2954,7 @@ var SchematicSearch = ({
|
|
|
2783
2954
|
}
|
|
2784
2955
|
}
|
|
2785
2956
|
),
|
|
2786
|
-
query && results.length > 0 ? /* @__PURE__ */
|
|
2957
|
+
query && results.length > 0 ? /* @__PURE__ */ jsx8(
|
|
2787
2958
|
"span",
|
|
2788
2959
|
{
|
|
2789
2960
|
style: {
|
|
@@ -2794,7 +2965,7 @@ var SchematicSearch = ({
|
|
|
2794
2965
|
},
|
|
2795
2966
|
children: resultCountLabel
|
|
2796
2967
|
}
|
|
2797
|
-
) : /* @__PURE__ */
|
|
2968
|
+
) : /* @__PURE__ */ jsx8(
|
|
2798
2969
|
"kbd",
|
|
2799
2970
|
{
|
|
2800
2971
|
style: {
|
|
@@ -2811,7 +2982,7 @@ var SchematicSearch = ({
|
|
|
2811
2982
|
children: shortcutLabel
|
|
2812
2983
|
}
|
|
2813
2984
|
),
|
|
2814
|
-
isOpen && /* @__PURE__ */
|
|
2985
|
+
isOpen && /* @__PURE__ */ jsx8(
|
|
2815
2986
|
"button",
|
|
2816
2987
|
{
|
|
2817
2988
|
type: "button",
|
|
@@ -2834,13 +3005,13 @@ var SchematicSearch = ({
|
|
|
2834
3005
|
padding: 0,
|
|
2835
3006
|
lineHeight: 1
|
|
2836
3007
|
},
|
|
2837
|
-
children: /* @__PURE__ */
|
|
3008
|
+
children: /* @__PURE__ */ jsx8(CloseIcon, { size: 16, strokeWidth: 2 })
|
|
2838
3009
|
}
|
|
2839
3010
|
)
|
|
2840
3011
|
]
|
|
2841
3012
|
}
|
|
2842
3013
|
),
|
|
2843
|
-
query && /* @__PURE__ */
|
|
3014
|
+
query && /* @__PURE__ */ jsx8(
|
|
2844
3015
|
"div",
|
|
2845
3016
|
{
|
|
2846
3017
|
ref: resultsListRef,
|
|
@@ -2855,7 +3026,7 @@ var SchematicSearch = ({
|
|
|
2855
3026
|
},
|
|
2856
3027
|
onWheel: (event) => event.stopPropagation(),
|
|
2857
3028
|
onTouchMove: (event) => event.stopPropagation(),
|
|
2858
|
-
children: results.length === 0 ? /* @__PURE__ */
|
|
3029
|
+
children: results.length === 0 ? /* @__PURE__ */ jsx8(
|
|
2859
3030
|
"div",
|
|
2860
3031
|
{
|
|
2861
3032
|
style: {
|
|
@@ -2865,7 +3036,7 @@ var SchematicSearch = ({
|
|
|
2865
3036
|
},
|
|
2866
3037
|
children: "No matching components or nets"
|
|
2867
3038
|
}
|
|
2868
|
-
) : /* @__PURE__ */
|
|
3039
|
+
) : /* @__PURE__ */ jsxs6(Fragment5, { children: [
|
|
2869
3040
|
renderResultSection("components", componentResults),
|
|
2870
3041
|
renderResultSection("nets", netResults)
|
|
2871
3042
|
] })
|
|
@@ -2879,9 +3050,9 @@ var SchematicSearch = ({
|
|
|
2879
3050
|
};
|
|
2880
3051
|
|
|
2881
3052
|
// lib/components/SchematicSheetSelector.tsx
|
|
2882
|
-
import { useState as
|
|
3053
|
+
import { useState as useState9 } from "react";
|
|
2883
3054
|
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
2884
|
-
import { Fragment as
|
|
3055
|
+
import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2885
3056
|
var FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
2886
3057
|
var contentStyles = {
|
|
2887
3058
|
backgroundColor: "#ffffff",
|
|
@@ -2931,7 +3102,7 @@ var MENU_CSS = `
|
|
|
2931
3102
|
.sv-sheet-chevron { transition: transform 0.2s ease; }
|
|
2932
3103
|
[data-state="open"] > .sv-sheet-chevron { transform: rotate(180deg); }
|
|
2933
3104
|
`;
|
|
2934
|
-
var CheckIcon = () => /* @__PURE__ */
|
|
3105
|
+
var CheckIcon = () => /* @__PURE__ */ jsx9(
|
|
2935
3106
|
"svg",
|
|
2936
3107
|
{
|
|
2937
3108
|
width: "14",
|
|
@@ -2943,10 +3114,10 @@ var CheckIcon = () => /* @__PURE__ */ jsx8(
|
|
|
2943
3114
|
strokeLinecap: "round",
|
|
2944
3115
|
strokeLinejoin: "round",
|
|
2945
3116
|
"aria-hidden": "true",
|
|
2946
|
-
children: /* @__PURE__ */
|
|
3117
|
+
children: /* @__PURE__ */ jsx9("path", { d: "M20 6 9 17l-5-5" })
|
|
2947
3118
|
}
|
|
2948
3119
|
);
|
|
2949
|
-
var ChevronDownIcon = ({ className }) => /* @__PURE__ */
|
|
3120
|
+
var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx9(
|
|
2950
3121
|
"svg",
|
|
2951
3122
|
{
|
|
2952
3123
|
className,
|
|
@@ -2960,7 +3131,7 @@ var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx8(
|
|
|
2960
3131
|
strokeLinejoin: "round",
|
|
2961
3132
|
style: { opacity: 0.6, flexShrink: 0 },
|
|
2962
3133
|
"aria-hidden": "true",
|
|
2963
|
-
children: /* @__PURE__ */
|
|
3134
|
+
children: /* @__PURE__ */ jsx9("path", { d: "m6 9 6 6 6-6" })
|
|
2964
3135
|
}
|
|
2965
3136
|
);
|
|
2966
3137
|
var SchematicSheetSelector = ({
|
|
@@ -2968,16 +3139,16 @@ var SchematicSheetSelector = ({
|
|
|
2968
3139
|
selectedSheetId,
|
|
2969
3140
|
onSelectSheet
|
|
2970
3141
|
}) => {
|
|
2971
|
-
const [open, setOpen] =
|
|
3142
|
+
const [open, setOpen] = useState9(false);
|
|
2972
3143
|
if (sheets.length <= 1) return null;
|
|
2973
3144
|
const selectedSheet = sheets.find(
|
|
2974
3145
|
(s) => s.schematic_sheet_id === selectedSheetId
|
|
2975
3146
|
);
|
|
2976
3147
|
const selectedLabel = selectedSheet?.name ?? "Select sheet";
|
|
2977
|
-
return /* @__PURE__ */
|
|
2978
|
-
/* @__PURE__ */
|
|
2979
|
-
/* @__PURE__ */
|
|
2980
|
-
/* @__PURE__ */
|
|
3148
|
+
return /* @__PURE__ */ jsxs7(Fragment6, { children: [
|
|
3149
|
+
/* @__PURE__ */ jsx9("style", { children: MENU_CSS }),
|
|
3150
|
+
/* @__PURE__ */ jsxs7(DropdownMenu.Root, { open, onOpenChange: setOpen, modal: false, children: [
|
|
3151
|
+
/* @__PURE__ */ jsx9(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs7(
|
|
2981
3152
|
"button",
|
|
2982
3153
|
{
|
|
2983
3154
|
type: "button",
|
|
@@ -3002,13 +3173,13 @@ var SchematicSheetSelector = ({
|
|
|
3002
3173
|
fontFamily: FONT_FAMILY
|
|
3003
3174
|
},
|
|
3004
3175
|
children: [
|
|
3005
|
-
/* @__PURE__ */
|
|
3006
|
-
/* @__PURE__ */
|
|
3007
|
-
/* @__PURE__ */
|
|
3176
|
+
/* @__PURE__ */ jsx9("span", { style: { color: "#888888", flexShrink: 0 }, children: "Sheet:" }),
|
|
3177
|
+
/* @__PURE__ */ jsx9("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: selectedLabel }),
|
|
3178
|
+
/* @__PURE__ */ jsx9(ChevronDownIcon, { className: "sv-sheet-chevron" })
|
|
3008
3179
|
]
|
|
3009
3180
|
}
|
|
3010
3181
|
) }),
|
|
3011
|
-
/* @__PURE__ */
|
|
3182
|
+
/* @__PURE__ */ jsx9(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx9(
|
|
3012
3183
|
DropdownMenu.Content,
|
|
3013
3184
|
{
|
|
3014
3185
|
style: contentStyles,
|
|
@@ -3018,7 +3189,7 @@ var SchematicSheetSelector = ({
|
|
|
3018
3189
|
collisionPadding: 10,
|
|
3019
3190
|
children: sheets.map((sheet) => {
|
|
3020
3191
|
const selected = sheet.schematic_sheet_id === selectedSheetId;
|
|
3021
|
-
return /* @__PURE__ */
|
|
3192
|
+
return /* @__PURE__ */ jsxs7(
|
|
3022
3193
|
DropdownMenu.Item,
|
|
3023
3194
|
{
|
|
3024
3195
|
className: "sv-sheet-item",
|
|
@@ -3030,8 +3201,8 @@ var SchematicSheetSelector = ({
|
|
|
3030
3201
|
setOpen(false);
|
|
3031
3202
|
},
|
|
3032
3203
|
children: [
|
|
3033
|
-
/* @__PURE__ */
|
|
3034
|
-
/* @__PURE__ */
|
|
3204
|
+
/* @__PURE__ */ jsx9("span", { style: iconSlotStyles, children: selected && /* @__PURE__ */ jsx9(CheckIcon, {}) }),
|
|
3205
|
+
/* @__PURE__ */ jsx9("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: sheet.name })
|
|
3035
3206
|
]
|
|
3036
3207
|
},
|
|
3037
3208
|
sheet.schematic_sheet_id
|
|
@@ -3044,14 +3215,14 @@ var SchematicSheetSelector = ({
|
|
|
3044
3215
|
};
|
|
3045
3216
|
|
|
3046
3217
|
// lib/components/SchematicWarningsButton.tsx
|
|
3047
|
-
import { jsx as
|
|
3218
|
+
import { jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
3048
3219
|
var SchematicWarningsButton = ({
|
|
3049
3220
|
count,
|
|
3050
3221
|
showWarnings,
|
|
3051
3222
|
onToggle
|
|
3052
3223
|
}) => {
|
|
3053
3224
|
const label = `${showWarnings ? "Hide" : "Show"} ${count} ${count === 1 ? "warning" : "warnings"}`;
|
|
3054
|
-
return /* @__PURE__ */
|
|
3225
|
+
return /* @__PURE__ */ jsxs8(
|
|
3055
3226
|
"button",
|
|
3056
3227
|
{
|
|
3057
3228
|
type: "button",
|
|
@@ -3081,7 +3252,7 @@ var SchematicWarningsButton = ({
|
|
|
3081
3252
|
fontWeight: 600
|
|
3082
3253
|
},
|
|
3083
3254
|
children: [
|
|
3084
|
-
/* @__PURE__ */
|
|
3255
|
+
/* @__PURE__ */ jsxs8(
|
|
3085
3256
|
"svg",
|
|
3086
3257
|
{
|
|
3087
3258
|
width: "16",
|
|
@@ -3094,12 +3265,12 @@ var SchematicWarningsButton = ({
|
|
|
3094
3265
|
strokeLinejoin: "round",
|
|
3095
3266
|
"aria-hidden": "true",
|
|
3096
3267
|
children: [
|
|
3097
|
-
/* @__PURE__ */
|
|
3098
|
-
/* @__PURE__ */
|
|
3268
|
+
/* @__PURE__ */ jsx10("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" }),
|
|
3269
|
+
/* @__PURE__ */ jsx10("path", { d: "M12 9v4m0 4h.01" })
|
|
3099
3270
|
]
|
|
3100
3271
|
}
|
|
3101
3272
|
),
|
|
3102
|
-
/* @__PURE__ */
|
|
3273
|
+
/* @__PURE__ */ jsx10("span", { children: count })
|
|
3103
3274
|
]
|
|
3104
3275
|
}
|
|
3105
3276
|
);
|
|
@@ -3113,7 +3284,7 @@ import { useMemo as useMemo5 } from "react";
|
|
|
3113
3284
|
// package.json
|
|
3114
3285
|
var package_default = {
|
|
3115
3286
|
name: "@tscircuit/schematic-viewer",
|
|
3116
|
-
version: "2.0.
|
|
3287
|
+
version: "2.0.101",
|
|
3117
3288
|
repository: {
|
|
3118
3289
|
type: "git",
|
|
3119
3290
|
url: "https://github.com/tscircuit/schematic-viewer"
|
|
@@ -3169,7 +3340,7 @@ var package_default = {
|
|
|
3169
3340
|
};
|
|
3170
3341
|
|
|
3171
3342
|
// lib/components/ViewMenu.tsx
|
|
3172
|
-
import { jsx as
|
|
3343
|
+
import { Fragment as Fragment7, jsx as jsx11, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
3173
3344
|
var FONT_FAMILY2 = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
3174
3345
|
var contentStyles2 = {
|
|
3175
3346
|
backgroundColor: "#262626",
|
|
@@ -3218,7 +3389,7 @@ var HIGHLIGHT_CSS = `
|
|
|
3218
3389
|
.sv-vm-item:hover:not([data-disabled]) { background-color: #404040; }
|
|
3219
3390
|
.sv-vm-item[data-disabled] { opacity: 0.45; cursor: not-allowed; }
|
|
3220
3391
|
`;
|
|
3221
|
-
var CheckIcon2 = () => /* @__PURE__ */
|
|
3392
|
+
var CheckIcon2 = () => /* @__PURE__ */ jsx11(
|
|
3222
3393
|
"svg",
|
|
3223
3394
|
{
|
|
3224
3395
|
width: "14",
|
|
@@ -3230,10 +3401,13 @@ var CheckIcon2 = () => /* @__PURE__ */ jsx10(
|
|
|
3230
3401
|
strokeLinecap: "round",
|
|
3231
3402
|
strokeLinejoin: "round",
|
|
3232
3403
|
"aria-hidden": "true",
|
|
3233
|
-
children: /* @__PURE__ */
|
|
3404
|
+
children: /* @__PURE__ */ jsx11("path", { d: "M20 6 9 17l-5-5" })
|
|
3234
3405
|
}
|
|
3235
3406
|
);
|
|
3236
3407
|
var ViewMenu = ({
|
|
3408
|
+
isComponentMenu = false,
|
|
3409
|
+
pcbComponent,
|
|
3410
|
+
onViewPcbComponent,
|
|
3237
3411
|
netLocations = [],
|
|
3238
3412
|
onSelectNetLocation,
|
|
3239
3413
|
circuitJson,
|
|
@@ -3284,7 +3458,8 @@ var ViewMenu = ({
|
|
|
3284
3458
|
return false;
|
|
3285
3459
|
}
|
|
3286
3460
|
}, [circuitJsonKey]);
|
|
3287
|
-
|
|
3461
|
+
if (isComponentMenu && (!pcbComponent || !onViewPcbComponent)) return null;
|
|
3462
|
+
return /* @__PURE__ */ jsx11(
|
|
3288
3463
|
"div",
|
|
3289
3464
|
{
|
|
3290
3465
|
ref: menuRef,
|
|
@@ -3295,9 +3470,9 @@ var ViewMenu = ({
|
|
|
3295
3470
|
width: 0,
|
|
3296
3471
|
height: 0
|
|
3297
3472
|
},
|
|
3298
|
-
children: /* @__PURE__ */
|
|
3299
|
-
/* @__PURE__ */
|
|
3300
|
-
/* @__PURE__ */
|
|
3473
|
+
children: /* @__PURE__ */ jsxs9(DropdownMenu2.Root, { open: true, onOpenChange, modal: false, children: [
|
|
3474
|
+
/* @__PURE__ */ jsx11(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx11("div", { style: { position: "absolute", width: 1, height: 1 } }) }),
|
|
3475
|
+
/* @__PURE__ */ jsx11(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsxs9(
|
|
3301
3476
|
DropdownMenu2.Content,
|
|
3302
3477
|
{
|
|
3303
3478
|
style: contentStyles2,
|
|
@@ -3306,20 +3481,35 @@ var ViewMenu = ({
|
|
|
3306
3481
|
collisionPadding: 10,
|
|
3307
3482
|
avoidCollisions: true,
|
|
3308
3483
|
children: [
|
|
3309
|
-
/* @__PURE__ */
|
|
3310
|
-
|
|
3311
|
-
|
|
3484
|
+
/* @__PURE__ */ jsx11("style", { children: HIGHLIGHT_CSS }),
|
|
3485
|
+
pcbComponent && onViewPcbComponent && /* @__PURE__ */ jsx11(Fragment7, { children: /* @__PURE__ */ jsxs9(
|
|
3486
|
+
DropdownMenu2.Item,
|
|
3487
|
+
{
|
|
3488
|
+
className: "sv-vm-item",
|
|
3489
|
+
style: itemStyles2,
|
|
3490
|
+
onSelect: () => {
|
|
3491
|
+
onOpenChange(false);
|
|
3492
|
+
onViewPcbComponent(pcbComponent);
|
|
3493
|
+
},
|
|
3494
|
+
children: [
|
|
3495
|
+
/* @__PURE__ */ jsx11("span", { style: iconSlotStyles2, children: "\u2197" }),
|
|
3496
|
+
/* @__PURE__ */ jsx11("span", { children: "Show on PCB" })
|
|
3497
|
+
]
|
|
3498
|
+
}
|
|
3499
|
+
) }),
|
|
3500
|
+
!isComponentMenu && netLocations.length > 0 && /* @__PURE__ */ jsxs9(DropdownMenu2.Sub, { children: [
|
|
3501
|
+
/* @__PURE__ */ jsxs9(
|
|
3312
3502
|
DropdownMenu2.SubTrigger,
|
|
3313
3503
|
{
|
|
3314
3504
|
className: "sv-vm-item",
|
|
3315
3505
|
style: itemStyles2,
|
|
3316
3506
|
children: [
|
|
3317
3507
|
"Net Locations ",
|
|
3318
|
-
/* @__PURE__ */
|
|
3508
|
+
/* @__PURE__ */ jsx11("span", { style: { marginLeft: "auto" }, children: "\u203A" })
|
|
3319
3509
|
]
|
|
3320
3510
|
}
|
|
3321
3511
|
),
|
|
3322
|
-
/* @__PURE__ */
|
|
3512
|
+
/* @__PURE__ */ jsx11(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx11(
|
|
3323
3513
|
DropdownMenu2.SubContent,
|
|
3324
3514
|
{
|
|
3325
3515
|
style: {
|
|
@@ -3328,7 +3518,7 @@ var ViewMenu = ({
|
|
|
3328
3518
|
overflowY: "auto"
|
|
3329
3519
|
},
|
|
3330
3520
|
collisionPadding: 10,
|
|
3331
|
-
children: netLocations.map((location, index) => /* @__PURE__ */
|
|
3521
|
+
children: netLocations.map((location, index) => /* @__PURE__ */ jsx11(
|
|
3332
3522
|
DropdownMenu2.Item,
|
|
3333
3523
|
{
|
|
3334
3524
|
className: "sv-vm-item",
|
|
@@ -3341,103 +3531,105 @@ var ViewMenu = ({
|
|
|
3341
3531
|
}
|
|
3342
3532
|
) })
|
|
3343
3533
|
] }),
|
|
3344
|
-
/* @__PURE__ */
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
|
|
3351
|
-
|
|
3352
|
-
|
|
3353
|
-
event
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
event
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
event
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
|
|
3402
|
-
|
|
3403
|
-
|
|
3404
|
-
|
|
3405
|
-
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
|
|
3425
|
-
|
|
3426
|
-
|
|
3427
|
-
|
|
3428
|
-
|
|
3429
|
-
|
|
3430
|
-
|
|
3431
|
-
|
|
3432
|
-
|
|
3433
|
-
|
|
3434
|
-
|
|
3435
|
-
|
|
3436
|
-
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3534
|
+
!isComponentMenu && /* @__PURE__ */ jsxs9(Fragment7, { children: [
|
|
3535
|
+
/* @__PURE__ */ jsxs9(
|
|
3536
|
+
DropdownMenu2.Item,
|
|
3537
|
+
{
|
|
3538
|
+
className: "sv-vm-item",
|
|
3539
|
+
style: itemStyles2,
|
|
3540
|
+
disabled: !hasPorts,
|
|
3541
|
+
title: hasPorts ? void 0 : "No ports found in this schematic",
|
|
3542
|
+
onSelect: (event) => event.preventDefault(),
|
|
3543
|
+
onPointerDown: (event) => {
|
|
3544
|
+
event.preventDefault();
|
|
3545
|
+
if (hasPorts) onTogglePorts(!showPorts);
|
|
3546
|
+
},
|
|
3547
|
+
children: [
|
|
3548
|
+
/* @__PURE__ */ jsx11("span", { style: iconSlotStyles2, children: showPorts && /* @__PURE__ */ jsx11(CheckIcon2, {}) }),
|
|
3549
|
+
/* @__PURE__ */ jsx11("span", { children: "Show Schematic Ports" })
|
|
3550
|
+
]
|
|
3551
|
+
}
|
|
3552
|
+
),
|
|
3553
|
+
/* @__PURE__ */ jsxs9(
|
|
3554
|
+
DropdownMenu2.Item,
|
|
3555
|
+
{
|
|
3556
|
+
className: "sv-vm-item",
|
|
3557
|
+
style: itemStyles2,
|
|
3558
|
+
disabled: !hasGroups,
|
|
3559
|
+
title: hasGroups ? void 0 : "No groups found in this schematic",
|
|
3560
|
+
onSelect: (event) => event.preventDefault(),
|
|
3561
|
+
onPointerDown: (event) => {
|
|
3562
|
+
event.preventDefault();
|
|
3563
|
+
if (hasGroups) onToggleGroups(!showGroups);
|
|
3564
|
+
},
|
|
3565
|
+
children: [
|
|
3566
|
+
/* @__PURE__ */ jsx11("span", { style: iconSlotStyles2, children: showGroups && /* @__PURE__ */ jsx11(CheckIcon2, {}) }),
|
|
3567
|
+
/* @__PURE__ */ jsx11("span", { children: "View Schematic Groups" })
|
|
3568
|
+
]
|
|
3569
|
+
}
|
|
3570
|
+
),
|
|
3571
|
+
/* @__PURE__ */ jsxs9(
|
|
3572
|
+
DropdownMenu2.Item,
|
|
3573
|
+
{
|
|
3574
|
+
className: "sv-vm-item",
|
|
3575
|
+
style: itemStyles2,
|
|
3576
|
+
onSelect: (event) => event.preventDefault(),
|
|
3577
|
+
onPointerDown: (event) => {
|
|
3578
|
+
event.preventDefault();
|
|
3579
|
+
onToggleGrid(!showGrid);
|
|
3580
|
+
},
|
|
3581
|
+
children: [
|
|
3582
|
+
/* @__PURE__ */ jsx11("span", { style: iconSlotStyles2, children: showGrid && /* @__PURE__ */ jsx11(CheckIcon2, {}) }),
|
|
3583
|
+
/* @__PURE__ */ jsx11("span", { children: "Show Grid" })
|
|
3584
|
+
]
|
|
3585
|
+
}
|
|
3586
|
+
),
|
|
3587
|
+
/* @__PURE__ */ jsxs9(
|
|
3588
|
+
DropdownMenu2.CheckboxItem,
|
|
3589
|
+
{
|
|
3590
|
+
className: "sv-vm-item",
|
|
3591
|
+
style: itemStyles2,
|
|
3592
|
+
checked: showWarnings,
|
|
3593
|
+
onCheckedChange: onToggleWarnings,
|
|
3594
|
+
onSelect: (event) => event.preventDefault(),
|
|
3595
|
+
children: [
|
|
3596
|
+
/* @__PURE__ */ jsx11("span", { style: iconSlotStyles2, children: /* @__PURE__ */ jsx11(DropdownMenu2.ItemIndicator, { children: /* @__PURE__ */ jsx11(CheckIcon2, {}) }) }),
|
|
3597
|
+
/* @__PURE__ */ jsx11("span", { children: "Show Warnings" })
|
|
3598
|
+
]
|
|
3599
|
+
}
|
|
3600
|
+
),
|
|
3601
|
+
/* @__PURE__ */ jsx11(DropdownMenu2.Separator, { style: separatorStyles }),
|
|
3602
|
+
/* @__PURE__ */ jsxs9(
|
|
3603
|
+
DropdownMenu2.Item,
|
|
3604
|
+
{
|
|
3605
|
+
className: "sv-vm-item",
|
|
3606
|
+
style: itemStyles2,
|
|
3607
|
+
onSelect: onRunStyleAnalysis,
|
|
3608
|
+
children: [
|
|
3609
|
+
/* @__PURE__ */ jsx11("span", { style: iconSlotStyles2 }),
|
|
3610
|
+
/* @__PURE__ */ jsx11("span", { children: "Run Style Analysis" })
|
|
3611
|
+
]
|
|
3612
|
+
}
|
|
3613
|
+
),
|
|
3614
|
+
/* @__PURE__ */ jsx11(DropdownMenu2.Separator, { style: separatorStyles }),
|
|
3615
|
+
/* @__PURE__ */ jsxs9(
|
|
3616
|
+
"div",
|
|
3617
|
+
{
|
|
3618
|
+
style: {
|
|
3619
|
+
padding: "4px 8px 4px 32px",
|
|
3620
|
+
fontSize: 11,
|
|
3621
|
+
opacity: 0.35,
|
|
3622
|
+
color: "#a1a1aa",
|
|
3623
|
+
letterSpacing: "0.2px",
|
|
3624
|
+
fontFamily: FONT_FAMILY2
|
|
3625
|
+
},
|
|
3626
|
+
children: [
|
|
3627
|
+
"@tscircuit/schematic-viewer@",
|
|
3628
|
+
String(package_default?.version)
|
|
3629
|
+
]
|
|
3630
|
+
}
|
|
3631
|
+
)
|
|
3632
|
+
] })
|
|
3441
3633
|
]
|
|
3442
3634
|
}
|
|
3443
3635
|
) })
|
|
@@ -3447,7 +3639,7 @@ var ViewMenu = ({
|
|
|
3447
3639
|
};
|
|
3448
3640
|
|
|
3449
3641
|
// lib/components/SchematicViewer.tsx
|
|
3450
|
-
import { jsx as
|
|
3642
|
+
import { jsx as jsx12, jsxs as jsxs10 } from "react/jsx-runtime";
|
|
3451
3643
|
var SchematicViewer = ({
|
|
3452
3644
|
circuitJson,
|
|
3453
3645
|
containerStyle,
|
|
@@ -3463,6 +3655,7 @@ var SchematicViewer = ({
|
|
|
3463
3655
|
onSchematicSheetChange,
|
|
3464
3656
|
searchEnabled = true,
|
|
3465
3657
|
controller,
|
|
3658
|
+
onViewPcbComponent,
|
|
3466
3659
|
css,
|
|
3467
3660
|
className
|
|
3468
3661
|
}) => {
|
|
@@ -3486,7 +3679,7 @@ var SchematicViewer = ({
|
|
|
3486
3679
|
}, [circuitJsonKey]);
|
|
3487
3680
|
const hasMultipleSheets = schematicSheets.length > 1;
|
|
3488
3681
|
const defaultSheetId = schematicSheets[0]?.schematic_sheet_id;
|
|
3489
|
-
const [selectedSheetId, setSelectedSheetId] =
|
|
3682
|
+
const [selectedSheetId, setSelectedSheetId] = useState10(
|
|
3490
3683
|
() => {
|
|
3491
3684
|
const stored = getStoredString(STORAGE_KEYS.SELECTED_SCHEMATIC_SHEET);
|
|
3492
3685
|
if (stored && schematicSheets.some((s) => s.schematic_sheet_id === stored)) {
|
|
@@ -3495,7 +3688,7 @@ var SchematicViewer = ({
|
|
|
3495
3688
|
return defaultSheetId;
|
|
3496
3689
|
}
|
|
3497
3690
|
);
|
|
3498
|
-
|
|
3691
|
+
useEffect13(() => {
|
|
3499
3692
|
const stillExists = selectedSheetId !== void 0 && schematicSheets.some((s) => s.schematic_sheet_id === selectedSheetId);
|
|
3500
3693
|
if (!stillExists) {
|
|
3501
3694
|
setSelectedSheetId(defaultSheetId);
|
|
@@ -3510,31 +3703,31 @@ var SchematicViewer = ({
|
|
|
3510
3703
|
},
|
|
3511
3704
|
[onSchematicSheetChange]
|
|
3512
3705
|
);
|
|
3513
|
-
const [showGridInternal, setShowGridInternal] =
|
|
3514
|
-
const [analysisCircuitJson, setAnalysisCircuitJson] =
|
|
3515
|
-
const [showWarnings, setShowWarnings] =
|
|
3706
|
+
const [showGridInternal, setShowGridInternal] = useState10(false);
|
|
3707
|
+
const [analysisCircuitJson, setAnalysisCircuitJson] = useState10(null);
|
|
3708
|
+
const [showWarnings, setShowWarnings] = useState10(false);
|
|
3516
3709
|
const warningCount = circuitJson.filter(
|
|
3517
3710
|
(element) => element.type.startsWith("schematic_") && element.type.endsWith("_warning")
|
|
3518
3711
|
).length;
|
|
3519
3712
|
const showGrid = debugGrid || showGridInternal;
|
|
3520
|
-
const [isInteractionEnabled, setIsInteractionEnabled] =
|
|
3713
|
+
const [isInteractionEnabled, setIsInteractionEnabled] = useState10(
|
|
3521
3714
|
!clickToInteractEnabled
|
|
3522
3715
|
);
|
|
3523
|
-
const [showSchematicGroups, setShowSchematicGroups] =
|
|
3716
|
+
const [showSchematicGroups, setShowSchematicGroups] = useState10(() => {
|
|
3524
3717
|
if (disableGroups) return false;
|
|
3525
3718
|
return getStoredBoolean(STORAGE_KEYS.IS_SHOWING_SCHEMATIC_GROUPS, false);
|
|
3526
3719
|
});
|
|
3527
|
-
const [showSchematicPortsInternal, setShowSchematicPortsInternal] =
|
|
3720
|
+
const [showSchematicPortsInternal, setShowSchematicPortsInternal] = useState10(
|
|
3528
3721
|
() => showSchematicPorts ?? getStoredBoolean(STORAGE_KEYS.IS_SHOWING_SCHEMATIC_PORTS, false)
|
|
3529
3722
|
);
|
|
3530
|
-
|
|
3723
|
+
useEffect13(() => {
|
|
3531
3724
|
if (showSchematicPorts !== void 0) {
|
|
3532
3725
|
setShowSchematicPortsInternal(showSchematicPorts);
|
|
3533
3726
|
}
|
|
3534
3727
|
}, [showSchematicPorts]);
|
|
3535
|
-
const [isHoveringClickableComponent, setIsHoveringClickableComponent] =
|
|
3728
|
+
const [isHoveringClickableComponent, setIsHoveringClickableComponent] = useState10(false);
|
|
3536
3729
|
const hoveringComponentsRef = useRef9(/* @__PURE__ */ new Set());
|
|
3537
|
-
const [selectedSchematicComponent, setSelectedSchematicComponent] =
|
|
3730
|
+
const [selectedSchematicComponent, setSelectedSchematicComponent] = useState10(null);
|
|
3538
3731
|
const handleComponentHoverChange = useCallback7(
|
|
3539
3732
|
(componentId, isHovering) => {
|
|
3540
3733
|
if (isHovering) {
|
|
@@ -3546,7 +3739,7 @@ var SchematicViewer = ({
|
|
|
3546
3739
|
},
|
|
3547
3740
|
[]
|
|
3548
3741
|
);
|
|
3549
|
-
const [isHoveringClickablePort, setIsHoveringClickablePort] =
|
|
3742
|
+
const [isHoveringClickablePort, setIsHoveringClickablePort] = useState10(false);
|
|
3550
3743
|
const hoveringPortsRef = useRef9(/* @__PURE__ */ new Set());
|
|
3551
3744
|
const handlePortHoverChange = useCallback7(
|
|
3552
3745
|
(portId, isHovering) => {
|
|
@@ -3699,10 +3892,10 @@ var SchematicViewer = ({
|
|
|
3699
3892
|
},
|
|
3700
3893
|
[containerRef, onSchematicComponentClicked]
|
|
3701
3894
|
);
|
|
3702
|
-
|
|
3895
|
+
useEffect13(() => {
|
|
3703
3896
|
setSelectedSchematicComponent(null);
|
|
3704
3897
|
}, [circuitJsonKey, activeSheetId]);
|
|
3705
|
-
|
|
3898
|
+
useEffect13(() => {
|
|
3706
3899
|
if (!selectedSchematicComponent) return;
|
|
3707
3900
|
const handleKeyDown = (event) => {
|
|
3708
3901
|
if (event.key === "Escape") {
|
|
@@ -3786,7 +3979,7 @@ var SchematicViewer = ({
|
|
|
3786
3979
|
enabled: netHoverHighlightEnabled
|
|
3787
3980
|
});
|
|
3788
3981
|
const svgDiv = useMemo6(
|
|
3789
|
-
() => /* @__PURE__ */
|
|
3982
|
+
() => /* @__PURE__ */ jsx12(
|
|
3790
3983
|
"div",
|
|
3791
3984
|
{
|
|
3792
3985
|
ref: svgDivRef,
|
|
@@ -3801,10 +3994,10 @@ var SchematicViewer = ({
|
|
|
3801
3994
|
[svgString, isInteractionEnabled, clickToInteractEnabled]
|
|
3802
3995
|
);
|
|
3803
3996
|
useSchematicWarnings({ svgDivRef, svgContent: svgDiv, circuitJsonKey });
|
|
3804
|
-
return /* @__PURE__ */
|
|
3805
|
-
netHoverHighlightEnabled && /* @__PURE__ */
|
|
3997
|
+
return /* @__PURE__ */ jsxs10(MouseTracker, { children: [
|
|
3998
|
+
netHoverHighlightEnabled && /* @__PURE__ */ jsx12("style", { children: `.sch-net-faded { opacity: 0.35; }
|
|
3806
3999
|
svg :is(g.trace, g.trace-overlays, g[data-schematic-component-id], [data-schematic-net-label-id]) { transition: opacity 0.12s ease-in-out; }` }),
|
|
3807
|
-
searchEnabled && /* @__PURE__ */
|
|
4000
|
+
searchEnabled && /* @__PURE__ */ jsx12("style", { children: `.schematic-search-match text,
|
|
3808
4001
|
text.schematic-search-match {
|
|
3809
4002
|
fill: #ff00d4 !important;
|
|
3810
4003
|
}
|
|
@@ -3820,9 +4013,9 @@ var SchematicViewer = ({
|
|
|
3820
4013
|
flex-direction: column;
|
|
3821
4014
|
}
|
|
3822
4015
|
}` }),
|
|
3823
|
-
/* @__PURE__ */
|
|
3824
|
-
onSchematicPortClicked && /* @__PURE__ */
|
|
3825
|
-
/* @__PURE__ */
|
|
4016
|
+
/* @__PURE__ */ jsx12("style", { children: ".schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }" }),
|
|
4017
|
+
onSchematicPortClicked && /* @__PURE__ */ jsx12("style", { children: "[data-schematic-port-id]:hover { cursor: pointer !important; }" }),
|
|
4018
|
+
/* @__PURE__ */ jsxs10(
|
|
3826
4019
|
"div",
|
|
3827
4020
|
{
|
|
3828
4021
|
ref: containerRef,
|
|
@@ -3857,7 +4050,7 @@ var SchematicViewer = ({
|
|
|
3857
4050
|
},
|
|
3858
4051
|
onTouchCancel: contextMenuEventHandlers.onTouchCancel,
|
|
3859
4052
|
children: [
|
|
3860
|
-
!isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */
|
|
4053
|
+
!isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */ jsx12(
|
|
3861
4054
|
"div",
|
|
3862
4055
|
{
|
|
3863
4056
|
onClick: (e) => {
|
|
@@ -3876,7 +4069,7 @@ var SchematicViewer = ({
|
|
|
3876
4069
|
pointerEvents: "all",
|
|
3877
4070
|
touchAction: "pan-x pan-y pinch-zoom"
|
|
3878
4071
|
},
|
|
3879
|
-
children: /* @__PURE__ */
|
|
4072
|
+
children: /* @__PURE__ */ jsx12(
|
|
3880
4073
|
"div",
|
|
3881
4074
|
{
|
|
3882
4075
|
style: {
|
|
@@ -3893,16 +4086,19 @@ var SchematicViewer = ({
|
|
|
3893
4086
|
)
|
|
3894
4087
|
}
|
|
3895
4088
|
),
|
|
3896
|
-
analysisCircuitJson && /* @__PURE__ */
|
|
4089
|
+
analysisCircuitJson && /* @__PURE__ */ jsx12(
|
|
3897
4090
|
StyleAnalysisDialog,
|
|
3898
4091
|
{
|
|
3899
4092
|
circuitJson: analysisCircuitJson,
|
|
3900
4093
|
onClose: () => setAnalysisCircuitJson(null)
|
|
3901
4094
|
}
|
|
3902
4095
|
),
|
|
3903
|
-
menuVisible && /* @__PURE__ */
|
|
4096
|
+
menuVisible && /* @__PURE__ */ jsx12(
|
|
3904
4097
|
ViewMenu,
|
|
3905
4098
|
{
|
|
4099
|
+
isComponentMenu: !!getSchematicComponentAtElement(menuTarget, circuitJson),
|
|
4100
|
+
pcbComponent: getPcbComponentAtElement(menuTarget, circuitJson),
|
|
4101
|
+
onViewPcbComponent,
|
|
3906
4102
|
circuitJson,
|
|
3907
4103
|
circuitJsonKey,
|
|
3908
4104
|
netLocations: (() => {
|
|
@@ -3941,7 +4137,7 @@ var SchematicViewer = ({
|
|
|
3941
4137
|
onToggleGrid: setShowGridInternal
|
|
3942
4138
|
}
|
|
3943
4139
|
),
|
|
3944
|
-
/* @__PURE__ */
|
|
4140
|
+
/* @__PURE__ */ jsxs10(
|
|
3945
4141
|
"div",
|
|
3946
4142
|
{
|
|
3947
4143
|
className: "schematic-viewer-toolbar",
|
|
@@ -3955,7 +4151,7 @@ var SchematicViewer = ({
|
|
|
3955
4151
|
zIndex: zIndexMap.schematicSearch
|
|
3956
4152
|
},
|
|
3957
4153
|
children: [
|
|
3958
|
-
/* @__PURE__ */
|
|
4154
|
+
/* @__PURE__ */ jsx12(
|
|
3959
4155
|
SchematicSheetSelector,
|
|
3960
4156
|
{
|
|
3961
4157
|
sheets: schematicSheets,
|
|
@@ -3963,7 +4159,7 @@ var SchematicViewer = ({
|
|
|
3963
4159
|
onSelectSheet: handleSelectSheet
|
|
3964
4160
|
}
|
|
3965
4161
|
),
|
|
3966
|
-
searchEnabled && /* @__PURE__ */
|
|
4162
|
+
searchEnabled && /* @__PURE__ */ jsx12(
|
|
3967
4163
|
SchematicSearch,
|
|
3968
4164
|
{
|
|
3969
4165
|
query: searchQuery,
|
|
@@ -3974,7 +4170,7 @@ var SchematicViewer = ({
|
|
|
3974
4170
|
viewerContainerRef: containerRef
|
|
3975
4171
|
}
|
|
3976
4172
|
),
|
|
3977
|
-
warningCount > 0 && /* @__PURE__ */
|
|
4173
|
+
warningCount > 0 && /* @__PURE__ */ jsx12(
|
|
3978
4174
|
SchematicWarningsButton,
|
|
3979
4175
|
{
|
|
3980
4176
|
count: warningCount,
|
|
@@ -3985,7 +4181,7 @@ var SchematicViewer = ({
|
|
|
3985
4181
|
]
|
|
3986
4182
|
}
|
|
3987
4183
|
),
|
|
3988
|
-
schematicComponentIds.map((componentId) => /* @__PURE__ */
|
|
4184
|
+
schematicComponentIds.map((componentId) => /* @__PURE__ */ jsx12(
|
|
3989
4185
|
SchematicComponentMouseTarget,
|
|
3990
4186
|
{
|
|
3991
4187
|
componentId,
|
|
@@ -3999,7 +4195,7 @@ var SchematicViewer = ({
|
|
|
3999
4195
|
componentId
|
|
4000
4196
|
)),
|
|
4001
4197
|
svgDiv,
|
|
4002
|
-
selectedComponentDetails && componentTooltipLayout && /* @__PURE__ */
|
|
4198
|
+
selectedComponentDetails && componentTooltipLayout && /* @__PURE__ */ jsx12(
|
|
4003
4199
|
SchematicComponentDetailsTooltip,
|
|
4004
4200
|
{
|
|
4005
4201
|
sourceComponent: selectedComponentDetails.sourceComponent,
|
|
@@ -4010,7 +4206,7 @@ var SchematicViewer = ({
|
|
|
4010
4206
|
...componentTooltipLayout
|
|
4011
4207
|
}
|
|
4012
4208
|
),
|
|
4013
|
-
showSchematicPortsInternal && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */
|
|
4209
|
+
showSchematicPortsInternal && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */ jsx12(
|
|
4014
4210
|
SchematicPortMouseTarget,
|
|
4015
4211
|
{
|
|
4016
4212
|
portId,
|
|
@@ -4040,7 +4236,7 @@ import {
|
|
|
4040
4236
|
convertCircuitJsonToSchematicSimulationSvg,
|
|
4041
4237
|
convertCircuitJsonToSimulationGraphSvg
|
|
4042
4238
|
} from "circuit-to-svg";
|
|
4043
|
-
import { useEffect as
|
|
4239
|
+
import { useEffect as useEffect14, useMemo as useMemo7, useRef as useRef10, useState as useState12 } from "react";
|
|
4044
4240
|
import { toString as transformToString2 } from "transformation-matrix";
|
|
4045
4241
|
import { useMouseMatrixTransform as useMouseMatrixTransform2 } from "use-mouse-matrix-transform";
|
|
4046
4242
|
|
|
@@ -4058,8 +4254,8 @@ var getAnalogSimulationBackgroundColor = (simulationSvg, colorOverrides) => getR
|
|
|
4058
4254
|
|
|
4059
4255
|
// lib/components/AnalogSimulationSelector.tsx
|
|
4060
4256
|
import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
|
|
4061
|
-
import { useState as
|
|
4062
|
-
import { Fragment as
|
|
4257
|
+
import { useState as useState11 } from "react";
|
|
4258
|
+
import { Fragment as Fragment8, jsx as jsx13, jsxs as jsxs11 } from "react/jsx-runtime";
|
|
4063
4259
|
var FONT_FAMILY3 = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
4064
4260
|
var contentStyles3 = {
|
|
4065
4261
|
backgroundColor: "#ffffff",
|
|
@@ -4109,7 +4305,7 @@ var MENU_CSS2 = `
|
|
|
4109
4305
|
.sv-simulation-chevron { transition: transform 0.2s ease; }
|
|
4110
4306
|
[data-state="open"] > .sv-simulation-chevron { transform: rotate(180deg); }
|
|
4111
4307
|
`;
|
|
4112
|
-
var CheckIcon3 = () => /* @__PURE__ */
|
|
4308
|
+
var CheckIcon3 = () => /* @__PURE__ */ jsx13(
|
|
4113
4309
|
"svg",
|
|
4114
4310
|
{
|
|
4115
4311
|
width: "14",
|
|
@@ -4121,10 +4317,10 @@ var CheckIcon3 = () => /* @__PURE__ */ jsx12(
|
|
|
4121
4317
|
strokeLinecap: "round",
|
|
4122
4318
|
strokeLinejoin: "round",
|
|
4123
4319
|
"aria-hidden": "true",
|
|
4124
|
-
children: /* @__PURE__ */
|
|
4320
|
+
children: /* @__PURE__ */ jsx13("path", { d: "M20 6 9 17l-5-5" })
|
|
4125
4321
|
}
|
|
4126
4322
|
);
|
|
4127
|
-
var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */
|
|
4323
|
+
var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */ jsx13(
|
|
4128
4324
|
"svg",
|
|
4129
4325
|
{
|
|
4130
4326
|
className,
|
|
@@ -4138,7 +4334,7 @@ var ChevronDownIcon2 = ({ className }) => /* @__PURE__ */ jsx12(
|
|
|
4138
4334
|
strokeLinejoin: "round",
|
|
4139
4335
|
style: { opacity: 0.6, flexShrink: 0 },
|
|
4140
4336
|
"aria-hidden": "true",
|
|
4141
|
-
children: /* @__PURE__ */
|
|
4337
|
+
children: /* @__PURE__ */ jsx13("path", { d: "m6 9 6 6 6-6" })
|
|
4142
4338
|
}
|
|
4143
4339
|
);
|
|
4144
4340
|
var getSimulationLabels = (simulations) => {
|
|
@@ -4157,17 +4353,17 @@ var AnalogSimulationSelector = ({
|
|
|
4157
4353
|
selectedSimulationExperimentId,
|
|
4158
4354
|
onSelectSimulation
|
|
4159
4355
|
}) => {
|
|
4160
|
-
const [open, setOpen] =
|
|
4356
|
+
const [open, setOpen] = useState11(false);
|
|
4161
4357
|
if (simulations.length <= 1) return null;
|
|
4162
4358
|
const simulationLabels = getSimulationLabels(simulations);
|
|
4163
4359
|
const selectedSimulation = simulationLabels.find(
|
|
4164
4360
|
({ simulation }) => simulation.simulation_experiment_id === selectedSimulationExperimentId
|
|
4165
4361
|
);
|
|
4166
4362
|
const selectedLabel = selectedSimulation?.label ?? "Select simulation";
|
|
4167
|
-
return /* @__PURE__ */
|
|
4168
|
-
/* @__PURE__ */
|
|
4169
|
-
/* @__PURE__ */
|
|
4170
|
-
/* @__PURE__ */
|
|
4363
|
+
return /* @__PURE__ */ jsxs11(Fragment8, { children: [
|
|
4364
|
+
/* @__PURE__ */ jsx13("style", { children: MENU_CSS2 }),
|
|
4365
|
+
/* @__PURE__ */ jsxs11(DropdownMenu3.Root, { open, onOpenChange: setOpen, modal: false, children: [
|
|
4366
|
+
/* @__PURE__ */ jsx13(DropdownMenu3.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs11(
|
|
4171
4367
|
"button",
|
|
4172
4368
|
{
|
|
4173
4369
|
type: "button",
|
|
@@ -4194,13 +4390,13 @@ var AnalogSimulationSelector = ({
|
|
|
4194
4390
|
zIndex: zIndexMap.viewMenuIcon
|
|
4195
4391
|
},
|
|
4196
4392
|
children: [
|
|
4197
|
-
/* @__PURE__ */
|
|
4198
|
-
/* @__PURE__ */
|
|
4199
|
-
/* @__PURE__ */
|
|
4393
|
+
/* @__PURE__ */ jsx13("span", { style: { color: "#888888", flexShrink: 0 }, children: "Simulation:" }),
|
|
4394
|
+
/* @__PURE__ */ jsx13("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: selectedLabel }),
|
|
4395
|
+
/* @__PURE__ */ jsx13(ChevronDownIcon2, { className: "sv-simulation-chevron" })
|
|
4200
4396
|
]
|
|
4201
4397
|
}
|
|
4202
4398
|
) }),
|
|
4203
|
-
/* @__PURE__ */
|
|
4399
|
+
/* @__PURE__ */ jsx13(DropdownMenu3.Portal, { children: /* @__PURE__ */ jsx13(
|
|
4204
4400
|
DropdownMenu3.Content,
|
|
4205
4401
|
{
|
|
4206
4402
|
style: contentStyles3,
|
|
@@ -4210,7 +4406,7 @@ var AnalogSimulationSelector = ({
|
|
|
4210
4406
|
collisionPadding: 10,
|
|
4211
4407
|
children: simulationLabels.map(({ simulation, label }) => {
|
|
4212
4408
|
const selected = simulation.simulation_experiment_id === selectedSimulationExperimentId;
|
|
4213
|
-
return /* @__PURE__ */
|
|
4409
|
+
return /* @__PURE__ */ jsxs11(
|
|
4214
4410
|
DropdownMenu3.Item,
|
|
4215
4411
|
{
|
|
4216
4412
|
className: "sv-simulation-item",
|
|
@@ -4222,8 +4418,8 @@ var AnalogSimulationSelector = ({
|
|
|
4222
4418
|
setOpen(false);
|
|
4223
4419
|
},
|
|
4224
4420
|
children: [
|
|
4225
|
-
/* @__PURE__ */
|
|
4226
|
-
/* @__PURE__ */
|
|
4421
|
+
/* @__PURE__ */ jsx13("span", { style: iconSlotStyles3, children: selected && /* @__PURE__ */ jsx13(CheckIcon3, {}) }),
|
|
4422
|
+
/* @__PURE__ */ jsx13("span", { style: { ...ellipsisStyles2, minWidth: 0 }, children: label })
|
|
4227
4423
|
]
|
|
4228
4424
|
},
|
|
4229
4425
|
simulation.simulation_experiment_id
|
|
@@ -4236,7 +4432,7 @@ var AnalogSimulationSelector = ({
|
|
|
4236
4432
|
};
|
|
4237
4433
|
|
|
4238
4434
|
// lib/components/AnalogSimulationViewer.tsx
|
|
4239
|
-
import { jsx as
|
|
4435
|
+
import { jsx as jsx14, jsxs as jsxs12 } from "react/jsx-runtime";
|
|
4240
4436
|
var DEFAULT_RENDER_WIDTH = 1200;
|
|
4241
4437
|
var DEFAULT_COMBINED_RENDER_ASPECT_RATIO = 1;
|
|
4242
4438
|
var DEFAULT_GRAPH_ONLY_RENDER_ASPECT_RATIO = 2;
|
|
@@ -4251,16 +4447,16 @@ var AnalogSimulationViewer = ({
|
|
|
4251
4447
|
onSimulationChange,
|
|
4252
4448
|
acSweepView = "magnitude"
|
|
4253
4449
|
}) => {
|
|
4254
|
-
const [circuitJson, setCircuitJson] =
|
|
4255
|
-
const [isLoading, setIsLoading] =
|
|
4256
|
-
const [error, setError] =
|
|
4257
|
-
const [svgObjectUrl, setSvgObjectUrl] =
|
|
4450
|
+
const [circuitJson, setCircuitJson] = useState12(null);
|
|
4451
|
+
const [isLoading, setIsLoading] = useState12(true);
|
|
4452
|
+
const [error, setError] = useState12(null);
|
|
4453
|
+
const [svgObjectUrl, setSvgObjectUrl] = useState12(null);
|
|
4258
4454
|
const containerRef = useRef10(null);
|
|
4259
4455
|
const imgRef = useRef10(null);
|
|
4260
4456
|
const { containerWidth } = useResizeHandling(
|
|
4261
4457
|
containerRef
|
|
4262
4458
|
);
|
|
4263
|
-
const [isDragging, setIsDragging] =
|
|
4459
|
+
const [isDragging, setIsDragging] = useState12(false);
|
|
4264
4460
|
const {
|
|
4265
4461
|
ref: transformRef,
|
|
4266
4462
|
cancelDrag: _cancelDrag,
|
|
@@ -4276,7 +4472,7 @@ var AnalogSimulationViewer = ({
|
|
|
4276
4472
|
const renderAspectRatio = width && height ? width / height : defaultRenderAspectRatio;
|
|
4277
4473
|
const effectiveWidth = width || (height ? height * renderAspectRatio : containerWidth) || DEFAULT_RENDER_WIDTH;
|
|
4278
4474
|
const effectiveHeight = height || effectiveWidth / renderAspectRatio;
|
|
4279
|
-
|
|
4475
|
+
useEffect14(() => {
|
|
4280
4476
|
setIsLoading(true);
|
|
4281
4477
|
setError(null);
|
|
4282
4478
|
setCircuitJson(inputCircuitJson);
|
|
@@ -4288,11 +4484,11 @@ var AnalogSimulationViewer = ({
|
|
|
4288
4484
|
(element) => element.type === "simulation_experiment"
|
|
4289
4485
|
);
|
|
4290
4486
|
}, [circuitJson]);
|
|
4291
|
-
const [selectedSimulationExperimentId, setSelectedSimulationExperimentId] =
|
|
4487
|
+
const [selectedSimulationExperimentId, setSelectedSimulationExperimentId] = useState12(null);
|
|
4292
4488
|
const simulationExperimentId = (selectedSimulationExperimentId && simulationExperiments.some(
|
|
4293
4489
|
(simulation) => simulation.simulation_experiment_id === selectedSimulationExperimentId
|
|
4294
4490
|
) ? selectedSimulationExperimentId : simulationExperiments[0]?.simulation_experiment_id) ?? null;
|
|
4295
|
-
|
|
4491
|
+
useEffect14(() => {
|
|
4296
4492
|
if (simulationExperimentId !== selectedSimulationExperimentId) {
|
|
4297
4493
|
setSelectedSimulationExperimentId(simulationExperimentId);
|
|
4298
4494
|
}
|
|
@@ -4329,7 +4525,7 @@ var AnalogSimulationViewer = ({
|
|
|
4329
4525
|
simulationExperimentId,
|
|
4330
4526
|
acSweepView
|
|
4331
4527
|
]);
|
|
4332
|
-
|
|
4528
|
+
useEffect14(() => {
|
|
4333
4529
|
if (!simulationSvg) {
|
|
4334
4530
|
setSvgObjectUrl(null);
|
|
4335
4531
|
return;
|
|
@@ -4355,7 +4551,7 @@ var AnalogSimulationViewer = ({
|
|
|
4355
4551
|
const handleTouchStart = (_e) => {
|
|
4356
4552
|
setIsDragging(true);
|
|
4357
4553
|
};
|
|
4358
|
-
|
|
4554
|
+
useEffect14(() => {
|
|
4359
4555
|
const handleMouseUp = () => {
|
|
4360
4556
|
setIsDragging(false);
|
|
4361
4557
|
};
|
|
@@ -4370,7 +4566,7 @@ var AnalogSimulationViewer = ({
|
|
|
4370
4566
|
};
|
|
4371
4567
|
}, []);
|
|
4372
4568
|
if (isLoading) {
|
|
4373
|
-
return /* @__PURE__ */
|
|
4569
|
+
return /* @__PURE__ */ jsx14(
|
|
4374
4570
|
"div",
|
|
4375
4571
|
{
|
|
4376
4572
|
style: {
|
|
@@ -4390,7 +4586,7 @@ var AnalogSimulationViewer = ({
|
|
|
4390
4586
|
);
|
|
4391
4587
|
}
|
|
4392
4588
|
if (error) {
|
|
4393
|
-
return /* @__PURE__ */
|
|
4589
|
+
return /* @__PURE__ */ jsx14(
|
|
4394
4590
|
"div",
|
|
4395
4591
|
{
|
|
4396
4592
|
style: {
|
|
@@ -4405,15 +4601,15 @@ var AnalogSimulationViewer = ({
|
|
|
4405
4601
|
...containerStyle
|
|
4406
4602
|
},
|
|
4407
4603
|
className,
|
|
4408
|
-
children: /* @__PURE__ */
|
|
4409
|
-
/* @__PURE__ */
|
|
4410
|
-
/* @__PURE__ */
|
|
4604
|
+
children: /* @__PURE__ */ jsxs12("div", { style: { textAlign: "center", padding: "20px" }, children: [
|
|
4605
|
+
/* @__PURE__ */ jsx14("div", { style: { fontWeight: "bold", marginBottom: "8px" }, children: "Circuit Conversion Error" }),
|
|
4606
|
+
/* @__PURE__ */ jsx14("div", { style: { fontSize: "14px" }, children: error })
|
|
4411
4607
|
] })
|
|
4412
4608
|
}
|
|
4413
4609
|
);
|
|
4414
4610
|
}
|
|
4415
4611
|
if (!simulationSvg) {
|
|
4416
|
-
return /* @__PURE__ */
|
|
4612
|
+
return /* @__PURE__ */ jsxs12(
|
|
4417
4613
|
"div",
|
|
4418
4614
|
{
|
|
4419
4615
|
style: {
|
|
@@ -4429,11 +4625,11 @@ var AnalogSimulationViewer = ({
|
|
|
4429
4625
|
},
|
|
4430
4626
|
className,
|
|
4431
4627
|
children: [
|
|
4432
|
-
/* @__PURE__ */
|
|
4433
|
-
/* @__PURE__ */
|
|
4628
|
+
/* @__PURE__ */ jsx14("div", { style: { fontSize: "16px", color: "#475569", fontWeight: 500 }, children: "No Simulation Found" }),
|
|
4629
|
+
/* @__PURE__ */ jsxs12("div", { style: { fontSize: "14px", color: "#64748b" }, children: [
|
|
4434
4630
|
"Use",
|
|
4435
4631
|
" ",
|
|
4436
|
-
/* @__PURE__ */
|
|
4632
|
+
/* @__PURE__ */ jsx14(
|
|
4437
4633
|
"code",
|
|
4438
4634
|
{
|
|
4439
4635
|
style: {
|
|
@@ -4453,7 +4649,7 @@ var AnalogSimulationViewer = ({
|
|
|
4453
4649
|
}
|
|
4454
4650
|
);
|
|
4455
4651
|
}
|
|
4456
|
-
return /* @__PURE__ */
|
|
4652
|
+
return /* @__PURE__ */ jsxs12(
|
|
4457
4653
|
"div",
|
|
4458
4654
|
{
|
|
4459
4655
|
ref: (node) => {
|
|
@@ -4472,7 +4668,7 @@ var AnalogSimulationViewer = ({
|
|
|
4472
4668
|
onMouseDown: handleMouseDown,
|
|
4473
4669
|
onTouchStart: handleTouchStart,
|
|
4474
4670
|
children: [
|
|
4475
|
-
/* @__PURE__ */
|
|
4671
|
+
/* @__PURE__ */ jsx14(
|
|
4476
4672
|
AnalogSimulationSelector,
|
|
4477
4673
|
{
|
|
4478
4674
|
simulations: simulationExperiments,
|
|
@@ -4480,7 +4676,7 @@ var AnalogSimulationViewer = ({
|
|
|
4480
4676
|
onSelectSimulation: handleSelectSimulation
|
|
4481
4677
|
}
|
|
4482
4678
|
),
|
|
4483
|
-
svgObjectUrl ? /* @__PURE__ */
|
|
4679
|
+
svgObjectUrl ? /* @__PURE__ */ jsx14(
|
|
4484
4680
|
"img",
|
|
4485
4681
|
{
|
|
4486
4682
|
ref: imgRef,
|
|
@@ -4494,7 +4690,7 @@ var AnalogSimulationViewer = ({
|
|
|
4494
4690
|
objectFit: "contain"
|
|
4495
4691
|
}
|
|
4496
4692
|
}
|
|
4497
|
-
) : /* @__PURE__ */
|
|
4693
|
+
) : /* @__PURE__ */ jsx14(
|
|
4498
4694
|
"div",
|
|
4499
4695
|
{
|
|
4500
4696
|
style: {
|
|
@@ -4515,9 +4711,9 @@ var AnalogSimulationViewer = ({
|
|
|
4515
4711
|
};
|
|
4516
4712
|
|
|
4517
4713
|
// lib/hooks/useSchematicViewerController.ts
|
|
4518
|
-
import { useCallback as useCallback8, useMemo as useMemo8, useState as
|
|
4714
|
+
import { useCallback as useCallback8, useMemo as useMemo8, useState as useState13 } from "react";
|
|
4519
4715
|
var useSchematicViewerController = () => {
|
|
4520
|
-
const [focusRequest, setFocusRequest] =
|
|
4716
|
+
const [focusRequest, setFocusRequest] = useState13(null);
|
|
4521
4717
|
const focusSchematicComponent = useCallback8(
|
|
4522
4718
|
(schematicComponentId) => {
|
|
4523
4719
|
setFocusRequest({ schematicComponentId });
|