@tscircuit/props 0.0.580 → 0.0.582

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,15 @@
1
+ import { expectTypesMatch } from "lib/typecheck"
2
+ import { z } from "zod"
3
+
4
+ export interface AssemblyDeviceProps {
5
+ /** Product-level assembly identity. */
6
+ name?: string
7
+ }
8
+
9
+ export const assemblyDeviceProps = z.object({
10
+ name: z.string().optional(),
11
+ })
12
+
13
+ export type AssemblyDevicePropsInput = z.input<typeof assemblyDeviceProps>
14
+
15
+ expectTypesMatch<AssemblyDeviceProps, AssemblyDevicePropsInput>(true)
@@ -0,0 +1,7 @@
1
+ import { assemblyDeviceProps } from "./device"
2
+
3
+ export * from "./device"
4
+
5
+ export const assemblyProps = {
6
+ device: assemblyDeviceProps,
7
+ } as const
@@ -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 { InternalCircuitProps } from "lib/components/internal-circuit"
3
4
  import type { SpiceModelProps } from "lib/components/spicemodel"
4
5
  import {
5
6
  type CommonComponentProps,
@@ -20,7 +21,7 @@ import {
20
21
  } from "lib/common/schematicPinLabel"
21
22
  import { expectTypesMatch } from "lib/typecheck"
22
23
  import type { Connections } from "lib/utility-types/connections-and-selectors"
23
- import type { ReactElement } from "react"
24
+ import { isValidElement, type ReactElement } from "react"
24
25
  import { z } from "zod"
25
26
 
26
27
  export type PinLabelsProp<
@@ -39,6 +40,10 @@ export interface PinCompatibleVariant {
39
40
  }
40
41
 
41
42
  export type SpiceModelElement = ReactElement<SpiceModelProps>
43
+ export type InternalCircuitElement = ReactElement<
44
+ InternalCircuitProps,
45
+ "internalcircuit"
46
+ >
42
47
 
43
48
  export interface ChipPropsSU<
44
49
  PinLabel extends SchematicPinLabel = SchematicPinLabel,
@@ -72,6 +77,11 @@ export interface ChipPropsSU<
72
77
  noConnect?: readonly PinLabel[] | PinLabel[]
73
78
  connections?: Connections<PinLabel>
74
79
  spiceModel?: SpiceModelElement
80
+ /**
81
+ * Functional components contained inside this physical chip package,
82
+ * wrapped in an `<internalcircuit />` element.
83
+ */
84
+ internalCircuit?: InternalCircuitElement
75
85
  }
76
86
 
77
87
  export type ChipProps<PinLabelMap extends PinLabelsProp | string = string> =
@@ -139,6 +149,10 @@ const spicemodelElement = z.custom<SpiceModelElement>(
139
149
  (v) => !!v && typeof v === "object" && "type" in v && "props" in v,
140
150
  )
141
151
 
152
+ const internalCircuitElement = z.custom<InternalCircuitElement>(
153
+ (value) => isValidElement(value) && value.type === "internalcircuit",
154
+ )
155
+
142
156
  export const pinLabelsProp = z.record(
143
157
  schematicPinLabel,
144
158
  schematicPinLabel
@@ -173,6 +187,7 @@ export const chipProps = commonComponentProps.extend({
173
187
  noConnect: noConnectProp.optional(),
174
188
  connections: connectionsProp.optional(),
175
189
  spiceModel: spicemodelElement.optional(),
190
+ internalCircuit: internalCircuitElement.optional(),
176
191
  })
177
192
 
178
193
  /**
@@ -0,0 +1,19 @@
1
+ import { expectTypesMatch } from "lib/typecheck"
2
+ import type { ReactNode } from "react"
3
+ import { z } from "zod"
4
+
5
+ /**
6
+ * Props for a semantic container that groups the functional components inside
7
+ * a physical chip package.
8
+ */
9
+ export interface InternalCircuitProps {
10
+ children?: ReactNode
11
+ }
12
+
13
+ export const internalCircuitProps = z.object({
14
+ children: z.custom<ReactNode>().optional(),
15
+ })
16
+
17
+ expectTypesMatch<InternalCircuitProps, z.input<typeof internalCircuitProps>>(
18
+ true,
19
+ )
package/lib/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  export * from "./common/direction"
2
2
  export * from "./common/commonShape"
3
+ export * from "./assembly"
3
4
  export * from "./enclosure"
4
5
  export * from "./common/portHints"
5
6
  export * from "./common/layout"
@@ -75,6 +76,7 @@ export * from "./components/transistor"
75
76
  export * from "./components/mosfet"
76
77
  export * from "./components/opamp"
77
78
  export * from "./components/inductor"
79
+ export * from "./components/internal-circuit"
78
80
  export * from "./components/diode"
79
81
  export * from "./components/led"
80
82
  export * from "./components/switch"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.580",
3
+ "version": "0.0.582",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",