@tscircuit/props 0.0.538 → 0.0.539

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,6 @@
1
1
  import { distance, supplier_name } from "circuit-json"
2
2
  import type { Distance } from "lib/common/distance"
3
+ import type { SpicemodelProps } from "lib/components/spicemodel"
3
4
  import {
4
5
  type CommonComponentProps,
5
6
  commonComponentProps,
@@ -19,6 +20,7 @@ import {
19
20
  } from "lib/common/schematicPinLabel"
20
21
  import { expectTypesMatch } from "lib/typecheck"
21
22
  import type { Connections } from "lib/utility-types/connections-and-selectors"
23
+ import type { ReactElement } from "react"
22
24
  import { z } from "zod"
23
25
 
24
26
  export type PinLabelsProp<
@@ -36,6 +38,8 @@ export interface PinCompatibleVariant {
36
38
  supplierPartNumber?: SupplierPartNumbers
37
39
  }
38
40
 
41
+ export type SpicemodelElement = ReactElement<SpicemodelProps>
42
+
39
43
  export interface ChipPropsSU<
40
44
  PinLabel extends SchematicPinLabel = SchematicPinLabel,
41
45
  > extends CommonComponentProps<PinLabel> {
@@ -67,6 +71,7 @@ export interface ChipPropsSU<
67
71
  */
68
72
  noConnect?: readonly PinLabel[] | PinLabel[]
69
73
  connections?: Connections<PinLabel>
74
+ spiceModel?: SpicemodelElement
70
75
  }
71
76
 
72
77
  export type ChipProps<PinLabelMap extends PinLabelsProp | string = string> =
@@ -130,6 +135,10 @@ const connectionsProp = z
130
135
  .custom<Connections>()
131
136
  .pipe(z.record(z.string(), connectionTarget))
132
137
 
138
+ const spicemodelElement = z.custom<SpicemodelElement>(
139
+ (v) => !!v && typeof v === "object" && "type" in v && "props" in v,
140
+ )
141
+
133
142
  export const pinLabelsProp = z.record(
134
143
  schematicPinLabel,
135
144
  schematicPinLabel
@@ -163,6 +172,7 @@ export const chipProps = commonComponentProps.extend({
163
172
  noSchematicRepresentation: z.boolean().optional(),
164
173
  noConnect: noConnectProp.optional(),
165
174
  connections: connectionsProp.optional(),
175
+ spiceModel: spicemodelElement.optional(),
166
176
  })
167
177
 
168
178
  /**
@@ -0,0 +1,15 @@
1
+ import { expectTypesMatch } from "lib/typecheck"
2
+ import { z } from "zod"
3
+
4
+ export interface SpicemodelProps {
5
+ source: string
6
+ spicePinMapping?: Record<string, string>
7
+ }
8
+
9
+ export const spicemodelProps = z.object({
10
+ source: z.string(),
11
+ spicePinMapping: z.record(z.string(), z.string()).optional(),
12
+ })
13
+
14
+ type InferredSpicemodelProps = z.input<typeof spicemodelProps>
15
+ expectTypesMatch<SpicemodelProps, InferredSpicemodelProps>(true)
package/lib/index.ts CHANGED
@@ -66,6 +66,7 @@ export * from "./components/push-button"
66
66
  export * from "./components/subcircuit"
67
67
  export * from "./components/analogsimulation"
68
68
  export * from "./components/autoroutingphase"
69
+ export * from "./components/spicemodel"
69
70
  export * from "./manual-edits"
70
71
  export * from "./components/transistor"
71
72
  export * from "./components/mosfet"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.538",
3
+ "version": "0.0.539",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",