@tscircuit/props 0.0.590 → 0.0.591

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,59 @@
1
+ import { rotation } from "circuit-json"
2
+ import { connectionTarget } from "lib/common/connectionsProp"
3
+ import { distance, type Distance } from "lib/common/distance"
4
+ import { expectTypesMatch } from "lib/typecheck"
5
+ import type { Connections } from "lib/utility-types/connections-and-selectors"
6
+ import { z } from "zod"
7
+
8
+ /**
9
+ * Places a named schematic-symbol representation of an existing physical
10
+ * component. The connection keys are labels exposed by `symbolName`; each
11
+ * value selects the corresponding port on the component referenced by
12
+ * `chipRef`.
13
+ *
14
+ * This is a schematic-only projection, so it accepts only the identity,
15
+ * connection, and schematic placement props it needs.
16
+ */
17
+ export interface SchematicSymbolProps {
18
+ /** Stable name for this representation, such as `A` or `B`. */
19
+ name: string
20
+ /** Optional human-facing name shown in the schematic. */
21
+ displayName?: string
22
+ /** Selector for the physical component represented by this symbol. */
23
+ chipRef?: string
24
+ /** Name of the symbol from the schematic-symbol library. */
25
+ symbolName: string
26
+ /** Maps symbol port labels to physical component port selectors. */
27
+ connections?: Connections
28
+ schX?: Distance
29
+ schY?: Distance
30
+ schRotation?: number | string
31
+ schSectionName?: string
32
+ schSheetName?: string
33
+ }
34
+
35
+ const schematicSymbolConnections = z
36
+ .custom<Connections>()
37
+ .pipe(z.record(z.string(), connectionTarget))
38
+ .refine((value) => Object.keys(value).length > 0, {
39
+ message: "connections must map at least one schematic symbol port",
40
+ })
41
+
42
+ export const schematicSymbolProps = z.object({
43
+ name: z.string().min(1),
44
+ displayName: z.string().optional(),
45
+ chipRef: z.string().min(1).optional(),
46
+ symbolName: z.string().min(1),
47
+ connections: schematicSymbolConnections.optional(),
48
+ schX: distance.optional(),
49
+ schY: distance.optional(),
50
+ schRotation: rotation.optional(),
51
+ schSectionName: z.string().optional(),
52
+ schSheetName: z.string().optional(),
53
+ })
54
+
55
+ export type InferredSchematicSymbolProps = z.input<typeof schematicSymbolProps>
56
+
57
+ expectTypesMatch<SchematicSymbolProps, z.input<typeof schematicSymbolProps>>(
58
+ true,
59
+ )
package/lib/index.ts CHANGED
@@ -104,6 +104,7 @@ export * from "./components/ammeter"
104
104
  export * from "./components/schematic-arc"
105
105
  export * from "./components/toolingrail"
106
106
  export * from "./components/schematic-box"
107
+ export * from "./components/schematic-symbol"
107
108
  export * from "./components/schematic-circle"
108
109
  export * from "./components/schematic-rect"
109
110
  export * from "./components/schematic-line"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.590",
3
+ "version": "0.0.591",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",