diff --git a/README.md b/README.md index 3dcd7613..ec029ea5 100644 --- a/README.md +++ b/README.md @@ -210,7 +210,10 @@ export interface AmmeterProps< > extends CommonComponentProps { connections: Connections; color?: string; - display?: AmmeterDisplayOptions; + graphDisplayName?: string; + graphCenter?: number; + graphOffsetDivs?: number; + graphUnitsPerDiv?: number; } ``` @@ -1958,7 +1961,10 @@ export interface VoltageProbeProps extends Omit { connectsTo: string; referenceTo?: string; color?: string; - display?: VoltageProbeDisplayOptions; + graphDisplayName?: string; + graphCenter?: number; + graphOffsetDivs?: number; + graphUnitsPerDiv?: number; } ``` diff --git a/generated/COMPONENT_TYPES.md b/generated/COMPONENT_TYPES.md index ae554b4b..8f57de72 100644 --- a/generated/COMPONENT_TYPES.md +++ b/generated/COMPONENT_TYPES.md @@ -868,31 +868,25 @@ export const url = z.preprocess((value) => { ### ammeter ```typescript -export interface AmmeterDisplayOptions { - label?: string - center?: number - offsetDivs?: number - unitsPerDiv?: number -} export interface AmmeterProps extends CommonComponentProps { connections: Connections color?: string - display?: AmmeterDisplayOptions + graphDisplayName?: string + graphCenter?: number + graphOffsetDivs?: number + graphUnitsPerDiv?: number } -export const ammeterDisplayOptions = z.object({ - label: z.string().optional(), - center: z.number().optional(), - offsetDivs: z.number().optional(), - unitsPerDiv: z.number().optional(), -}) export const ammeterProps = commonComponentProps.extend({ connections: createConnectionsProp(ammeterPinLabels).refine( hasAmmeterConnectionPair, "Ammeter connections must include either pos/neg or pin1/pin2", ), color: z.string().optional(), - display: ammeterDisplayOptions.optional(), + graphDisplayName: z.string().optional(), + graphCenter: z.number().optional(), + graphOffsetDivs: z.number().optional(), + graphUnitsPerDiv: z.number().optional(), }) ``` @@ -1436,17 +1430,15 @@ export const courtyardPillProps = pcbLayoutProps ### courtyard-rect ```typescript -export const courtyardRectProps = pcbLayoutProps - .omit({ pcbRotation: true }) - .extend({ - width: distance, - height: distance, - strokeWidth: distance.optional(), - isFilled: z.boolean().optional(), - hasStroke: z.boolean().optional(), - isStrokeDashed: z.boolean().optional(), - color: z.string().optional(), - }) +export const courtyardRectProps = pcbLayoutProps.extend({ + width: distance, + height: distance, + strokeWidth: distance.optional(), + isFilled: z.boolean().optional(), + hasStroke: z.boolean().optional(), + isStrokeDashed: z.boolean().optional(), + color: z.string().optional(), +}) ``` ### crystal @@ -4185,13 +4177,10 @@ export interface VoltageProbeProps extends Omit { connectsTo: string referenceTo?: string color?: string - display?: VoltageProbeDisplayOptions -} -export interface VoltageProbeDisplayOptions { - label?: string - center?: number - offsetDivs?: number - unitsPerDiv?: number + graphDisplayName?: string + graphCenter?: number + graphOffsetDivs?: number + graphUnitsPerDiv?: number } export const voltageProbeProps = commonComponentProps .omit({ name: true }) @@ -4200,14 +4189,10 @@ export const voltageProbeProps = commonComponentProps connectsTo: z.string(), referenceTo: z.string().optional(), color: z.string().optional(), - display: z - .object({ - label: z.string().optional(), - center: z.number().optional(), - offsetDivs: z.number().optional(), - unitsPerDiv: z.number().optional(), - }) - .optional(), + graphDisplayName: z.string().optional(), + graphCenter: z.number().optional(), + graphOffsetDivs: z.number().optional(), + graphUnitsPerDiv: z.number().optional(), }) ``` diff --git a/generated/PROPS_OVERVIEW.md b/generated/PROPS_OVERVIEW.md index a0340bab..57959ede 100644 --- a/generated/PROPS_OVERVIEW.md +++ b/generated/PROPS_OVERVIEW.md @@ -18,19 +18,14 @@ const validatedProps = chipProps.parse(unknownProps) ## Available Props ```ts -export interface AmmeterDisplayOptions { - label?: string - center?: number - offsetDivs?: number - unitsPerDiv?: number -} - - export interface AmmeterProps extends CommonComponentProps { connections: Connections color?: string - display?: AmmeterDisplayOptions + graphDisplayName?: string + graphCenter?: number + graphOffsetDivs?: number + graphUnitsPerDiv?: number } @@ -2270,20 +2265,15 @@ export interface ViaProps extends CommonLayoutProps { } -export interface VoltageProbeDisplayOptions { - label?: string - center?: number - offsetDivs?: number - unitsPerDiv?: number -} - - export interface VoltageProbeProps extends Omit { name?: string connectsTo: string referenceTo?: string color?: string - display?: VoltageProbeDisplayOptions + graphDisplayName?: string + graphCenter?: number + graphOffsetDivs?: number + graphUnitsPerDiv?: number } diff --git a/lib/components/ammeter.ts b/lib/components/ammeter.ts index 1fee8452..f61b8fc2 100644 --- a/lib/components/ammeter.ts +++ b/lib/components/ammeter.ts @@ -10,18 +10,14 @@ import { z } from "zod" export const ammeterPinLabels = ["pin1", "pin2", "pos", "neg"] as const export type AmmeterPinLabels = (typeof ammeterPinLabels)[number] -export interface AmmeterDisplayOptions { - label?: string - center?: number - offsetDivs?: number - unitsPerDiv?: number -} - export interface AmmeterProps extends CommonComponentProps { connections: Connections color?: string - display?: AmmeterDisplayOptions + graphDisplayName?: string + graphCenter?: number + graphOffsetDivs?: number + graphUnitsPerDiv?: number } const hasAmmeterConnectionPair = ( @@ -33,20 +29,16 @@ const hasAmmeterConnectionPair = ( ) } -export const ammeterDisplayOptions = z.object({ - label: z.string().optional(), - center: z.number().optional(), - offsetDivs: z.number().optional(), - unitsPerDiv: z.number().optional(), -}) - export const ammeterProps = commonComponentProps.extend({ connections: createConnectionsProp(ammeterPinLabels).refine( hasAmmeterConnectionPair, "Ammeter connections must include either pos/neg or pin1/pin2", ), color: z.string().optional(), - display: ammeterDisplayOptions.optional(), + graphDisplayName: z.string().optional(), + graphCenter: z.number().optional(), + graphOffsetDivs: z.number().optional(), + graphUnitsPerDiv: z.number().optional(), }) export const ammeterPins = ammeterPinLabels diff --git a/lib/components/voltageprobe.ts b/lib/components/voltageprobe.ts index 96c5706b..68e904db 100644 --- a/lib/components/voltageprobe.ts +++ b/lib/components/voltageprobe.ts @@ -10,14 +10,10 @@ export interface VoltageProbeProps extends Omit { connectsTo: string referenceTo?: string color?: string - display?: VoltageProbeDisplayOptions -} - -export interface VoltageProbeDisplayOptions { - label?: string - center?: number - offsetDivs?: number - unitsPerDiv?: number + graphDisplayName?: string + graphCenter?: number + graphOffsetDivs?: number + graphUnitsPerDiv?: number } export const voltageProbeProps = commonComponentProps @@ -27,14 +23,10 @@ export const voltageProbeProps = commonComponentProps connectsTo: z.string(), referenceTo: z.string().optional(), color: z.string().optional(), - display: z - .object({ - label: z.string().optional(), - center: z.number().optional(), - offsetDivs: z.number().optional(), - unitsPerDiv: z.number().optional(), - }) - .optional(), + graphDisplayName: z.string().optional(), + graphCenter: z.number().optional(), + graphOffsetDivs: z.number().optional(), + graphUnitsPerDiv: z.number().optional(), }) expectTypesMatch>(true) diff --git a/tests/ammeter.test.ts b/tests/ammeter.test.ts index 13883507..7909364d 100644 --- a/tests/ammeter.test.ts +++ b/tests/ammeter.test.ts @@ -35,7 +35,7 @@ test("should parse ammeter with pin1 and pin2 connections", () => { }) }) -test("should parse ammeter with color and display options", () => { +test("should parse ammeter with color and display props", () => { const raw: AmmeterProps = { name: "A3", color: "green", @@ -43,22 +43,18 @@ test("should parse ammeter with color and display options", () => { pos: "net.IN", neg: "net.OUT", }, - display: { - label: "I_LOAD", - center: 0, - offsetDivs: 2, - unitsPerDiv: 0.01, - }, + graphDisplayName: "I_LOAD", + graphCenter: 0, + graphOffsetDivs: 2, + graphUnitsPerDiv: 0.01, } const parsed = ammeterProps.parse(raw) expect(parsed.color).toBe("green") - expect(parsed.display).toEqual({ - label: "I_LOAD", - center: 0, - offsetDivs: 2, - unitsPerDiv: 0.01, - }) + expect(parsed.graphDisplayName).toBe("I_LOAD") + expect(parsed.graphCenter).toBe(0) + expect(parsed.graphOffsetDivs).toBe(2) + expect(parsed.graphUnitsPerDiv).toBe(0.01) }) test("should reject missing ammeter connections", () => { diff --git a/tests/voltageprobe.test.ts b/tests/voltageprobe.test.ts index 0f74cfc4..0586d10f 100644 --- a/tests/voltageprobe.test.ts +++ b/tests/voltageprobe.test.ts @@ -43,25 +43,21 @@ test("should parse voltageprobe with referenceTo", () => { expect(parsed.referenceTo).toBe(".R1 > .p2") }) -test("should parse voltageprobe with display options", () => { +test("should parse voltageprobe with display props", () => { const raw: VoltageProbeProps = { connectsTo: ".DUT .U1 .VOUT", referenceTo: "net.GND", name: "VOUT_PROBE", - display: { - label: "VO", - center: 3.3, - offsetDivs: 3, - unitsPerDiv: 0.05, - }, + graphDisplayName: "VO", + graphCenter: 3.3, + graphOffsetDivs: 3, + graphUnitsPerDiv: 0.05, } const parsed = voltageProbeProps.parse(raw) - expect(parsed.display).toEqual({ - label: "VO", - center: 3.3, - offsetDivs: 3, - unitsPerDiv: 0.05, - }) + expect(parsed.graphDisplayName).toBe("VO") + expect(parsed.graphCenter).toBe(3.3) + expect(parsed.graphOffsetDivs).toBe(3) + expect(parsed.graphUnitsPerDiv).toBe(0.05) }) test("should not parse voltageprobe with array connectsTo", () => {