import { html, nothing } from "lit" import ElementFactory from "../../element/ElementFactory" import NodeTemplate from "./NodeTemplate" /** * @typedef {import("../../element/NodeElement").default} NodeElement * @typedef {import("../../element/PinElement").default} PinElement * @typedef {import("../../element/PinElement").PinElementConstructor} PinElementConstructor */ export default class VariableAccessNodeTemplate extends NodeTemplate { #hasInput = false #hasOutput = false #displayName = "" /** @param {NodeElement} element */ initialize(element) { super.initialize(element) this.element.classList.add("ueb-node-style-glass") this.#displayName = this.element.getNodeDisplayName() } render() { return html`
${this.#displayName ? html`
${this.#displayName}
` : nothing}
${this.#hasInput ? html`
` : nothing} ${this.#hasOutput ? html`
` : nothing}
` } createPinElements() { return this.element.getPinEntities() .filter(v => !v.isHidden()) .map(v => { this.#hasInput ||= v.isInput() this.#hasOutput ||= v.isOutput() const result = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")) .newObject(v, undefined, this.element) return result }) } setupPins() { super.setupPins() let outputPin = this.element.getPinElements().find(p => !p.entity.isHidden() && !p.entity.isExecution()) this.element.style.setProperty("--ueb-node-color", outputPin.getColor().cssText) } }