@tscircuit/core 0.0.136 → 0.0.137

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 CHANGED
@@ -1,4 +1,4 @@
1
- import React, { ReactElement, ComponentProps } from 'react';
1
+ import React, { ReactElement } from 'react';
2
2
  import * as zod from 'zod';
3
3
  import { ZodType, z } from 'zod';
4
4
  import { SchSymbol, BaseSymbolName } from 'schematic-symbols';
@@ -6220,7 +6220,14 @@ declare const useRenderedCircuit: (reactElements: React.ReactElement) => {
6220
6220
  circuitJson?: AnyCircuitElement[];
6221
6221
  };
6222
6222
 
6223
- 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; };
6223
+ type ComponentWithPins<Props, PinLabel extends string | never = never, PropsFromHook extends Omit<Props, "name"> | undefined = undefined> = React.ComponentType<(PropsFromHook extends undefined ? Omit<Props, "name"> : Omit<Partial<Props>, "name">) & {
6224
+ [key in PinLabel]?: string;
6225
+ }> & {
6226
+ [key in PinLabel]: string;
6227
+ };
6228
+ declare const createUseComponent: <Props, PinLabel extends string | never = never>(Component: React.ComponentType<Props>, pins: readonly PinLabel[] | readonly (readonly PinLabel[])[] | {
6229
+ [key: string]: readonly PinLabel[];
6230
+ }) => (<PropsFromHook extends Omit<Props, "name"> | undefined = undefined>(name: string, props?: PropsFromHook) => ComponentWithPins<Props, PinLabel, PropsFromHook>);
6224
6231
 
6225
6232
  declare global {
6226
6233
  namespace JSX {
@@ -6269,4 +6276,4 @@ declare global {
6269
6276
  }
6270
6277
  }
6271
6278
 
6272
- export { Battery, Board, Capacitor, Chip, Circuit, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Net, NetAlias, NormalComponent, PlatedHole, Port, PowerSource, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenCircle, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Trace, TraceHint, Via, createUseComponent, useRenderedCircuit };
6279
+ export { Battery, Board, Capacitor, Chip, Circuit, type ComponentWithPins, Constraint, Diode, FabricationNotePath, FabricationNoteText, Footprint, Group, Hole, type IRenderable, Inductor, Jumper, Keepout, Led, Net, NetAlias, NormalComponent, PlatedHole, Port, PowerSource, PrimitiveComponent, Project, Renderable, Resistor, SilkscreenCircle, SilkscreenPath, SilkscreenRect, SilkscreenText, SmtPad, Trace, TraceHint, Via, createUseComponent, useRenderedCircuit };
package/dist/index.js CHANGED
@@ -4661,10 +4661,17 @@ import "@tscircuit/props";
4661
4661
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4662
4662
  var createUseComponent = (Component2, pins) => {
4663
4663
  return (name, props) => {
4664
+ const pinLabelsFlatArray = [];
4665
+ if (Array.isArray(pins)) {
4666
+ pinLabelsFlatArray.push(...pins.flat());
4667
+ } else if (typeof pins === "object") {
4668
+ pinLabelsFlatArray.push(...Object.values(pins).flat());
4669
+ pinLabelsFlatArray.push(...Object.keys(pins));
4670
+ }
4664
4671
  const R = (props2) => {
4665
4672
  const combinedProps = { ...props, ...props2, name };
4666
4673
  const tracesToCreate = [];
4667
- for (const portLabel of pins) {
4674
+ for (const portLabel of pinLabelsFlatArray) {
4668
4675
  if (combinedProps[portLabel]) {
4669
4676
  const from = `.${name} > .${portLabel}`;
4670
4677
  const to = combinedProps[portLabel];
@@ -4680,7 +4687,7 @@ var createUseComponent = (Component2, pins) => {
4680
4687
  ))
4681
4688
  ] });
4682
4689
  };
4683
- for (const port of pins) {
4690
+ for (const port of pinLabelsFlatArray) {
4684
4691
  R[port] = `.${name} > .${port}`;
4685
4692
  }
4686
4693
  return R;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.136",
4
+ "version": "0.0.137",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",
@@ -29,6 +29,7 @@
29
29
  "debug": "^4.3.6",
30
30
  "howfat": "^0.3.8",
31
31
  "looks-same": "^9.0.1",
32
+ "ts-expect": "^1.3.0",
32
33
  "tsup": "^8.2.4"
33
34
  },
34
35
  "peerDependencies": {