@tscircuit/core 0.0.1219 → 0.0.1220

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.
Files changed (2) hide show
  1. package/dist/index.js +22 -5
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -18682,7 +18682,6 @@ function computeCenterFromAnchorPosition(anchorPosition, ctx) {
18682
18682
  if (!pcbAnchorAlignment) return anchorPosition;
18683
18683
  const alignment = pcbAnchorAlignment;
18684
18684
  if (typeof width !== "number" || typeof height !== "number") {
18685
- console.log("width or height is not a number");
18686
18685
  return anchorPosition;
18687
18686
  }
18688
18687
  const ax = anchorPosition.x;
@@ -18911,13 +18910,31 @@ var Group6 = class extends NormalComponent3 {
18911
18910
  centerX += (padRight - padLeft) / 2;
18912
18911
  centerY += (padTop - padBottom) / 2;
18913
18912
  }
18914
- const center = hasExplicitPositioning ? db.pcb_group.get(this.pcb_group_id)?.center ?? {
18913
+ const resolvedWidth = Number(props.width ?? width);
18914
+ const resolvedHeight = Number(props.height ?? height);
18915
+ const existingPcbGroup = db.pcb_group.get(this.pcb_group_id);
18916
+ let center = hasExplicitPositioning ? existingPcbGroup?.center ?? {
18915
18917
  x: centerX,
18916
18918
  y: centerY
18917
18919
  } : { x: centerX, y: centerY };
18920
+ if (hasExplicitPositioning && props.pcbAnchorAlignment) {
18921
+ const anchorPosition = this._getGlobalPcbPositionBeforeLayout();
18922
+ const anchorAlignedCenter = computeCenterFromAnchorPosition(
18923
+ anchorPosition,
18924
+ {
18925
+ ...this.props,
18926
+ width: resolvedWidth,
18927
+ height: resolvedHeight
18928
+ }
18929
+ );
18930
+ if (Math.abs(anchorAlignedCenter.x - center.x) > 1e-6 || Math.abs(anchorAlignedCenter.y - center.y) > 1e-6) {
18931
+ this._repositionOnPcb(anchorAlignedCenter);
18932
+ }
18933
+ center = anchorAlignedCenter;
18934
+ }
18918
18935
  db.pcb_group.update(this.pcb_group_id, {
18919
- width: Number(props.width ?? width),
18920
- height: Number(props.height ?? height),
18936
+ width: resolvedWidth,
18937
+ height: resolvedHeight,
18921
18938
  center
18922
18939
  });
18923
18940
  }
@@ -20459,7 +20476,7 @@ import { identity as identity5 } from "transformation-matrix";
20459
20476
  var package_default = {
20460
20477
  name: "@tscircuit/core",
20461
20478
  type: "module",
20462
- version: "0.0.1218",
20479
+ version: "0.0.1219",
20463
20480
  types: "dist/index.d.ts",
20464
20481
  main: "dist/index.js",
20465
20482
  module: "dist/index.js",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tscircuit/core",
3
3
  "type": "module",
4
- "version": "0.0.1219",
4
+ "version": "0.0.1220",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.js",