@tscircuit/props 0.0.182 → 0.0.184
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 +56 -0
- package/dist/index.d.ts +242 -9
- package/dist/index.js +172 -132
- package/dist/index.js.map +1 -1
- package/lib/components/cutout.ts +77 -0
- package/lib/components/platedhole.ts +4 -4
- package/lib/index.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
import { distance, type Distance } from "lib/common/distance"
|
|
3
|
+
import { point, type Point } from "lib/common/point"
|
|
4
|
+
import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
|
|
5
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
6
|
+
|
|
7
|
+
export interface RectCutoutProps
|
|
8
|
+
extends Omit<PcbLayoutProps, "layer" | "pcbRotation"> {
|
|
9
|
+
name?: string
|
|
10
|
+
shape: "rect"
|
|
11
|
+
width: Distance
|
|
12
|
+
height: Distance
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export const rectCutoutProps = pcbLayoutProps
|
|
16
|
+
.omit({
|
|
17
|
+
layer: true,
|
|
18
|
+
pcbRotation: true,
|
|
19
|
+
})
|
|
20
|
+
.extend({
|
|
21
|
+
name: z.string().optional(),
|
|
22
|
+
shape: z.literal("rect"),
|
|
23
|
+
width: distance,
|
|
24
|
+
height: distance,
|
|
25
|
+
})
|
|
26
|
+
expectTypesMatch<RectCutoutProps, z.input<typeof rectCutoutProps>>(true)
|
|
27
|
+
|
|
28
|
+
export interface CircleCutoutProps
|
|
29
|
+
extends Omit<PcbLayoutProps, "layer" | "pcbRotation"> {
|
|
30
|
+
name?: string
|
|
31
|
+
shape: "circle"
|
|
32
|
+
radius: Distance
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const circleCutoutProps = pcbLayoutProps
|
|
36
|
+
.omit({
|
|
37
|
+
layer: true,
|
|
38
|
+
pcbRotation: true,
|
|
39
|
+
})
|
|
40
|
+
.extend({
|
|
41
|
+
name: z.string().optional(),
|
|
42
|
+
shape: z.literal("circle"),
|
|
43
|
+
radius: distance,
|
|
44
|
+
})
|
|
45
|
+
expectTypesMatch<CircleCutoutProps, z.input<typeof circleCutoutProps>>(true)
|
|
46
|
+
|
|
47
|
+
export interface PolygonCutoutProps
|
|
48
|
+
extends Omit<PcbLayoutProps, "layer" | "pcbRotation"> {
|
|
49
|
+
name?: string
|
|
50
|
+
shape: "polygon"
|
|
51
|
+
points: Point[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const polygonCutoutProps = pcbLayoutProps
|
|
55
|
+
.omit({
|
|
56
|
+
layer: true,
|
|
57
|
+
pcbRotation: true,
|
|
58
|
+
})
|
|
59
|
+
.extend({
|
|
60
|
+
name: z.string().optional(),
|
|
61
|
+
shape: z.literal("polygon"),
|
|
62
|
+
points: z.array(point),
|
|
63
|
+
})
|
|
64
|
+
expectTypesMatch<PolygonCutoutProps, z.input<typeof polygonCutoutProps>>(true)
|
|
65
|
+
|
|
66
|
+
export type CutoutProps =
|
|
67
|
+
| RectCutoutProps
|
|
68
|
+
| CircleCutoutProps
|
|
69
|
+
| PolygonCutoutProps
|
|
70
|
+
|
|
71
|
+
export const cutoutProps = z.discriminatedUnion("shape", [
|
|
72
|
+
rectCutoutProps,
|
|
73
|
+
circleCutoutProps,
|
|
74
|
+
polygonCutoutProps,
|
|
75
|
+
])
|
|
76
|
+
|
|
77
|
+
export type CutoutPropsInput = z.input<typeof cutoutProps>
|
|
@@ -55,7 +55,7 @@ export interface CircularHoleWithRectPlatedProps
|
|
|
55
55
|
rectPadHeight: number | string
|
|
56
56
|
holeShape?: "circle"
|
|
57
57
|
padShape?: "rect"
|
|
58
|
-
shape?: "
|
|
58
|
+
shape?: "circular_hole_with_rect_pad"
|
|
59
59
|
portHints?: PortHints
|
|
60
60
|
}
|
|
61
61
|
|
|
@@ -112,17 +112,17 @@ export const platedHoleProps = z
|
|
|
112
112
|
rectPadHeight: distance,
|
|
113
113
|
holeShape: z.literal("circle").optional(),
|
|
114
114
|
padShape: z.literal("rect").optional(),
|
|
115
|
-
shape: z.literal("
|
|
115
|
+
shape: z.literal("circular_hole_with_rect_pad").optional(),
|
|
116
116
|
portHints: portHints.optional(),
|
|
117
117
|
})
|
|
118
118
|
.refine(
|
|
119
119
|
(prop) => {
|
|
120
|
-
return prop.shape === "
|
|
120
|
+
return prop.shape === "circular_hole_with_rect_pad"
|
|
121
121
|
? prop.holeDiameter && prop.rectPadWidth && prop.rectPadHeight
|
|
122
122
|
: true
|
|
123
123
|
},
|
|
124
124
|
{
|
|
125
|
-
message: "Missing required fields for
|
|
125
|
+
message: "Missing required fields for circular_hole_with_rect_pad",
|
|
126
126
|
},
|
|
127
127
|
),
|
|
128
128
|
])
|
package/lib/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export * from "./components/group"
|
|
|
23
23
|
export * from "./components/net"
|
|
24
24
|
export * from "./components/constrainedlayout"
|
|
25
25
|
export * from "./components/constraint"
|
|
26
|
+
export * from "./components/cutout"
|
|
26
27
|
export * from "./components/smtpad"
|
|
27
28
|
export * from "./components/solderpaste"
|
|
28
29
|
export * from "./components/hole"
|