Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 3 additions & 26 deletions lib/components/normal-components/VoltageSource.ts
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
3 changes: 1 addition & 2 deletions lib/fiber/intrinsic-jsx.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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
Expand Down