import { html, nothing } from "lit" import Configuration from "../../Configuration.js" import ElementFactory from "../../element/ElementFactory.js" import MinimalPinTemplate from "../pin/MinimalPinTemplate.js" import NodeTemplate from "./NodeTemplate.js" /** * @typedef {import("../../element/PinElement.js").PinElementConstructor} PinElementConstructor * @typedef {import("lit").PropertyValues} PropertyValues */ export default class EventNodeTemplate extends NodeTemplate { static nodeStyleClasses = [...super.nodeStyleClasses, "ueb-node-style-event"] /** @param {PropertyValues} changedProperties */ firstUpdated(changedProperties) { super.firstUpdated(changedProperties) this.element.querySelector(".ueb-node-top").appendChild(this.createDelegatePinElement()) } renderTop() { const icon = this.renderNodeIcon() const name = this.renderNodeName() const customEvent = this.element.getType() === Configuration.paths.customEvent && (this.element.entity.CustomFunctionName || this.element.entity.FunctionReference.MemberParent) return html`
${icon ? html`
${icon}
` : nothing} ${name ? html`
${name} ${customEvent ? html`
Custom Event
`: nothing}
` : nothing}
` } createDelegatePinElement() { const pin = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")).newObject( this.element.getPinEntities().find(v => !v.isHidden() && v.PinType.PinCategory === "delegate"), new MinimalPinTemplate(), this.element ) pin.template.isNameRendered = false return pin } createPinElements() { return this.element.getPinEntities() .filter(v => !v.isHidden() && v.PinType.PinCategory !== "delegate") .map(pinEntity => /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")) .newObject(pinEntity, undefined, this.element) ) } }