astrimid/sch-section-wrapper

Group tscircuit components into schematic sections without repeating schSectionName on every element.

Version
0.0.1
License
MIT
Stars
0

dist/index.js

import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
import React, { cloneElement } from 'react';

const SchSection = ({ children, name, displayName, }) => {
    const sectionName = name;
    if (children) {
        return (jsx(Fragment, { children: React.Children.map(children, (child) => {
                if (React.isValidElement(child)) {
                    return cloneElement(child, { schSectionName: sectionName });
                }
                return child;
            }) }));
    }
    else {
        return jsx("schematicsection", { name: name, displayName: displayName || name.toUpperCase() });
    }
};
var index = () => (jsxs("board", { width: "10mm", height: "10mm", children: [jsx(SchSection, { name: "filter" }), jsx(SchSection, { name: "power" }), jsxs(SchSection, { name: "power", children: [jsx("capacitor", { name: "C1", capacitance: "100uF", footprint: "0805", schX: -4, schY: 3 }), jsx("capacitor", { name: "C2", capacitance: "100nF", footprint: "0402", schX: -2, schY: 3 })] }), jsxs(SchSection, { name: "filter", children: [jsx("resistor", { name: "R1", resistance: "10k", footprint: "0402", schX: 2, schY: 3 }), jsx("capacitor", { name: "C3", capacitance: "10nF", footprint: "0402", schX: 4, schY: 3 })] })] }));

export { SchSection, index as default };