@tscircuit/props 0.0.327 → 0.0.328
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 +23 -1
- package/dist/index.d.ts +87 -5
- package/dist/index.js +9 -1
- package/dist/index.js.map +1 -1
- package/lib/components/hole.ts +22 -3
- package/package.json +1 -1
package/lib/components/hole.ts
CHANGED
|
@@ -3,16 +3,26 @@ import { distance, type Distance } from "lib/common/distance"
|
|
|
3
3
|
import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
|
|
4
4
|
import { expectTypesMatch } from "lib/typecheck"
|
|
5
5
|
|
|
6
|
-
export interface
|
|
6
|
+
export interface CircleHoleProps extends PcbLayoutProps {
|
|
7
7
|
name?: string
|
|
8
|
+
shape?: "circle"
|
|
8
9
|
diameter?: Distance
|
|
9
10
|
radius?: Distance
|
|
10
11
|
}
|
|
11
12
|
|
|
12
|
-
export
|
|
13
|
-
|
|
13
|
+
export interface PillHoleProps extends PcbLayoutProps {
|
|
14
|
+
name?: string
|
|
15
|
+
shape: "pill"
|
|
16
|
+
width: Distance
|
|
17
|
+
height: Distance
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type HoleProps = CircleHoleProps | PillHoleProps
|
|
21
|
+
|
|
22
|
+
const circleHoleProps = pcbLayoutProps
|
|
14
23
|
.extend({
|
|
15
24
|
name: z.string().optional(),
|
|
25
|
+
shape: z.literal("circle").optional(),
|
|
16
26
|
diameter: distance.optional(),
|
|
17
27
|
radius: distance.optional(),
|
|
18
28
|
})
|
|
@@ -22,6 +32,15 @@ export const holeProps = pcbLayoutProps
|
|
|
22
32
|
radius: d.radius ?? d.diameter! / 2,
|
|
23
33
|
}))
|
|
24
34
|
|
|
35
|
+
const pillHoleProps = pcbLayoutProps.extend({
|
|
36
|
+
name: z.string().optional(),
|
|
37
|
+
shape: z.literal("pill"),
|
|
38
|
+
width: distance,
|
|
39
|
+
height: distance,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
export const holeProps = z.union([circleHoleProps, pillHoleProps])
|
|
43
|
+
|
|
25
44
|
export type InferredHoleProps = z.input<typeof holeProps>
|
|
26
45
|
|
|
27
46
|
expectTypesMatch<HoleProps, InferredHoleProps>(true)
|