Files
ueblueprint/js/element/IElement.js
BarsDev 6ba2705386 Large refactoring and new nodes
* Fix node reference when changing elements

* Fix ScriptVariables parsing

* Fix invariant text and niagara types

* Niagara convert nodes

* Move node tests to own files

* More Niagara tests

* Niagara float and smaller fixes

* More Decoding

* More decoding

* WIP

* Float is real

* WIP

* More types and colors

* Test case and small polish

* WIP

* WIP

* Fix niagara script variables merging

* Fix Niagara variables

* Fixing mirrored ExportPath

* Fix Export paths name adjustments

* Simplify arc calculation

* Simplify a bit arc calculation

* source / destionation => origin / target

* Minor refactoring

* Fix switched link position

* Rename some properties for uniformity

* Fix input escape

* Simplify test

* About window

* Dialog backdrop style

* About dialog touches

* Remove dependency and minot improvement

* Light mode

* Fix link location and css small improvement

* Link direction and minor fixes

* Some minor fixes and refactoring

* Refactoring WIP

* Shorting repetitive bits

* More tests

* Simplify linking tests
2025-02-07 00:36:03 +02:00

125 lines
2.9 KiB
JavaScript
Executable File

import { LitElement } from "lit"
import Configuration from "../Configuration.js"
/**
* @template {IEntity} EntityT
* @template {ITemplate} TemplateT
*/
export default class IElement extends LitElement {
/** @type {Blueprint} */
#blueprint
get blueprint() {
return this.#blueprint
}
set blueprint(v) {
this.#blueprint = v
}
/** @type {EntityT} */
#entity
get entity() {
return this.#entity
}
set entity(entity) {
this.#entity = entity
}
/** @type {TemplateT} */
#template
get template() {
return this.#template
}
isInitialized = false
isSetup = false
/** @type {IInput[]} */
inputObjects = []
/**
* @param {EntityT} entity
* @param {TemplateT} template
*/
initialize(entity, template) {
this.requestUpdate()
this.#entity = entity
this.#template = template
this.#template.initialize(this)
if (this.isConnected) {
this.updateComplete.then(() => this.setup())
}
this.isInitialized = true
}
connectedCallback() {
super.connectedCallback()
this.blueprint = /** @type {Blueprint} */(this.closest("ueb-blueprint"))
if (this.isInitialized) {
this.requestUpdate()
this.updateComplete.then(() => this.setup())
}
}
disconnectedCallback() {
super.disconnectedCallback()
if (this.isSetup) {
this.updateComplete.then(() => this.cleanup())
}
this.acknowledgeDelete()
}
createRenderRoot() {
return this
}
setup() {
this.template.setup()
this.isSetup = true
}
cleanup() {
this.template.cleanup()
this.isSetup = false
}
/** @param {PropertyValues} changedProperties */
willUpdate(changedProperties) {
super.willUpdate(changedProperties)
this.template.willUpdate(changedProperties)
}
/** @param {PropertyValues} changedProperties */
update(changedProperties) {
super.update(changedProperties)
this.template.update(changedProperties)
}
render() {
return this.template.render()
}
/** @param {PropertyValues} changedProperties */
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties)
this.template.firstUpdated(changedProperties)
this.template.inputSetup()
}
/** @param {PropertyValues} changedProperties */
updated(changedProperties) {
super.updated(changedProperties)
this.template.updated(changedProperties)
}
acknowledgeDelete() {
let deleteEvent = new CustomEvent(Configuration.removeEventName)
this.dispatchEvent(deleteEvent)
}
/** @param {IElement} element */
isSameGraph(element) {
return this.blueprint && this.blueprint == element?.blueprint
}
}