@tscircuit/props 0.0.529 → 0.0.531
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 +134 -108
- package/dist/index.d.ts +2 -1178
- package/dist/index.js +3 -4
- package/dist/index.js.map +1 -1
- package/lib/components/resistor.ts +34 -32
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
commonComponentProps,
|
|
6
6
|
lrPins,
|
|
7
7
|
} from "lib/common/layout"
|
|
8
|
+
import { footprintProp } from "lib/common/footprintProp"
|
|
8
9
|
import {
|
|
9
10
|
schematicSymbolSize,
|
|
10
11
|
type SchematicSymbolSize,
|
|
@@ -56,43 +57,44 @@ const mapResistorFootprint = (
|
|
|
56
57
|
if (!resistorImperialFootprintNames.has(footprint)) return footprint
|
|
57
58
|
return `res${footprint}`
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
60
|
+
|
|
61
|
+
const resistorFootprintProp: z.ZodType<ResistorFootprint> = footprintProp
|
|
62
|
+
.optional()
|
|
63
|
+
.transform(mapResistorFootprint)
|
|
64
|
+
|
|
65
|
+
export const resistorProps = commonComponentProps.extend({
|
|
66
|
+
footprint: resistorFootprintProp,
|
|
67
|
+
resistance,
|
|
68
|
+
tolerance: z
|
|
69
|
+
.union([z.string(), z.number()])
|
|
70
|
+
.transform((val) => {
|
|
71
|
+
if (typeof val === "string") {
|
|
72
|
+
if (val.endsWith("%")) {
|
|
73
|
+
return parseFloat(val.slice(0, -1)) / 100
|
|
70
74
|
}
|
|
71
|
-
return val
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
return parseFloat(val)
|
|
76
|
+
}
|
|
77
|
+
return val
|
|
78
|
+
})
|
|
79
|
+
.pipe(
|
|
80
|
+
z
|
|
81
|
+
.number()
|
|
82
|
+
.min(0, "Tolerance must be non-negative")
|
|
83
|
+
.max(1, "Tolerance cannot be greater than 100%"),
|
|
84
|
+
)
|
|
85
|
+
.optional(),
|
|
80
86
|
|
|
81
|
-
|
|
82
|
-
|
|
87
|
+
pullupFor: z.string().optional(),
|
|
88
|
+
pullupTo: z.string().optional(),
|
|
83
89
|
|
|
84
|
-
|
|
85
|
-
|
|
90
|
+
pulldownFor: z.string().optional(),
|
|
91
|
+
pulldownTo: z.string().optional(),
|
|
86
92
|
|
|
87
|
-
|
|
88
|
-
|
|
93
|
+
schOrientation: schematicOrientation.optional(),
|
|
94
|
+
schSize: schematicSymbolSize.optional(),
|
|
89
95
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
.transform((props) => ({
|
|
93
|
-
...props,
|
|
94
|
-
footprint: mapResistorFootprint(props.footprint),
|
|
95
|
-
}))
|
|
96
|
+
connections: createConnectionsProp(resistorPinLabels).optional(),
|
|
97
|
+
})
|
|
96
98
|
export const resistorPins = lrPins
|
|
97
99
|
|
|
98
100
|
type InferredResistorProps = z.input<typeof resistorProps>
|