@tscircuit/props 0.0.710 → 0.0.712
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 +8 -0
- package/dist/index.d.ts +96 -1
- package/dist/index.js +21 -3
- package/dist/index.js.map +1 -1
- package/lib/assembly/drawing/dimension.ts +33 -1
- package/lib/components/transistor.ts +9 -0
- package/package.json +1 -1
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { z } from "zod"
|
|
2
2
|
import { expectTypesMatch } from "lib/typecheck"
|
|
3
3
|
|
|
4
|
+
const dimensionAnchor = z.enum(["center", "left", "right", "top", "bottom"])
|
|
5
|
+
export type AssemblyDrawingDimensionAnchor = z.infer<typeof dimensionAnchor>
|
|
6
|
+
|
|
4
7
|
/** Authoring intent for a dimension of model geometry or a part view's extent.
|
|
5
8
|
* Core resolves geometry, measurement text and paper placement in a follow-up.
|
|
6
9
|
*/
|
|
@@ -13,6 +16,14 @@ export interface AssemblyDrawingDimensionProps {
|
|
|
13
16
|
widthOfView?: boolean
|
|
14
17
|
/** Request the selected geometry's height in the view. Conflicts with edgeRef and widthOfView=true. */
|
|
15
18
|
heightOfView?: boolean
|
|
19
|
+
/** Paired selectors for holes, boards or named model outlines. Both are required; conflicts with edgeRef and true view targets. */
|
|
20
|
+
fromRef?: string
|
|
21
|
+
toRef?: string
|
|
22
|
+
/** Anchor on the reference's projected bounds. Defaults to center; directions are relative to the drawing view, not CAD world axes. */
|
|
23
|
+
fromAnchor?: AssemblyDrawingDimensionAnchor
|
|
24
|
+
toAnchor?: AssemblyDrawingDimensionAnchor
|
|
25
|
+
/** Measure separation on the view's horizontal (x) or vertical (y) axis. Omitted chooses the larger separation, x on ties. Requires paired references. */
|
|
26
|
+
axis?: "x" | "y"
|
|
16
27
|
}
|
|
17
28
|
|
|
18
29
|
export const assemblyDrawingDimensionProps = z
|
|
@@ -21,18 +32,39 @@ export const assemblyDrawingDimensionProps = z
|
|
|
21
32
|
edgeRef: z.string().trim().min(1).optional(),
|
|
22
33
|
widthOfView: z.boolean().optional(),
|
|
23
34
|
heightOfView: z.boolean().optional(),
|
|
35
|
+
fromRef: z.string().trim().min(1).optional(),
|
|
36
|
+
toRef: z.string().trim().min(1).optional(),
|
|
37
|
+
fromAnchor: dimensionAnchor.optional(),
|
|
38
|
+
toAnchor: dimensionAnchor.optional(),
|
|
39
|
+
axis: z.enum(["x", "y"]).optional(),
|
|
24
40
|
})
|
|
25
41
|
.superRefine((dimension, ctx) => {
|
|
26
42
|
const targets = [
|
|
27
43
|
dimension.edgeRef !== undefined,
|
|
28
44
|
dimension.widthOfView === true,
|
|
29
45
|
dimension.heightOfView === true,
|
|
46
|
+
dimension.fromRef !== undefined || dimension.toRef !== undefined,
|
|
30
47
|
].filter(Boolean).length
|
|
31
48
|
if (targets !== 1)
|
|
32
49
|
ctx.addIssue({
|
|
33
50
|
code: "custom",
|
|
34
51
|
message:
|
|
35
|
-
"Specify exactly one of edgeRef, widthOfView=true,
|
|
52
|
+
"Specify exactly one of edgeRef, widthOfView=true, heightOfView=true, or paired fromRef/toRef",
|
|
53
|
+
})
|
|
54
|
+
if ((dimension.fromRef === undefined) !== (dimension.toRef === undefined))
|
|
55
|
+
ctx.addIssue({
|
|
56
|
+
code: "custom",
|
|
57
|
+
message: "fromRef and toRef must be specified together",
|
|
58
|
+
})
|
|
59
|
+
if (
|
|
60
|
+
(dimension.axis !== undefined ||
|
|
61
|
+
dimension.fromAnchor !== undefined ||
|
|
62
|
+
dimension.toAnchor !== undefined) &&
|
|
63
|
+
(dimension.fromRef === undefined || dimension.toRef === undefined)
|
|
64
|
+
)
|
|
65
|
+
ctx.addIssue({
|
|
66
|
+
code: "custom",
|
|
67
|
+
message: "axis, fromAnchor and toAnchor require paired fromRef/toRef",
|
|
36
68
|
})
|
|
37
69
|
})
|
|
38
70
|
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import { expectTypesMatch } from "lib/typecheck"
|
|
6
6
|
import { z } from "zod"
|
|
7
7
|
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
8
|
+
import { pinLabelsProp, type PinLabelsProp } from "./chip"
|
|
8
9
|
import { createConnectionsProp } from "lib/common/connectionsProp"
|
|
9
10
|
|
|
10
11
|
export const transistorPinsLabels = [
|
|
@@ -23,11 +24,19 @@ export type transistorPinsLabels = (typeof transistorPinsLabels)[number]
|
|
|
23
24
|
export interface TransistorProps<PinLabel extends string = string>
|
|
24
25
|
extends CommonComponentProps<PinLabel> {
|
|
25
26
|
type: "npn" | "pnp" | "bjt" | "jfet" | "mosfet" | "igbt"
|
|
27
|
+
/**
|
|
28
|
+
* Physical package pins mapped to semantic terminal names (and optional aliases).
|
|
29
|
+
* For MMBT3904 SOT-23: { pin1: "base", pin2: "emitter", pin3: "collector" }.
|
|
30
|
+
* Use full terminal names to retain schematic and simulation semantics.
|
|
31
|
+
* Omit to retain the symbol's default pin order; no package pinout is inferred.
|
|
32
|
+
*/
|
|
33
|
+
pinLabels?: PinLabelsProp<string, PinLabel>
|
|
26
34
|
connections?: Connections<transistorPinsLabels>
|
|
27
35
|
}
|
|
28
36
|
|
|
29
37
|
export const transistorProps = commonComponentProps.extend({
|
|
30
38
|
type: z.enum(["npn", "pnp", "bjt", "jfet", "mosfet", "igbt"]),
|
|
39
|
+
pinLabels: pinLabelsProp.optional(),
|
|
31
40
|
connections: createConnectionsProp(transistorPinsLabels).optional(),
|
|
32
41
|
})
|
|
33
42
|
|