@tscircuit/props 0.0.507 → 0.0.509
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 +5 -0
- package/dist/index.d.ts +281 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/lib/components/footprint.ts +37 -0
- package/lib/components/trace.ts +10 -2
- package/package.json +1 -1
|
@@ -3,6 +3,33 @@ import { expectTypesMatch } from "lib/typecheck"
|
|
|
3
3
|
import { z } from "zod"
|
|
4
4
|
import { type FootprintProp, footprintProp } from "../common/footprintProp"
|
|
5
5
|
|
|
6
|
+
export type FootprintInsertionDirection =
|
|
7
|
+
| "from_above"
|
|
8
|
+
| "from_left"
|
|
9
|
+
| "from_right"
|
|
10
|
+
| "from_front"
|
|
11
|
+
| "from_back"
|
|
12
|
+
| "x+"
|
|
13
|
+
| "x-"
|
|
14
|
+
| "y+"
|
|
15
|
+
| "y-"
|
|
16
|
+
|
|
17
|
+
export const footprintInsertionDirection = z.enum([
|
|
18
|
+
"from_above",
|
|
19
|
+
"from_left",
|
|
20
|
+
"from_right",
|
|
21
|
+
"from_front",
|
|
22
|
+
"from_back",
|
|
23
|
+
"x+",
|
|
24
|
+
"x-",
|
|
25
|
+
"y+",
|
|
26
|
+
"y-",
|
|
27
|
+
])
|
|
28
|
+
expectTypesMatch<
|
|
29
|
+
FootprintInsertionDirection,
|
|
30
|
+
z.infer<typeof footprintInsertionDirection>
|
|
31
|
+
>(true)
|
|
32
|
+
|
|
6
33
|
export interface FootprintProps {
|
|
7
34
|
children?: any
|
|
8
35
|
/**
|
|
@@ -24,6 +51,11 @@ export interface FootprintProps {
|
|
|
24
51
|
* Can be a footprint or kicad string
|
|
25
52
|
*/
|
|
26
53
|
src?: FootprintProp
|
|
54
|
+
/**
|
|
55
|
+
* Direction a cable or mating part is inserted into this footprint in its
|
|
56
|
+
* unrotated orientation.
|
|
57
|
+
*/
|
|
58
|
+
insertionDirection?: FootprintInsertionDirection
|
|
27
59
|
}
|
|
28
60
|
|
|
29
61
|
export const footprintProps = z.object({
|
|
@@ -31,6 +63,11 @@ export const footprintProps = z.object({
|
|
|
31
63
|
originalLayer: layer_ref.default("top").optional(),
|
|
32
64
|
circuitJson: z.array(z.any()).optional(),
|
|
33
65
|
src: footprintProp.describe("Can be a footprint or kicad string").optional(),
|
|
66
|
+
insertionDirection: footprintInsertionDirection
|
|
67
|
+
.optional()
|
|
68
|
+
.describe(
|
|
69
|
+
"Direction a cable or mating part is inserted into this footprint in its unrotated orientation.",
|
|
70
|
+
),
|
|
34
71
|
})
|
|
35
72
|
|
|
36
73
|
export type FootprintPropsInput = z.input<typeof footprintProps>
|
package/lib/components/trace.ts
CHANGED
|
@@ -4,8 +4,12 @@ import { point } from "../common/point"
|
|
|
4
4
|
|
|
5
5
|
export const portRef = z.union([
|
|
6
6
|
z.string(),
|
|
7
|
-
z.custom<{ getPortSelector: () => string }>(
|
|
8
|
-
|
|
7
|
+
z.custom<{ getPortSelector: () => string }>(
|
|
8
|
+
(v) =>
|
|
9
|
+
typeof v === "object" &&
|
|
10
|
+
v !== null &&
|
|
11
|
+
"getPortSelector" in v &&
|
|
12
|
+
typeof v.getPortSelector === "function",
|
|
9
13
|
),
|
|
10
14
|
])
|
|
11
15
|
|
|
@@ -64,6 +68,10 @@ export const traceProps = z.union([
|
|
|
64
68
|
from: portRef,
|
|
65
69
|
to: portRef,
|
|
66
70
|
}),
|
|
71
|
+
baseTraceProps.extend({
|
|
72
|
+
start: portRef,
|
|
73
|
+
end: portRef,
|
|
74
|
+
}),
|
|
67
75
|
])
|
|
68
76
|
|
|
69
77
|
export type TraceProps = z.input<typeof traceProps>
|