@tscircuit/schematic-viewer 1.1.4 → 1.1.6
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/schematic-viewer",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": "tscircuit/schematic-viewer",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@storybook/nextjs": "^7.4.0",
|
|
33
33
|
"@storybook/react": "^7.4.0",
|
|
34
34
|
"@storybook/testing-library": "^0.0.14-next.2",
|
|
35
|
-
"@tscircuit/builder": "^1.
|
|
35
|
+
"@tscircuit/builder": "^1.5.5",
|
|
36
36
|
"@tscircuit/react-fiber": "^1.0.6",
|
|
37
37
|
"@tscircuit/routing": "^1.3.0",
|
|
38
38
|
"@tscircuit/table-viewer": "^0.0.6",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"react-error-boundary": "^4.0.4",
|
|
64
|
-
"react-supergrid": "^1.0.
|
|
64
|
+
"react-supergrid": "^1.0.8",
|
|
65
65
|
"use-mouse-matrix-transform": "^1.1.9"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/Schematic.tsx
CHANGED
|
@@ -16,7 +16,7 @@ import { ErrorBoundary } from "react-error-boundary"
|
|
|
16
16
|
import { identity, compose, scale, translate } from "transformation-matrix"
|
|
17
17
|
import { useRenderContext } from "lib/render-context"
|
|
18
18
|
import useMeasure from "react-use-measure"
|
|
19
|
-
import {
|
|
19
|
+
import { TableViewer } from "./schematic-components/TableViewer"
|
|
20
20
|
|
|
21
21
|
const fallbackRender =
|
|
22
22
|
(elm) =>
|
|
@@ -146,9 +146,7 @@ export const Schematic = ({
|
|
|
146
146
|
</ErrorBoundary>
|
|
147
147
|
))}
|
|
148
148
|
</div>
|
|
149
|
-
{showTable !== false && elements &&
|
|
150
|
-
<SoupTableViewer elements={elements} />
|
|
151
|
-
)}
|
|
149
|
+
{showTable !== false && elements && <TableViewer elements={elements} />}
|
|
152
150
|
</>
|
|
153
151
|
)
|
|
154
152
|
}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import * as Type from "lib/types"
|
|
2
2
|
import SVGPathComponent from "./SVGPathComponent"
|
|
3
3
|
import range from "lodash/range"
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
getPortPosition,
|
|
6
|
+
getPortArrangementSize,
|
|
7
|
+
getPortIndices,
|
|
8
|
+
} from "@tscircuit/builder"
|
|
5
9
|
import getSVGPathBounds from "lib/utils/get-svg-path-bounds"
|
|
6
10
|
|
|
7
11
|
interface Props {
|
|
@@ -22,6 +26,7 @@ export const SchematicBug = ({ component: { source, schematic } }: Props) => {
|
|
|
22
26
|
let bugh = schematic.size.height
|
|
23
27
|
const { total_ports, width, height } =
|
|
24
28
|
getPortArrangementSize(port_arrangement)
|
|
29
|
+
const port_indices = getPortIndices(port_arrangement)
|
|
25
30
|
|
|
26
31
|
// TODO remove, this seems to be due to a builder bug
|
|
27
32
|
if (isNaN(bugw)) bugw = width
|
|
@@ -36,7 +41,7 @@ export const SchematicBug = ({ component: { source, schematic } }: Props) => {
|
|
|
36
41
|
bugw / 2
|
|
37
42
|
} ${bugh / 2} L ${-bugw / 2} ${bugh / 2}Z`,
|
|
38
43
|
},
|
|
39
|
-
...
|
|
44
|
+
...port_indices.map((portNum) => {
|
|
40
45
|
const pos = getPortPosition(port_arrangement, portNum)
|
|
41
46
|
|
|
42
47
|
const x2 =
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { lazy, Suspense } from "react"
|
|
2
|
+
|
|
3
|
+
const LazyTableViewer = lazy(() =>
|
|
4
|
+
import("@tscircuit/table-viewer").then((m) => ({
|
|
5
|
+
default: m.SoupTableViewer,
|
|
6
|
+
}))
|
|
7
|
+
)
|
|
8
|
+
|
|
9
|
+
export const TableViewer = (params: Parameters<typeof LazyTableViewer>[0]) => (
|
|
10
|
+
<Suspense fallback={<div>Loading...</div>}>
|
|
11
|
+
<LazyTableViewer {...params} />
|
|
12
|
+
</Suspense>
|
|
13
|
+
)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { Schematic } from "Schematic"
|
|
2
|
+
|
|
3
|
+
export const FTDIBasic3v3 = () => (
|
|
4
|
+
<group>
|
|
5
|
+
<bug
|
|
6
|
+
name="U1"
|
|
7
|
+
port_arrangement={{
|
|
8
|
+
left_side: {
|
|
9
|
+
pins: [16, 15, 20, 17, 4, 27, 28, 19, 26, 25, 7, 18, 21],
|
|
10
|
+
direction: "top-to-bottom",
|
|
11
|
+
},
|
|
12
|
+
right_side: {
|
|
13
|
+
pins: [1, 5, 11, 3, 2, 9, 10, 6, 23, 22, 14, 13, 12],
|
|
14
|
+
direction: "top-to-bottom",
|
|
15
|
+
},
|
|
16
|
+
}}
|
|
17
|
+
footprint="ssop28Db"
|
|
18
|
+
port_labels={{
|
|
19
|
+
"1": "TXD",
|
|
20
|
+
"5": "RXD",
|
|
21
|
+
"11": "CTS",
|
|
22
|
+
"3": "RTS",
|
|
23
|
+
"2": "DTR",
|
|
24
|
+
"9": "DSR",
|
|
25
|
+
"10": "DCD",
|
|
26
|
+
"6": "RI",
|
|
27
|
+
"23": "TXLED",
|
|
28
|
+
"22": "RXLED",
|
|
29
|
+
"14": "PWRUN",
|
|
30
|
+
"13": "TXDEN",
|
|
31
|
+
"12": "SLEEP",
|
|
32
|
+
"16": "USBDM",
|
|
33
|
+
"15": "USBDP",
|
|
34
|
+
"20": "VCC",
|
|
35
|
+
"17": "3V3OUT",
|
|
36
|
+
"4": "VCCIO",
|
|
37
|
+
"27": "OSCI",
|
|
38
|
+
"28": "OSCO",
|
|
39
|
+
"19": "RESET",
|
|
40
|
+
"26": "TEST",
|
|
41
|
+
"25": "AGND",
|
|
42
|
+
"7": "GND7",
|
|
43
|
+
"18": "GND18",
|
|
44
|
+
"21": "GND21",
|
|
45
|
+
}}
|
|
46
|
+
/>
|
|
47
|
+
<resistor
|
|
48
|
+
resistance="1kohm"
|
|
49
|
+
name="R1"
|
|
50
|
+
footprint="0805"
|
|
51
|
+
center={[3, 0]}
|
|
52
|
+
rotation="90deg"
|
|
53
|
+
/>
|
|
54
|
+
<resistor
|
|
55
|
+
resistance="1kohm"
|
|
56
|
+
name="R2"
|
|
57
|
+
footprint="0805"
|
|
58
|
+
center={[4.5, 0]}
|
|
59
|
+
rotation="90deg"
|
|
60
|
+
/>
|
|
61
|
+
<diode name="LED1" footprint="0805" rotation="90deg" center={[3, 2]} />
|
|
62
|
+
<diode name="LED2" footprint="0805" rotation="90deg" center={[4.5, 2]} />
|
|
63
|
+
<netalias net="5V" center={[3, -2]} />
|
|
64
|
+
<netalias net="5V" center={[4.5, -2]} />
|
|
65
|
+
<trace path={[".5V", ".R2 > port.left"]} />
|
|
66
|
+
<trace path={[".5V", ".R1 > port.left"]} />
|
|
67
|
+
<trace path={[".R1 > port.right", ".LED1 > port.left"]} />
|
|
68
|
+
<trace path={[".R2 > port.right", ".LED2 > port.left"]} />
|
|
69
|
+
<trace path={[".LED1 > port.right", ".U1 > .TXLED"]} />
|
|
70
|
+
<trace path={[".LED2 > port.right", ".U1 > .RXLED"]} />
|
|
71
|
+
<netalias net="GND" center={[-3, 4]} rotation="180deg" />
|
|
72
|
+
<netalias net="GND" center={[-5, 3]} rotation="180deg" />
|
|
73
|
+
<netalias net="GND" center={[-6, 3]} rotation="180deg" />
|
|
74
|
+
<netalias net="GND" center={[-7, 3]} rotation="180deg" />
|
|
75
|
+
<netalias net="GND" center={[-8, 2]} rotation="180deg" />
|
|
76
|
+
{/* <component>
|
|
77
|
+
<schematicbox
|
|
78
|
+
name="USB"
|
|
79
|
+
center={[-9, 0]}
|
|
80
|
+
type="schematic_box"
|
|
81
|
+
drawing_type="box"
|
|
82
|
+
width={2}
|
|
83
|
+
height={2}
|
|
84
|
+
/>
|
|
85
|
+
</component> */}
|
|
86
|
+
</group>
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
export const BugHighPortNumbers = () => {
|
|
90
|
+
return (
|
|
91
|
+
<Schematic style={{ height: 600 }}>
|
|
92
|
+
<FTDIBasic3v3 />
|
|
93
|
+
</Schematic>
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export default {
|
|
98
|
+
title: "BugHighPortNumbers",
|
|
99
|
+
component: BugHighPortNumbers,
|
|
100
|
+
}
|