import { html, nothing } from "lit" import ISelectableDraggableTemplate from "./ISelectableDraggableTemplate" import PinElement from "../element/PinElement" /** @typedef {import("../element/NodeElement").default} NodeElement */ /** @extends {ISelectableDraggableTemplate} */ export default class NodeTemplate extends ISelectableDraggableTemplate { toggleAdvancedDisplayHandler = _ => { this.element.toggleShowAdvancedPinDisplay() this.element.addNextUpdatedCallbacks(() => this.element.dispatchReflowEvent(), true) } render() { return html`
${this.element.nodeDisplayName}
${this.element.enabledState?.toString() == "DevelopmentOnly" ? html`
Development Only
` : nothing} ${this.element.advancedPinDisplay ? html`
` : nothing}
` } /** @param {Map} changedProperties */ firstUpdated(changedProperties) { super.firstUpdated(changedProperties) const inputContainer = /** @type {HTMLElement} */(this.element.querySelector(".ueb-node-inputs")) const outputContainer = /** @type {HTMLElement} */(this.element.querySelector(".ueb-node-outputs")) Promise.all(this.element.getPinElements().map(n => n.updateComplete)).then(() => this.element.dispatchReflowEvent()) this.element.getPinElements().forEach(p => { if (p.isInput()) { inputContainer.appendChild(p) } else if (p.isOutput()) { outputContainer.appendChild(p) } }) this.element.nodeNameElement = /** @type {HTMLElement} */(this.element.querySelector(".ueb-node-name-text")) } /** * @param {NodeElement} node * @returns {NodeListOf} */ getPinElements(node) { return node.querySelectorAll("ueb-pin") } }