@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.
@@ -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
- 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)
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
- .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(),
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
- pullupFor: z.string().optional(),
82
- pullupTo: z.string().optional(),
87
+ pullupFor: z.string().optional(),
88
+ pullupTo: z.string().optional(),
83
89
 
84
- pulldownFor: z.string().optional(),
85
- pulldownTo: z.string().optional(),
90
+ pulldownFor: z.string().optional(),
91
+ pulldownTo: z.string().optional(),
86
92
 
87
- schOrientation: schematicOrientation.optional(),
88
- schSize: schematicSymbolSize.optional(),
93
+ schOrientation: schematicOrientation.optional(),
94
+ schSize: schematicSymbolSize.optional(),
89
95
 
90
- connections: createConnectionsProp(resistorPinLabels).optional(),
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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscircuit/props",
3
- "version": "0.0.529",
3
+ "version": "0.0.531",
4
4
  "description": "Props for tscircuit builtin component types",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",