@tscircuit/props 0.0.634 → 0.0.636
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 +21 -3
- package/dist/index.d.ts +703 -572
- package/dist/index.js +36 -0
- package/dist/index.js.map +1 -1
- package/lib/components/board.ts +67 -1
- package/lib/components/netlabel.ts +7 -0
- package/package.json +1 -1
package/lib/components/board.ts
CHANGED
|
@@ -23,8 +23,60 @@ export type BoardColor = AutocompleteString<BoardColorPreset>
|
|
|
23
23
|
|
|
24
24
|
const boardColor = z.custom<BoardColor>((value) => typeof value === "string")
|
|
25
25
|
|
|
26
|
+
export interface BoardOutlinePoint extends Point {
|
|
27
|
+
/** Marks this outline point as the center of a castellated plated hole */
|
|
28
|
+
isCastellatedHole?: boolean
|
|
29
|
+
/** Diameter of the drilled hole. Required when `isCastellatedHole` is true. */
|
|
30
|
+
holeDiameter?: Distance
|
|
31
|
+
/** Diameter of the copper pad. Required when `isCastellatedHole` is true. */
|
|
32
|
+
padDiameter?: Distance
|
|
33
|
+
/** Connection target or targets for the castellated hole */
|
|
34
|
+
connectsTo?: string | string[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const boardOutlinePoint = z
|
|
38
|
+
.object({
|
|
39
|
+
...point.shape,
|
|
40
|
+
isCastellatedHole: z.boolean().optional(),
|
|
41
|
+
holeDiameter: distance.optional(),
|
|
42
|
+
padDiameter: distance.optional(),
|
|
43
|
+
connectsTo: z.string().or(z.array(z.string())).optional(),
|
|
44
|
+
})
|
|
45
|
+
.superRefine((outlinePoint, ctx) => {
|
|
46
|
+
if (outlinePoint.isCastellatedHole) {
|
|
47
|
+
if (outlinePoint.holeDiameter === undefined) {
|
|
48
|
+
ctx.addIssue({
|
|
49
|
+
code: z.ZodIssueCode.custom,
|
|
50
|
+
path: ["holeDiameter"],
|
|
51
|
+
message: "holeDiameter is required for a castellated hole",
|
|
52
|
+
})
|
|
53
|
+
}
|
|
54
|
+
if (outlinePoint.padDiameter === undefined) {
|
|
55
|
+
ctx.addIssue({
|
|
56
|
+
code: z.ZodIssueCode.custom,
|
|
57
|
+
path: ["padDiameter"],
|
|
58
|
+
message: "padDiameter is required for a castellated hole",
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (
|
|
65
|
+
outlinePoint.holeDiameter !== undefined ||
|
|
66
|
+
outlinePoint.padDiameter !== undefined ||
|
|
67
|
+
outlinePoint.connectsTo !== undefined
|
|
68
|
+
) {
|
|
69
|
+
ctx.addIssue({
|
|
70
|
+
code: z.ZodIssueCode.custom,
|
|
71
|
+
path: ["isCastellatedHole"],
|
|
72
|
+
message:
|
|
73
|
+
"isCastellatedHole must be true when castellated hole props are provided",
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
|
|
26
78
|
export interface BoardProps
|
|
27
|
-
extends Omit<SubcircuitGroupProps, "subcircuit" | "connections"> {
|
|
79
|
+
extends Omit<SubcircuitGroupProps, "subcircuit" | "connections" | "outline"> {
|
|
28
80
|
title?: string
|
|
29
81
|
material?: "fr4" | "fr1" | "flex"
|
|
30
82
|
/** Number of layers for the PCB */
|
|
@@ -39,6 +91,18 @@ export interface BoardProps
|
|
|
39
91
|
boardAnchorPosition?: Point
|
|
40
92
|
anchorAlignment?: z.infer<typeof ninePointAnchor>
|
|
41
93
|
boardAnchorAlignment?: z.infer<typeof ninePointAnchor>
|
|
94
|
+
/**
|
|
95
|
+
* Points defining the board edge. Set `isCastellatedHole` on a point to
|
|
96
|
+
* place a castellated plated hole centered on that location.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```tsx
|
|
100
|
+
* { x: "-5mm", y: 0, isCastellatedHole: true,
|
|
101
|
+
* holeDiameter: "0.8mm", padDiameter: "1.2mm",
|
|
102
|
+
* connectsTo: "net.GND" }
|
|
103
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
outline?: BoardOutlinePoint[]
|
|
42
106
|
/** Color applied to both top and bottom solder masks */
|
|
43
107
|
solderMaskColor?: BoardColor
|
|
44
108
|
/** Color of the top solder mask */
|
|
@@ -86,6 +150,7 @@ export const boardProps = subcircuitGroupProps
|
|
|
86
150
|
boardAnchorAlignment: ninePointAnchor
|
|
87
151
|
.optional()
|
|
88
152
|
.describe("Prefer using anchorAlignment when possible"),
|
|
153
|
+
outline: z.array(boardOutlinePoint).optional(),
|
|
89
154
|
title: z.string().optional(),
|
|
90
155
|
solderMaskColor: boardColor.optional(),
|
|
91
156
|
topSolderMaskColor: boardColor.optional(),
|
|
@@ -104,4 +169,5 @@ export const boardProps = subcircuitGroupProps
|
|
|
104
169
|
})
|
|
105
170
|
|
|
106
171
|
type InferredBoardProps = z.input<typeof boardProps>
|
|
172
|
+
expectTypesMatch<BoardOutlinePoint, z.input<typeof boardOutlinePoint>>(true)
|
|
107
173
|
expectTypesMatch<BoardProps, InferredBoardProps>(true)
|
|
@@ -7,6 +7,12 @@ export interface NetLabelProps {
|
|
|
7
7
|
net?: string
|
|
8
8
|
connection?: string
|
|
9
9
|
connectsTo?: string | string[]
|
|
10
|
+
/**
|
|
11
|
+
* Render the net name along its schematic trace instead of as an anchored
|
|
12
|
+
* label. Inline placement is automatic, so schematic anchor positioning
|
|
13
|
+
* props are ignored.
|
|
14
|
+
*/
|
|
15
|
+
inline?: boolean
|
|
10
16
|
schX?: number | string
|
|
11
17
|
schY?: number | string
|
|
12
18
|
schRotation?: number | string
|
|
@@ -17,6 +23,7 @@ export const netLabelProps = z.object({
|
|
|
17
23
|
net: z.string().optional(),
|
|
18
24
|
connection: z.string().optional(),
|
|
19
25
|
connectsTo: z.string().or(z.array(z.string())).optional(),
|
|
26
|
+
inline: z.boolean().optional(),
|
|
20
27
|
schX: distance.optional(),
|
|
21
28
|
schY: distance.optional(),
|
|
22
29
|
schRotation: rotation.optional(),
|