@tscircuit/props 0.0.549 → 0.0.551
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 +16 -1
- package/dist/index.d.ts +4586 -5
- package/dist/index.js +204 -177
- package/dist/index.js.map +1 -1
- package/lib/components/ammeter.ts +55 -0
- package/lib/components/fiducial.ts +2 -2
- package/lib/index.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type CommonComponentProps,
|
|
3
|
+
commonComponentProps,
|
|
4
|
+
} from "lib/common/layout"
|
|
5
|
+
import { createConnectionsProp } from "lib/common/connectionsProp"
|
|
6
|
+
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
7
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
8
|
+
import { z } from "zod"
|
|
9
|
+
|
|
10
|
+
export const ammeterPinLabels = ["pin1", "pin2", "pos", "neg"] as const
|
|
11
|
+
export type AmmeterPinLabels = (typeof ammeterPinLabels)[number]
|
|
12
|
+
|
|
13
|
+
export interface AmmeterDisplayOptions {
|
|
14
|
+
label?: string
|
|
15
|
+
center?: number
|
|
16
|
+
offsetDivs?: number
|
|
17
|
+
unitsPerDiv?: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface AmmeterProps<PinLabel extends string = string>
|
|
21
|
+
extends CommonComponentProps<PinLabel> {
|
|
22
|
+
connections: Connections<AmmeterPinLabels>
|
|
23
|
+
color?: string
|
|
24
|
+
display?: AmmeterDisplayOptions
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const hasAmmeterConnectionPair = (
|
|
28
|
+
connections: Connections<AmmeterPinLabels>,
|
|
29
|
+
) => {
|
|
30
|
+
return (
|
|
31
|
+
(connections.pos !== undefined && connections.neg !== undefined) ||
|
|
32
|
+
(connections.pin1 !== undefined && connections.pin2 !== undefined)
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const ammeterDisplayOptions = z.object({
|
|
37
|
+
label: z.string().optional(),
|
|
38
|
+
center: z.number().optional(),
|
|
39
|
+
offsetDivs: z.number().optional(),
|
|
40
|
+
unitsPerDiv: z.number().optional(),
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export const ammeterProps = commonComponentProps.extend({
|
|
44
|
+
connections: createConnectionsProp(ammeterPinLabels).refine(
|
|
45
|
+
hasAmmeterConnectionPair,
|
|
46
|
+
"Ammeter connections must include either pos/neg or pin1/pin2",
|
|
47
|
+
),
|
|
48
|
+
color: z.string().optional(),
|
|
49
|
+
display: ammeterDisplayOptions.optional(),
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
export const ammeterPins = ammeterPinLabels
|
|
53
|
+
|
|
54
|
+
type InferredAmmeterProps = z.input<typeof ammeterProps>
|
|
55
|
+
expectTypesMatch<AmmeterProps, InferredAmmeterProps>(true)
|
|
@@ -8,12 +8,12 @@ import { z } from "zod"
|
|
|
8
8
|
|
|
9
9
|
export interface FiducialProps extends CommonComponentProps {
|
|
10
10
|
soldermaskPullback?: Distance
|
|
11
|
-
padDiameter
|
|
11
|
+
padDiameter: Distance
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
export const fiducialProps = commonComponentProps.extend({
|
|
15
15
|
soldermaskPullback: distance.optional(),
|
|
16
|
-
padDiameter: distance
|
|
16
|
+
padDiameter: distance,
|
|
17
17
|
})
|
|
18
18
|
|
|
19
19
|
type InferredFiducialProps = z.input<typeof fiducialProps>
|
package/lib/index.ts
CHANGED
|
@@ -95,6 +95,7 @@ export * from "./components/power-source"
|
|
|
95
95
|
export * from "./components/voltagesource"
|
|
96
96
|
export * from "./components/currentsource"
|
|
97
97
|
export * from "./components/voltageprobe"
|
|
98
|
+
export * from "./components/ammeter"
|
|
98
99
|
export * from "./components/schematic-arc"
|
|
99
100
|
export * from "./components/toolingrail"
|
|
100
101
|
export * from "./components/schematic-box"
|