@tscircuit/schematic-viewer 2.0.66 → 2.0.68
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 +3 -1
- package/dist/index.js +447 -265
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
package/dist/index.js
CHANGED
|
@@ -470,7 +470,7 @@ var enableDebug = () => {
|
|
|
470
470
|
var debug_default = debug;
|
|
471
471
|
|
|
472
472
|
// lib/components/SchematicViewer.tsx
|
|
473
|
-
import { useCallback as useCallback6, useEffect as useEffect12, useMemo as useMemo5, useRef as useRef8, useState as
|
|
473
|
+
import { useCallback as useCallback6, useEffect as useEffect12, useMemo as useMemo5, useRef as useRef8, useState as useState8 } from "react";
|
|
474
474
|
import {
|
|
475
475
|
fromString,
|
|
476
476
|
identity,
|
|
@@ -794,65 +794,15 @@ var GridIcon = ({
|
|
|
794
794
|
);
|
|
795
795
|
};
|
|
796
796
|
|
|
797
|
-
// lib/components/ViewMenuIcon.tsx
|
|
798
|
-
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
799
|
-
var ViewMenuIcon = ({
|
|
800
|
-
onClick,
|
|
801
|
-
active
|
|
802
|
-
}) => {
|
|
803
|
-
const handleInteraction = (e) => {
|
|
804
|
-
e.preventDefault();
|
|
805
|
-
onClick();
|
|
806
|
-
};
|
|
807
|
-
return /* @__PURE__ */ jsx3(
|
|
808
|
-
"div",
|
|
809
|
-
{
|
|
810
|
-
onClick: handleInteraction,
|
|
811
|
-
onTouchEnd: handleInteraction,
|
|
812
|
-
title: active ? "Hide view menu" : "Show view menu",
|
|
813
|
-
style: {
|
|
814
|
-
position: "absolute",
|
|
815
|
-
top: "16px",
|
|
816
|
-
right: "16px",
|
|
817
|
-
backgroundColor: active ? "#4CAF50" : "#fff",
|
|
818
|
-
color: active ? "#fff" : "#000",
|
|
819
|
-
padding: "8px",
|
|
820
|
-
borderRadius: "4px",
|
|
821
|
-
cursor: "pointer",
|
|
822
|
-
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
823
|
-
display: "flex",
|
|
824
|
-
alignItems: "center",
|
|
825
|
-
gap: "4px",
|
|
826
|
-
zIndex: zIndexMap.viewMenuIcon
|
|
827
|
-
},
|
|
828
|
-
children: /* @__PURE__ */ jsxs2(
|
|
829
|
-
"svg",
|
|
830
|
-
{
|
|
831
|
-
width: "16",
|
|
832
|
-
height: "16",
|
|
833
|
-
viewBox: "0 0 24 24",
|
|
834
|
-
fill: "none",
|
|
835
|
-
stroke: "currentColor",
|
|
836
|
-
strokeWidth: "2",
|
|
837
|
-
children: [
|
|
838
|
-
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "12", r: "1" }),
|
|
839
|
-
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "5", r: "1" }),
|
|
840
|
-
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "19", r: "1" })
|
|
841
|
-
]
|
|
842
|
-
}
|
|
843
|
-
)
|
|
844
|
-
}
|
|
845
|
-
);
|
|
846
|
-
};
|
|
847
|
-
|
|
848
797
|
// lib/components/ViewMenu.tsx
|
|
849
798
|
import { useMemo } from "react";
|
|
850
799
|
import { su as su5 } from "@tscircuit/soup-util";
|
|
800
|
+
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
851
801
|
|
|
852
802
|
// package.json
|
|
853
803
|
var package_default = {
|
|
854
804
|
name: "@tscircuit/schematic-viewer",
|
|
855
|
-
version: "2.0.
|
|
805
|
+
version: "2.0.67",
|
|
856
806
|
main: "dist/index.js",
|
|
857
807
|
type: "module",
|
|
858
808
|
scripts: {
|
|
@@ -882,17 +832,18 @@ var package_default = {
|
|
|
882
832
|
"react-dom": "^19.1.0",
|
|
883
833
|
"react-reconciler": "^0.31.0",
|
|
884
834
|
semver: "^7.7.2",
|
|
885
|
-
tscircuit: "^0.0.
|
|
835
|
+
tscircuit: "^0.0.1972",
|
|
886
836
|
tsup: "^8.3.5",
|
|
887
837
|
vite: "^6.0.3"
|
|
888
838
|
},
|
|
889
839
|
peerDependencies: {
|
|
890
840
|
typescript: "^5.0.0",
|
|
891
|
-
tscircuit: "*"
|
|
841
|
+
tscircuit: "*",
|
|
842
|
+
"circuit-json-to-spice": "*"
|
|
892
843
|
},
|
|
893
844
|
dependencies: {
|
|
845
|
+
"@radix-ui/react-dropdown-menu": "^2.1.16",
|
|
894
846
|
"chart.js": "^4.5.0",
|
|
895
|
-
"circuit-json-to-spice": "^0.0.39",
|
|
896
847
|
debug: "^4.4.0",
|
|
897
848
|
"performance-now": "^2.1.0",
|
|
898
849
|
"react-chartjs-2": "^5.3.0",
|
|
@@ -900,13 +851,123 @@ var package_default = {
|
|
|
900
851
|
}
|
|
901
852
|
};
|
|
902
853
|
|
|
854
|
+
// lib/components/ViewMenuIcon.tsx
|
|
855
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
856
|
+
var ViewMenuIcon = ({
|
|
857
|
+
active = false,
|
|
858
|
+
...props
|
|
859
|
+
}) => {
|
|
860
|
+
return /* @__PURE__ */ jsx3(
|
|
861
|
+
"button",
|
|
862
|
+
{
|
|
863
|
+
type: "button",
|
|
864
|
+
title: active ? "Hide view menu" : "Show view menu",
|
|
865
|
+
...props,
|
|
866
|
+
style: {
|
|
867
|
+
position: "absolute",
|
|
868
|
+
top: "16px",
|
|
869
|
+
right: "16px",
|
|
870
|
+
backgroundColor: active ? "#4CAF50" : "#fff",
|
|
871
|
+
color: active ? "#fff" : "#000",
|
|
872
|
+
padding: "8px",
|
|
873
|
+
border: "none",
|
|
874
|
+
borderRadius: "4px",
|
|
875
|
+
cursor: "pointer",
|
|
876
|
+
outline: "none",
|
|
877
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
878
|
+
display: "flex",
|
|
879
|
+
alignItems: "center",
|
|
880
|
+
gap: "4px",
|
|
881
|
+
zIndex: zIndexMap.viewMenuIcon
|
|
882
|
+
},
|
|
883
|
+
children: /* @__PURE__ */ jsxs2(
|
|
884
|
+
"svg",
|
|
885
|
+
{
|
|
886
|
+
width: "16",
|
|
887
|
+
height: "16",
|
|
888
|
+
viewBox: "0 0 24 24",
|
|
889
|
+
fill: "none",
|
|
890
|
+
stroke: "currentColor",
|
|
891
|
+
strokeWidth: "2",
|
|
892
|
+
children: [
|
|
893
|
+
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "12", r: "1" }),
|
|
894
|
+
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "5", r: "1" }),
|
|
895
|
+
/* @__PURE__ */ jsx3("circle", { cx: "12", cy: "19", r: "1" })
|
|
896
|
+
]
|
|
897
|
+
}
|
|
898
|
+
)
|
|
899
|
+
}
|
|
900
|
+
);
|
|
901
|
+
};
|
|
902
|
+
|
|
903
903
|
// lib/components/ViewMenu.tsx
|
|
904
|
-
import {
|
|
904
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
905
|
+
var FONT_FAMILY = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
906
|
+
var contentStyles = {
|
|
907
|
+
backgroundColor: "#ffffff",
|
|
908
|
+
color: "#111111",
|
|
909
|
+
borderRadius: 8,
|
|
910
|
+
boxShadow: "0 6px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08)",
|
|
911
|
+
border: "1px solid #e5e7eb",
|
|
912
|
+
padding: 4,
|
|
913
|
+
minWidth: 224,
|
|
914
|
+
fontSize: 13,
|
|
915
|
+
fontFamily: FONT_FAMILY,
|
|
916
|
+
outline: "none",
|
|
917
|
+
zIndex: zIndexMap.viewMenu
|
|
918
|
+
};
|
|
919
|
+
var itemStyles = {
|
|
920
|
+
display: "flex",
|
|
921
|
+
alignItems: "center",
|
|
922
|
+
gap: 8,
|
|
923
|
+
padding: "7px 10px 7px 8px",
|
|
924
|
+
borderRadius: 6,
|
|
925
|
+
cursor: "pointer",
|
|
926
|
+
outline: "none",
|
|
927
|
+
userSelect: "none",
|
|
928
|
+
color: "#111111",
|
|
929
|
+
fontSize: 13,
|
|
930
|
+
fontFamily: FONT_FAMILY
|
|
931
|
+
};
|
|
932
|
+
var iconSlotStyles = {
|
|
933
|
+
width: 16,
|
|
934
|
+
height: 16,
|
|
935
|
+
flexShrink: 0,
|
|
936
|
+
display: "inline-flex",
|
|
937
|
+
alignItems: "center",
|
|
938
|
+
justifyContent: "center",
|
|
939
|
+
color: "#111111"
|
|
940
|
+
};
|
|
941
|
+
var separatorStyles = {
|
|
942
|
+
height: 1,
|
|
943
|
+
backgroundColor: "#ececec",
|
|
944
|
+
margin: "4px 0"
|
|
945
|
+
};
|
|
946
|
+
var HIGHLIGHT_CSS = `
|
|
947
|
+
.sv-vm-item[data-highlighted]:not([data-disabled]),
|
|
948
|
+
.sv-vm-item:hover:not([data-disabled]) { background-color: #f1f3f5; }
|
|
949
|
+
.sv-vm-item[data-disabled] { opacity: 0.45; cursor: not-allowed; }
|
|
950
|
+
`;
|
|
951
|
+
var CheckIcon = () => /* @__PURE__ */ jsx4(
|
|
952
|
+
"svg",
|
|
953
|
+
{
|
|
954
|
+
width: "14",
|
|
955
|
+
height: "14",
|
|
956
|
+
viewBox: "0 0 24 24",
|
|
957
|
+
fill: "none",
|
|
958
|
+
stroke: "currentColor",
|
|
959
|
+
strokeWidth: "2.5",
|
|
960
|
+
strokeLinecap: "round",
|
|
961
|
+
strokeLinejoin: "round",
|
|
962
|
+
"aria-hidden": "true",
|
|
963
|
+
children: /* @__PURE__ */ jsx4("path", { d: "M20 6 9 17l-5-5" })
|
|
964
|
+
}
|
|
965
|
+
);
|
|
905
966
|
var ViewMenu = ({
|
|
906
967
|
circuitJson,
|
|
907
968
|
circuitJsonKey,
|
|
908
|
-
|
|
909
|
-
|
|
969
|
+
open,
|
|
970
|
+
onOpenChange,
|
|
910
971
|
showGroups,
|
|
911
972
|
onToggleGroups,
|
|
912
973
|
showGrid,
|
|
@@ -936,166 +997,58 @@ var ViewMenu = ({
|
|
|
936
997
|
return false;
|
|
937
998
|
}
|
|
938
999
|
}, [circuitJsonKey]);
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
/* @__PURE__ */ jsx4(
|
|
942
|
-
|
|
943
|
-
{
|
|
944
|
-
onClick: onClose,
|
|
945
|
-
onTouchEnd: (e) => {
|
|
946
|
-
e.preventDefault();
|
|
947
|
-
onClose();
|
|
948
|
-
},
|
|
949
|
-
style: {
|
|
950
|
-
position: "absolute",
|
|
951
|
-
inset: 0,
|
|
952
|
-
backgroundColor: "transparent",
|
|
953
|
-
zIndex: zIndexMap.viewMenuBackdrop
|
|
954
|
-
}
|
|
955
|
-
}
|
|
956
|
-
),
|
|
957
|
-
/* @__PURE__ */ jsxs3(
|
|
958
|
-
"div",
|
|
1000
|
+
return /* @__PURE__ */ jsxs3(DropdownMenu.Root, { open, onOpenChange, modal: false, children: [
|
|
1001
|
+
/* @__PURE__ */ jsx4(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx4(ViewMenuIcon, { active: open }) }),
|
|
1002
|
+
/* @__PURE__ */ jsx4(DropdownMenu.Portal, { children: /* @__PURE__ */ jsxs3(
|
|
1003
|
+
DropdownMenu.Content,
|
|
959
1004
|
{
|
|
960
|
-
style:
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
color: "#000000",
|
|
966
|
-
border: "1px solid #ccc",
|
|
967
|
-
borderRadius: "4px",
|
|
968
|
-
boxShadow: "0 4px 12px rgba(0,0,0,0.1)",
|
|
969
|
-
minWidth: "200px",
|
|
970
|
-
zIndex: zIndexMap.viewMenu
|
|
971
|
-
},
|
|
1005
|
+
style: contentStyles,
|
|
1006
|
+
side: "bottom",
|
|
1007
|
+
align: "end",
|
|
1008
|
+
sideOffset: 8,
|
|
1009
|
+
collisionPadding: 10,
|
|
972
1010
|
children: [
|
|
1011
|
+
/* @__PURE__ */ jsx4("style", { children: HIGHLIGHT_CSS }),
|
|
973
1012
|
/* @__PURE__ */ jsxs3(
|
|
974
|
-
|
|
1013
|
+
DropdownMenu.Item,
|
|
975
1014
|
{
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
if (hasGroups) {
|
|
984
|
-
onToggleGroups(!showGroups);
|
|
985
|
-
}
|
|
986
|
-
},
|
|
987
|
-
style: {
|
|
988
|
-
padding: "8px 12px",
|
|
989
|
-
cursor: hasGroups ? "pointer" : "not-allowed",
|
|
990
|
-
opacity: hasGroups ? 1 : 0.5,
|
|
991
|
-
fontSize: "13px",
|
|
992
|
-
color: "#000000",
|
|
993
|
-
fontFamily: "sans-serif",
|
|
994
|
-
display: "flex",
|
|
995
|
-
alignItems: "center",
|
|
996
|
-
gap: "8px"
|
|
997
|
-
},
|
|
998
|
-
onMouseEnter: (e) => {
|
|
999
|
-
if (hasGroups) {
|
|
1000
|
-
e.currentTarget.style.backgroundColor = "#f0f0f0";
|
|
1001
|
-
}
|
|
1002
|
-
},
|
|
1003
|
-
onMouseLeave: (e) => {
|
|
1004
|
-
if (hasGroups) {
|
|
1005
|
-
e.currentTarget.style.backgroundColor = "transparent";
|
|
1006
|
-
}
|
|
1015
|
+
className: "sv-vm-item",
|
|
1016
|
+
style: itemStyles,
|
|
1017
|
+
disabled: !hasGroups,
|
|
1018
|
+
title: hasGroups ? void 0 : "No groups found in this schematic",
|
|
1019
|
+
onSelect: (e) => e.preventDefault(),
|
|
1020
|
+
onPointerUp: () => {
|
|
1021
|
+
if (hasGroups) onToggleGroups(!showGroups);
|
|
1007
1022
|
},
|
|
1008
1023
|
children: [
|
|
1009
|
-
/* @__PURE__ */ jsx4(
|
|
1010
|
-
|
|
1011
|
-
{
|
|
1012
|
-
style: {
|
|
1013
|
-
width: "16px",
|
|
1014
|
-
height: "16px",
|
|
1015
|
-
border: "2px solid #000",
|
|
1016
|
-
borderRadius: "2px",
|
|
1017
|
-
backgroundColor: "transparent",
|
|
1018
|
-
display: "flex",
|
|
1019
|
-
alignItems: "center",
|
|
1020
|
-
justifyContent: "center",
|
|
1021
|
-
fontSize: "10px",
|
|
1022
|
-
fontWeight: "bold"
|
|
1023
|
-
},
|
|
1024
|
-
children: showGroups && "\u2713"
|
|
1025
|
-
}
|
|
1026
|
-
),
|
|
1027
|
-
"View Schematic Groups"
|
|
1024
|
+
/* @__PURE__ */ jsx4("span", { style: iconSlotStyles, children: showGroups && /* @__PURE__ */ jsx4(CheckIcon, {}) }),
|
|
1025
|
+
/* @__PURE__ */ jsx4("span", { children: "View Schematic Groups" })
|
|
1028
1026
|
]
|
|
1029
1027
|
}
|
|
1030
1028
|
),
|
|
1031
|
-
!hasGroups && /* @__PURE__ */ jsx4(
|
|
1032
|
-
"div",
|
|
1033
|
-
{
|
|
1034
|
-
style: {
|
|
1035
|
-
padding: "8px 12px",
|
|
1036
|
-
fontSize: "11px",
|
|
1037
|
-
color: "#666",
|
|
1038
|
-
fontStyle: "italic"
|
|
1039
|
-
},
|
|
1040
|
-
children: "No groups found in this schematic"
|
|
1041
|
-
}
|
|
1042
|
-
),
|
|
1043
1029
|
/* @__PURE__ */ jsxs3(
|
|
1044
|
-
|
|
1030
|
+
DropdownMenu.Item,
|
|
1045
1031
|
{
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
},
|
|
1051
|
-
style: {
|
|
1052
|
-
padding: "8px 12px",
|
|
1053
|
-
cursor: "pointer",
|
|
1054
|
-
fontSize: "13px",
|
|
1055
|
-
color: "#000000",
|
|
1056
|
-
fontFamily: "sans-serif",
|
|
1057
|
-
display: "flex",
|
|
1058
|
-
alignItems: "center",
|
|
1059
|
-
gap: "8px"
|
|
1060
|
-
},
|
|
1061
|
-
onMouseEnter: (e) => {
|
|
1062
|
-
e.currentTarget.style.backgroundColor = "#f0f0f0";
|
|
1063
|
-
},
|
|
1064
|
-
onMouseLeave: (e) => {
|
|
1065
|
-
e.currentTarget.style.backgroundColor = "transparent";
|
|
1066
|
-
},
|
|
1032
|
+
className: "sv-vm-item",
|
|
1033
|
+
style: itemStyles,
|
|
1034
|
+
onSelect: (e) => e.preventDefault(),
|
|
1035
|
+
onPointerUp: () => onToggleGrid(!showGrid),
|
|
1067
1036
|
children: [
|
|
1068
|
-
/* @__PURE__ */ jsx4(
|
|
1069
|
-
|
|
1070
|
-
{
|
|
1071
|
-
style: {
|
|
1072
|
-
width: "16px",
|
|
1073
|
-
height: "16px",
|
|
1074
|
-
border: "2px solid #000",
|
|
1075
|
-
borderRadius: "2px",
|
|
1076
|
-
backgroundColor: "transparent",
|
|
1077
|
-
display: "flex",
|
|
1078
|
-
alignItems: "center",
|
|
1079
|
-
justifyContent: "center",
|
|
1080
|
-
fontSize: "10px",
|
|
1081
|
-
fontWeight: "bold"
|
|
1082
|
-
},
|
|
1083
|
-
children: showGrid && "\u2713"
|
|
1084
|
-
}
|
|
1085
|
-
),
|
|
1086
|
-
"Show Grid"
|
|
1037
|
+
/* @__PURE__ */ jsx4("span", { style: iconSlotStyles, children: showGrid && /* @__PURE__ */ jsx4(CheckIcon, {}) }),
|
|
1038
|
+
/* @__PURE__ */ jsx4("span", { children: "Show Grid" })
|
|
1087
1039
|
]
|
|
1088
1040
|
}
|
|
1089
1041
|
),
|
|
1042
|
+
/* @__PURE__ */ jsx4(DropdownMenu.Separator, { style: separatorStyles }),
|
|
1090
1043
|
/* @__PURE__ */ jsxs3(
|
|
1091
1044
|
"div",
|
|
1092
1045
|
{
|
|
1093
1046
|
style: {
|
|
1094
1047
|
padding: "4px 8px",
|
|
1095
|
-
fontSize:
|
|
1096
|
-
color: "#
|
|
1097
|
-
|
|
1098
|
-
|
|
1048
|
+
fontSize: 12,
|
|
1049
|
+
color: "#9ca3af",
|
|
1050
|
+
textAlign: "center",
|
|
1051
|
+
fontFamily: FONT_FAMILY
|
|
1099
1052
|
},
|
|
1100
1053
|
children: [
|
|
1101
1054
|
"v",
|
|
@@ -1105,7 +1058,7 @@ var ViewMenu = ({
|
|
|
1105
1058
|
)
|
|
1106
1059
|
]
|
|
1107
1060
|
}
|
|
1108
|
-
)
|
|
1061
|
+
) })
|
|
1109
1062
|
] });
|
|
1110
1063
|
};
|
|
1111
1064
|
|
|
@@ -1818,6 +1771,10 @@ var getSpiceFromCircuitJson = (circuitJson, options) => {
|
|
|
1818
1771
|
|
|
1819
1772
|
// lib/hooks/useLocalStorage.ts
|
|
1820
1773
|
import { useCallback as useCallback2 } from "react";
|
|
1774
|
+
var STORAGE_KEYS = {
|
|
1775
|
+
IS_SHOWING_SCHEMATIC_GROUPS: "schematic_viewer_show_groups",
|
|
1776
|
+
SELECTED_SCHEMATIC_SHEET: "schematic_viewer_selected_sheet"
|
|
1777
|
+
};
|
|
1821
1778
|
var getStoredBoolean = (key, defaultValue) => {
|
|
1822
1779
|
if (typeof window === "undefined") return defaultValue;
|
|
1823
1780
|
try {
|
|
@@ -1834,6 +1791,21 @@ var setStoredBoolean = (key, value) => {
|
|
|
1834
1791
|
} catch {
|
|
1835
1792
|
}
|
|
1836
1793
|
};
|
|
1794
|
+
var getStoredString = (key) => {
|
|
1795
|
+
if (typeof window === "undefined") return null;
|
|
1796
|
+
try {
|
|
1797
|
+
return localStorage.getItem(key);
|
|
1798
|
+
} catch {
|
|
1799
|
+
return null;
|
|
1800
|
+
}
|
|
1801
|
+
};
|
|
1802
|
+
var setStoredString = (key, value) => {
|
|
1803
|
+
if (typeof window === "undefined") return;
|
|
1804
|
+
try {
|
|
1805
|
+
localStorage.setItem(key, value);
|
|
1806
|
+
} catch {
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1837
1809
|
|
|
1838
1810
|
// lib/components/MouseTracker.tsx
|
|
1839
1811
|
import {
|
|
@@ -1844,7 +1816,7 @@ import {
|
|
|
1844
1816
|
useMemo as useMemo3,
|
|
1845
1817
|
useRef as useRef4
|
|
1846
1818
|
} from "react";
|
|
1847
|
-
import { Fragment
|
|
1819
|
+
import { Fragment, jsx as jsx9 } from "react/jsx-runtime";
|
|
1848
1820
|
var MouseTrackerContext = createContext(null);
|
|
1849
1821
|
var DRAG_THRESHOLD_PX = 5;
|
|
1850
1822
|
var boundsAreEqual = (a, b) => {
|
|
@@ -1855,7 +1827,7 @@ var boundsAreEqual = (a, b) => {
|
|
|
1855
1827
|
var MouseTracker = ({ children }) => {
|
|
1856
1828
|
const existingContext = useContext(MouseTrackerContext);
|
|
1857
1829
|
if (existingContext) {
|
|
1858
|
-
return /* @__PURE__ */ jsx9(
|
|
1830
|
+
return /* @__PURE__ */ jsx9(Fragment, { children });
|
|
1859
1831
|
}
|
|
1860
1832
|
const storeRef = useRef4({
|
|
1861
1833
|
pointer: null,
|
|
@@ -2204,7 +2176,7 @@ var SchematicComponentMouseTarget = ({
|
|
|
2204
2176
|
|
|
2205
2177
|
// lib/components/SchematicPortMouseTarget.tsx
|
|
2206
2178
|
import { useCallback as useCallback5, useEffect as useEffect11, useRef as useRef7, useState as useState6 } from "react";
|
|
2207
|
-
import { Fragment as
|
|
2179
|
+
import { Fragment as Fragment2, jsx as jsx11, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
2208
2180
|
var areMeasurementsEqual2 = (a, b) => {
|
|
2209
2181
|
if (!a && !b) return true;
|
|
2210
2182
|
if (!a || !b) return false;
|
|
@@ -2319,7 +2291,7 @@ var SchematicPortMouseTarget = ({
|
|
|
2319
2291
|
return null;
|
|
2320
2292
|
}
|
|
2321
2293
|
const rect = measurement.rect;
|
|
2322
|
-
return /* @__PURE__ */ jsxs6(
|
|
2294
|
+
return /* @__PURE__ */ jsxs6(Fragment2, { children: [
|
|
2323
2295
|
/* @__PURE__ */ jsx11(
|
|
2324
2296
|
"div",
|
|
2325
2297
|
{
|
|
@@ -2362,8 +2334,175 @@ var SchematicPortMouseTarget = ({
|
|
|
2362
2334
|
] });
|
|
2363
2335
|
};
|
|
2364
2336
|
|
|
2337
|
+
// lib/components/SchematicSheetSelector.tsx
|
|
2338
|
+
import { useState as useState7 } from "react";
|
|
2339
|
+
import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
|
|
2340
|
+
import { Fragment as Fragment3, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
2341
|
+
var FONT_FAMILY2 = 'system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif';
|
|
2342
|
+
var contentStyles2 = {
|
|
2343
|
+
backgroundColor: "#ffffff",
|
|
2344
|
+
color: "#111111",
|
|
2345
|
+
borderRadius: 8,
|
|
2346
|
+
boxShadow: "0 6px 24px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08)",
|
|
2347
|
+
border: "1px solid #e5e7eb",
|
|
2348
|
+
padding: 4,
|
|
2349
|
+
minWidth: 200,
|
|
2350
|
+
maxWidth: 320,
|
|
2351
|
+
maxHeight: 320,
|
|
2352
|
+
overflowY: "auto",
|
|
2353
|
+
fontSize: 13,
|
|
2354
|
+
fontFamily: FONT_FAMILY2,
|
|
2355
|
+
outline: "none",
|
|
2356
|
+
zIndex: zIndexMap.viewMenu
|
|
2357
|
+
};
|
|
2358
|
+
var itemStyles2 = {
|
|
2359
|
+
display: "flex",
|
|
2360
|
+
alignItems: "center",
|
|
2361
|
+
gap: 8,
|
|
2362
|
+
padding: "7px 10px 7px 8px",
|
|
2363
|
+
borderRadius: 6,
|
|
2364
|
+
cursor: "pointer",
|
|
2365
|
+
outline: "none",
|
|
2366
|
+
userSelect: "none",
|
|
2367
|
+
color: "#111111",
|
|
2368
|
+
fontSize: 13,
|
|
2369
|
+
fontFamily: FONT_FAMILY2
|
|
2370
|
+
};
|
|
2371
|
+
var iconSlotStyles2 = {
|
|
2372
|
+
width: 16,
|
|
2373
|
+
height: 16,
|
|
2374
|
+
flexShrink: 0,
|
|
2375
|
+
display: "inline-flex",
|
|
2376
|
+
alignItems: "center",
|
|
2377
|
+
justifyContent: "center",
|
|
2378
|
+
color: "#111111"
|
|
2379
|
+
};
|
|
2380
|
+
var ellipsisStyles = {
|
|
2381
|
+
overflow: "hidden",
|
|
2382
|
+
textOverflow: "ellipsis",
|
|
2383
|
+
whiteSpace: "nowrap"
|
|
2384
|
+
};
|
|
2385
|
+
var MENU_CSS = `
|
|
2386
|
+
.sv-sheet-item[data-highlighted], .sv-sheet-item:hover { background-color: #f1f3f5; }
|
|
2387
|
+
.sv-sheet-chevron { transition: transform 0.2s ease; }
|
|
2388
|
+
[data-state="open"] > .sv-sheet-chevron { transform: rotate(180deg); }
|
|
2389
|
+
`;
|
|
2390
|
+
var CheckIcon2 = () => /* @__PURE__ */ jsx12(
|
|
2391
|
+
"svg",
|
|
2392
|
+
{
|
|
2393
|
+
width: "14",
|
|
2394
|
+
height: "14",
|
|
2395
|
+
viewBox: "0 0 24 24",
|
|
2396
|
+
fill: "none",
|
|
2397
|
+
stroke: "currentColor",
|
|
2398
|
+
strokeWidth: "2.5",
|
|
2399
|
+
strokeLinecap: "round",
|
|
2400
|
+
strokeLinejoin: "round",
|
|
2401
|
+
"aria-hidden": "true",
|
|
2402
|
+
children: /* @__PURE__ */ jsx12("path", { d: "M20 6 9 17l-5-5" })
|
|
2403
|
+
}
|
|
2404
|
+
);
|
|
2405
|
+
var ChevronDownIcon = ({ className }) => /* @__PURE__ */ jsx12(
|
|
2406
|
+
"svg",
|
|
2407
|
+
{
|
|
2408
|
+
className,
|
|
2409
|
+
width: "14",
|
|
2410
|
+
height: "14",
|
|
2411
|
+
viewBox: "0 0 24 24",
|
|
2412
|
+
fill: "none",
|
|
2413
|
+
stroke: "currentColor",
|
|
2414
|
+
strokeWidth: "2",
|
|
2415
|
+
strokeLinecap: "round",
|
|
2416
|
+
strokeLinejoin: "round",
|
|
2417
|
+
style: { opacity: 0.6, flexShrink: 0 },
|
|
2418
|
+
"aria-hidden": "true",
|
|
2419
|
+
children: /* @__PURE__ */ jsx12("path", { d: "m6 9 6 6 6-6" })
|
|
2420
|
+
}
|
|
2421
|
+
);
|
|
2422
|
+
var SchematicSheetSelector = ({
|
|
2423
|
+
sheets,
|
|
2424
|
+
selectedSheetId,
|
|
2425
|
+
onSelectSheet
|
|
2426
|
+
}) => {
|
|
2427
|
+
const [open, setOpen] = useState7(false);
|
|
2428
|
+
if (sheets.length <= 1) return null;
|
|
2429
|
+
const selectedSheet = sheets.find(
|
|
2430
|
+
(s) => s.schematic_sheet_id === selectedSheetId
|
|
2431
|
+
);
|
|
2432
|
+
const selectedLabel = selectedSheet?.name ?? "Select sheet";
|
|
2433
|
+
return /* @__PURE__ */ jsxs7(Fragment3, { children: [
|
|
2434
|
+
/* @__PURE__ */ jsx12("style", { children: MENU_CSS }),
|
|
2435
|
+
/* @__PURE__ */ jsxs7(DropdownMenu2.Root, { open, onOpenChange: setOpen, modal: false, children: [
|
|
2436
|
+
/* @__PURE__ */ jsx12(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsxs7(
|
|
2437
|
+
"button",
|
|
2438
|
+
{
|
|
2439
|
+
type: "button",
|
|
2440
|
+
title: selectedLabel,
|
|
2441
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
2442
|
+
style: {
|
|
2443
|
+
position: "absolute",
|
|
2444
|
+
top: "16px",
|
|
2445
|
+
left: "16px",
|
|
2446
|
+
display: "flex",
|
|
2447
|
+
alignItems: "center",
|
|
2448
|
+
gap: "6px",
|
|
2449
|
+
maxWidth: "220px",
|
|
2450
|
+
padding: "8px 12px",
|
|
2451
|
+
backgroundColor: "#ffffff",
|
|
2452
|
+
color: "#000000",
|
|
2453
|
+
border: "none",
|
|
2454
|
+
outline: "none",
|
|
2455
|
+
borderRadius: "4px",
|
|
2456
|
+
cursor: "pointer",
|
|
2457
|
+
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
|
|
2458
|
+
fontSize: "13px",
|
|
2459
|
+
fontFamily: FONT_FAMILY2,
|
|
2460
|
+
zIndex: zIndexMap.viewMenuIcon
|
|
2461
|
+
},
|
|
2462
|
+
children: [
|
|
2463
|
+
/* @__PURE__ */ jsx12("span", { style: { color: "#888888", flexShrink: 0 }, children: "Sheet:" }),
|
|
2464
|
+
/* @__PURE__ */ jsx12("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: selectedLabel }),
|
|
2465
|
+
/* @__PURE__ */ jsx12(ChevronDownIcon, { className: "sv-sheet-chevron" })
|
|
2466
|
+
]
|
|
2467
|
+
}
|
|
2468
|
+
) }),
|
|
2469
|
+
/* @__PURE__ */ jsx12(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx12(
|
|
2470
|
+
DropdownMenu2.Content,
|
|
2471
|
+
{
|
|
2472
|
+
style: contentStyles2,
|
|
2473
|
+
side: "bottom",
|
|
2474
|
+
align: "start",
|
|
2475
|
+
sideOffset: 8,
|
|
2476
|
+
collisionPadding: 10,
|
|
2477
|
+
children: sheets.map((sheet) => {
|
|
2478
|
+
const selected = sheet.schematic_sheet_id === selectedSheetId;
|
|
2479
|
+
return /* @__PURE__ */ jsxs7(
|
|
2480
|
+
DropdownMenu2.Item,
|
|
2481
|
+
{
|
|
2482
|
+
className: "sv-sheet-item",
|
|
2483
|
+
style: itemStyles2,
|
|
2484
|
+
title: sheet.name,
|
|
2485
|
+
onSelect: (e) => e.preventDefault(),
|
|
2486
|
+
onPointerUp: () => {
|
|
2487
|
+
onSelectSheet(sheet.schematic_sheet_id);
|
|
2488
|
+
setOpen(false);
|
|
2489
|
+
},
|
|
2490
|
+
children: [
|
|
2491
|
+
/* @__PURE__ */ jsx12("span", { style: iconSlotStyles2, children: selected && /* @__PURE__ */ jsx12(CheckIcon2, {}) }),
|
|
2492
|
+
/* @__PURE__ */ jsx12("span", { style: { ...ellipsisStyles, minWidth: 0 }, children: sheet.name })
|
|
2493
|
+
]
|
|
2494
|
+
},
|
|
2495
|
+
sheet.schematic_sheet_id
|
|
2496
|
+
);
|
|
2497
|
+
})
|
|
2498
|
+
}
|
|
2499
|
+
) })
|
|
2500
|
+
] })
|
|
2501
|
+
] });
|
|
2502
|
+
};
|
|
2503
|
+
|
|
2365
2504
|
// lib/components/SchematicViewer.tsx
|
|
2366
|
-
import { jsx as
|
|
2505
|
+
import { jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
2367
2506
|
var SchematicViewer = ({
|
|
2368
2507
|
circuitJson,
|
|
2369
2508
|
containerStyle,
|
|
@@ -2380,14 +2519,15 @@ var SchematicViewer = ({
|
|
|
2380
2519
|
onSchematicComponentClicked,
|
|
2381
2520
|
showSchematicPorts = false,
|
|
2382
2521
|
onSchematicPortClicked,
|
|
2522
|
+
onSchematicSheetChange,
|
|
2383
2523
|
css,
|
|
2384
2524
|
className
|
|
2385
2525
|
}) => {
|
|
2386
2526
|
if (debug3) {
|
|
2387
2527
|
enableDebug();
|
|
2388
2528
|
}
|
|
2389
|
-
const [showSpiceOverlay, setShowSpiceOverlay] =
|
|
2390
|
-
const [spiceSimOptions, setSpiceSimOptions] =
|
|
2529
|
+
const [showSpiceOverlay, setShowSpiceOverlay] = useState8(false);
|
|
2530
|
+
const [spiceSimOptions, setSpiceSimOptions] = useState8({
|
|
2391
2531
|
showVoltage: true,
|
|
2392
2532
|
showCurrent: false,
|
|
2393
2533
|
startTime: 0,
|
|
@@ -2402,6 +2542,40 @@ var SchematicViewer = ({
|
|
|
2402
2542
|
() => getCircuitHash(circuitJson),
|
|
2403
2543
|
[circuitJson]
|
|
2404
2544
|
);
|
|
2545
|
+
const schematicSheets = useMemo5(() => {
|
|
2546
|
+
try {
|
|
2547
|
+
return circuitJson.filter((elm) => elm?.type === "schematic_sheet").slice().sort((a, b) => (a.sheet_index ?? 0) - (b.sheet_index ?? 0));
|
|
2548
|
+
} catch (err) {
|
|
2549
|
+
console.error("Failed to derive schematic sheets", err);
|
|
2550
|
+
return [];
|
|
2551
|
+
}
|
|
2552
|
+
}, [circuitJsonKey]);
|
|
2553
|
+
const hasMultipleSheets = schematicSheets.length > 1;
|
|
2554
|
+
const defaultSheetId = schematicSheets[0]?.schematic_sheet_id;
|
|
2555
|
+
const [selectedSheetId, setSelectedSheetId] = useState8(
|
|
2556
|
+
() => {
|
|
2557
|
+
const stored = getStoredString(STORAGE_KEYS.SELECTED_SCHEMATIC_SHEET);
|
|
2558
|
+
if (stored && schematicSheets.some((s) => s.schematic_sheet_id === stored)) {
|
|
2559
|
+
return stored;
|
|
2560
|
+
}
|
|
2561
|
+
return defaultSheetId;
|
|
2562
|
+
}
|
|
2563
|
+
);
|
|
2564
|
+
useEffect12(() => {
|
|
2565
|
+
const stillExists = selectedSheetId !== void 0 && schematicSheets.some((s) => s.schematic_sheet_id === selectedSheetId);
|
|
2566
|
+
if (!stillExists) {
|
|
2567
|
+
setSelectedSheetId(defaultSheetId);
|
|
2568
|
+
}
|
|
2569
|
+
}, [circuitJsonKey]);
|
|
2570
|
+
const activeSheetId = hasMultipleSheets ? selectedSheetId ?? defaultSheetId : void 0;
|
|
2571
|
+
const handleSelectSheet = useCallback6(
|
|
2572
|
+
(sheetId) => {
|
|
2573
|
+
setSelectedSheetId(sheetId);
|
|
2574
|
+
setStoredString(STORAGE_KEYS.SELECTED_SCHEMATIC_SHEET, sheetId);
|
|
2575
|
+
onSchematicSheetChange?.(sheetId);
|
|
2576
|
+
},
|
|
2577
|
+
[onSchematicSheetChange]
|
|
2578
|
+
);
|
|
2405
2579
|
const spiceString = useMemo5(() => {
|
|
2406
2580
|
if (!spiceSimulationEnabled) return null;
|
|
2407
2581
|
try {
|
|
@@ -2416,7 +2590,7 @@ var SchematicViewer = ({
|
|
|
2416
2590
|
spiceSimOptions.startTime,
|
|
2417
2591
|
spiceSimOptions.duration
|
|
2418
2592
|
]);
|
|
2419
|
-
const [hasSpiceSimRun, setHasSpiceSimRun] =
|
|
2593
|
+
const [hasSpiceSimRun, setHasSpiceSimRun] = useState8(false);
|
|
2420
2594
|
useEffect12(() => {
|
|
2421
2595
|
setHasSpiceSimRun(false);
|
|
2422
2596
|
}, [circuitJsonKey]);
|
|
@@ -2426,19 +2600,19 @@ var SchematicViewer = ({
|
|
|
2426
2600
|
isLoading: isSpiceSimLoading,
|
|
2427
2601
|
error: spiceSimError
|
|
2428
2602
|
} = useSpiceSimulation(hasSpiceSimRun ? spiceString : null);
|
|
2429
|
-
const [editModeEnabled, setEditModeEnabled] =
|
|
2430
|
-
const [snapToGrid, setSnapToGrid] =
|
|
2431
|
-
const [showGridInternal, setShowGridInternal] =
|
|
2603
|
+
const [editModeEnabled, setEditModeEnabled] = useState8(defaultEditMode);
|
|
2604
|
+
const [snapToGrid, setSnapToGrid] = useState8(true);
|
|
2605
|
+
const [showGridInternal, setShowGridInternal] = useState8(false);
|
|
2432
2606
|
const showGrid = debugGrid || showGridInternal;
|
|
2433
|
-
const [isInteractionEnabled, setIsInteractionEnabled] =
|
|
2607
|
+
const [isInteractionEnabled, setIsInteractionEnabled] = useState8(
|
|
2434
2608
|
!clickToInteractEnabled
|
|
2435
2609
|
);
|
|
2436
|
-
const [showViewMenu, setShowViewMenu] =
|
|
2437
|
-
const [showSchematicGroups, setShowSchematicGroups] =
|
|
2610
|
+
const [showViewMenu, setShowViewMenu] = useState8(false);
|
|
2611
|
+
const [showSchematicGroups, setShowSchematicGroups] = useState8(() => {
|
|
2438
2612
|
if (disableGroups) return false;
|
|
2439
2613
|
return getStoredBoolean("schematic_viewer_show_groups", false);
|
|
2440
2614
|
});
|
|
2441
|
-
const [isHoveringClickableComponent, setIsHoveringClickableComponent] =
|
|
2615
|
+
const [isHoveringClickableComponent, setIsHoveringClickableComponent] = useState8(false);
|
|
2442
2616
|
const hoveringComponentsRef = useRef8(/* @__PURE__ */ new Set());
|
|
2443
2617
|
const handleComponentHoverChange = useCallback6(
|
|
2444
2618
|
(componentId, isHovering) => {
|
|
@@ -2451,7 +2625,7 @@ var SchematicViewer = ({
|
|
|
2451
2625
|
},
|
|
2452
2626
|
[]
|
|
2453
2627
|
);
|
|
2454
|
-
const [isHoveringClickablePort, setIsHoveringClickablePort] =
|
|
2628
|
+
const [isHoveringClickablePort, setIsHoveringClickablePort] = useState8(false);
|
|
2455
2629
|
const hoveringPortsRef = useRef8(/* @__PURE__ */ new Set());
|
|
2456
2630
|
const handlePortHoverChange = useCallback6(
|
|
2457
2631
|
(portId, isHovering) => {
|
|
@@ -2468,16 +2642,21 @@ var SchematicViewer = ({
|
|
|
2468
2642
|
const touchStartRef = useRef8(null);
|
|
2469
2643
|
const schematicComponentIds = useMemo5(() => {
|
|
2470
2644
|
try {
|
|
2471
|
-
|
|
2645
|
+
const components = su6(circuitJson).schematic_component?.list() ?? [];
|
|
2646
|
+
return components.filter(
|
|
2647
|
+
(component) => !activeSheetId || component.schematic_sheet_id === activeSheetId
|
|
2648
|
+
).map((component) => component.schematic_component_id);
|
|
2472
2649
|
} catch (err) {
|
|
2473
2650
|
console.error("Failed to derive schematic component ids", err);
|
|
2474
2651
|
return [];
|
|
2475
2652
|
}
|
|
2476
|
-
}, [circuitJsonKey, circuitJson]);
|
|
2653
|
+
}, [circuitJsonKey, circuitJson, activeSheetId]);
|
|
2477
2654
|
const schematicPortsInfo = useMemo5(() => {
|
|
2478
2655
|
if (!showSchematicPorts) return [];
|
|
2479
2656
|
try {
|
|
2480
|
-
const ports = su6(circuitJson).schematic_port?.list() ?? []
|
|
2657
|
+
const ports = (su6(circuitJson).schematic_port?.list() ?? []).filter(
|
|
2658
|
+
(port) => !activeSheetId || port.schematic_sheet_id === activeSheetId
|
|
2659
|
+
);
|
|
2481
2660
|
return ports.map((port) => {
|
|
2482
2661
|
const sourcePort = su6(circuitJson).source_port.get(port.source_port_id);
|
|
2483
2662
|
const sourceComponent = sourcePort?.source_component_id ? su6(circuitJson).source_component.get(sourcePort.source_component_id) : null;
|
|
@@ -2492,7 +2671,7 @@ var SchematicViewer = ({
|
|
|
2492
2671
|
console.error("Failed to derive schematic port info", err);
|
|
2493
2672
|
return [];
|
|
2494
2673
|
}
|
|
2495
|
-
}, [circuitJsonKey, circuitJson, showSchematicPorts]);
|
|
2674
|
+
}, [circuitJsonKey, circuitJson, showSchematicPorts, activeSheetId]);
|
|
2496
2675
|
const handleTouchStart = (e) => {
|
|
2497
2676
|
const touch = e.touches[0];
|
|
2498
2677
|
touchStartRef.current = {
|
|
@@ -2512,7 +2691,7 @@ var SchematicViewer = ({
|
|
|
2512
2691
|
}
|
|
2513
2692
|
touchStartRef.current = null;
|
|
2514
2693
|
};
|
|
2515
|
-
const [internalEditEvents, setInternalEditEvents] =
|
|
2694
|
+
const [internalEditEvents, setInternalEditEvents] = useState8([]);
|
|
2516
2695
|
const circuitJsonRef = useRef8(circuitJson);
|
|
2517
2696
|
useEffect12(() => {
|
|
2518
2697
|
const circuitHash = getCircuitHash(circuitJson);
|
|
@@ -2541,6 +2720,7 @@ var SchematicViewer = ({
|
|
|
2541
2720
|
width: containerWidth,
|
|
2542
2721
|
height: containerHeight || 720,
|
|
2543
2722
|
drawPorts: showSchematicPorts,
|
|
2723
|
+
schematicSheetId: activeSheetId,
|
|
2544
2724
|
grid: !showGrid ? void 0 : {
|
|
2545
2725
|
cellSize: 1,
|
|
2546
2726
|
labelCells: true
|
|
@@ -2554,7 +2734,8 @@ var SchematicViewer = ({
|
|
|
2554
2734
|
containerWidth,
|
|
2555
2735
|
containerHeight,
|
|
2556
2736
|
showGrid,
|
|
2557
|
-
showSchematicPorts
|
|
2737
|
+
showSchematicPorts,
|
|
2738
|
+
activeSheetId
|
|
2558
2739
|
]);
|
|
2559
2740
|
const containerBackgroundColor = useMemo5(() => {
|
|
2560
2741
|
const match = svgString.match(
|
|
@@ -2614,7 +2795,7 @@ var SchematicViewer = ({
|
|
|
2614
2795
|
useSchematicGroupsOverlay({
|
|
2615
2796
|
svgDivRef,
|
|
2616
2797
|
circuitJson,
|
|
2617
|
-
circuitJsonKey
|
|
2798
|
+
circuitJsonKey: `${circuitJsonKey}_${activeSheetId ?? ""}`,
|
|
2618
2799
|
showGroups: showSchematicGroups && !disableGroups
|
|
2619
2800
|
});
|
|
2620
2801
|
const handleComponentTouchStartRef = useRef8(handleComponentTouchStart);
|
|
@@ -2622,7 +2803,7 @@ var SchematicViewer = ({
|
|
|
2622
2803
|
handleComponentTouchStartRef.current = handleComponentTouchStart;
|
|
2623
2804
|
}, [handleComponentTouchStart]);
|
|
2624
2805
|
const svgDiv = useMemo5(
|
|
2625
|
-
() => /* @__PURE__ */
|
|
2806
|
+
() => /* @__PURE__ */ jsx13(
|
|
2626
2807
|
"div",
|
|
2627
2808
|
{
|
|
2628
2809
|
ref: svgDivRef,
|
|
@@ -2647,10 +2828,10 @@ var SchematicViewer = ({
|
|
|
2647
2828
|
showSpiceOverlay
|
|
2648
2829
|
]
|
|
2649
2830
|
);
|
|
2650
|
-
return /* @__PURE__ */
|
|
2651
|
-
onSchematicComponentClicked && /* @__PURE__ */
|
|
2652
|
-
onSchematicPortClicked && /* @__PURE__ */
|
|
2653
|
-
/* @__PURE__ */
|
|
2831
|
+
return /* @__PURE__ */ jsxs8(MouseTracker, { children: [
|
|
2832
|
+
onSchematicComponentClicked && /* @__PURE__ */ jsx13("style", { children: `.schematic-component-clickable [data-schematic-component-id]:hover { cursor: pointer !important; }` }),
|
|
2833
|
+
onSchematicPortClicked && /* @__PURE__ */ jsx13("style", { children: `[data-schematic-port-id]:hover { cursor: pointer !important; }` }),
|
|
2834
|
+
/* @__PURE__ */ jsxs8(
|
|
2654
2835
|
"div",
|
|
2655
2836
|
{
|
|
2656
2837
|
ref: containerRef,
|
|
@@ -2691,7 +2872,7 @@ var SchematicViewer = ({
|
|
|
2691
2872
|
handleTouchEnd(e);
|
|
2692
2873
|
},
|
|
2693
2874
|
children: [
|
|
2694
|
-
!isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */
|
|
2875
|
+
!isInteractionEnabled && clickToInteractEnabled && /* @__PURE__ */ jsx13(
|
|
2695
2876
|
"div",
|
|
2696
2877
|
{
|
|
2697
2878
|
onClick: (e) => {
|
|
@@ -2710,7 +2891,7 @@ var SchematicViewer = ({
|
|
|
2710
2891
|
pointerEvents: "all",
|
|
2711
2892
|
touchAction: "pan-x pan-y pinch-zoom"
|
|
2712
2893
|
},
|
|
2713
|
-
children: /* @__PURE__ */
|
|
2894
|
+
children: /* @__PURE__ */ jsx13(
|
|
2714
2895
|
"div",
|
|
2715
2896
|
{
|
|
2716
2897
|
style: {
|
|
@@ -2727,34 +2908,27 @@ var SchematicViewer = ({
|
|
|
2727
2908
|
)
|
|
2728
2909
|
}
|
|
2729
2910
|
),
|
|
2730
|
-
/* @__PURE__ */
|
|
2731
|
-
ViewMenuIcon,
|
|
2732
|
-
{
|
|
2733
|
-
active: showViewMenu,
|
|
2734
|
-
onClick: () => setShowViewMenu(!showViewMenu)
|
|
2735
|
-
}
|
|
2736
|
-
),
|
|
2737
|
-
editingEnabled && /* @__PURE__ */ jsx12(
|
|
2911
|
+
editingEnabled && /* @__PURE__ */ jsx13(
|
|
2738
2912
|
EditIcon,
|
|
2739
2913
|
{
|
|
2740
2914
|
active: editModeEnabled,
|
|
2741
2915
|
onClick: () => setEditModeEnabled(!editModeEnabled)
|
|
2742
2916
|
}
|
|
2743
2917
|
),
|
|
2744
|
-
editingEnabled && editModeEnabled && /* @__PURE__ */
|
|
2918
|
+
editingEnabled && editModeEnabled && /* @__PURE__ */ jsx13(
|
|
2745
2919
|
GridIcon,
|
|
2746
2920
|
{
|
|
2747
2921
|
active: snapToGrid,
|
|
2748
2922
|
onClick: () => setSnapToGrid(!snapToGrid)
|
|
2749
2923
|
}
|
|
2750
2924
|
),
|
|
2751
|
-
/* @__PURE__ */
|
|
2925
|
+
/* @__PURE__ */ jsx13(
|
|
2752
2926
|
ViewMenu,
|
|
2753
2927
|
{
|
|
2754
2928
|
circuitJson,
|
|
2755
2929
|
circuitJsonKey,
|
|
2756
|
-
|
|
2757
|
-
|
|
2930
|
+
open: showViewMenu,
|
|
2931
|
+
onOpenChange: setShowViewMenu,
|
|
2758
2932
|
showGroups: showSchematicGroups,
|
|
2759
2933
|
onToggleGroups: (value) => {
|
|
2760
2934
|
if (!disableGroups) {
|
|
@@ -2766,8 +2940,16 @@ var SchematicViewer = ({
|
|
|
2766
2940
|
onToggleGrid: setShowGridInternal
|
|
2767
2941
|
}
|
|
2768
2942
|
),
|
|
2769
|
-
|
|
2770
|
-
|
|
2943
|
+
/* @__PURE__ */ jsx13(
|
|
2944
|
+
SchematicSheetSelector,
|
|
2945
|
+
{
|
|
2946
|
+
sheets: schematicSheets,
|
|
2947
|
+
selectedSheetId: activeSheetId,
|
|
2948
|
+
onSelectSheet: handleSelectSheet
|
|
2949
|
+
}
|
|
2950
|
+
),
|
|
2951
|
+
spiceSimulationEnabled && /* @__PURE__ */ jsx13(SpiceSimulationIcon, { onClick: () => setShowSpiceOverlay(true) }),
|
|
2952
|
+
showSpiceOverlay && /* @__PURE__ */ jsx13(
|
|
2771
2953
|
SpiceSimulationOverlay,
|
|
2772
2954
|
{
|
|
2773
2955
|
spiceString,
|
|
@@ -2784,7 +2966,7 @@ var SchematicViewer = ({
|
|
|
2784
2966
|
hasRun: hasSpiceSimRun
|
|
2785
2967
|
}
|
|
2786
2968
|
),
|
|
2787
|
-
onSchematicComponentClicked && schematicComponentIds.map((componentId) => /* @__PURE__ */
|
|
2969
|
+
onSchematicComponentClicked && schematicComponentIds.map((componentId) => /* @__PURE__ */ jsx13(
|
|
2788
2970
|
SchematicComponentMouseTarget,
|
|
2789
2971
|
{
|
|
2790
2972
|
componentId,
|
|
@@ -2803,7 +2985,7 @@ var SchematicViewer = ({
|
|
|
2803
2985
|
componentId
|
|
2804
2986
|
)),
|
|
2805
2987
|
svgDiv,
|
|
2806
|
-
showSchematicPorts && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */
|
|
2988
|
+
showSchematicPorts && schematicPortsInfo.map(({ portId, label }) => /* @__PURE__ */ jsx13(
|
|
2807
2989
|
SchematicPortMouseTarget,
|
|
2808
2990
|
{
|
|
2809
2991
|
portId,
|
|
@@ -2832,10 +3014,10 @@ var SchematicViewer = ({
|
|
|
2832
3014
|
import {
|
|
2833
3015
|
convertCircuitJsonToSchematicSimulationSvg
|
|
2834
3016
|
} from "circuit-to-svg";
|
|
2835
|
-
import { useEffect as useEffect13, useState as
|
|
3017
|
+
import { useEffect as useEffect13, useState as useState9, useMemo as useMemo6, useRef as useRef9 } from "react";
|
|
2836
3018
|
import { useMouseMatrixTransform as useMouseMatrixTransform2 } from "use-mouse-matrix-transform";
|
|
2837
3019
|
import { toString as transformToString2 } from "transformation-matrix";
|
|
2838
|
-
import { jsx as
|
|
3020
|
+
import { jsx as jsx14, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
2839
3021
|
var DEFAULT_RENDER_WIDTH = 1200;
|
|
2840
3022
|
var DEFAULT_RENDER_ASPECT_RATIO = 1;
|
|
2841
3023
|
var AnalogSimulationViewer = ({
|
|
@@ -2846,16 +3028,16 @@ var AnalogSimulationViewer = ({
|
|
|
2846
3028
|
height,
|
|
2847
3029
|
className
|
|
2848
3030
|
}) => {
|
|
2849
|
-
const [circuitJson, setCircuitJson] =
|
|
2850
|
-
const [isLoading, setIsLoading] =
|
|
2851
|
-
const [error, setError] =
|
|
2852
|
-
const [svgObjectUrl, setSvgObjectUrl] =
|
|
3031
|
+
const [circuitJson, setCircuitJson] = useState9(null);
|
|
3032
|
+
const [isLoading, setIsLoading] = useState9(true);
|
|
3033
|
+
const [error, setError] = useState9(null);
|
|
3034
|
+
const [svgObjectUrl, setSvgObjectUrl] = useState9(null);
|
|
2853
3035
|
const containerRef = useRef9(null);
|
|
2854
3036
|
const imgRef = useRef9(null);
|
|
2855
3037
|
const { containerWidth } = useResizeHandling(
|
|
2856
3038
|
containerRef
|
|
2857
3039
|
);
|
|
2858
|
-
const [isDragging, setIsDragging] =
|
|
3040
|
+
const [isDragging, setIsDragging] = useState9(false);
|
|
2859
3041
|
const {
|
|
2860
3042
|
ref: transformRef,
|
|
2861
3043
|
cancelDrag: _cancelDrag,
|
|
@@ -2962,7 +3144,7 @@ var AnalogSimulationViewer = ({
|
|
|
2962
3144
|
};
|
|
2963
3145
|
}, []);
|
|
2964
3146
|
if (isLoading) {
|
|
2965
|
-
return /* @__PURE__ */
|
|
3147
|
+
return /* @__PURE__ */ jsx14(
|
|
2966
3148
|
"div",
|
|
2967
3149
|
{
|
|
2968
3150
|
style: {
|
|
@@ -2982,7 +3164,7 @@ var AnalogSimulationViewer = ({
|
|
|
2982
3164
|
);
|
|
2983
3165
|
}
|
|
2984
3166
|
if (error) {
|
|
2985
|
-
return /* @__PURE__ */
|
|
3167
|
+
return /* @__PURE__ */ jsx14(
|
|
2986
3168
|
"div",
|
|
2987
3169
|
{
|
|
2988
3170
|
style: {
|
|
@@ -2997,15 +3179,15 @@ var AnalogSimulationViewer = ({
|
|
|
2997
3179
|
...containerStyle
|
|
2998
3180
|
},
|
|
2999
3181
|
className,
|
|
3000
|
-
children: /* @__PURE__ */
|
|
3001
|
-
/* @__PURE__ */
|
|
3002
|
-
/* @__PURE__ */
|
|
3182
|
+
children: /* @__PURE__ */ jsxs9("div", { style: { textAlign: "center", padding: "20px" }, children: [
|
|
3183
|
+
/* @__PURE__ */ jsx14("div", { style: { fontWeight: "bold", marginBottom: "8px" }, children: "Circuit Conversion Error" }),
|
|
3184
|
+
/* @__PURE__ */ jsx14("div", { style: { fontSize: "14px" }, children: error })
|
|
3003
3185
|
] })
|
|
3004
3186
|
}
|
|
3005
3187
|
);
|
|
3006
3188
|
}
|
|
3007
3189
|
if (!simulationSvg) {
|
|
3008
|
-
return /* @__PURE__ */
|
|
3190
|
+
return /* @__PURE__ */ jsxs9(
|
|
3009
3191
|
"div",
|
|
3010
3192
|
{
|
|
3011
3193
|
style: {
|
|
@@ -3021,11 +3203,11 @@ var AnalogSimulationViewer = ({
|
|
|
3021
3203
|
},
|
|
3022
3204
|
className,
|
|
3023
3205
|
children: [
|
|
3024
|
-
/* @__PURE__ */
|
|
3025
|
-
/* @__PURE__ */
|
|
3206
|
+
/* @__PURE__ */ jsx14("div", { style: { fontSize: "16px", color: "#475569", fontWeight: 500 }, children: "No Simulation Found" }),
|
|
3207
|
+
/* @__PURE__ */ jsxs9("div", { style: { fontSize: "14px", color: "#64748b" }, children: [
|
|
3026
3208
|
"Use",
|
|
3027
3209
|
" ",
|
|
3028
|
-
/* @__PURE__ */
|
|
3210
|
+
/* @__PURE__ */ jsx14(
|
|
3029
3211
|
"code",
|
|
3030
3212
|
{
|
|
3031
3213
|
style: {
|
|
@@ -3045,7 +3227,7 @@ var AnalogSimulationViewer = ({
|
|
|
3045
3227
|
}
|
|
3046
3228
|
);
|
|
3047
3229
|
}
|
|
3048
|
-
return /* @__PURE__ */
|
|
3230
|
+
return /* @__PURE__ */ jsx14(
|
|
3049
3231
|
"div",
|
|
3050
3232
|
{
|
|
3051
3233
|
ref: (node) => {
|
|
@@ -3063,7 +3245,7 @@ var AnalogSimulationViewer = ({
|
|
|
3063
3245
|
className,
|
|
3064
3246
|
onMouseDown: handleMouseDown,
|
|
3065
3247
|
onTouchStart: handleTouchStart,
|
|
3066
|
-
children: svgObjectUrl ? /* @__PURE__ */
|
|
3248
|
+
children: svgObjectUrl ? /* @__PURE__ */ jsx14(
|
|
3067
3249
|
"img",
|
|
3068
3250
|
{
|
|
3069
3251
|
ref: imgRef,
|
|
@@ -3077,7 +3259,7 @@ var AnalogSimulationViewer = ({
|
|
|
3077
3259
|
objectFit: "contain"
|
|
3078
3260
|
}
|
|
3079
3261
|
}
|
|
3080
|
-
) : /* @__PURE__ */
|
|
3262
|
+
) : /* @__PURE__ */ jsx14(
|
|
3081
3263
|
"div",
|
|
3082
3264
|
{
|
|
3083
3265
|
style: {
|