Files
ueblueprint/js/element/PinElement.js
2022-03-06 22:38:33 +01:00

83 lines
1.7 KiB
JavaScript

import IElement from "./IElement"
import MouseCreateLink from "../input/mouse/MouseCreateLink"
import PinTemplate from "../template/PinTemplate"
export default class PinElement extends IElement {
static tagName = "ueb-pin"
/** @type {HTMLElement} */
clickableElement
/** @type {String} */
#color
constructor(entity) {
super(entity, new PinTemplate())
/** @type {import("../entity/PinEntity").default} */
this.entity
/** @type {PinTemplate} */
this.template
}
connectedCallback() {
super.connectedCallback()
this.#color = window.getComputedStyle(this).getPropertyValue("--ueb-pin-color")
}
createInputObjects() {
return [
new MouseCreateLink(this.clickableElement, this.blueprint, {
moveEverywhere: true,
looseTarget: true
}),
]
}
/**
*
* @returns {String}
*/
getPinDisplayName() {
return this.entity.PinName
}
isInput() {
return this.entity.isInput()
}
isOutput() {
return this.entity.isOutput()
}
isConnected() {
return this.entity.isConnected()
}
getType() {
return this.entity.getType()
}
getClickableElement() {
return this.clickableElement
}
getColor() {
return this.#color
}
/**
* Returns The exact location where the link originates from or arrives at.
* @returns {Number[]} The location array
*/
getLinkLocation() {
return this.template.getLinkLocation(this)
}
getNodeElement() {
return this.closest("ueb-node")
}
}
customElements.define(PinElement.tagName, PinElement)