diff --git a/dist/ueblueprint.js b/dist/ueblueprint.js
index aec8a13..39dc8d3 100755
--- a/dist/ueblueprint.js
+++ b/dist/ueblueprint.js
@@ -1764,60 +1764,42 @@ class ITemplate {
/** @param {T} element */
constructed(element) {
+ this.element = element;
}
- /** @param {T} element */
- connectedCallback(element) {
+ connectedCallback() {
}
- /**
- * @param {T} element
- * @param {Map} changedProperties
- */
- willUpdate(element, changedProperties) {
+ /** @param {Map} changedProperties */
+ willUpdate(changedProperties) {
}
- /**
- * @param {T} element
- * @param {Map} changedProperties
- */
- update(element, changedProperties) {
+ /** @param {Map} changedProperties */
+ update(changedProperties) {
}
- /** @param {T} element */
- render(element) {
+ render() {
return $``
}
- /**
- * @param {T} element
- * @param {Map} changedProperties
- */
- firstUpdated(element, changedProperties) {
+ /** @param {Map} changedProperties */
+ firstUpdated(changedProperties) {
}
- /**
- * @param {T} element
- * @param {Map} changedProperties
- */
- updated(element, changedProperties) {
+ /** @param {Map} changedProperties */
+ updated(changedProperties) {
}
- /** @param {T} element */
- inputSetup(element) {
- this.#inputObjects = this.createInputObjects(element);
+ inputSetup() {
+ this.#inputObjects = this.createInputObjects();
}
- /** @param {T} element */
- cleanup(element) {
+ cleanup() {
this.#inputObjects.forEach(v => v.unlistenDOMElement());
}
- /**
- * @param {T} element
- * @returns {IInput[]}
- */
- createInputObjects(element) {
+ /** @returns {IInput[]} */
+ createInputObjects() {
return []
}
}
@@ -2384,42 +2366,42 @@ class IElement extends s {
connectedCallback() {
super.connectedCallback();
this.blueprint = this.closest("ueb-blueprint");
- this.template.connectedCallback(this);
+ this.template.connectedCallback();
}
/** @param {Map} changedProperties */
willUpdate(changedProperties) {
super.willUpdate(changedProperties);
- this.template.willUpdate(this, changedProperties);
+ this.template.willUpdate(changedProperties);
}
/** @param {Map} changedProperties */
update(changedProperties) {
super.update(changedProperties);
- this.template.update(this, changedProperties);
+ this.template.update(changedProperties);
}
render() {
- return this.template.render(this)
+ return this.template.render()
}
/** @param {Map} changedProperties */
firstUpdated(changedProperties) {
super.firstUpdated(changedProperties);
- this.template.firstUpdated(this, changedProperties);
- this.template.inputSetup(this);
+ this.template.firstUpdated(changedProperties);
+ this.template.inputSetup();
}
updated(changedProperties) {
super.updated(changedProperties);
- this.template.updated(this, changedProperties);
+ this.template.updated(changedProperties);
this.#nextUpdatedCallbacks.forEach(f => f(changedProperties));
this.#nextUpdatedCallbacks = [];
}
disconnectedCallback() {
super.disconnectedCallback();
- this.template.cleanup(this);
+ this.template.cleanup();
}
addNextUpdatedCallbacks(callback, requestUpdate = false) {
@@ -2649,23 +2631,20 @@ class IFromToPositionedElement extends IElement {
*/
class IFromToPositionedTemplate extends ITemplate {
- /**
- * @param {T} selector
- * @param {Map} changedProperties
- */
- update(selector, changedProperties) {
- super.update(selector, changedProperties);
+ /** @param {Map} changedProperties */
+ update(changedProperties) {
+ super.update(changedProperties);
if (changedProperties.has("initialPositionX")) {
- selector.style.setProperty("--ueb-from-x", `${selector.initialPositionX}`);
+ this.element.style.setProperty("--ueb-from-x", `${this.element.initialPositionX}`);
}
if (changedProperties.has("initialPositionY")) {
- selector.style.setProperty("--ueb-from-y", `${selector.initialPositionY}`);
+ this.element.style.setProperty("--ueb-from-y", `${this.element.initialPositionY}`);
}
if (changedProperties.has("finaPositionX")) {
- selector.style.setProperty("--ueb-to-x", `${selector.finaPositionX}`);
+ this.element.style.setProperty("--ueb-to-x", `${this.element.finaPositionX}`);
}
if (changedProperties.has("finaPositionY")) {
- selector.style.setProperty("--ueb-to-y", `${selector.finaPositionY}`);
+ this.element.style.setProperty("--ueb-to-y", `${this.element.finaPositionY}`);
}
}
@@ -2725,66 +2704,63 @@ class LinkTemplate extends IFromToPositionedTemplate {
static c2Clamped = LinkTemplate.clampedLine([0, 100], [200, 30])
/**
- * @param {LinkElement} link
* @param {Map} changedProperties
*/
- willUpdate(link, changedProperties) {
- super.willUpdate(link, changedProperties);
- const dx = Math.max(Math.abs(link.initialPositionX - link.finaPositionX), 1);
+ willUpdate(changedProperties) {
+ super.willUpdate(changedProperties);
+ const dx = Math.max(Math.abs(this.element.initialPositionX - this.element.finaPositionX), 1);
const width = Math.max(dx, Configuration.linkMinWidth);
// const height = Math.max(Math.abs(link.initialPositionY - link.finaPositionY), 1)
const fillRatio = dx / width;
// const aspectRatio = width / height
- const xInverted = link.originatesFromInput
- ? link.initialPositionX < link.finaPositionX
- : link.finaPositionX < link.initialPositionX;
- link.startPixels = dx < width // If under minimum width
+ const xInverted = this.element.originatesFromInput
+ ? this.element.initialPositionX < this.element.finaPositionX
+ : this.element.finaPositionX < this.element.initialPositionX;
+ this.element.startPixels = dx < width // If under minimum width
? (width - dx) / 2 // Start from half the empty space
: 0; // Otherwise start from the beginning
- link.startPercentage = xInverted ? link.startPixels + fillRatio * 100 : link.startPixels;
+ this.element.startPercentage = xInverted ? this.element.startPixels + fillRatio * 100 : this.element.startPixels;
const c1
- = link.startPercentage
+ = this.element.startPercentage
+ (xInverted
? LinkTemplate.c1DecreasingValue(width)
: 10
)
* fillRatio;
- let c2 = LinkTemplate.c2Clamped(xInverted ? -dx : dx) + link.startPercentage;
+ let c2 = LinkTemplate.c2Clamped(xInverted ? -dx : dx) + this.element.startPercentage;
c2 = Math.min(c2, LinkTemplate.c2DecreasingValue(width));
- link.svgPathD = Configuration.linkRightSVGPath(link.startPercentage, c1, c2);
+ this.element.svgPathD = Configuration.linkRightSVGPath(this.element.startPercentage, c1, c2);
}
/**
- * @param {LinkElement} link
* @param {Map} changedProperties
*/
- update(link, changedProperties) {
- super.update(link, changedProperties);
+ update(changedProperties) {
+ super.update(changedProperties);
if (changedProperties.has("originatesFromInput")) {
- link.style.setProperty("--ueb-from-input", link.originatesFromInput ? "1" : "0");
+ this.element.style.setProperty("--ueb-from-input", this.element.originatesFromInput ? "1" : "0");
}
- const referencePin = link.sourcePin ?? link.destinationPin;
+ const referencePin = this.element.sourcePin ?? this.element.destinationPin;
if (referencePin) {
- link.style.setProperty("--ueb-link-color-rgb", Utility.printLinearColor(referencePin.color));
+ this.element.style.setProperty("--ueb-link-color-rgb", Utility.printLinearColor(referencePin.color));
}
- link.style.setProperty("--ueb-link-start", `${Math.round(link.startPixels)}`);
- link.style.setProperty("--ueb-start-percentage", `${Math.round(link.startPercentage)}%`);
+ this.element.style.setProperty("--ueb-link-start", `${Math.round(this.element.startPixels)}`);
+ this.element.style.setProperty("--ueb-start-percentage", `${Math.round(this.element.startPercentage)}%`);
}
- /** @param {LinkElement} link */
- render(link) {
+ render() {
const uniqueId = "ueb-id-" + Math.floor(Math.random() * 1E12);
return $`
- ${link.linkMessageIcon != "" || link.linkMessageText != "" ? $`
+ ${this.element.linkMessageIcon != "" || this.element.linkMessageText != "" ? $`
-
- ${link.linkMessageText}
+
+ ${this.element.linkMessageText}
` : $``}
`
@@ -3142,41 +3118,36 @@ class PinTemplate extends ITemplate {
static styles = r$2``
- /** @param {PinElement} pin */
- connectedCallback(pin) {
- super.connectedCallback(pin);
- pin.nodeElement = pin.closest("ueb-node");
+ connectedCallback() {
+ super.connectedCallback();
+ this.element.nodeElement = this.element.closest("ueb-node");
}
- /**
- * @param {PinElement} pin
- * @returns {IInput[]}
- */
- createInputObjects(pin) {
+ /** @returns {IInput[]} */
+ createInputObjects() {
return [
- new MouseCreateLink(pin.clickableElement, pin.blueprint, {
+ new MouseCreateLink(this.element.clickableElement, this.element.blueprint, {
moveEverywhere: true,
looseTarget: true
})
]
}
- /** @param {PinElement} pin */
- render(pin) {
+ render() {
const icon = $`
- ${this.renderIcon(pin)}
+ ${this.renderIcon()}
`;
const content = $`
- ${pin.getPinDisplayName()}
- ${this.renderInput(pin)}
+ ${this.element.getPinDisplayName()}
+ ${this.renderInput()}
`;
return $`
- ${pin.isInput() ? $`${icon}${content}` : $`${content}${icon}`}
+ ${this.element.isInput() ? $`${icon}${content}` : $`${content}${icon}`}
`
}
@@ -3196,14 +3167,11 @@ class PinTemplate extends ITemplate {
return $``
}
- /**
- * @param {PinElement} pin
- * @param {Map} changedProperties
- */
- firstUpdated(pin, changedProperties) {
- super.firstUpdated(pin, changedProperties);
- pin.dataset.id = pin.GetPinIdValue();
- pin.clickableElement = pin;
+ /** @param {Map} changedProperties */
+ firstUpdated(changedProperties) {
+ super.firstUpdated(changedProperties);
+ this.element.dataset.id = this.element.GetPinIdValue();
+ this.element.clickableElement = this.element;
}
/** @param {PinElement} pin */
@@ -3240,21 +3208,20 @@ class IInputPinTemplate extends PinTemplate {
}
/**
- * @param {PinElement} pin
* @param {Map} changedProperties
*/
- firstUpdated(pin, changedProperties) {
- super.firstUpdated(pin, changedProperties);
- this.#inputContentElements = [...pin.querySelectorAll(".ueb-pin-input-content")];
+ firstUpdated(changedProperties) {
+ super.firstUpdated(changedProperties);
+ this.#inputContentElements = [...this.element.querySelectorAll(".ueb-pin-input-content")];
if (this.#inputContentElements.length) {
- this.setInputs(pin, this.getInputs(pin), false);
+ this.setInputs(this.getInputs(this.element), false);
let self = this;
- this.onFocusHandler = _ => pin.blueprint.dispatchEditTextEvent(true);
+ this.onFocusHandler = _ => this.element.blueprint.dispatchEditTextEvent(true);
this.onFocusOutHandler = e => {
e.preventDefault();
document.getSelection()?.removeAllRanges(); // Deselect text inside the input
- self.setInputs(pin, this.getInputs(pin), true);
- pin.blueprint.dispatchEditTextEvent(false);
+ self.setInputs(this.getInputs(this.element), true);
+ this.element.blueprint.dispatchEditTextEvent(false);
};
this.#inputContentElements.forEach(element => {
element.addEventListener("focus", this.onFocusHandler);
@@ -3263,30 +3230,26 @@ class IInputPinTemplate extends PinTemplate {
}
}
- /** @param {PinElement} pin */
- cleanup(pin) {
- super.cleanup(pin);
+ cleanup() {
+ super.cleanup();
this.#inputContentElements.forEach(element => {
element.removeEventListener("focus", this.onFocusHandler);
element.removeEventListener("focusout", this.onFocusOutHandler);
});
}
- /** @param {PinElement} pin */
- createInputObjects(pin) {
+ createInputObjects() {
return [
- ...super.createInputObjects(pin),
- ...this.#inputContentElements.map(element => new MouseIgnore(element, pin.blueprint))
+ ...super.createInputObjects(),
+ ...this.#inputContentElements.map(elem => new MouseIgnore(elem, this.element.blueprint))
]
}
- /** @param {PinElement} pin */
- getInput(pin) {
- return this.getInputs(pin).reduce((acc, cur) => acc + cur, "")
+ getInput() {
+ return this.getInputs(this.element).reduce((acc, cur) => acc + cur, "")
}
- /** @param {PinElement} pin */
- getInputs(pin) {
+ getInputs() {
return this.#inputContentElements.map(element =>
// Faster than innerText which causes reflow
element.innerHTML
@@ -3295,30 +3258,26 @@ class IInputPinTemplate extends PinTemplate {
)
}
- /**
- * @param {PinElement} pin
- * @param {String[]?} values
- */
- setInputs(pin, values = [], updateDefaultValue = true) {
+ /** @param {String[]?} values */
+ setInputs(values = [], updateDefaultValue = true) {
this.#inputContentElements.forEach(
- (element, i) => element.innerText = values[i]
+ (elem, i) => elem.innerText = values[i]
);
if (updateDefaultValue) {
- this.setDefaultValue(pin, values.map(v => IInputPinTemplate.stringFromInputToUE(v)), values);
+ this.setDefaultValue(values.map(v => IInputPinTemplate.stringFromInputToUE(v)), values);
}
}
- setDefaultValue(pin, values = [], rawValues = values) {
- pin.setDefaultValue(values.reduce((acc, cur) => acc + cur, ""));
+ setDefaultValue(values = [], rawValues = values) {
+ this.element.setDefaultValue(values.reduce((acc, cur) => acc + cur, ""));
}
- /** @param {PinElement} pin */
- renderInput(pin) {
- if (pin.isInput()) {
+ renderInput() {
+ if (this.element.isInput()) {
return $`
+ .innerText="${IInputPinTemplate.stringFromUEToInput(this.element.unreactiveDefaultValue.toString())}">
`
}
@@ -3333,41 +3292,35 @@ class BoolPinTemplate extends IInputPinTemplate {
/** @type {HTMLInputElement} */
#input
- /**
- * @param {PinElement} pin
- * @param {Map} changedProperties
- */
- firstUpdated(pin, changedProperties) {
- super.firstUpdated(pin, changedProperties);
- this.#input = pin.querySelector(".ueb-pin-input");
+ /** @param {Map} changedProperties */
+ firstUpdated(changedProperties) {
+ super.firstUpdated(changedProperties);
+ this.#input = this.element.querySelector(".ueb-pin-input");
let self = this;
- this.onChangeHandler = _ => pin.entity.DefaultValue = self.#input.checked ? "true" : "false";
+ this.onChangeHandler = _ => this.element.entity.DefaultValue = self.#input.checked ? "true" : "false";
this.#input.addEventListener("change", this.onChangeHandler);
}
- /** @param {PinElement} pin */
- cleanup(pin) {
- super.cleanup(pin);
+ cleanup() {
+ super.cleanup();
this.#input.removeEventListener("change", this.onChangeHandler);
}
- /** @param {PinElement} pin */
- getInputs(pin) {
+ getInputs() {
return [this.#input.checked ? "true" : "false"]
}
- setDefaultValue(pin, values = [], rawValues = values) {
- pin.setDefaultValue(values[0] == "true");
+ setDefaultValue(values = [], rawValues = values) {
+ this.element.setDefaultValue(values[0] == "true");
}
- /** @param {PinElement} pin */
- renderInput(pin) {
- if (pin.isInput()) {
+ renderInput() {
+ if (this.element.isInput()) {
return $`
-
+
`
}
- return super.renderInput(pin)
+ return super.renderInput()
}
}
@@ -3502,37 +3455,34 @@ class MouseMoveDraggable extends IMouseClickDrag {
*/
class IDraggableTemplate extends ITemplate {
- /** @param {T} element */
- getDraggableElement(element) {
- return element
+ getDraggableElement() {
+ return this.element
}
- createDraggableObject(element) {
- return new MouseMoveDraggable(element, element.blueprint, {
- draggableElement: this.getDraggableElement(element),
+ createDraggableObject() {
+ return new MouseMoveDraggable(this.element, this.element.blueprint, {
+ draggableElement: this.getDraggableElement(),
looseTarget: true,
})
}
- /** @param {T} element */
- createInputObjects(element) {
+ createInputObjects() {
return [
- ...super.createInputObjects(element),
- this.createDraggableObject(element),
+ ...super.createInputObjects(),
+ this.createDraggableObject(),
]
}
/**
- * @param {T} element
* @param {Map} changedProperties
*/
- update(element, changedProperties) {
- super.update(element, changedProperties);
+ update(changedProperties) {
+ super.update(changedProperties);
if (changedProperties.has("locationX")) {
- element.style.setProperty("--ueb-position-x", `${element.locationX}`);
+ this.element.style.setProperty("--ueb-position-x", `${this.element.locationX}`);
}
if (changedProperties.has("locationY")) {
- element.style.setProperty("--ueb-position-y", `${element.locationY}`);
+ this.element.style.setProperty("--ueb-position-y", `${this.element.locationY}`);
}
}
}
@@ -3546,30 +3496,27 @@ class WindowTemplate extends IDraggableTemplate {
toggleAdvancedDisplayHandler
- /** @param {WindowElement} element */
- getDraggableElement(element) {
- return element.querySelector(".ueb-window-top")
+ getDraggableElement() {
+ return this.element.querySelector(".ueb-window-top")
}
- createDraggableObject(element) {
- return new MouseMoveDraggable(element, element.blueprint, {
- draggableElement: this.getDraggableElement(element),
+ createDraggableObject() {
+ return new MouseMoveDraggable(this.element, this.element.blueprint, {
+ draggableElement: this.getDraggableElement(),
looseTarget: true,
stepSize: 1,
- movementSpace: element.blueprint,
+ movementSpace: this.element.blueprint,
})
}
- /** @param {T} element */
- createInputObjects(element) {
+ createInputObjects() {
return [
- ...super.createInputObjects(element),
- this.createDraggableObject(element),
+ ...super.createInputObjects(),
+ this.createDraggableObject(),
]
}
- /** @param {WindowElement} element */
- render(element) {
+ render() {
return $`
@@ -3661,23 +3608,17 @@ class LinearColorPinTemplate extends IInputPinTemplate {
/** @type {HTMLInputElement} */
#input
- /**
- * @param {PinElement} pin
- * @param {Map} changedProperties
- */
- firstUpdated(pin, changedProperties) {
- super.firstUpdated(pin, changedProperties);
- this.#input = pin.querySelector(".ueb-pin-input");
+ /** @param {Map} changedProperties */
+ firstUpdated(changedProperties) {
+ super.firstUpdated(changedProperties);
+ this.#input = this.element.querySelector(".ueb-pin-input");
}
- /**
- * @param {PinElement} pin
- * @returns {IInput[]}
- */
- createInputObjects(pin) {
+ /** @returns {IInput[]} */
+ createInputObjects() {
return [
- ...super.createInputObjects(pin),
- new MouseOpenWindow(this.#input, pin.blueprint, {
+ ...super.createInputObjects(),
+ new MouseOpenWindow(this.#input, this.element.blueprint, {
moveEverywhere: true,
looseTarget: true
})
@@ -3689,23 +3630,19 @@ class LinearColorPinTemplate extends IInputPinTemplate {
return [this.#input.dataset.linearColor]
}
- /**
- * @param {PinElement} pin
- * @param {String[]} value
- */
- setInputs(pin, value = []) {
+ /** @param {String[]} value */
+ setInputs(value = []) {
}
- /** @param {PinElement} pin */
- renderInput(pin) {
- if (pin.isInput()) {
+ renderInput() {
+ if (this.element.isInput()) {
return $`
-
+
`
}
- return super.renderInput(pin)
+ return super.renderInput()
}
}
@@ -3720,8 +3657,8 @@ class NamePinTemplate extends IInputPinTemplate {
* @param {PinElement} pin
* @param {Map} changedProperties
*/
- firstUpdated(pin, changedProperties) {
- super.firstUpdated(pin, changedProperties);
+ firstUpdated(changedProperties) {
+ super.firstUpdated(changedProperties);
this.onInputHandler = e => {
e.stopPropagation();
if (
@@ -3738,9 +3675,8 @@ class NamePinTemplate extends IInputPinTemplate {
});
}
- /** @param {PinElement} pin */
- cleanup(pin) {
- super.cleanup(pin);
+ cleanup() {
+ super.cleanup();
this.inputContentElements.forEach(element => {
element.removeEventListener("input", /** @type {(e : Event) => void} */(this.onInputHandler));
});
@@ -3751,13 +3687,10 @@ class NamePinTemplate extends IInputPinTemplate {
return this.inputContentElements.map(element => element.textContent) // textContent for performance reason
}
- /**
- * @param {PinElement} pin
- * @param {String[]?} values
- */
- setInputs(pin, values = [], updateDefaultValue = true) {
+ /** @param {String[]?} values */
+ setInputs(values = [], updateDefaultValue = true) {
values = values.map(value => value.replaceAll("\n", "")); // get rid of the new lines
- super.setInputs(pin, values, updateDefaultValue);
+ super.setInputs(values, updateDefaultValue);
}
}
@@ -3765,21 +3698,17 @@ class NamePinTemplate extends IInputPinTemplate {
class RealPinTemplate extends IInputPinTemplate {
- /**
- * @param {PinElement} pin
- * @param {String[]?} values
- */
- setInputs(pin, values = [], updateDefaultValue = false) {
+ setInputs(values = [], updateDefaultValue = false) {
if (!values || values.length == 0) {
- values = this.getInput(pin);
+ values = this.getInput();
}
let parsedValues = [];
for (let i = 0; i < values.length; ++i) {
let num = parseFloat(values[i]);
if (isNaN(num)) {
- num = parseFloat(pin.entity.DefaultValue != ""
- ? /** @type {String} */(pin.entity.DefaultValue)
- : pin.entity.AutogeneratedDefaultValue);
+ num = parseFloat(this.element.entity.DefaultValue != ""
+ ? /** @type {String} */(this.element.entity.DefaultValue)
+ : this.element.entity.AutogeneratedDefaultValue);
}
if (isNaN(num)) {
num = 0;
@@ -3788,12 +3717,12 @@ class RealPinTemplate extends IInputPinTemplate {
parsedValues.push(num);
values[i] = Utility.minDecimals(num);
}
- super.setInputs(pin, values, false);
- this.setDefaultValue(pin, parsedValues, values);
+ super.setInputs(values, false);
+ this.setDefaultValue(parsedValues, values);
}
- setDefaultValue(pin, values = [], rawValues = values) {
- pin.setDefaultValue(values[0]);
+ setDefaultValue(values = [], rawValues = values) {
+ this.element.setDefaultValue(values[0]);
}
}
@@ -3807,35 +3736,34 @@ class StringPinTemplate extends IInputPinTemplate {
class VectorPinTemplate extends RealPinTemplate {
- setDefaultValue(pin, values = [], rawValues = values) {
- if (!(pin.entity.DefaultValue instanceof VectorEntity)) {
+ setDefaultValue(values = [], rawValues = values) {
+ if (!(this.element.entity.DefaultValue instanceof VectorEntity)) {
throw new TypeError("Expected DefaultValue to be a VectorEntity")
}
- let vector = pin.entity.DefaultValue;
+ let vector = this.element.entity.DefaultValue;
vector.X = values[0];
vector.Y = values[1];
vector.Z = values[2];
}
- /** @param {PinElement} pin */
- renderInput(pin) {
- if (pin.isInput()) {
+ renderInput() {
+ if (this.element.isInput()) {
return $`
`
@@ -3846,8 +3774,7 @@ class VectorPinTemplate extends RealPinTemplate {
class ReferencePinTemplate extends PinTemplate {
- /** @param {PinElement} pin */
- renderIcon(pin) {
+ renderIcon() {
return $`
- ${node.enabledState?.toString() == "DevelopmentOnly" ? $`
+ ${this.element.enabledState?.toString() == "DevelopmentOnly" ? $`
Development Only
` : $``}
- ${node.advancedPinDisplay ? $`
+ ${this.element.advancedPinDisplay ? $`