@tscircuit/schematic-viewer 1.0.16 → 1.0.18
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/.storybook/preview.ts +2 -0
- package/README.md +3 -0
- package/dist/index.js +43 -45
- package/dist/index.js.map +1 -1
- package/package.json +9 -6
- package/src/Schematic.tsx +37 -33
- package/src/schematic-components/SchematicComponent.tsx +7 -1
- package/src/schematic-components/SchematicElement.tsx +6 -0
- package/src/stories/led-circuit-react.stories.tsx +6 -4
package/.storybook/preview.ts
CHANGED
package/README.md
CHANGED
|
@@ -11,6 +11,9 @@ View schematics from [tscircuit jsx](https://tscircuit.com).
|
|
|
11
11
|
```tsx
|
|
12
12
|
import { Schematic } from "@tscircuit/schematic-viewer"
|
|
13
13
|
|
|
14
|
+
// To get styles for debug table
|
|
15
|
+
import "react-data-grid/lib/styles.css"
|
|
16
|
+
|
|
14
17
|
export const MyReactApp = () => (
|
|
15
18
|
return (
|
|
16
19
|
<Schematic>
|
package/dist/index.js
CHANGED
|
@@ -2046,19 +2046,6 @@ var SimpleInductor = ({ component: { source, schematic } }) => {
|
|
|
2046
2046
|
|
|
2047
2047
|
// src/schematic-components/SimpleDiode.tsx
|
|
2048
2048
|
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
2049
|
-
var SimpleDiode = ({ component: { source, schematic } }) => {
|
|
2050
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(SVGPathComponent_default, {
|
|
2051
|
-
rotation: schematic.rotation,
|
|
2052
|
-
center: schematic.center,
|
|
2053
|
-
size: schematic.size,
|
|
2054
|
-
paths: [
|
|
2055
|
-
{ stroke: "red", strokeWidth: 2, d: "M 0,0 H 21" },
|
|
2056
|
-
{ stroke: "red", strokeWidth: 2, d: "M 49,0 H 59" },
|
|
2057
|
-
{ stroke: "red", strokeWidth: 2, d: "M 49,0 L 21 14 V -14 Z" },
|
|
2058
|
-
{ stroke: "red", strokeWidth: 2, d: "M 49,-14 V 14" }
|
|
2059
|
-
]
|
|
2060
|
-
});
|
|
2061
|
-
};
|
|
2062
2049
|
|
|
2063
2050
|
// src/schematic-components/SchematicComponent.tsx
|
|
2064
2051
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
@@ -2096,9 +2083,7 @@ var SchematicComponent = ({ component }) => {
|
|
|
2096
2083
|
});
|
|
2097
2084
|
}
|
|
2098
2085
|
case "simple_diode": {
|
|
2099
|
-
return
|
|
2100
|
-
component: { source, schematic }
|
|
2101
|
-
});
|
|
2086
|
+
return null;
|
|
2102
2087
|
}
|
|
2103
2088
|
default: {
|
|
2104
2089
|
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", {
|
|
@@ -2200,12 +2185,18 @@ var SchematicElement = ({
|
|
|
2200
2185
|
schematic_text: element
|
|
2201
2186
|
});
|
|
2202
2187
|
}
|
|
2188
|
+
if (element.type === "source_error") {
|
|
2189
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(RenderError_default, {
|
|
2190
|
+
text: element.message
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2203
2193
|
return null;
|
|
2204
2194
|
};
|
|
2205
2195
|
|
|
2206
2196
|
// src/Schematic.tsx
|
|
2207
2197
|
var import_use_mouse_matrix_transform = require("use-mouse-matrix-transform");
|
|
2208
2198
|
var import_react_error_boundary = require("react-error-boundary");
|
|
2199
|
+
var import_table_viewer = require("@tscircuit/table-viewer");
|
|
2209
2200
|
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
2210
2201
|
var fallbackRender = (elm) => ({ error, resetErrorBoundary }) => {
|
|
2211
2202
|
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", {
|
|
@@ -2265,38 +2256,45 @@ var Schematic = ({
|
|
|
2265
2256
|
throw e;
|
|
2266
2257
|
});
|
|
2267
2258
|
}, [children]);
|
|
2268
|
-
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
|
|
2269
|
-
style: {
|
|
2270
|
-
width: "100%",
|
|
2271
|
-
backgroundColor: "rgba(255,255,255,0)",
|
|
2272
|
-
minHeight: 200,
|
|
2273
|
-
overflow: "hidden",
|
|
2274
|
-
position: "relative",
|
|
2275
|
-
cursor: "grab",
|
|
2276
|
-
...style
|
|
2277
|
-
},
|
|
2278
|
-
ref: (el) => {
|
|
2279
|
-
ref.current = el;
|
|
2280
|
-
boundsRef(el);
|
|
2281
|
-
},
|
|
2259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, {
|
|
2282
2260
|
children: [
|
|
2283
|
-
/* @__PURE__ */ (0, import_jsx_runtime18.
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2261
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", {
|
|
2262
|
+
style: {
|
|
2263
|
+
width: "100%",
|
|
2264
|
+
backgroundColor: "rgba(255,255,255,0)",
|
|
2265
|
+
minHeight: 200,
|
|
2266
|
+
overflow: "hidden",
|
|
2267
|
+
position: "relative",
|
|
2268
|
+
cursor: "grab",
|
|
2269
|
+
...style
|
|
2270
|
+
},
|
|
2271
|
+
ref: (el) => {
|
|
2272
|
+
ref.current = el;
|
|
2273
|
+
boundsRef(el);
|
|
2288
2274
|
},
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2275
|
+
children: [
|
|
2276
|
+
/* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_supergrid.SuperGrid, {
|
|
2277
|
+
stringifyCoord: (x, y, z) => {
|
|
2278
|
+
if (z === 0)
|
|
2279
|
+
return "";
|
|
2280
|
+
return `${toMMSINeg(x, z)}, ${toMMSINeg(y, z)}`;
|
|
2281
|
+
},
|
|
2282
|
+
width: bounds.width,
|
|
2283
|
+
height: bounds.height,
|
|
2284
|
+
transform: cameraTransform
|
|
2285
|
+
}),
|
|
2286
|
+
elements == null ? void 0 : elements.map((elm, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_react_error_boundary.ErrorBoundary, {
|
|
2287
|
+
fallbackRender: fallbackRender(elm),
|
|
2288
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SchematicElement, {
|
|
2289
|
+
element: elm,
|
|
2290
|
+
allElements: elements
|
|
2291
|
+
}, JSON.stringify(elm))
|
|
2292
|
+
}, i))
|
|
2293
|
+
]
|
|
2292
2294
|
}),
|
|
2293
|
-
elements
|
|
2294
|
-
|
|
2295
|
-
|
|
2296
|
-
element: elm,
|
|
2297
|
-
allElements: elements
|
|
2298
|
-
}, JSON.stringify(elm))
|
|
2299
|
-
}, i))
|
|
2295
|
+
elements && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_table_viewer.SoupTableViewer, {
|
|
2296
|
+
elements
|
|
2297
|
+
})
|
|
2300
2298
|
]
|
|
2301
2299
|
});
|
|
2302
2300
|
};
|