@gravity-ui/graph
Version:
Modern graph editor component
37 lines (36 loc) • 912 B
JavaScript
import { signal } from "@preact/signals-core";
export var EAnchorType;
(function (EAnchorType) {
EAnchorType["IN"] = "IN";
EAnchorType["OUT"] = "OUT";
})(EAnchorType || (EAnchorType = {}));
export class AnchorState {
get id() {
return this.$state.value.id;
}
get blockId() {
return this.$state.value.blockId;
}
get state() {
return this.$state.value;
}
constructor(block, anchor) {
this.block = block;
this.$state = signal(undefined);
this.$selected = signal(false);
this.$state.value = anchor;
}
update(anchor) {
this.$state.value = anchor;
}
setSelection(selected, silent) {
if (silent) {
this.$selected.value = selected;
return;
}
this.block.onAnchorSelected(this.id, selected);
}
asTAnchor() {
return this.$state.value;
}
}