@tscircuit/props 0.0.538 → 0.0.540
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 +13 -0
- package/dist/index.d.ts +41 -9
- package/dist/index.js +304 -291
- package/dist/index.js.map +1 -1
- package/lib/components/chip.ts +10 -0
- package/lib/components/spicemodel.ts +15 -0
- package/lib/index.ts +1 -0
- package/package.json +1 -1
package/lib/components/chip.ts
CHANGED
|
@@ -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"
|