import { html, nothing } from "lit" import ElementFactory from "../element/ElementFactory" import ISelectableDraggableTemplate from "./ISelectableDraggableTemplate" /** * @typedef {import("../element/NodeElement").default} NodeElement * @typedef {import("../element/PinElement").default} PinElement */ /** @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") } createPinElements() { return this.element.getPinEntities() .filter(v => !v.isHidden()) .map(v => /** @type {PinElement} */( new (ElementFactory.getConstructor("ueb-pin"))(v, undefined, this.element) )) } }