@tscircuit/props 0.0.548 → 0.0.550
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 +15 -0
- package/dist/index.d.ts +4582 -7
- package/dist/index.js +204 -178
- package/dist/index.js.map +1 -1
- package/lib/components/ammeter.ts +55 -0
- package/lib/components/voltageprobe.ts +0 -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)
|
|
@@ -18,7 +18,6 @@ export interface VoltageProbeDisplayOptions {
|
|
|
18
18
|
center?: number
|
|
19
19
|
offsetDivs?: number
|
|
20
20
|
unitsPerDiv?: number
|
|
21
|
-
color?: string
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export const voltageProbeProps = commonComponentProps
|
|
@@ -34,7 +33,6 @@ export const voltageProbeProps = commonComponentProps
|
|
|
34
33
|
center: z.number().optional(),
|
|
35
34
|
offsetDivs: z.number().optional(),
|
|
36
35
|
unitsPerDiv: z.number().optional(),
|
|
37
|
-
color: z.string().optional(),
|
|
38
36
|
})
|
|
39
37
|
.optional(),
|
|
40
38
|
})
|
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"
|