@tscircuit/props 0.0.358 → 0.0.360

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.
@@ -0,0 +1,41 @@
1
+ import { distance, length } from "circuit-json"
2
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
3
+ import { point, type Point } from "lib/common/point"
4
+ import { expectTypesMatch } from "lib/typecheck"
5
+ import { z } from "zod"
6
+
7
+ const dimensionTarget = z.union([z.string(), point])
8
+
9
+ export interface FabricationNoteDimensionProps
10
+ extends Omit<PcbLayoutProps, "pcbX" | "pcbY" | "pcbRotation"> {
11
+ from: string | Point
12
+ to: string | Point
13
+ text?: string
14
+ offset?: string | number
15
+ font?: "tscircuit2024"
16
+ fontSize?: string | number
17
+ color?: string
18
+ arrowSize?: string | number
19
+ }
20
+
21
+ export const fabricationNoteDimensionProps = pcbLayoutProps
22
+ .omit({ pcbX: true, pcbY: true, pcbRotation: true })
23
+ .extend({
24
+ from: dimensionTarget,
25
+ to: dimensionTarget,
26
+ text: z.string().optional(),
27
+ offset: distance.optional(),
28
+ font: z.enum(["tscircuit2024"]).optional(),
29
+ fontSize: length.optional(),
30
+ color: z.string().optional(),
31
+ arrowSize: distance.optional(),
32
+ })
33
+
34
+ expectTypesMatch<
35
+ FabricationNoteDimensionProps,
36
+ z.input<typeof fabricationNoteDimensionProps>
37
+ >(true)
38
+
39
+ export type FabricationNoteDimensionPropsInput = z.input<
40
+ typeof fabricationNoteDimensionProps
41
+ >
@@ -1,7 +1,21 @@
1
1
  import { length } from "circuit-json"
2
- import { pcbLayoutProps } from "lib/common/layout"
2
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
3
+ import { expectTypesMatch } from "lib/typecheck"
3
4
  import { z } from "zod"
4
5
 
6
+ export interface FabricationNoteTextProps extends PcbLayoutProps {
7
+ text: string
8
+ anchorAlignment?:
9
+ | "center"
10
+ | "top_left"
11
+ | "top_right"
12
+ | "bottom_left"
13
+ | "bottom_right"
14
+ font?: "tscircuit2024"
15
+ fontSize?: string | number
16
+ color?: string
17
+ }
18
+
5
19
  export const fabricationNoteTextProps = pcbLayoutProps.extend({
6
20
  text: z.string(),
7
21
  anchorAlignment: z
@@ -11,4 +25,12 @@ export const fabricationNoteTextProps = pcbLayoutProps.extend({
11
25
  fontSize: length.optional(),
12
26
  color: z.string().optional(),
13
27
  })
14
- export type FabricationNoteTextProps = z.input<typeof fabricationNoteTextProps>
28
+
29
+ expectTypesMatch<
30
+ FabricationNoteTextProps,
31
+ z.input<typeof fabricationNoteTextProps>
32
+ >(true)
33
+
34
+ export type FabricationNoteTextPropsInput = z.input<
35
+ typeof fabricationNoteTextProps
36
+ >
@@ -6,6 +6,7 @@ import {
6
6
  commonLayoutProps,
7
7
  type SupplierPartNumbers,
8
8
  } from "lib/common/layout"
9
+ import { ninePointAnchor } from "lib/common/ninePointAnchor"
9
10
  import { type Point, point } from "lib/common/point"
10
11
  import { expectTypesMatch } from "lib/typecheck"
11
12
  import { z } from "zod"
@@ -210,6 +211,10 @@ export interface BaseGroupProps extends CommonLayoutProps, LayoutConfig {
210
211
  pcbPaddingRight?: Distance
211
212
  pcbPaddingTop?: Distance
212
213
  pcbPaddingBottom?: Distance
214
+ /**
215
+ * Anchor to use when interpreting pcbX/pcbY relative to pcbPosition
216
+ */
217
+ pcbPositionAnchor?: AutocompleteString<z.infer<typeof ninePointAnchor>>
213
218
 
214
219
  /** @deprecated Use `pcbGrid` */
215
220
  grid?: boolean
@@ -325,6 +330,10 @@ export type AutorouterProp =
325
330
  | AutorouterConfig
326
331
  | AutocompleteString<AutorouterPreset>
327
332
 
333
+ const pcbPositionAnchorAutocomplete = z.custom<
334
+ AutocompleteString<z.infer<typeof ninePointAnchor>>
335
+ >((value) => typeof value === "string")
336
+
328
337
  export const autorouterConfig = z.object({
329
338
  serverUrl: z.string().optional(),
330
339
  inputFormat: z.enum(["simplified", "circuit-json"]).optional(),
@@ -520,6 +529,7 @@ export const baseGroupProps = commonLayoutProps.extend({
520
529
  pcbPaddingRight: length.optional(),
521
530
  pcbPaddingTop: length.optional(),
522
531
  pcbPaddingBottom: length.optional(),
532
+ pcbPositionAnchor: pcbPositionAnchorAutocomplete.optional(),
523
533
  })
524
534
 
525
535
  export const partsEngine = z.custom<PartsEngine>((v) => "findPart" in v)
@@ -0,0 +1,38 @@
1
+ import { distance, length } from "circuit-json"
2
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
3
+ import { point, type Point } from "lib/common/point"
4
+ import { expectTypesMatch } from "lib/typecheck"
5
+ import { z } from "zod"
6
+
7
+ const dimensionTarget = z.union([z.string(), point])
8
+
9
+ export interface PcbNoteDimensionProps
10
+ extends Omit<PcbLayoutProps, "pcbX" | "pcbY" | "pcbRotation"> {
11
+ from: string | Point
12
+ to: string | Point
13
+ text?: string
14
+ offset?: string | number
15
+ font?: "tscircuit2024"
16
+ fontSize?: string | number
17
+ color?: string
18
+ arrowSize?: string | number
19
+ }
20
+
21
+ export const pcbNoteDimensionProps = pcbLayoutProps
22
+ .omit({ pcbX: true, pcbY: true, pcbRotation: true })
23
+ .extend({
24
+ from: dimensionTarget,
25
+ to: dimensionTarget,
26
+ text: z.string().optional(),
27
+ offset: distance.optional(),
28
+ font: z.enum(["tscircuit2024"]).optional(),
29
+ fontSize: length.optional(),
30
+ color: z.string().optional(),
31
+ arrowSize: distance.optional(),
32
+ })
33
+
34
+ expectTypesMatch<PcbNoteDimensionProps, z.input<typeof pcbNoteDimensionProps>>(
35
+ true,
36
+ )
37
+
38
+ export type PcbNoteDimensionPropsInput = z.input<typeof pcbNoteDimensionProps>
@@ -0,0 +1,31 @@
1
+ import { distance } from "circuit-json"
2
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
3
+ import { expectTypesMatch } from "lib/typecheck"
4
+ import { z } from "zod"
5
+
6
+ export interface PcbNoteLineProps
7
+ extends Omit<PcbLayoutProps, "pcbX" | "pcbY" | "pcbRotation"> {
8
+ x1: string | number
9
+ y1: string | number
10
+ x2: string | number
11
+ y2: string | number
12
+ strokeWidth?: string | number
13
+ color?: string
14
+ isDashed?: boolean
15
+ }
16
+
17
+ export const pcbNoteLineProps = pcbLayoutProps
18
+ .omit({ pcbX: true, pcbY: true, pcbRotation: true })
19
+ .extend({
20
+ x1: distance,
21
+ y1: distance,
22
+ x2: distance,
23
+ y2: distance,
24
+ strokeWidth: distance.optional(),
25
+ color: z.string().optional(),
26
+ isDashed: z.boolean().optional(),
27
+ })
28
+
29
+ expectTypesMatch<PcbNoteLineProps, z.input<typeof pcbNoteLineProps>>(true)
30
+
31
+ export type PcbNoteLinePropsInput = z.input<typeof pcbNoteLineProps>
@@ -0,0 +1,27 @@
1
+ import {
2
+ length,
3
+ route_hint_point,
4
+ type RouteHintPointInput,
5
+ } from "circuit-json"
6
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
7
+ import { expectTypesMatch } from "lib/typecheck"
8
+ import { z } from "zod"
9
+
10
+ export interface PcbNotePathProps
11
+ extends Omit<PcbLayoutProps, "pcbX" | "pcbY" | "pcbRotation"> {
12
+ route: RouteHintPointInput[]
13
+ strokeWidth?: string | number
14
+ color?: string
15
+ }
16
+
17
+ export const pcbNotePathProps = pcbLayoutProps
18
+ .omit({ pcbX: true, pcbY: true, pcbRotation: true })
19
+ .extend({
20
+ route: z.array(route_hint_point),
21
+ strokeWidth: length.optional(),
22
+ color: z.string().optional(),
23
+ })
24
+
25
+ expectTypesMatch<PcbNotePathProps, z.input<typeof pcbNotePathProps>>(true)
26
+
27
+ export type PcbNotePathPropsInput = z.input<typeof pcbNotePathProps>
@@ -0,0 +1,30 @@
1
+ import { distance } from "circuit-json"
2
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
3
+ import { expectTypesMatch } from "lib/typecheck"
4
+ import { z } from "zod"
5
+
6
+ export interface PcbNoteRectProps extends Omit<PcbLayoutProps, "pcbRotation"> {
7
+ width: string | number
8
+ height: string | number
9
+ strokeWidth?: string | number
10
+ isFilled?: boolean
11
+ hasStroke?: boolean
12
+ isStrokeDashed?: boolean
13
+ color?: string
14
+ }
15
+
16
+ export const pcbNoteRectProps = pcbLayoutProps
17
+ .omit({ pcbRotation: true })
18
+ .extend({
19
+ width: distance,
20
+ height: distance,
21
+ strokeWidth: distance.optional(),
22
+ isFilled: z.boolean().optional(),
23
+ hasStroke: z.boolean().optional(),
24
+ isStrokeDashed: z.boolean().optional(),
25
+ color: z.string().optional(),
26
+ })
27
+
28
+ expectTypesMatch<PcbNoteRectProps, z.input<typeof pcbNoteRectProps>>(true)
29
+
30
+ export type PcbNoteRectPropsInput = z.input<typeof pcbNoteRectProps>
@@ -0,0 +1,31 @@
1
+ import { length } from "circuit-json"
2
+ import { pcbLayoutProps, type PcbLayoutProps } from "lib/common/layout"
3
+ import { expectTypesMatch } from "lib/typecheck"
4
+ import { z } from "zod"
5
+
6
+ export interface PcbNoteTextProps extends PcbLayoutProps {
7
+ text: string
8
+ anchorAlignment?:
9
+ | "center"
10
+ | "top_left"
11
+ | "top_right"
12
+ | "bottom_left"
13
+ | "bottom_right"
14
+ font?: "tscircuit2024"
15
+ fontSize?: string | number
16
+ color?: string
17
+ }
18
+
19
+ export const pcbNoteTextProps = pcbLayoutProps.extend({
20
+ text: z.string(),
21
+ anchorAlignment: z
22
+ .enum(["center", "top_left", "top_right", "bottom_left", "bottom_right"])
23
+ .default("center"),
24
+ font: z.enum(["tscircuit2024"]).optional(),
25
+ fontSize: length.optional(),
26
+ color: z.string().optional(),
27
+ })
28
+
29
+ expectTypesMatch<PcbNoteTextProps, z.input<typeof pcbNoteTextProps>>(true)
30
+
31
+ export type PcbNoteTextPropsInput = z.input<typeof pcbNoteTextProps>
package/lib/index.ts CHANGED
@@ -57,6 +57,7 @@ export * from "./components/switch"
57
57
  export * from "./components/fabrication-note-text"
58
58
  export * from "./components/fabrication-note-rect"
59
59
  export * from "./components/fabrication-note-path"
60
+ export * from "./components/fabrication-note-dimension"
60
61
  export * from "./components/pcb-trace"
61
62
  export * from "./components/via"
62
63
  export * from "./components/testpoint"
@@ -87,6 +88,11 @@ export * from "./components/silkscreen-rect"
87
88
  export * from "./components/silkscreen-circle"
88
89
  export * from "./components/trace-hint"
89
90
  export * from "./components/port"
91
+ export * from "./components/pcb-note-text"
92
+ export * from "./components/pcb-note-rect"
93
+ export * from "./components/pcb-note-path"
94
+ export * from "./components/pcb-note-line"
95
+ export * from "./components/pcb-note-dimension"
90
96
  export * from "./platformConfig"
91
97
  export * from "./projectConfig"
92
98
  export * from "./utility-types/connections-and-selectors"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.358",
3
+ "version": "0.0.360",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",