import React, { Component, ComponentProps } from "react" import { z } from "zod" import { resistorProps, resistorPins } from "@tscircuit/props" export const createUseComponent = < C extends React.ComponentType, PiD extends string >( Component: C, pins: readonly PiD[] ) => { return , "name"> | undefined = undefined>( name: string, props?: T ): React.ComponentType< (T extends undefined ? Omit, "name"> : Omit>, "name">) & { [key in typeof pins[number]]?: string } > & { [key in typeof pins[number]]: string } => { const R: any = (props2: any) => { const combinedProps = { ...props, ...props2, name } const tracesToCreate: any[] = [] for (const portLabel of pins) { if (combinedProps[portLabel]) { const from = `.${name} > .${portLabel}` const to = combinedProps[portLabel] tracesToCreate.push({ from, to }) delete combinedProps[portLabel] } } return ( <> {tracesToCreate.map((trace, i) => ( ))} ) } for (const port of pins) { R[port] = `.${name} > .${port}` } return R } }