Skip to content
Open
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
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ resistorProps.parse({ resistance: "10k" } as ResistorPropsInput);
| `<schematicrect />` | [`SchematicRectProps`](#schematicrectprops-schematicrect) |
| `<schematicrow />` | [`SchematicRowProps`](#schematicrowprops-schematicrow) |
| `<schematicsection />` | [`SchematicSectionProps`](#schematicsectionprops-schematicsection) |
| `<schematicsheet />` | [`SchematicSheetProps`](#schematicsheetprops-schematicsheet) |
| `<schematictable />` | [`SchematicTableProps`](#schematictableprops-schematictable) |
| `<schematictext />` | [`SchematicTextProps`](#schematictextprops-schematictext) |
| `<silkscreencircle />` | [`SilkscreenCircleProps`](#silkscreencircleprops-silkscreencircle) |
Expand Down Expand Up @@ -163,6 +164,10 @@ export interface CommonComponentProps extends CommonLayoutProps {
* This component will be drawn as part of this section e.g. "Power"
*/
schSectionName?: string;
/**
* This component will be drawn as part of this sheet e.g. "Main"
*/
schSheetName?: string;
}
```

Expand Down Expand Up @@ -1615,6 +1620,18 @@ export interface SchematicSectionProps {

[Source](https://github.com/tscircuit/props/blob/main/lib/components/schematic-section.ts)

### SchematicSheetProps `<schematicsheet />`

```ts
export interface SchematicSheetProps {
name: string;
displayName: string;
children?: any;
}
```

[Source](https://github.com/tscircuit/props/blob/main/lib/components/schematic-sheet.ts)

### SchematicTableProps `<schematictable />`

```ts
Expand Down
22 changes: 22 additions & 0 deletions generated/COMPONENT_TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,7 @@ export interface CommonComponentProps<PinLabel extends string = string>
mfn?: string
manufacturerPartNumber?: string
schSectionName?: string
schSheetName?: string
}
.extend({
key: z.any().optional(),
Expand All @@ -561,6 +562,12 @@ export interface CommonComponentProps<PinLabel extends string = string>
.describe(
'This component will be drawn as part of this section e.g. "Power"',
),
schSheetName: z
.string()
.optional()
.describe(
'This component will be drawn as part of this sheet e.g. "Main"',
),
datasheetUrl: url.optional(),
cadModel: cadModelProp.optional(),
kicadFootprintMetadata: kicadFootprintMetadata.optional(),
Expand Down Expand Up @@ -3564,6 +3571,21 @@ export const schematicSectionProps = z.object({
})
```

### schematic-sheet

```typescript
export interface SchematicSheetProps {
name: string
displayName: string
children?: any
}
export const schematicSheetProps = z.object({
name: z.string(),
displayName: z.string(),
children: z.any().optional(),
})
```

### schematic-table

```typescript
Expand Down
13 changes: 12 additions & 1 deletion generated/PROPS_OVERVIEW.md
Original file line number Diff line number Diff line change
Expand Up @@ -543,9 +543,13 @@ export interface CommonComponentProps<PinLabel extends string = string>
mfn?: string
manufacturerPartNumber?: string
/**
*This component will be drawn as part of this section e.g. \"Power\
* This component will be drawn as part of this section e.g. "Power"
*/
schSectionName?: string
/**
* This component will be drawn as part of this sheet e.g. "Main"
*/
schSheetName?: string
}


Expand Down Expand Up @@ -1982,6 +1986,13 @@ export interface SchematicSectionProps {
}


export interface SchematicSheetProps {
name: string
displayName: string
children?: any
}


export interface SchematicTableProps {
schX?: number | string
schY?: number | string
Expand Down
12 changes: 11 additions & 1 deletion lib/common/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,13 @@ export interface CommonComponentProps<PinLabel extends string = string>
mfn?: string
manufacturerPartNumber?: string
/**
*This component will be drawn as part of this section e.g. \"Power\
* This component will be drawn as part of this section e.g. "Power"
*/
schSectionName?: string
/**
* This component will be drawn as part of this sheet e.g. "Main"
*/
schSheetName?: string
}

export const commonComponentProps = commonLayoutProps
Expand All @@ -278,6 +282,12 @@ export const commonComponentProps = commonLayoutProps
.describe(
'This component will be drawn as part of this section e.g. "Power"',
),
schSheetName: z
.string()
.optional()
.describe(
'This component will be drawn as part of this sheet e.g. "Main"',
),
datasheetUrl: url.optional(),
cadModel: cadModelProp.optional(),
kicadFootprintMetadata: kicadFootprintMetadata.optional(),
Expand Down
18 changes: 18 additions & 0 deletions lib/components/schematic-sheet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { z } from "zod"
import { expectTypesMatch } from "lib/typecheck"

export interface SchematicSheetProps {
name: string
displayName: string
children?: any
}

export const schematicSheetProps = z.object({
name: z.string(),
displayName: z.string(),
children: z.any().optional(),
})

export type InferredSchematicSheetProps = z.input<typeof schematicSheetProps>

expectTypesMatch<SchematicSheetProps, z.input<typeof schematicSheetProps>>(true)
1 change: 1 addition & 0 deletions lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ export * from "./components/schematic-table"
export * from "./components/schematic-row"
export * from "./components/schematic-cell"
export * from "./components/schematic-section"
export * from "./components/schematic-sheet"
export * from "./components/copper-text"
export * from "./components/silkscreen-text"
export * from "./components/silkscreen-path"
Expand Down
4 changes: 4 additions & 0 deletions scripts/generate-readme-docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,10 @@ function generateInterfaceDefinitions(
* This component will be drawn as part of this section e.g. "Power"
*/
schSectionName?: string
/**
* This component will be drawn as part of this sheet e.g. "Main"
*/
schSheetName?: string
}`,
filePath: "lib/common/layout.ts",
},
Expand Down
34 changes: 34 additions & 0 deletions tests/schematic-sheet.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { expect, test } from "bun:test"
import {
schematicSheetProps,
type SchematicSheetProps,
} from "lib/components/schematic-sheet"
import { expectTypeOf } from "expect-type"

test("should parse schematic sheet with name, displayName, and children", () => {
const raw: SchematicSheetProps = {
name: "main",
displayName: "Main Sheet",
children: [{ type: "resistor", props: { name: "R1" } }],
}

expectTypeOf(raw).toMatchTypeOf<SchematicSheetProps>()
const parsed = schematicSheetProps.parse(raw)
expect(parsed.name).toBe("main")
expect(parsed.displayName).toBe("Main Sheet")
expect(parsed.children).toEqual([{ type: "resistor", props: { name: "R1" } }])
})

test("should parse schematic sheet without children", () => {
const raw: SchematicSheetProps = {
name: "power",
displayName: "Power Sheet",
}

const parsed = schematicSheetProps.parse(raw)
expect(parsed.children).toBeUndefined()
})

test("should fail without displayName", () => {
expect(() => schematicSheetProps.parse({ name: "main" })).toThrow()
})
Comment on lines +1 to +34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file contains three test(...) calls, but the rule states that a *.test.ts file may have AT MOST one test(...). Please split this into multiple numbered files, e.g. schematic-sheet1.test.ts, schematic-sheet2.test.ts, and schematic-sheet3.test.ts, each containing exactly one test.

Spotted by Graphite (based on custom rule: Custom rule)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

Loading