@tscircuit/core 0.0.462 → 0.0.463
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.js +120 -10
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -9526,6 +9526,81 @@ var SchematicText = class extends PrimitiveComponent2 {
|
|
|
9526
9526
|
|
|
9527
9527
|
// lib/components/primitive-components/SchematicBox.ts
|
|
9528
9528
|
import { schematicBoxProps } from "@tscircuit/props";
|
|
9529
|
+
|
|
9530
|
+
// lib/components/primitive-components/getTitleAnchorAndPosition.ts
|
|
9531
|
+
function getTitleAnchorAndPosition({
|
|
9532
|
+
anchor,
|
|
9533
|
+
x,
|
|
9534
|
+
y,
|
|
9535
|
+
width,
|
|
9536
|
+
height,
|
|
9537
|
+
isInside
|
|
9538
|
+
}) {
|
|
9539
|
+
switch (anchor) {
|
|
9540
|
+
case "top_left":
|
|
9541
|
+
return {
|
|
9542
|
+
x,
|
|
9543
|
+
y: y + height,
|
|
9544
|
+
textAnchor: isInside ? "top_left" : "bottom_left"
|
|
9545
|
+
};
|
|
9546
|
+
case "top_center":
|
|
9547
|
+
return {
|
|
9548
|
+
x: x + width / 2,
|
|
9549
|
+
y: y + height,
|
|
9550
|
+
textAnchor: isInside ? "top_center" : "bottom_center"
|
|
9551
|
+
};
|
|
9552
|
+
case "top_right":
|
|
9553
|
+
return {
|
|
9554
|
+
x: x + width,
|
|
9555
|
+
y: y + height,
|
|
9556
|
+
textAnchor: isInside ? "top_right" : "bottom_right"
|
|
9557
|
+
};
|
|
9558
|
+
case "center_left":
|
|
9559
|
+
return {
|
|
9560
|
+
x,
|
|
9561
|
+
y: y + height / 2,
|
|
9562
|
+
textAnchor: isInside ? "center_left" : "center_right"
|
|
9563
|
+
};
|
|
9564
|
+
case "center":
|
|
9565
|
+
return {
|
|
9566
|
+
x: x + width / 2,
|
|
9567
|
+
y: y + height / 2,
|
|
9568
|
+
textAnchor: "center"
|
|
9569
|
+
};
|
|
9570
|
+
case "center_right":
|
|
9571
|
+
return {
|
|
9572
|
+
x: x + width,
|
|
9573
|
+
y: y + height / 2,
|
|
9574
|
+
textAnchor: isInside ? "center_right" : "center_left"
|
|
9575
|
+
};
|
|
9576
|
+
case "bottom_left":
|
|
9577
|
+
return {
|
|
9578
|
+
x,
|
|
9579
|
+
y,
|
|
9580
|
+
textAnchor: isInside ? "bottom_left" : "top_left"
|
|
9581
|
+
};
|
|
9582
|
+
case "bottom_center":
|
|
9583
|
+
return {
|
|
9584
|
+
x: x + width / 2,
|
|
9585
|
+
y,
|
|
9586
|
+
textAnchor: isInside ? "bottom_center" : "top_center"
|
|
9587
|
+
};
|
|
9588
|
+
case "bottom_right":
|
|
9589
|
+
return {
|
|
9590
|
+
x: x + width,
|
|
9591
|
+
y,
|
|
9592
|
+
textAnchor: isInside ? "bottom_right" : "top_right"
|
|
9593
|
+
};
|
|
9594
|
+
default:
|
|
9595
|
+
return {
|
|
9596
|
+
x: x + width / 2,
|
|
9597
|
+
y: y + height,
|
|
9598
|
+
textAnchor: "center"
|
|
9599
|
+
};
|
|
9600
|
+
}
|
|
9601
|
+
}
|
|
9602
|
+
|
|
9603
|
+
// lib/components/primitive-components/SchematicBox.ts
|
|
9529
9604
|
var SchematicBox = class extends PrimitiveComponent2 {
|
|
9530
9605
|
isSchematicPrimitive = true;
|
|
9531
9606
|
get config() {
|
|
@@ -9539,11 +9614,6 @@ var SchematicBox = class extends PrimitiveComponent2 {
|
|
|
9539
9614
|
if (this.root?.schematicDisabled) return;
|
|
9540
9615
|
const { db } = this.root;
|
|
9541
9616
|
const { _parsedProps: props } = this;
|
|
9542
|
-
const result = schematicBoxProps.safeParse(props);
|
|
9543
|
-
if (!result.success) {
|
|
9544
|
-
console.error("Validation failed:", result.error.format());
|
|
9545
|
-
throw result.error;
|
|
9546
|
-
}
|
|
9547
9617
|
const basePadding = 0.6;
|
|
9548
9618
|
const generalPadding = typeof props.padding === "number" ? props.padding : 0;
|
|
9549
9619
|
const paddingTop = typeof props.paddingTop === "number" ? props.paddingTop : generalPadding;
|
|
@@ -9556,6 +9626,8 @@ var SchematicBox = class extends PrimitiveComponent2 {
|
|
|
9556
9626
|
let height;
|
|
9557
9627
|
let x;
|
|
9558
9628
|
let y;
|
|
9629
|
+
let centerX;
|
|
9630
|
+
let centerY;
|
|
9559
9631
|
if (hasOverlay) {
|
|
9560
9632
|
const portsWithSelectors = props.overlay.map((selector) => ({
|
|
9561
9633
|
selector,
|
|
@@ -9589,11 +9661,13 @@ var SchematicBox = class extends PrimitiveComponent2 {
|
|
|
9589
9661
|
height = bottom - top;
|
|
9590
9662
|
x = left + (props.schX ?? 0);
|
|
9591
9663
|
y = top + (props.schY ?? 0);
|
|
9664
|
+
centerX = x + width / 2;
|
|
9665
|
+
centerY = y + height / 2;
|
|
9592
9666
|
} else if (hasFixedSize) {
|
|
9593
9667
|
width = props.width;
|
|
9594
9668
|
height = props.height;
|
|
9595
|
-
|
|
9596
|
-
|
|
9669
|
+
centerX = typeof props.schX === "number" ? props.schX : 0;
|
|
9670
|
+
centerY = typeof props.schY === "number" ? props.schY : 0;
|
|
9597
9671
|
x = centerX - width / 2;
|
|
9598
9672
|
y = centerY - height / 2;
|
|
9599
9673
|
} else {
|
|
@@ -9607,6 +9681,42 @@ var SchematicBox = class extends PrimitiveComponent2 {
|
|
|
9607
9681
|
is_dashed: props.strokeStyle === "dashed",
|
|
9608
9682
|
schematic_component_id: ""
|
|
9609
9683
|
});
|
|
9684
|
+
if (props.title) {
|
|
9685
|
+
const isInside = props.titleInside ?? false;
|
|
9686
|
+
const TITLE_PADDING = 0.1;
|
|
9687
|
+
const anchor = props.titleAlignment ?? "bottom_center";
|
|
9688
|
+
const anchorPos = getTitleAnchorAndPosition({
|
|
9689
|
+
anchor,
|
|
9690
|
+
x,
|
|
9691
|
+
y,
|
|
9692
|
+
width,
|
|
9693
|
+
height,
|
|
9694
|
+
isInside
|
|
9695
|
+
});
|
|
9696
|
+
let titleOffsetY;
|
|
9697
|
+
let titleOffsetX;
|
|
9698
|
+
const textAnchor = anchorPos.textAnchor;
|
|
9699
|
+
if (isInside) {
|
|
9700
|
+
titleOffsetY = anchor.includes("top") ? -TITLE_PADDING : anchor.includes("bottom") ? TITLE_PADDING : 0;
|
|
9701
|
+
titleOffsetX = anchor.includes("left") ? TITLE_PADDING : anchor.includes("right") ? -TITLE_PADDING : 0;
|
|
9702
|
+
} else {
|
|
9703
|
+
titleOffsetY = anchor.includes("top") ? TITLE_PADDING : anchor.includes("bottom") ? -TITLE_PADDING : 0;
|
|
9704
|
+
titleOffsetX = anchor.includes("center_left") ? -TITLE_PADDING : anchor.includes("center_right") ? TITLE_PADDING : 0;
|
|
9705
|
+
}
|
|
9706
|
+
const titleX = anchorPos.x + titleOffsetX;
|
|
9707
|
+
const titleY = anchorPos.y + titleOffsetY;
|
|
9708
|
+
db.schematic_text.insert({
|
|
9709
|
+
anchor: textAnchor,
|
|
9710
|
+
text: props.title,
|
|
9711
|
+
font_size: props.titleFontSize ?? 0.18,
|
|
9712
|
+
color: props.titleColor ?? "#000000",
|
|
9713
|
+
position: {
|
|
9714
|
+
x: titleX,
|
|
9715
|
+
y: titleY
|
|
9716
|
+
},
|
|
9717
|
+
rotation: 0
|
|
9718
|
+
});
|
|
9719
|
+
}
|
|
9610
9720
|
}
|
|
9611
9721
|
};
|
|
9612
9722
|
|
|
@@ -9619,7 +9729,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
9619
9729
|
var package_default = {
|
|
9620
9730
|
name: "@tscircuit/core",
|
|
9621
9731
|
type: "module",
|
|
9622
|
-
version: "0.0.
|
|
9732
|
+
version: "0.0.462",
|
|
9623
9733
|
types: "dist/index.d.ts",
|
|
9624
9734
|
main: "dist/index.js",
|
|
9625
9735
|
module: "dist/index.js",
|
|
@@ -9651,7 +9761,7 @@ var package_default = {
|
|
|
9651
9761
|
"@tscircuit/layout": "^0.0.28",
|
|
9652
9762
|
"@tscircuit/log-soup": "^1.0.2",
|
|
9653
9763
|
"@tscircuit/math-utils": "^0.0.18",
|
|
9654
|
-
"@tscircuit/props": "^0.0.
|
|
9764
|
+
"@tscircuit/props": "^0.0.219",
|
|
9655
9765
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
9656
9766
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
9657
9767
|
"@tscircuit/simple-3d-svg": "^0.0.6",
|
|
@@ -9662,7 +9772,7 @@ var package_default = {
|
|
|
9662
9772
|
"@types/react-reconciler": "^0.28.9",
|
|
9663
9773
|
"bun-match-svg": "0.0.8",
|
|
9664
9774
|
"chokidar-cli": "^3.0.0",
|
|
9665
|
-
"circuit-json": "^0.0.
|
|
9775
|
+
"circuit-json": "^0.0.204",
|
|
9666
9776
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
9667
9777
|
"circuit-json-to-simple-3d": "^0.0.2",
|
|
9668
9778
|
"circuit-to-svg": "^0.0.151",
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tscircuit/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.463",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"module": "dist/index.js",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"@tscircuit/layout": "^0.0.28",
|
|
34
34
|
"@tscircuit/log-soup": "^1.0.2",
|
|
35
35
|
"@tscircuit/math-utils": "^0.0.18",
|
|
36
|
-
"@tscircuit/props": "^0.0.
|
|
36
|
+
"@tscircuit/props": "^0.0.219",
|
|
37
37
|
"@tscircuit/schematic-autolayout": "^0.0.6",
|
|
38
38
|
"@tscircuit/schematic-match-adapt": "^0.0.16",
|
|
39
39
|
"@tscircuit/simple-3d-svg": "^0.0.6",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@types/react-reconciler": "^0.28.9",
|
|
45
45
|
"bun-match-svg": "0.0.8",
|
|
46
46
|
"chokidar-cli": "^3.0.0",
|
|
47
|
-
"circuit-json": "^0.0.
|
|
47
|
+
"circuit-json": "^0.0.204",
|
|
48
48
|
"circuit-json-to-connectivity-map": "^0.0.22",
|
|
49
49
|
"circuit-json-to-simple-3d": "^0.0.2",
|
|
50
50
|
"circuit-to-svg": "^0.0.151",
|