@tscircuit/props 0.0.258 → 0.0.259

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,8 @@
1
+ import { z } from "zod"
2
+
3
+ /**
4
+ * Valid pin label string. Must consist only of letters,
5
+ * numbers, or underscores.
6
+ */
7
+ export const schematicPinLabel = z.string().regex(/^[A-Za-z0-9_]+$/)
8
+ export type SchematicPinLabel = z.infer<typeof schematicPinLabel>
@@ -13,6 +13,10 @@ import {
13
13
  type SchematicPinStyle,
14
14
  schematicPinStyle,
15
15
  } from "lib/common/schematicPinStyle"
16
+ import {
17
+ schematicPinLabel,
18
+ type SchematicPinLabel,
19
+ } from "lib/common/schematicPinLabel"
16
20
  import { expectTypesMatch } from "lib/typecheck"
17
21
  import type { Connections } from "lib/utility-types/connections-and-selectors"
18
22
  import { z } from "zod"
@@ -32,10 +36,11 @@ export interface PinCompatibleVariant {
32
36
  supplierPartNumber?: SupplierPartNumbers
33
37
  }
34
38
 
35
- export interface ChipPropsSU<PinLabel extends string = string>
36
- extends CommonComponentProps<PinLabel> {
39
+ export interface ChipPropsSU<
40
+ PinLabel extends SchematicPinLabel = SchematicPinLabel,
41
+ > extends CommonComponentProps<PinLabel> {
37
42
  manufacturerPartNumber?: string
38
- pinLabels?: PinLabelsProp<string, PinLabel>
43
+ pinLabels?: PinLabelsProp<SchematicPinLabel, PinLabel>
39
44
  /**
40
45
  * Whether to show pin aliases in the schematic
41
46
  */
@@ -115,8 +120,10 @@ const connectionsProp = z
115
120
  .pipe(z.record(z.string(), connectionTarget))
116
121
 
117
122
  export const pinLabelsProp = z.record(
118
- z.string(),
119
- z.string().or(z.array(z.string()).readonly()).or(z.array(z.string())),
123
+ schematicPinLabel,
124
+ schematicPinLabel
125
+ .or(z.array(schematicPinLabel).readonly())
126
+ .or(z.array(schematicPinLabel)),
120
127
  )
121
128
 
122
129
  expectTypesMatch<PinLabelsProp, z.input<typeof pinLabelsProp>>(true)
@@ -11,12 +11,19 @@ import {
11
11
  type SchematicPinStyle,
12
12
  schematicPinStyle,
13
13
  } from "lib/common/schematicPinStyle"
14
+ import {
15
+ schematicPinLabel,
16
+ type SchematicPinLabel,
17
+ } from "lib/common/schematicPinLabel"
14
18
  import { expectTypesMatch } from "lib/typecheck"
15
19
  import { z } from "zod"
16
20
 
17
21
  export interface ConnectorProps extends CommonComponentProps {
18
22
  manufacturerPartNumber?: string
19
- pinLabels?: Record<number | string, string | string[]>
23
+ pinLabels?: Record<
24
+ number | SchematicPinLabel,
25
+ SchematicPinLabel | SchematicPinLabel[]
26
+ >
20
27
  schPinStyle?: SchematicPinStyle
21
28
  schPinSpacing?: number | string
22
29
  schWidth?: number | string
@@ -37,7 +44,10 @@ export interface ConnectorProps extends CommonComponentProps {
37
44
  export const connectorProps = commonComponentProps.extend({
38
45
  manufacturerPartNumber: z.string().optional(),
39
46
  pinLabels: z
40
- .record(z.number().or(z.string()), z.string().or(z.array(z.string())))
47
+ .record(
48
+ z.number().or(schematicPinLabel),
49
+ schematicPinLabel.or(z.array(schematicPinLabel)),
50
+ )
41
51
  .optional(),
42
52
  schPinStyle: schematicPinStyle.optional(),
43
53
  schPinSpacing: distance.optional(),
@@ -12,13 +12,20 @@ import {
12
12
  schematicPinStyle,
13
13
  } from "lib/common/schematicPinStyle"
14
14
  import { connectionTarget } from "lib/common/connectionsProp"
15
+ import {
16
+ schematicPinLabel,
17
+ type SchematicPinLabel,
18
+ } from "lib/common/schematicPinLabel"
15
19
  import type { Connections } from "lib/utility-types/connections-and-selectors"
16
20
  import { expectTypesMatch } from "lib/typecheck"
17
21
  import { z } from "zod"
18
22
 
19
23
  export interface JumperProps extends CommonComponentProps {
20
24
  manufacturerPartNumber?: string
21
- pinLabels?: Record<number | string, string | string[]>
25
+ pinLabels?: Record<
26
+ number | SchematicPinLabel,
27
+ SchematicPinLabel | SchematicPinLabel[]
28
+ >
22
29
  schPinStyle?: SchematicPinStyle
23
30
  schPinSpacing?: number | string
24
31
  schWidth?: number | string
@@ -47,7 +54,10 @@ export interface JumperProps extends CommonComponentProps {
47
54
  export const jumperProps = commonComponentProps.extend({
48
55
  manufacturerPartNumber: z.string().optional(),
49
56
  pinLabels: z
50
- .record(z.number().or(z.string()), z.string().or(z.array(z.string())))
57
+ .record(
58
+ z.number().or(schematicPinLabel),
59
+ schematicPinLabel.or(z.array(schematicPinLabel)),
60
+ )
51
61
  .optional(),
52
62
  schPinStyle: schematicPinStyle.optional(),
53
63
  schPinSpacing: distance.optional(),
@@ -12,6 +12,10 @@ import {
12
12
  schematicPinStyle,
13
13
  } from "lib/common/schematicPinStyle"
14
14
  import { connectionTarget } from "lib/common/connectionsProp"
15
+ import {
16
+ schematicPinLabel,
17
+ type SchematicPinLabel,
18
+ } from "lib/common/schematicPinLabel"
15
19
  import type { Connections } from "lib/utility-types/connections-and-selectors"
16
20
  import { expectTypesMatch } from "lib/typecheck"
17
21
  import { z } from "zod"
@@ -65,7 +69,7 @@ export interface PinHeaderProps extends CommonComponentProps {
65
69
  /**
66
70
  * Labels for each pin
67
71
  */
68
- pinLabels?: string[]
72
+ pinLabels?: SchematicPinLabel[]
69
73
 
70
74
  /**
71
75
  * Connections to other components
@@ -113,7 +117,7 @@ export const pinHeaderProps = commonComponentProps.extend({
113
117
  doubleRow: z.boolean().optional(),
114
118
  holeDiameter: distance.optional(),
115
119
  platedDiameter: distance.optional(),
116
- pinLabels: z.array(z.string()).optional(),
120
+ pinLabels: z.array(schematicPinLabel).optional(),
117
121
  connections: z
118
122
  .custom<Connections>()
119
123
  .pipe(z.record(z.string(), connectionTarget))
package/lib/index.ts CHANGED
@@ -8,6 +8,7 @@ export * from "./common/schematicOrientation"
8
8
  export * from "./common/schematicPinDefinitions"
9
9
  export * from "./common/schematicPinStyle"
10
10
  export * from "./common/cadModel"
11
+ export * from "./common/schematicPinLabel"
11
12
 
12
13
  export * from "./components/board"
13
14
  export * from "./components/breakout"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.258",
3
+ "version": "0.0.259",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",