Various fixes

This commit is contained in:
barsdeveloper
2022-03-28 23:04:24 +02:00
parent ca5948792a
commit a0eeca11d1
73 changed files with 446 additions and 125 deletions

View File

@@ -1,3 +1,5 @@
// @ts-check
/**
* @typedef {import("../Blueprint").default} Blueprint
* @typedef {import("../entity/IEntity").default} IEntity
@@ -53,12 +55,12 @@ export default class IElement extends HTMLElement {
}
/**
* @template {} T
* @param {new () => T} type
* @template {IContext} T
* @param {new (...args: any[]) => T} type
* @returns {T}
*/
getInputObject(type) {
return this.inputObjects.find(object => object.constructor == type)
return /** @type {T} */ (this.inputObjects.find(object => object.constructor == type))
}
// Subclasses will want to override

View File

@@ -1,12 +1,16 @@
// @ts-check
import Configuration from "../Configuration"
import IElement from "./IElement"
import MouseMoveNodes from "../input/mouse/MouseMoveNodes"
/** @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate */
/**
* @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate
*/
export default class ISelectableDraggableElement extends IElement {
constructor(...args) {
// @ts-expect-error
super(...args)
this.dragObject = null
this.location = [0, 0]
@@ -28,6 +32,9 @@ export default class ISelectableDraggableElement extends IElement {
]
}
/**
* @param {Number[]} value
*/
setLocation(value = [0, 0]) {
const d = [value[0] - this.location[0], value[1] - this.location[1]]
const dragLocalEvent = new CustomEvent(Configuration.nodeDragLocalEventName, {

View File

@@ -1,3 +1,5 @@
// @ts-check
import Configuration from "../Configuration"
import IElement from "./IElement"
import LinkTemplate from "../template/LinkTemplate"
@@ -86,7 +88,7 @@ export default class LinkElement extends IElement {
/**
* @param {Number[]} location
*/
setSourceLocation(location) {
setSourceLocation(location = null) {
if (location == null) {
location = this.#source.template.getLinkLocation(this.#source)
}
@@ -115,7 +117,7 @@ export default class LinkElement extends IElement {
/**
* @param {Number[]} location
*/
setDestinationLocation(location) {
setDestinationLocation(location = null) {
if (location == null) {
location = this.#destination.template.getLinkLocation(this.#destination)
}

View File

@@ -1,10 +1,12 @@
// @ts-check
import IElement from "./IElement"
import LinkMessageTemplate from "../template/LinkMessageTemplate"
/**
* @typedef {import("./PinElement").default} PinElement
* @typedef {import("./LinkElement").default} LinkElement
* @typedef {(sourcePin: PinElement, sourcePin: PinElement) => String} LinkRetrieval
* @typedef {(sourcePin: PinElement, destinationPin: PinElement) => String} LinkRetrieval
*/
export default class LinkMessageElement extends IElement {

View File

@@ -1,3 +1,5 @@
// @ts-check
import Configuration from "../Configuration"
import ISelectableDraggableElement from "./ISelectableDraggableElement"
import NodeTemplate from "../template/NodeTemplate"

View File

@@ -1,3 +1,5 @@
// @ts-check
import IElement from "./IElement"
import MouseCreateLink from "../input/mouse/MouseCreateLink"
import PinTemplate from "../template/PinTemplate"

View File

@@ -1,3 +1,5 @@
// @ts-check
import FastSelectionModel from "../selection/FastSelectionModel"
import IElement from "./IElement"
import SelectorTemplate from "../template/SelectorTemplate"