@tscircuit/props 0.0.527 → 0.0.528

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.
@@ -33,38 +33,66 @@ export interface ResistorProps<PinLabel extends string = string>
33
33
  connections?: Connections<ResistorPinLabels>
34
34
  }
35
35
 
36
- export const resistorProps = commonComponentProps.extend({
37
- resistance,
38
- tolerance: z
39
- .union([z.string(), z.number()])
40
- .transform((val) => {
41
- if (typeof val === "string") {
42
- if (val.endsWith("%")) {
43
- return parseFloat(val.slice(0, -1)) / 100
36
+ type ResistorFootprint = CommonComponentProps["footprint"]
37
+
38
+ const resistorImperialFootprintNames = new Set([
39
+ "01005",
40
+ "0201",
41
+ "0402",
42
+ "0504",
43
+ "0603",
44
+ "0805",
45
+ "1206",
46
+ "1210",
47
+ "1812",
48
+ "2010",
49
+ "2512",
50
+ ])
51
+
52
+ const mapResistorFootprint = (
53
+ footprint: ResistorFootprint,
54
+ ): ResistorFootprint => {
55
+ if (typeof footprint !== "string") return footprint
56
+ if (!resistorImperialFootprintNames.has(footprint)) return footprint
57
+ return `res${footprint}`
58
+ }
59
+ export const resistorProps = commonComponentProps
60
+ .extend({
61
+ resistance,
62
+ tolerance: z
63
+ .union([z.string(), z.number()])
64
+ .transform((val) => {
65
+ if (typeof val === "string") {
66
+ if (val.endsWith("%")) {
67
+ return parseFloat(val.slice(0, -1)) / 100
68
+ }
69
+ return parseFloat(val)
44
70
  }
45
- return parseFloat(val)
46
- }
47
- return val
48
- })
49
- .pipe(
50
- z
51
- .number()
52
- .min(0, "Tolerance must be non-negative")
53
- .max(1, "Tolerance cannot be greater than 100%"),
54
- )
55
- .optional(),
71
+ return val
72
+ })
73
+ .pipe(
74
+ z
75
+ .number()
76
+ .min(0, "Tolerance must be non-negative")
77
+ .max(1, "Tolerance cannot be greater than 100%"),
78
+ )
79
+ .optional(),
56
80
 
57
- pullupFor: z.string().optional(),
58
- pullupTo: z.string().optional(),
81
+ pullupFor: z.string().optional(),
82
+ pullupTo: z.string().optional(),
59
83
 
60
- pulldownFor: z.string().optional(),
61
- pulldownTo: z.string().optional(),
84
+ pulldownFor: z.string().optional(),
85
+ pulldownTo: z.string().optional(),
62
86
 
63
- schOrientation: schematicOrientation.optional(),
64
- schSize: schematicSymbolSize.optional(),
87
+ schOrientation: schematicOrientation.optional(),
88
+ schSize: schematicSymbolSize.optional(),
65
89
 
66
- connections: createConnectionsProp(resistorPinLabels).optional(),
67
- })
90
+ connections: createConnectionsProp(resistorPinLabels).optional(),
91
+ })
92
+ .transform((props) => ({
93
+ ...props,
94
+ footprint: mapResistorFootprint(props.footprint),
95
+ }))
68
96
  export const resistorPins = lrPins
69
97
 
70
98
  type InferredResistorProps = z.input<typeof resistorProps>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.527",
3
+ "version": "0.0.528",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",