@tscircuit/props 0.0.420 → 0.0.422

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.
@@ -1,5 +1,11 @@
1
+ import { distance as baseDistance, length } from "circuit-json"
1
2
  import { z } from "zod"
2
3
 
3
4
  export type Distance = number | string
4
5
 
5
- export { distance, length } from "circuit-json"
6
+ const calcString = z.string().regex(/^calc\(.*\)$/)
7
+
8
+ export const distance = baseDistance
9
+ export const pcbCoordinate = calcString.or(baseDistance)
10
+
11
+ export { length }
@@ -6,6 +6,7 @@ import {
6
6
  supplier_name,
7
7
  } from "circuit-json"
8
8
  import { expectTypesMatch } from "lib/typecheck"
9
+ import { pcbCoordinate } from "./distance"
9
10
  import { z } from "zod"
10
11
  import { type CadModelProp, cadModelProp } from "./cadModel"
11
12
  import { type FootprintProp, footprintProp } from "./footprintProp"
@@ -25,6 +26,14 @@ export type PositionMode = PcbPositionMode
25
26
  export interface PcbLayoutProps {
26
27
  pcbX?: string | number
27
28
  pcbY?: string | number
29
+ /**
30
+ * Position the left, right, top, or bottom edge of the component. Setting any of these
31
+ * properties changes the anchor used for pcb positioning to the specified edge.
32
+ */
33
+ pcbLeftEdgeX?: string | number
34
+ pcbRightEdgeX?: string | number
35
+ pcbTopEdgeY?: string | number
36
+ pcbBottomEdgeY?: string | number
28
37
  pcbOffsetX?: string | number
29
38
  pcbOffsetY?: string | number
30
39
  pcbRotation?: string | number
@@ -51,6 +60,14 @@ export interface PcbLayoutProps {
51
60
  export interface CommonLayoutProps {
52
61
  pcbX?: string | number
53
62
  pcbY?: string | number
63
+ /**
64
+ * Position the left, right, top, or bottom edge of the component. Setting any of these
65
+ * properties changes the anchor used for pcb positioning to the specified edge.
66
+ */
67
+ pcbLeftEdgeX?: string | number
68
+ pcbRightEdgeX?: string | number
69
+ pcbTopEdgeY?: string | number
70
+ pcbBottomEdgeY?: string | number
54
71
  pcbOffsetX?: string | number
55
72
  pcbOffsetY?: string | number
56
73
  pcbRotation?: string | number
@@ -98,8 +115,12 @@ export interface CommonLayoutProps {
98
115
  }
99
116
 
100
117
  export const pcbLayoutProps = z.object({
101
- pcbX: distance.optional(),
102
- pcbY: distance.optional(),
118
+ pcbX: pcbCoordinate.optional(),
119
+ pcbY: pcbCoordinate.optional(),
120
+ pcbLeftEdgeX: pcbCoordinate.optional(),
121
+ pcbRightEdgeX: pcbCoordinate.optional(),
122
+ pcbTopEdgeY: pcbCoordinate.optional(),
123
+ pcbBottomEdgeY: pcbCoordinate.optional(),
103
124
  pcbOffsetX: distance.optional(),
104
125
  pcbOffsetY: distance.optional(),
105
126
  pcbRotation: rotation.optional(),
@@ -127,8 +148,12 @@ type InferredPcbLayoutProps = z.input<typeof pcbLayoutProps>
127
148
  expectTypesMatch<PcbLayoutProps, InferredPcbLayoutProps>(true)
128
149
 
129
150
  export const commonLayoutProps = z.object({
130
- pcbX: distance.optional(),
131
- pcbY: distance.optional(),
151
+ pcbX: pcbCoordinate.optional(),
152
+ pcbY: pcbCoordinate.optional(),
153
+ pcbLeftEdgeX: pcbCoordinate.optional(),
154
+ pcbRightEdgeX: pcbCoordinate.optional(),
155
+ pcbTopEdgeY: pcbCoordinate.optional(),
156
+ pcbBottomEdgeY: pcbCoordinate.optional(),
132
157
  pcbOffsetX: distance.optional(),
133
158
  pcbOffsetY: distance.optional(),
134
159
  pcbRotation: rotation.optional(),
@@ -1,4 +1,4 @@
1
- import { distance, type Distance } from "lib/common/distance"
1
+ import { distance, pcbCoordinate, type Distance } from "lib/common/distance"
2
2
  import { expectTypesMatch } from "lib/typecheck"
3
3
  import { cadModelBase, type CadModelBase } from "../common/cadModel"
4
4
  import { z } from "zod"
@@ -8,14 +8,22 @@ export interface CadModelProps extends CadModelBase {
8
8
  stepUrl?: string
9
9
  pcbX?: Distance
10
10
  pcbY?: Distance
11
+ pcbLeftEdgeX?: Distance
12
+ pcbRightEdgeX?: Distance
13
+ pcbTopEdgeY?: Distance
14
+ pcbBottomEdgeY?: Distance
11
15
  pcbOffsetX?: Distance
12
16
  pcbOffsetY?: Distance
13
17
  pcbZ?: Distance
14
18
  }
15
19
 
16
20
  const pcbPosition = z.object({
17
- pcbX: distance.optional(),
18
- pcbY: distance.optional(),
21
+ pcbX: pcbCoordinate.optional(),
22
+ pcbY: pcbCoordinate.optional(),
23
+ pcbLeftEdgeX: pcbCoordinate.optional(),
24
+ pcbRightEdgeX: pcbCoordinate.optional(),
25
+ pcbTopEdgeY: pcbCoordinate.optional(),
26
+ pcbBottomEdgeY: pcbCoordinate.optional(),
19
27
  pcbOffsetX: distance.optional(),
20
28
  pcbOffsetY: distance.optional(),
21
29
  pcbZ: distance.optional(),
@@ -5,6 +5,10 @@ import { z } from "zod"
5
5
 
6
6
  export const courtyardOutlineProps = pcbLayoutProps
7
7
  .omit({
8
+ pcbLeftEdgeX: true,
9
+ pcbRightEdgeX: true,
10
+ pcbTopEdgeY: true,
11
+ pcbBottomEdgeY: true,
8
12
  pcbX: true,
9
13
  pcbY: true,
10
14
  pcbOffsetX: true,
@@ -9,7 +9,15 @@ const dimensionTarget = z.union([z.string(), point])
9
9
  export interface FabricationNoteDimensionProps
10
10
  extends Omit<
11
11
  PcbLayoutProps,
12
- "pcbX" | "pcbY" | "pcbOffsetX" | "pcbOffsetY" | "pcbRotation"
12
+ | "pcbLeftEdgeX"
13
+ | "pcbRightEdgeX"
14
+ | "pcbTopEdgeY"
15
+ | "pcbBottomEdgeY"
16
+ | "pcbX"
17
+ | "pcbY"
18
+ | "pcbOffsetX"
19
+ | "pcbOffsetY"
20
+ | "pcbRotation"
13
21
  > {
14
22
  from: string | Point
15
23
  to: string | Point
@@ -27,6 +35,10 @@ export interface FabricationNoteDimensionProps
27
35
 
28
36
  export const fabricationNoteDimensionProps = pcbLayoutProps
29
37
  .omit({
38
+ pcbLeftEdgeX: true,
39
+ pcbRightEdgeX: true,
40
+ pcbTopEdgeY: true,
41
+ pcbBottomEdgeY: true,
30
42
  pcbX: true,
31
43
  pcbY: true,
32
44
  pcbOffsetX: true,
@@ -4,6 +4,10 @@ import { z } from "zod"
4
4
 
5
5
  export const fabricationNotePathProps = pcbLayoutProps
6
6
  .omit({
7
+ pcbLeftEdgeX: true,
8
+ pcbRightEdgeX: true,
9
+ pcbTopEdgeY: true,
10
+ pcbBottomEdgeY: true,
7
11
  pcbX: true,
8
12
  pcbY: true,
9
13
  pcbOffsetX: true,
@@ -9,7 +9,15 @@ const dimensionTarget = z.union([z.string(), point])
9
9
  export interface PcbNoteDimensionProps
10
10
  extends Omit<
11
11
  PcbLayoutProps,
12
- "pcbX" | "pcbY" | "pcbOffsetX" | "pcbOffsetY" | "pcbRotation"
12
+ | "pcbLeftEdgeX"
13
+ | "pcbRightEdgeX"
14
+ | "pcbTopEdgeY"
15
+ | "pcbBottomEdgeY"
16
+ | "pcbX"
17
+ | "pcbY"
18
+ | "pcbOffsetX"
19
+ | "pcbOffsetY"
20
+ | "pcbRotation"
13
21
  > {
14
22
  from: string | Point
15
23
  to: string | Point
@@ -27,6 +35,10 @@ export interface PcbNoteDimensionProps
27
35
 
28
36
  export const pcbNoteDimensionProps = pcbLayoutProps
29
37
  .omit({
38
+ pcbLeftEdgeX: true,
39
+ pcbRightEdgeX: true,
40
+ pcbTopEdgeY: true,
41
+ pcbBottomEdgeY: true,
30
42
  pcbX: true,
31
43
  pcbY: true,
32
44
  pcbOffsetX: true,
@@ -6,7 +6,15 @@ import { z } from "zod"
6
6
  export interface PcbNoteLineProps
7
7
  extends Omit<
8
8
  PcbLayoutProps,
9
- "pcbX" | "pcbY" | "pcbOffsetX" | "pcbOffsetY" | "pcbRotation"
9
+ | "pcbLeftEdgeX"
10
+ | "pcbRightEdgeX"
11
+ | "pcbTopEdgeY"
12
+ | "pcbBottomEdgeY"
13
+ | "pcbX"
14
+ | "pcbY"
15
+ | "pcbOffsetX"
16
+ | "pcbOffsetY"
17
+ | "pcbRotation"
10
18
  > {
11
19
  x1: string | number
12
20
  y1: string | number
@@ -19,6 +27,10 @@ export interface PcbNoteLineProps
19
27
 
20
28
  export const pcbNoteLineProps = pcbLayoutProps
21
29
  .omit({
30
+ pcbLeftEdgeX: true,
31
+ pcbRightEdgeX: true,
32
+ pcbTopEdgeY: true,
33
+ pcbBottomEdgeY: true,
22
34
  pcbX: true,
23
35
  pcbY: true,
24
36
  pcbOffsetX: true,
@@ -10,7 +10,15 @@ import { z } from "zod"
10
10
  export interface PcbNotePathProps
11
11
  extends Omit<
12
12
  PcbLayoutProps,
13
- "pcbX" | "pcbY" | "pcbOffsetX" | "pcbOffsetY" | "pcbRotation"
13
+ | "pcbLeftEdgeX"
14
+ | "pcbRightEdgeX"
15
+ | "pcbTopEdgeY"
16
+ | "pcbBottomEdgeY"
17
+ | "pcbX"
18
+ | "pcbY"
19
+ | "pcbOffsetX"
20
+ | "pcbOffsetY"
21
+ | "pcbRotation"
14
22
  > {
15
23
  route: RouteHintPointInput[]
16
24
  strokeWidth?: string | number
@@ -19,6 +27,10 @@ export interface PcbNotePathProps
19
27
 
20
28
  export const pcbNotePathProps = pcbLayoutProps
21
29
  .omit({
30
+ pcbLeftEdgeX: true,
31
+ pcbRightEdgeX: true,
32
+ pcbTopEdgeY: true,
33
+ pcbBottomEdgeY: true,
22
34
  pcbX: true,
23
35
  pcbY: true,
24
36
  pcbOffsetX: true,
@@ -4,6 +4,10 @@ import { z } from "zod"
4
4
 
5
5
  export const silkscreenPathProps = pcbLayoutProps
6
6
  .omit({
7
+ pcbLeftEdgeX: true,
8
+ pcbRightEdgeX: true,
9
+ pcbTopEdgeY: true,
10
+ pcbBottomEdgeY: true,
7
11
  pcbX: true,
8
12
  pcbY: true,
9
13
  pcbOffsetX: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.420",
3
+ "version": "0.0.422",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",