@tscircuit/props 0.0.317 → 0.0.319

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.
@@ -2,6 +2,7 @@ import { z } from "zod"
2
2
  import { expectTypesMatch } from "lib/typecheck"
3
3
  import { distance, type Distance } from "./distance"
4
4
  import { point3 } from "./point3"
5
+ import type { ReactElement } from "react"
5
6
 
6
7
  export const rotationPoint3 = z.object({
7
8
  x: z.union([z.number(), z.string()]),
@@ -85,6 +86,7 @@ export const cadModelJscad = cadModelBase.extend({
85
86
  export type CadModelProp =
86
87
  | null
87
88
  | string
89
+ | ReactElement
88
90
  | CadModelStl
89
91
  | CadModelObj
90
92
  | CadModelGltf
@@ -96,6 +98,9 @@ export type CadModelProp =
96
98
  export const cadModelProp = z.union([
97
99
  z.null(),
98
100
  z.string(),
101
+ z.custom<ReactElement>((v) => {
102
+ return v && typeof v === "object" && "type" in v && "props" in v
103
+ }),
99
104
  cadModelStl,
100
105
  cadModelObj,
101
106
  cadModelGltf,
@@ -0,0 +1,28 @@
1
+ import { type LayerRef, layer_ref } from "circuit-json"
2
+ import { expectTypesMatch } from "lib/typecheck"
3
+ import { z } from "zod"
4
+
5
+ export interface CadAssemblyProps {
6
+ /**
7
+ * The layer that the CAD assembly is designed for. If you set this to "top"
8
+ * then it means the children were intended to represent the top layer. If
9
+ * the <chip /> with this assembly is moved to the bottom layer, then the
10
+ * components will be mirrored.
11
+ *
12
+ * Generally, you shouldn't set this except where it can help prevent
13
+ * confusion because you have a complex multi-layer assembly. Default is
14
+ * "top" and this is most intuitive.
15
+ */
16
+ originalLayer?: LayerRef
17
+
18
+ children?: any
19
+ }
20
+
21
+ export const cadassemblyProps = z.object({
22
+ originalLayer: layer_ref.default("top").optional(),
23
+ children: z.any().optional(),
24
+ })
25
+
26
+ export type CadAssemblyPropsInput = z.input<typeof cadassemblyProps>
27
+ type InferredCadAssemblyProps = z.infer<typeof cadassemblyProps>
28
+ expectTypesMatch<InferredCadAssemblyProps, CadAssemblyProps>(true)
@@ -0,0 +1,28 @@
1
+ import { distance, type Distance } from "lib/common/distance"
2
+ import { expectTypesMatch } from "lib/typecheck"
3
+ import { cadModelBase, type CadModelBase } from "../common/cadModel"
4
+ import { z } from "zod"
5
+
6
+ export interface CadModelProps extends CadModelBase {
7
+ modelUrl: string
8
+ pcbX?: Distance
9
+ pcbY?: Distance
10
+ pcbZ?: Distance
11
+ }
12
+
13
+ const pcbPosition = z.object({
14
+ pcbX: distance.optional(),
15
+ pcbY: distance.optional(),
16
+ pcbZ: distance.optional(),
17
+ })
18
+
19
+ const cadModelBaseWithUrl = cadModelBase.extend({
20
+ modelUrl: z.string(),
21
+ })
22
+
23
+ const cadModelObject = cadModelBaseWithUrl.merge(pcbPosition)
24
+ expectTypesMatch<CadModelProps, z.input<typeof cadModelObject>>(true)
25
+
26
+ export const cadmodelProps = z.union([z.null(), z.string(), cadModelObject])
27
+
28
+ export type CadModelPropsInput = z.input<typeof cadmodelProps>
package/lib/index.ts CHANGED
@@ -61,6 +61,8 @@ export * from "./components/testpoint"
61
61
  export * from "./components/breakoutpoint"
62
62
  export * from "./components/pcb-keepout"
63
63
  export * from "./components/copper-pour"
64
+ export * from "./components/cadassembly"
65
+ export * from "./components/cadmodel"
64
66
  export * from "./components/power-source"
65
67
  export * from "./components/voltagesource"
66
68
  export * from "./components/schematic-box"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.317",
3
+ "version": "0.0.319",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",