@tscircuit/core 0.0.765 → 0.0.766
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 +68 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8313,6 +8313,56 @@ var NormalComponent3 = class extends PrimitiveComponent2 {
|
|
|
8313
8313
|
}
|
|
8314
8314
|
};
|
|
8315
8315
|
|
|
8316
|
+
// lib/utils/boards/get-board-center-from-anchor.ts
|
|
8317
|
+
var getBoardCenterFromAnchor = ({
|
|
8318
|
+
boardAnchorPosition,
|
|
8319
|
+
boardAnchorAlignment,
|
|
8320
|
+
width,
|
|
8321
|
+
height
|
|
8322
|
+
}) => {
|
|
8323
|
+
const { x: ax, y: ay } = boardAnchorPosition;
|
|
8324
|
+
let cx = ax;
|
|
8325
|
+
let cy = ay;
|
|
8326
|
+
switch (boardAnchorAlignment) {
|
|
8327
|
+
case "top_left":
|
|
8328
|
+
cx = ax + width / 2;
|
|
8329
|
+
cy = ay - height / 2;
|
|
8330
|
+
break;
|
|
8331
|
+
case "top_right":
|
|
8332
|
+
cx = ax - width / 2;
|
|
8333
|
+
cy = ay - height / 2;
|
|
8334
|
+
break;
|
|
8335
|
+
case "bottom_left":
|
|
8336
|
+
cx = ax + width / 2;
|
|
8337
|
+
cy = ay + height / 2;
|
|
8338
|
+
break;
|
|
8339
|
+
case "bottom_right":
|
|
8340
|
+
cx = ax - width / 2;
|
|
8341
|
+
cy = ay + height / 2;
|
|
8342
|
+
break;
|
|
8343
|
+
case "top":
|
|
8344
|
+
cx = ax;
|
|
8345
|
+
cy = ay - height / 2;
|
|
8346
|
+
break;
|
|
8347
|
+
case "bottom":
|
|
8348
|
+
cx = ax;
|
|
8349
|
+
cy = ay + height / 2;
|
|
8350
|
+
break;
|
|
8351
|
+
case "left":
|
|
8352
|
+
cx = ax + width / 2;
|
|
8353
|
+
cy = ay;
|
|
8354
|
+
break;
|
|
8355
|
+
case "right":
|
|
8356
|
+
cx = ax - width / 2;
|
|
8357
|
+
cy = ay;
|
|
8358
|
+
break;
|
|
8359
|
+
case "center":
|
|
8360
|
+
default:
|
|
8361
|
+
break;
|
|
8362
|
+
}
|
|
8363
|
+
return { x: cx, y: cy };
|
|
8364
|
+
};
|
|
8365
|
+
|
|
8316
8366
|
// lib/components/normal-components/Board.ts
|
|
8317
8367
|
import { boardProps } from "@tscircuit/props";
|
|
8318
8368
|
import { identity as identity4 } from "transformation-matrix";
|
|
@@ -12859,10 +12909,17 @@ var Board = class extends Group6 {
|
|
|
12859
12909
|
for (const pcbGroup of allPcbGroups) {
|
|
12860
12910
|
updateBounds(pcbGroup.center, pcbGroup.width, pcbGroup.height);
|
|
12861
12911
|
}
|
|
12912
|
+
if (props.boardAnchorPosition) {
|
|
12913
|
+
const { x, y } = props.boardAnchorPosition;
|
|
12914
|
+
minX = Math.min(minX, x);
|
|
12915
|
+
minY = Math.min(minY, y);
|
|
12916
|
+
maxX = Math.max(maxX, x);
|
|
12917
|
+
maxY = Math.max(maxY, y);
|
|
12918
|
+
}
|
|
12862
12919
|
const padding = 2;
|
|
12863
12920
|
const computedWidth = hasComponents ? maxX - minX + padding * 2 : 0;
|
|
12864
12921
|
const computedHeight = hasComponents ? maxY - minY + padding * 2 : 0;
|
|
12865
|
-
|
|
12922
|
+
let center = {
|
|
12866
12923
|
x: hasComponents ? (minX + maxX) / 2 + (props.outlineOffsetX ?? 0) : props.outlineOffsetX ?? 0,
|
|
12867
12924
|
y: hasComponents ? (minY + maxY) / 2 + (props.outlineOffsetY ?? 0) : props.outlineOffsetY ?? 0
|
|
12868
12925
|
};
|
|
@@ -12935,6 +12992,15 @@ var Board = class extends Group6 {
|
|
|
12935
12992
|
x: (props.pcbX ?? 0) + (props.outlineOffsetX ?? 0),
|
|
12936
12993
|
y: (props.pcbY ?? 0) + (props.outlineOffsetY ?? 0)
|
|
12937
12994
|
};
|
|
12995
|
+
const { boardAnchorPosition, boardAnchorAlignment } = props;
|
|
12996
|
+
if (boardAnchorPosition) {
|
|
12997
|
+
center = getBoardCenterFromAnchor({
|
|
12998
|
+
boardAnchorPosition,
|
|
12999
|
+
boardAnchorAlignment: boardAnchorAlignment ?? "center",
|
|
13000
|
+
width: computedWidth,
|
|
13001
|
+
height: computedHeight
|
|
13002
|
+
});
|
|
13003
|
+
}
|
|
12938
13004
|
if (props.outline) {
|
|
12939
13005
|
const xValues = props.outline.map((point) => point.x);
|
|
12940
13006
|
const yValues = props.outline.map((point) => point.y);
|
|
@@ -15995,7 +16061,7 @@ import { identity as identity6 } from "transformation-matrix";
|
|
|
15995
16061
|
var package_default = {
|
|
15996
16062
|
name: "@tscircuit/core",
|
|
15997
16063
|
type: "module",
|
|
15998
|
-
version: "0.0.
|
|
16064
|
+
version: "0.0.765",
|
|
15999
16065
|
types: "dist/index.d.ts",
|
|
16000
16066
|
main: "dist/index.js",
|
|
16001
16067
|
module: "dist/index.js",
|