@tscircuit/props 0.0.706 → 0.0.707
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/dist/index.d.ts +252 -1
- package/dist/index.js +1403 -1347
- package/dist/index.js.map +1 -1
- package/lib/assembly/explosion/index.ts +11 -0
- package/lib/assembly/explosion/move.ts +72 -0
- package/lib/assembly/explosion/stage.ts +30 -0
- package/lib/assembly/index.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { assemblyExplosionMoveProps } from "./move"
|
|
2
|
+
import { assemblyExplosionStageProps } from "./stage"
|
|
3
|
+
|
|
4
|
+
export * from "./move"
|
|
5
|
+
export * from "./stage"
|
|
6
|
+
|
|
7
|
+
/** Explosion elements; no separate explosion container is needed. */
|
|
8
|
+
export const assemblyExplosionProps = {
|
|
9
|
+
stage: assemblyExplosionStageProps,
|
|
10
|
+
move: assemblyExplosionMoveProps,
|
|
11
|
+
} as const
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { type Distance, distance } from "lib/common/distance"
|
|
2
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
/** One straight, incremental movement within an explosion stage. */
|
|
6
|
+
export interface AssemblyExplosionMoveProps {
|
|
7
|
+
/** Parts or subassemblies to move together, relative to the stage owner.
|
|
8
|
+
* Accepts a comma-separated string or an array; parsed as a nonempty array of
|
|
9
|
+
* trimmed references. Supply exactly one of targetRefs or targetRef.
|
|
10
|
+
*/
|
|
11
|
+
targetRefs?: string | string[]
|
|
12
|
+
/** Single-target compatibility alias for targetRefs. Parsed as targetRefs:
|
|
13
|
+
* [targetRef]; cannot be combined with targetRefs. React reserves ref.
|
|
14
|
+
*/
|
|
15
|
+
targetRef?: string
|
|
16
|
+
/** Signed X displacement in the stage owner's frame, in mm or a unit string.
|
|
17
|
+
* Omitted axes mean zero in the consumer; parsed props remain omitted.
|
|
18
|
+
*/
|
|
19
|
+
offX?: Distance
|
|
20
|
+
/** Signed Y displacement in the stage owner's frame, in mm or a unit string. */
|
|
21
|
+
offY?: Distance
|
|
22
|
+
/** Signed Z displacement in the stage owner's frame, in mm or a unit string. */
|
|
23
|
+
offZ?: Distance
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const offset = distance.pipe(z.number().finite())
|
|
27
|
+
const reference = z.string().trim().min(1)
|
|
28
|
+
const references = z
|
|
29
|
+
.union([
|
|
30
|
+
z.string().transform((value) => value.split(",")),
|
|
31
|
+
z.array(z.string()),
|
|
32
|
+
])
|
|
33
|
+
.pipe(z.array(reference).min(1))
|
|
34
|
+
|
|
35
|
+
export const assemblyExplosionMoveProps = z
|
|
36
|
+
.object({
|
|
37
|
+
targetRefs: references.optional(),
|
|
38
|
+
targetRef: reference.optional(),
|
|
39
|
+
offX: offset.optional(),
|
|
40
|
+
offY: offset.optional(),
|
|
41
|
+
offZ: offset.optional(),
|
|
42
|
+
})
|
|
43
|
+
.refine(
|
|
44
|
+
(move) =>
|
|
45
|
+
(move.targetRefs !== undefined) !== (move.targetRef !== undefined),
|
|
46
|
+
{
|
|
47
|
+
message: "Provide exactly one of targetRefs or targetRef",
|
|
48
|
+
path: ["targetRefs"],
|
|
49
|
+
},
|
|
50
|
+
)
|
|
51
|
+
.refine(
|
|
52
|
+
(move) =>
|
|
53
|
+
move.offX !== undefined ||
|
|
54
|
+
move.offY !== undefined ||
|
|
55
|
+
move.offZ !== undefined,
|
|
56
|
+
{
|
|
57
|
+
message: "Provide at least one of offX, offY, or offZ",
|
|
58
|
+
path: ["offX"],
|
|
59
|
+
},
|
|
60
|
+
)
|
|
61
|
+
.transform(({ targetRef, targetRefs, ...move }) => ({
|
|
62
|
+
...move,
|
|
63
|
+
targetRefs: targetRefs ?? [targetRef!],
|
|
64
|
+
}))
|
|
65
|
+
|
|
66
|
+
export type AssemblyExplosionMovePropsInput = z.input<
|
|
67
|
+
typeof assemblyExplosionMoveProps
|
|
68
|
+
>
|
|
69
|
+
|
|
70
|
+
expectTypesMatch<AssemblyExplosionMoveProps, AssemblyExplosionMovePropsInput>(
|
|
71
|
+
true,
|
|
72
|
+
)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
2
|
+
import type { ReactNode } from "react"
|
|
3
|
+
import { z } from "zod"
|
|
4
|
+
|
|
5
|
+
/** A named explosion stage owned by its containing device or subassembly. */
|
|
6
|
+
export interface AssemblyExplosionStageProps {
|
|
7
|
+
/** Stable stage identity, unique within the owning assembly. */
|
|
8
|
+
name: string
|
|
9
|
+
/** Stage that must execute after this one; qualified names may cross assembly scopes. */
|
|
10
|
+
nextStageRef?: string
|
|
11
|
+
/** Stage that must execute before this one; qualified names may cross assembly scopes. */
|
|
12
|
+
prevStageRef?: string
|
|
13
|
+
/** Ordered explosion moves; preserved unchanged for the consumer. */
|
|
14
|
+
children?: ReactNode
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const assemblyExplosionStageProps = z.object({
|
|
18
|
+
name: z.string().trim().min(1),
|
|
19
|
+
nextStageRef: z.string().trim().min(1).optional(),
|
|
20
|
+
prevStageRef: z.string().trim().min(1).optional(),
|
|
21
|
+
children: z.custom<ReactNode>().optional(),
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
export type AssemblyExplosionStagePropsInput = z.input<
|
|
25
|
+
typeof assemblyExplosionStageProps
|
|
26
|
+
>
|
|
27
|
+
|
|
28
|
+
expectTypesMatch<AssemblyExplosionStageProps, AssemblyExplosionStagePropsInput>(
|
|
29
|
+
true,
|
|
30
|
+
)
|
package/lib/assembly/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { assemblyPrintedPartProps } from "./printedpart"
|
|
|
9
9
|
import { assemblyMotorProps } from "./motor"
|
|
10
10
|
import { assemblyScreenProps } from "./screen"
|
|
11
11
|
import { assemblySubassemblyProps } from "./subassembly"
|
|
12
|
+
import { assemblyExplosionProps } from "./explosion"
|
|
12
13
|
|
|
13
14
|
export * from "./board-mounting"
|
|
14
15
|
export * from "./bolt"
|
|
@@ -22,8 +23,10 @@ export * from "./printedpart"
|
|
|
22
23
|
export * from "./screen"
|
|
23
24
|
export * from "./subassembly"
|
|
24
25
|
export * from "./cadassembly"
|
|
26
|
+
export * from "./explosion"
|
|
25
27
|
|
|
26
28
|
export const assemblyProps = {
|
|
29
|
+
explosion: assemblyExplosionProps,
|
|
27
30
|
bolt: assemblyBoltProps,
|
|
28
31
|
fastener: assemblyFastenerProps,
|
|
29
32
|
cable: assemblyCableProps,
|