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