From 911b3befd7c003c4c7cf445d93b8c38fe24aa5fc Mon Sep 17 00:00:00 2001 From: rushabhcodes Date: Mon, 24 Nov 2025 22:58:01 +0530 Subject: [PATCH] Refactor: Simplify VoltageSource imports and update intrinsic JSX types --- .../normal-components/VoltageSource.ts | 29 ++----------------- lib/fiber/intrinsic-jsx.ts | 3 +- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/lib/components/normal-components/VoltageSource.ts b/lib/components/normal-components/VoltageSource.ts index 7a6751b20..5d405bcf8 100644 --- a/lib/components/normal-components/VoltageSource.ts +++ b/lib/components/normal-components/VoltageSource.ts @@ -1,35 +1,12 @@ -import { frequency, rotation, voltage } from "circuit-json" -import { - commonComponentProps, - type CommonComponentProps, -} from "@tscircuit/props" -import { z } from "zod" +import { voltageSourceProps } from "@tscircuit/props" import { NormalComponent } from "../base-components/NormalComponent/NormalComponent" -import { FTYPE, type BaseSymbolName, type Ftype } from "lib/utils/constants" +import { type BaseSymbolName, type Ftype } from "lib/utils/constants" import type { SimulationAcVoltageSource } from "circuit-json" -import { Port } from "../primitive-components/Port" + import type { RenderPhase } from "lib/components/base-components/Renderable" export type WaveShape = "sinewave" | "square" | "triangle" | "sawtooth" -export interface VoltageSourceProps extends CommonComponentProps { - voltage?: number | string - frequency?: number | string - peakToPeakVoltage?: number | string - waveShape?: WaveShape - phase?: number | string - dutyCycle?: number -} - -export const voltageSourceProps = commonComponentProps.extend({ - voltage: voltage.optional(), - frequency: frequency.optional(), - peakToPeakVoltage: voltage.optional(), - waveShape: z.enum(["sinewave", "square", "triangle", "sawtooth"]).optional(), - phase: rotation.optional(), - dutyCycle: z.number().optional(), -}) - export class VoltageSource extends NormalComponent< typeof voltageSourceProps, "terminal1" | "terminal2" diff --git a/lib/fiber/intrinsic-jsx.ts b/lib/fiber/intrinsic-jsx.ts index 3aecbf81c..c2618103b 100644 --- a/lib/fiber/intrinsic-jsx.ts +++ b/lib/fiber/intrinsic-jsx.ts @@ -1,5 +1,4 @@ import type * as Props from "@tscircuit/props" -import type { VoltageSourceProps } from "lib/components/normal-components/VoltageSource" import type { DetailedHTMLProps, SVGProps } from "react" export interface TscircuitElements { @@ -75,7 +74,7 @@ export interface TscircuitElements { switch: Props.SwitchProps mosfet: Props.MosfetProps testpoint: Props.TestpointProps - voltagesource: VoltageSourceProps + voltagesource: Props.VoltageSourceProps voltageprobe: Props.VoltageProbeProps copperpour: Props.CopperPourProps analogsimulation: Props.AnalogSimulationProps