@tscircuit/core 0.0.523 → 0.0.524
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.d.ts +3 -1
- package/dist/index.js +36 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7407,7 +7407,9 @@ declare class NetLabel extends PrimitiveComponent<typeof netLabelProps> {
|
|
|
7407
7407
|
anchorSide?: "left" | "right" | "top" | "bottom" | undefined;
|
|
7408
7408
|
}>;
|
|
7409
7409
|
};
|
|
7410
|
-
|
|
7410
|
+
_getAnchorSide(): "top" | "bottom" | "left" | "right";
|
|
7411
|
+
_getConnectedPorts(): Port[];
|
|
7412
|
+
doInitialSchematicPrimitiveRender(): void;
|
|
7411
7413
|
_resolveConnectsTo(): string[] | undefined;
|
|
7412
7414
|
_getNetName(): string;
|
|
7413
7415
|
doInitialCreateNetsFromProps(): void;
|
package/dist/index.js
CHANGED
|
@@ -9408,18 +9408,50 @@ var NetLabel = class extends PrimitiveComponent2 {
|
|
|
9408
9408
|
zodProps: netLabelProps
|
|
9409
9409
|
};
|
|
9410
9410
|
}
|
|
9411
|
-
|
|
9411
|
+
_getAnchorSide() {
|
|
9412
|
+
const { _parsedProps: props } = this;
|
|
9413
|
+
if (props.anchorSide) return props.anchorSide;
|
|
9414
|
+
const connectsTo = this._resolveConnectsTo();
|
|
9415
|
+
if (!connectsTo) return "right";
|
|
9416
|
+
const anchorPos = this._getGlobalSchematicPositionBeforeLayout();
|
|
9417
|
+
const connectedPorts = this._getConnectedPorts();
|
|
9418
|
+
if (connectedPorts.length === 0) return "right";
|
|
9419
|
+
const connectedPortPosition = connectedPorts[0]._getGlobalSchematicPositionBeforeLayout();
|
|
9420
|
+
const dx = connectedPortPosition.x - anchorPos.x;
|
|
9421
|
+
const dy = connectedPortPosition.y - anchorPos.y;
|
|
9422
|
+
if (Math.abs(dx) > Math.abs(dy)) {
|
|
9423
|
+
if (dx > 0) return "right";
|
|
9424
|
+
if (dx < 0) return "left";
|
|
9425
|
+
} else {
|
|
9426
|
+
if (dy > 0) return "top";
|
|
9427
|
+
if (dy < 0) return "bottom";
|
|
9428
|
+
}
|
|
9429
|
+
return "right";
|
|
9430
|
+
}
|
|
9431
|
+
_getConnectedPorts() {
|
|
9432
|
+
const connectsTo = this._resolveConnectsTo();
|
|
9433
|
+
if (!connectsTo) return [];
|
|
9434
|
+
const connectedPorts = [];
|
|
9435
|
+
for (const connection of connectsTo) {
|
|
9436
|
+
const port = this.getSubcircuit().selectOne(connection);
|
|
9437
|
+
if (port) {
|
|
9438
|
+
connectedPorts.push(port);
|
|
9439
|
+
}
|
|
9440
|
+
}
|
|
9441
|
+
return connectedPorts;
|
|
9442
|
+
}
|
|
9443
|
+
doInitialSchematicPrimitiveRender() {
|
|
9412
9444
|
if (this.root?.schematicDisabled) return;
|
|
9413
9445
|
const { db } = this.root;
|
|
9414
9446
|
const { _parsedProps: props } = this;
|
|
9415
|
-
const anchorPos =
|
|
9447
|
+
const anchorPos = this._getGlobalSchematicPositionBeforeLayout();
|
|
9416
9448
|
const netLabel = db.schematic_net_label.insert({
|
|
9417
9449
|
text: props.net,
|
|
9418
9450
|
source_net_id: props.net,
|
|
9419
9451
|
anchor_position: anchorPos,
|
|
9420
9452
|
// TODO compute the center based on the text size
|
|
9421
9453
|
center: anchorPos,
|
|
9422
|
-
anchor_side:
|
|
9454
|
+
anchor_side: this._getAnchorSide()
|
|
9423
9455
|
});
|
|
9424
9456
|
this.source_net_label_id = netLabel.source_net_id;
|
|
9425
9457
|
}
|
|
@@ -10563,7 +10595,7 @@ import { identity as identity4 } from "transformation-matrix";
|
|
|
10563
10595
|
var package_default = {
|
|
10564
10596
|
name: "@tscircuit/core",
|
|
10565
10597
|
type: "module",
|
|
10566
|
-
version: "0.0.
|
|
10598
|
+
version: "0.0.523",
|
|
10567
10599
|
types: "dist/index.d.ts",
|
|
10568
10600
|
main: "dist/index.js",
|
|
10569
10601
|
module: "dist/index.js",
|