@tscircuit/schematic-viewer 1.3.0 → 1.4.1
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/README.md +1 -1
- package/biome.json +45 -0
- package/dist/index.d.ts +3 -4
- package/dist/index.js +734 -688
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
- package/src/Schematic.tsx +141 -65
- package/src/lib/render-context/index.ts +1 -1
- package/src/lib/types/core.ts +14 -49
- package/src/lib/types/source-component.ts +6 -1
- package/src/lib/utils/collect-element-refs.ts +5 -4
- package/src/lib/utils/colors.ts +235 -0
- package/src/lib/utils/direction-to-vec.ts +3 -3
- package/src/schematic-components/SVGPathComponent.tsx +71 -112
- package/src/schematic-components/SchematicChip.tsx +222 -0
- package/src/schematic-components/SchematicComponent.tsx +25 -22
- package/src/schematic-components/SchematicComponentFromSymbol.tsx +46 -0
- package/src/schematic-components/SchematicElement.tsx +0 -28
- package/src/schematic-components/SchematicNetLabel.tsx +3 -0
- package/src/schematic-components/SchematicText.tsx +4 -6
- package/src/schematic-components/SchematicTrace.tsx +4 -3
- package/src/schematic-components/TableViewer.tsx +1 -1
- package/src/schematic-components/index.tsx +6 -14
- package/src/stories/basics/schematic-net-label.stories.tsx +2 -0
- package/src/stories/basics/schematic-net-labels-2.stories.tsx +22 -20
- package/src/stories/bug-connections.stories.tsx +18 -13
- package/src/stories/bug-high-port-numbers.stories.tsx +107 -85
- package/src/stories/bug-one-sided.stories.tsx +17 -15
- package/src/stories/bug-pin-spacing.stories.tsx +19 -17
- package/src/stories/bugs/bug1-y-flip.stories.tsx +7 -5
- package/src/stories/bugs/bug3-scaling-trace.stories.tsx +11 -5
- package/src/stories/bugs/bug4-schematic-line.stories.tsx +0 -1
- package/src/stories/bugs/bug5-diode.stories.tsx +3 -2
- package/src/stories/bugs/bug6-trace-scaling.stories.tsx +5 -41
- package/src/stories/bugs/bug8-autolayout.stories.tsx +20 -29
- package/src/stories/circuit-components/diode.stories.tsx +3 -1
- package/src/stories/circuit-components/resistor.stories.tsx +3 -1
- package/src/stories/led-circuit-react.stories.tsx +35 -48
- package/src/stories/rotated-resistor.stories.tsx +10 -8
- package/src/stories/three-sided-bug.stories.tsx +17 -15
- package/src/pages/led-circuit.tsx +0 -96
- package/src/schematic-components/ProjectComponent.tsx +0 -70
- package/src/schematic-components/SchematicBox.tsx +0 -29
- package/src/schematic-components/SchematicBug.tsx +0 -107
- package/src/schematic-components/SchematicLine.tsx +0 -48
- package/src/schematic-components/SchematicPath.tsx +0 -51
- package/src/schematic-components/SchematicPort.tsx +0 -63
- package/src/schematic-components/SimpleCapacitor.tsx +0 -29
- package/src/schematic-components/SimpleDiode.tsx +0 -42
- package/src/schematic-components/SimpleGround.tsx +0 -30
- package/src/schematic-components/SimpleInductor.tsx +0 -29
- package/src/schematic-components/SimplePowerSource.tsx +0 -43
- package/src/schematic-components/SimpleResistor.tsx +0 -28
- package/src/stories/led-circuit-builder.stories.tsx +0 -104
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import * as Type from "lib/types"
|
|
2
|
-
import SVGPathComponent from "./SVGPathComponent"
|
|
3
|
-
|
|
4
|
-
interface Props {
|
|
5
|
-
component: {
|
|
6
|
-
source: Type.SimpleResistor
|
|
7
|
-
schematic: Type.SchematicComponent
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const SimpleResistor = ({ component: { source, schematic } }: Props) => {
|
|
12
|
-
return (
|
|
13
|
-
<SVGPathComponent
|
|
14
|
-
rotation={schematic.rotation}
|
|
15
|
-
center={schematic.center}
|
|
16
|
-
size={schematic.size}
|
|
17
|
-
paths={[
|
|
18
|
-
{
|
|
19
|
-
stroke: "red",
|
|
20
|
-
strokeWidth: 1,
|
|
21
|
-
d: "M 0 15 l 10 0 l 0 -6 l 20 0 l 0 12 l -20 0 l 0 -6 m 20 0 l 10 0",
|
|
22
|
-
},
|
|
23
|
-
]}
|
|
24
|
-
/>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export default SimpleResistor
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { useMaybePromise } from "lib/hooks"
|
|
2
|
-
import { Schematic } from "../Schematic"
|
|
3
|
-
import { createProjectBuilder } from "@tscircuit/builder"
|
|
4
|
-
|
|
5
|
-
const pb = createProjectBuilder()
|
|
6
|
-
const $soup = pb
|
|
7
|
-
.addGroup((gb) =>
|
|
8
|
-
gb
|
|
9
|
-
.addResistor((rb) =>
|
|
10
|
-
rb
|
|
11
|
-
.setSourceProperties({
|
|
12
|
-
resistance: "10 ohm",
|
|
13
|
-
name: "R1",
|
|
14
|
-
})
|
|
15
|
-
.setSchematicCenter(2, 1)
|
|
16
|
-
)
|
|
17
|
-
.addCapacitor((cb) =>
|
|
18
|
-
cb
|
|
19
|
-
.setSourceProperties({
|
|
20
|
-
name: "C1",
|
|
21
|
-
capacitance: "10 uF",
|
|
22
|
-
})
|
|
23
|
-
.setSchematicCenter(4, 2)
|
|
24
|
-
.setSchematicRotation("90deg")
|
|
25
|
-
)
|
|
26
|
-
.addResistor((cb) =>
|
|
27
|
-
cb
|
|
28
|
-
.setSourceProperties({
|
|
29
|
-
resistance: "10 ohm",
|
|
30
|
-
name: "R2",
|
|
31
|
-
})
|
|
32
|
-
.setSchematicCenter(6, 1)
|
|
33
|
-
.setSchematicRotation("90deg")
|
|
34
|
-
)
|
|
35
|
-
.addTrace([".R1 > port.right", ".C1 > port.left", ".R2 > port.left"])
|
|
36
|
-
.addPowerSource((cb) =>
|
|
37
|
-
cb
|
|
38
|
-
.setSourceProperties({
|
|
39
|
-
voltage: "5V",
|
|
40
|
-
name: "main_power",
|
|
41
|
-
})
|
|
42
|
-
.setSchematicCenter(1, 2)
|
|
43
|
-
)
|
|
44
|
-
.addTrace(["power > port.positive", ".R1 > port.left"])
|
|
45
|
-
.addTrace([
|
|
46
|
-
"power > port.negative",
|
|
47
|
-
".C1 > port.right",
|
|
48
|
-
".R2 > port.right",
|
|
49
|
-
])
|
|
50
|
-
.addBug((cb) =>
|
|
51
|
-
cb
|
|
52
|
-
.setSourceProperties({ name: "B1" })
|
|
53
|
-
.setSchematicProperties({
|
|
54
|
-
port_arrangement: {
|
|
55
|
-
left_size: 3,
|
|
56
|
-
right_size: 3,
|
|
57
|
-
},
|
|
58
|
-
})
|
|
59
|
-
.labelPort(1, "PWR")
|
|
60
|
-
.labelPort(2, "NC")
|
|
61
|
-
.labelPort(3, "RG")
|
|
62
|
-
.labelPort(4, "D0")
|
|
63
|
-
.labelPort(5, "D1")
|
|
64
|
-
.labelPort(6, "GND")
|
|
65
|
-
.setSchematicCenter(8, 3)
|
|
66
|
-
)
|
|
67
|
-
.addTrace([".B1 > port.PWR", ".R2 > port.left"])
|
|
68
|
-
.addGround((cb) =>
|
|
69
|
-
cb
|
|
70
|
-
.setSourceProperties({
|
|
71
|
-
name: "GND",
|
|
72
|
-
})
|
|
73
|
-
.setSchematicCenter(11, 3)
|
|
74
|
-
)
|
|
75
|
-
.addTrace([".B1 > port.GND", ".gnd"])
|
|
76
|
-
.addDiode((db) =>
|
|
77
|
-
db
|
|
78
|
-
.setSourceProperties({ name: "D1" })
|
|
79
|
-
.setSchematicCenter(6, 3.5)
|
|
80
|
-
.setSchematicRotation("180deg")
|
|
81
|
-
)
|
|
82
|
-
.addTrace([".D1 > .left", ".B1 > .RG"])
|
|
83
|
-
.addTrace([".D1 > .right", ".C1 > .right"])
|
|
84
|
-
.add("net_alias", (nab) =>
|
|
85
|
-
nab
|
|
86
|
-
.setSourceProperties({
|
|
87
|
-
net: "D0BUS",
|
|
88
|
-
})
|
|
89
|
-
.setSchematicCenter("10mm", "1mm")
|
|
90
|
-
)
|
|
91
|
-
.addTrace([".D0BUS", ".B1 > .D0"])
|
|
92
|
-
)
|
|
93
|
-
.build(pb.createBuildContext())
|
|
94
|
-
|
|
95
|
-
export const LEDCircuitBuilder = () => {
|
|
96
|
-
const soup = useMaybePromise($soup)
|
|
97
|
-
if (!soup) return null
|
|
98
|
-
return <Schematic style={{ height: 600 }} soup={soup as any} />
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export default {
|
|
102
|
-
title: "LEDCircuitBuilder",
|
|
103
|
-
component: LEDCircuitBuilder,
|
|
104
|
-
}
|