import { html } from "lit" import ITemplate from "./ITemplate" import MouseCreateLink from "../input/mouse/MouseCreateLink" import Utility from "../Utility" /** * @typedef {import("../input/IInput").default} IInput */ /** * @template T * @typedef {import("../element/PinElement").default} PinElement */ /** * @template T * @extends ITemplate> */ export default class PinTemplate extends ITemplate { connectedCallback() { super.connectedCallback() this.element.nodeElement = this.element.closest("ueb-node") } /** @returns {IInput[]} */ createInputObjects() { return [ new MouseCreateLink(this.element.clickableElement, this.element.blueprint, { moveEverywhere: true, looseTarget: true, }) ] } render() { const icon = html`
${this.renderIcon()}
` const content = html`
${this.element.getPinDisplayName()} ${this.renderInput()}
` return html`
${this.element.isInput() ? html`${icon}${content}` : html`${content}${icon}`}
` } renderIcon() { return html` ` } renderInput() { return html`` } /** @param {Map} changedProperties */ firstUpdated(changedProperties) { super.firstUpdated(changedProperties) this.element.dataset.id = this.element.GetPinIdValue() this.element.clickableElement = this.element } getLinkLocation() { const rect = this.element.querySelector(".ueb-pin-icon").getBoundingClientRect() const location = Utility.convertLocation( [(rect.left + rect.right) / 2, (rect.top + rect.bottom) / 2], this.element.blueprint.gridElement ) return this.element.blueprint.compensateTranslation(location) } }