@tscircuit/core 0.0.110 → 0.0.111
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.
- package/dist/index.d.ts +4 -2
- package/dist/index.js +34 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { ReactElement } from 'react';
|
|
1
|
+
import React, { ReactElement, ComponentProps } from 'react';
|
|
2
2
|
import * as zod from 'zod';
|
|
3
3
|
import { ZodType, z } from 'zod';
|
|
4
4
|
import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
|
|
@@ -4803,6 +4803,8 @@ declare const useRenderedCircuit: (reactElements: React.ReactElement) => {
|
|
|
4803
4803
|
circuitJson?: AnyCircuitElement[];
|
|
4804
4804
|
};
|
|
4805
4805
|
|
|
4806
|
+
declare const createUseComponent: <C extends React.ComponentType<any>, PiD extends string>(Component: C, pins: readonly PiD[]) => <T extends Omit<ComponentProps<C>, "name"> | undefined = undefined>(name: string, props?: T) => React.ComponentType<(T extends undefined ? Omit<ComponentProps<C>, "name"> : Omit<Partial<ComponentProps<C>>, "name">) & { [key in (typeof pins)[number]]?: string; }> & { [key in (typeof pins)[number]]: string; };
|
|
4807
|
+
|
|
4806
4808
|
declare global {
|
|
4807
4809
|
namespace JSX {
|
|
4808
4810
|
interface IntrinsicElements {
|
|
@@ -4849,4 +4851,4 @@ declare global {
|
|
|
4849
4851
|
}
|
|
4850
4852
|
}
|
|
4851
4853
|
|
|
4852
|
-
export { Board, Capacitor, Chip, Circuit, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Jumper, Keepout, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenCircle, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Trace, TraceHint, Via, useRenderedCircuit };
|
|
4854
|
+
export { Board, Capacitor, Chip, Circuit, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Jumper, Keepout, Led, Net, NormalComponent, PlatedHole, Port, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenCircle, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Trace, TraceHint, Via, createUseComponent, useRenderedCircuit };
|
package/dist/index.js
CHANGED
|
@@ -4053,6 +4053,39 @@ var useRenderedCircuit = (reactElements) => {
|
|
|
4053
4053
|
return { isLoading, error, circuit, circuitJson };
|
|
4054
4054
|
};
|
|
4055
4055
|
|
|
4056
|
+
// lib/hooks/create-use-component.tsx
|
|
4057
|
+
import "react";
|
|
4058
|
+
import "zod";
|
|
4059
|
+
import "@tscircuit/props";
|
|
4060
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4061
|
+
var createUseComponent = (Component2, pins) => {
|
|
4062
|
+
return (name, props) => {
|
|
4063
|
+
const R = (props2) => {
|
|
4064
|
+
const combinedProps = { ...props, ...props2, name };
|
|
4065
|
+
const tracesToCreate = [];
|
|
4066
|
+
for (const portLabel of pins) {
|
|
4067
|
+
if (combinedProps[portLabel]) {
|
|
4068
|
+
const from = `.${name} > .${portLabel}`;
|
|
4069
|
+
const to = combinedProps[portLabel];
|
|
4070
|
+
tracesToCreate.push({ from, to });
|
|
4071
|
+
delete combinedProps[portLabel];
|
|
4072
|
+
}
|
|
4073
|
+
}
|
|
4074
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4075
|
+
/* @__PURE__ */ jsx(Component2, { ...combinedProps }),
|
|
4076
|
+
tracesToCreate.map((trace, i) => (
|
|
4077
|
+
// biome-ignore lint/suspicious/noArrayIndexKey: <explanation>
|
|
4078
|
+
/* @__PURE__ */ jsx("trace", { ...trace }, i)
|
|
4079
|
+
))
|
|
4080
|
+
] });
|
|
4081
|
+
};
|
|
4082
|
+
for (const port of pins) {
|
|
4083
|
+
R[port] = `.${name} > .${port}`;
|
|
4084
|
+
}
|
|
4085
|
+
return R;
|
|
4086
|
+
};
|
|
4087
|
+
};
|
|
4088
|
+
|
|
4056
4089
|
// lib/register-catalogue.ts
|
|
4057
4090
|
extendCatalogue(components_exports);
|
|
4058
4091
|
extendCatalogue({
|
|
@@ -4089,5 +4122,6 @@ export {
|
|
|
4089
4122
|
Trace,
|
|
4090
4123
|
TraceHint,
|
|
4091
4124
|
Via,
|
|
4125
|
+
createUseComponent,
|
|
4092
4126
|
useRenderedCircuit
|
|
4093
4127
|
};
|