@tscircuit/props 0.0.237 → 0.0.239
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 +4 -0
- package/dist/index.d.ts +49 -1
- package/dist/index.js +455 -425
- package/dist/index.js.map +1 -1
- package/lib/common/schematicOrientation.ts +35 -0
- package/lib/components/battery.ts +6 -0
- package/lib/components/capacitor.ts +6 -0
- package/lib/components/crystal.ts +6 -0
- package/lib/components/diode.ts +6 -0
- package/lib/components/fuse.ts +7 -0
- package/lib/components/inductor.ts +6 -0
- package/lib/components/jumper.ts +10 -0
- package/lib/components/led.ts +5 -0
- package/lib/components/resistor.ts +7 -0
- package/lib/index.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { expectTypesMatch } from "lib/typecheck"
|
|
2
|
+
import { z } from "zod"
|
|
3
|
+
|
|
4
|
+
export const schematicOrientation = z
|
|
5
|
+
.enum([
|
|
6
|
+
"vertical",
|
|
7
|
+
"horizontal",
|
|
8
|
+
"pos_top",
|
|
9
|
+
"pos_bottom",
|
|
10
|
+
"pos_left",
|
|
11
|
+
"pos_right",
|
|
12
|
+
"neg_top",
|
|
13
|
+
"neg_bottom",
|
|
14
|
+
"neg_left",
|
|
15
|
+
"neg_right",
|
|
16
|
+
])
|
|
17
|
+
.describe(
|
|
18
|
+
"horizontal means pins go 1->2 rightward and vertical means pins go 1->2 downward (generally, positive on top)",
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
export type SchematicOrientation =
|
|
22
|
+
| "vertical"
|
|
23
|
+
| "horizontal"
|
|
24
|
+
| "pos_top"
|
|
25
|
+
| "pos_bottom"
|
|
26
|
+
| "pos_left"
|
|
27
|
+
| "pos_right"
|
|
28
|
+
| "neg_top"
|
|
29
|
+
| "neg_bottom"
|
|
30
|
+
| "neg_left"
|
|
31
|
+
| "neg_right"
|
|
32
|
+
|
|
33
|
+
expectTypesMatch<SchematicOrientation, z.infer<typeof schematicOrientation>>(
|
|
34
|
+
true,
|
|
35
|
+
)
|
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
lrPolarPins,
|
|
6
6
|
type CommonComponentProps,
|
|
7
7
|
} from "lib/common/layout"
|
|
8
|
+
import {
|
|
9
|
+
schematicOrientation,
|
|
10
|
+
type SchematicOrientation,
|
|
11
|
+
} from "lib/common/schematicOrientation"
|
|
8
12
|
import { expectTypesMatch } from "lib/typecheck"
|
|
9
13
|
|
|
10
14
|
/** @deprecated use battery_capacity from circuit-json when circuit-json is updated */
|
|
@@ -26,10 +30,12 @@ const capacity = z
|
|
|
26
30
|
|
|
27
31
|
export interface BatteryProps extends CommonComponentProps {
|
|
28
32
|
capacity?: number | string
|
|
33
|
+
schOrientation?: SchematicOrientation
|
|
29
34
|
}
|
|
30
35
|
|
|
31
36
|
export const batteryProps = commonComponentProps.extend({
|
|
32
37
|
capacity: capacity.optional(),
|
|
38
|
+
schOrientation: schematicOrientation.optional(),
|
|
33
39
|
})
|
|
34
40
|
export const batteryPins = lrPolarPins
|
|
35
41
|
|
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
commonComponentProps,
|
|
6
6
|
lrPolarPins,
|
|
7
7
|
} from "lib/common/layout"
|
|
8
|
+
import {
|
|
9
|
+
schematicOrientation,
|
|
10
|
+
type SchematicOrientation,
|
|
11
|
+
} from "lib/common/schematicOrientation"
|
|
8
12
|
import { expectTypesMatch } from "lib/typecheck"
|
|
9
13
|
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
10
14
|
import { z } from "zod"
|
|
@@ -29,6 +33,7 @@ export interface CapacitorProps extends CommonComponentProps {
|
|
|
29
33
|
bypassFor?: string
|
|
30
34
|
bypassTo?: string
|
|
31
35
|
maxDecouplingTraceLength?: number
|
|
36
|
+
schOrientation?: SchematicOrientation
|
|
32
37
|
connections?: Connections<CapacitorPinLabels>
|
|
33
38
|
}
|
|
34
39
|
|
|
@@ -42,6 +47,7 @@ export const capacitorProps = commonComponentProps.extend({
|
|
|
42
47
|
bypassFor: z.string().optional(),
|
|
43
48
|
bypassTo: z.string().optional(),
|
|
44
49
|
maxDecouplingTraceLength: z.number().optional(),
|
|
50
|
+
schOrientation: schematicOrientation.optional(),
|
|
45
51
|
connections: createConnectionsProp(capacitorPinLabels).optional(),
|
|
46
52
|
})
|
|
47
53
|
export const capacitorPins = lrPolarPins
|
|
@@ -4,6 +4,10 @@ import {
|
|
|
4
4
|
commonComponentProps,
|
|
5
5
|
lrPins,
|
|
6
6
|
} from "lib/common/layout"
|
|
7
|
+
import {
|
|
8
|
+
schematicOrientation,
|
|
9
|
+
type SchematicOrientation,
|
|
10
|
+
} from "lib/common/schematicOrientation"
|
|
7
11
|
import { expectTypesMatch } from "lib/typecheck"
|
|
8
12
|
import { z } from "zod"
|
|
9
13
|
|
|
@@ -13,12 +17,14 @@ export interface CrystalProps extends CommonComponentProps {
|
|
|
13
17
|
frequency: number | string
|
|
14
18
|
loadCapacitance: number | string
|
|
15
19
|
pinVariant?: PinVariant
|
|
20
|
+
schOrientation?: SchematicOrientation
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
export const crystalProps = commonComponentProps.extend({
|
|
19
24
|
frequency: frequency,
|
|
20
25
|
loadCapacitance: capacitance,
|
|
21
26
|
pinVariant: z.enum(["two_pin", "four_pin"]).optional(),
|
|
27
|
+
schOrientation: schematicOrientation.optional(),
|
|
22
28
|
})
|
|
23
29
|
export const crystalPins = lrPins
|
|
24
30
|
|
package/lib/components/diode.ts
CHANGED
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
} from "lib/common/layout"
|
|
6
6
|
import { z } from "zod"
|
|
7
7
|
import { expectTypesMatch } from "lib/typecheck"
|
|
8
|
+
import {
|
|
9
|
+
schematicOrientation,
|
|
10
|
+
type SchematicOrientation,
|
|
11
|
+
} from "lib/common/schematicOrientation"
|
|
8
12
|
|
|
9
13
|
const diodeConnectionKeys = z.enum([
|
|
10
14
|
"anode",
|
|
@@ -33,6 +37,7 @@ export const diodeProps = commonComponentProps
|
|
|
33
37
|
zener: z.boolean().optional(),
|
|
34
38
|
photo: z.boolean().optional(),
|
|
35
39
|
tvs: z.boolean().optional(),
|
|
40
|
+
schOrientation: schematicOrientation.optional(),
|
|
36
41
|
})
|
|
37
42
|
.superRefine((data, ctx) => {
|
|
38
43
|
// Check if multiple boolean flags are set directly
|
|
@@ -111,6 +116,7 @@ export interface DiodeProps extends CommonComponentProps {
|
|
|
111
116
|
zener?: boolean
|
|
112
117
|
photo?: boolean
|
|
113
118
|
tvs?: boolean
|
|
119
|
+
schOrientation?: SchematicOrientation
|
|
114
120
|
}
|
|
115
121
|
|
|
116
122
|
export type InferredDiodeProps = z.input<typeof diodeProps>
|
package/lib/components/fuse.ts
CHANGED
|
@@ -3,6 +3,10 @@ import {
|
|
|
3
3
|
type CommonComponentProps,
|
|
4
4
|
commonComponentProps,
|
|
5
5
|
} from "lib/common/layout"
|
|
6
|
+
import {
|
|
7
|
+
schematicOrientation,
|
|
8
|
+
type SchematicOrientation,
|
|
9
|
+
} from "lib/common/schematicOrientation"
|
|
6
10
|
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
7
11
|
|
|
8
12
|
/**
|
|
@@ -28,6 +32,8 @@ export interface FuseProps extends CommonComponentProps {
|
|
|
28
32
|
*/
|
|
29
33
|
schShowRatings?: boolean
|
|
30
34
|
|
|
35
|
+
schOrientation?: SchematicOrientation
|
|
36
|
+
|
|
31
37
|
/**
|
|
32
38
|
* Connections to other components
|
|
33
39
|
*/
|
|
@@ -41,6 +47,7 @@ export const fuseProps = commonComponentProps.extend({
|
|
|
41
47
|
currentRating: z.union([z.number(), z.string()]),
|
|
42
48
|
voltageRating: z.union([z.number(), z.string()]).optional(),
|
|
43
49
|
schShowRatings: z.boolean().optional(),
|
|
50
|
+
schOrientation: schematicOrientation.optional(),
|
|
44
51
|
connections: z
|
|
45
52
|
.record(
|
|
46
53
|
z.string(),
|
|
@@ -4,17 +4,23 @@ import {
|
|
|
4
4
|
commonComponentProps,
|
|
5
5
|
lrPins,
|
|
6
6
|
} from "lib/common/layout"
|
|
7
|
+
import {
|
|
8
|
+
schematicOrientation,
|
|
9
|
+
type SchematicOrientation,
|
|
10
|
+
} from "lib/common/schematicOrientation"
|
|
7
11
|
import { expectTypesMatch } from "lib/typecheck"
|
|
8
12
|
import { z } from "zod"
|
|
9
13
|
|
|
10
14
|
export interface InductorProps extends CommonComponentProps {
|
|
11
15
|
inductance: number | string
|
|
12
16
|
maxCurrentRating?: number | string
|
|
17
|
+
schOrientation?: SchematicOrientation
|
|
13
18
|
}
|
|
14
19
|
|
|
15
20
|
export const inductorProps = commonComponentProps.extend({
|
|
16
21
|
inductance,
|
|
17
22
|
maxCurrentRating: z.union([z.string(), z.number()]).optional(),
|
|
23
|
+
schOrientation: schematicOrientation.optional(),
|
|
18
24
|
})
|
|
19
25
|
|
|
20
26
|
export const inductorPins = lrPins
|
package/lib/components/jumper.ts
CHANGED
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
type SchematicPinStyle,
|
|
12
12
|
schematicPinStyle,
|
|
13
13
|
} from "lib/common/schematicPinStyle"
|
|
14
|
+
import { connectionTarget } from "lib/common/connectionsProp"
|
|
15
|
+
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
14
16
|
import { expectTypesMatch } from "lib/typecheck"
|
|
15
17
|
import { z } from "zod"
|
|
16
18
|
|
|
@@ -32,6 +34,10 @@ export interface JumperProps extends CommonComponentProps {
|
|
|
32
34
|
* e.g., [["1","2"], ["2","3"]]
|
|
33
35
|
*/
|
|
34
36
|
internallyConnectedPins?: string[][]
|
|
37
|
+
/**
|
|
38
|
+
* Connections to other components
|
|
39
|
+
*/
|
|
40
|
+
connections?: Connections<string>
|
|
35
41
|
}
|
|
36
42
|
|
|
37
43
|
export const jumperProps = commonComponentProps.extend({
|
|
@@ -47,6 +53,10 @@ export const jumperProps = commonComponentProps.extend({
|
|
|
47
53
|
schPortArrangement: schematicPortArrangement.optional(),
|
|
48
54
|
pinCount: z.union([z.literal(2), z.literal(3)]).optional(),
|
|
49
55
|
internallyConnectedPins: z.array(z.array(z.string())).optional(),
|
|
56
|
+
connections: z
|
|
57
|
+
.custom<Connections>()
|
|
58
|
+
.pipe(z.record(z.string(), connectionTarget))
|
|
59
|
+
.optional(),
|
|
50
60
|
})
|
|
51
61
|
|
|
52
62
|
type InferredJumperProps = z.input<typeof jumperProps>
|
package/lib/components/led.ts
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { commonComponentProps, lrPolarPins } from "lib/common/layout"
|
|
2
|
+
import {
|
|
3
|
+
schematicOrientation,
|
|
4
|
+
type SchematicOrientation,
|
|
5
|
+
} from "lib/common/schematicOrientation"
|
|
2
6
|
import { z } from "zod"
|
|
3
7
|
|
|
4
8
|
export const ledProps = commonComponentProps.extend({
|
|
5
9
|
color: z.string().optional(),
|
|
6
10
|
wavelength: z.string().optional(),
|
|
7
11
|
schDisplayValue: z.string().optional(),
|
|
12
|
+
schOrientation: schematicOrientation.optional(),
|
|
8
13
|
})
|
|
9
14
|
export const ledPins = lrPolarPins
|
|
10
15
|
export type LedProps = z.input<typeof ledProps>
|
|
@@ -5,6 +5,10 @@ import {
|
|
|
5
5
|
commonComponentProps,
|
|
6
6
|
lrPins,
|
|
7
7
|
} from "lib/common/layout"
|
|
8
|
+
import {
|
|
9
|
+
schematicOrientation,
|
|
10
|
+
type SchematicOrientation,
|
|
11
|
+
} from "lib/common/schematicOrientation"
|
|
8
12
|
import { expectTypesMatch } from "lib/typecheck"
|
|
9
13
|
import type { Connections } from "lib/utility-types/connections-and-selectors"
|
|
10
14
|
import { z } from "zod"
|
|
@@ -18,6 +22,7 @@ export interface ResistorProps extends CommonComponentProps {
|
|
|
18
22
|
pullupTo?: string
|
|
19
23
|
pulldownFor?: string
|
|
20
24
|
pulldownTo?: string
|
|
25
|
+
schOrientation?: SchematicOrientation
|
|
21
26
|
connections?: Connections<ResistorPinLabels>
|
|
22
27
|
}
|
|
23
28
|
|
|
@@ -30,6 +35,8 @@ export const resistorProps = commonComponentProps.extend({
|
|
|
30
35
|
pulldownFor: z.string().optional(),
|
|
31
36
|
pulldownTo: z.string().optional(),
|
|
32
37
|
|
|
38
|
+
schOrientation: schematicOrientation.optional(),
|
|
39
|
+
|
|
33
40
|
connections: createConnectionsProp(resistorPinLabels).optional(),
|
|
34
41
|
})
|
|
35
42
|
export const resistorPins = lrPins
|
package/lib/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./common/layout"
|
|
|
4
4
|
export * from "./common/point3"
|
|
5
5
|
export * from "./common/portHints"
|
|
6
6
|
export * from "./common/footprintProp"
|
|
7
|
+
export * from "./common/schematicOrientation"
|
|
7
8
|
export * from "./common/schematicPinDefinitions"
|
|
8
9
|
export * from "./common/schematicPinStyle"
|
|
9
10
|
export * from "./common/cadModel"
|