mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-20 05:24:52 +08:00
Links improved, refactoring
This commit is contained in:
58
js/graph/GraphLinkMessage.js
Normal file
58
js/graph/GraphLinkMessage.js
Normal file
@@ -0,0 +1,58 @@
|
||||
import LinkMessageTemplate from "../template/LinkMessageTemplate";
|
||||
import GraphElement from "./GraphElement";
|
||||
|
||||
/**
|
||||
* @typedef {import("./GraphPin").default} GraphPin
|
||||
* @typedef {import("./GraphLink").default} GraphLink
|
||||
* @typedef {(sourcePin: GraphPin, sourcePin: GraphPin) => String} LinkRetrieval
|
||||
*/
|
||||
export default class GraphLinkMessage extends GraphElement {
|
||||
|
||||
static tagName = "ueb-link-message"
|
||||
static CONVERT_TYPE = _ => new GraphLinkMessage(
|
||||
"ueb-icon-conver-type",
|
||||
/** @type {LinkRetrieval} */
|
||||
(s, d) => `Convert ${s.getType()} to ${d.getType()}.`
|
||||
)
|
||||
static DIRECTIONS_INCOMPATIBLE = _ => new GraphLinkMessage(
|
||||
"ueb-icon-directions-incompatible",
|
||||
/** @type {LinkRetrieval} */
|
||||
(s, d) => "Directions are not compatbile."
|
||||
)
|
||||
static PLACE_NODE = _ => new GraphLinkMessage(
|
||||
"ueb-icon-place-node",
|
||||
/** @type {LinkRetrieval} */
|
||||
(s, d) => "Place a new node."
|
||||
)
|
||||
static REPLACE_LiNK = _ => new GraphLinkMessage(
|
||||
"ueb-icon-replace-link",
|
||||
/** @type {LinkRetrieval} */
|
||||
(s, d) => "Replace existing input connections."
|
||||
)
|
||||
static SAME_NODE = _ => new GraphLinkMessage(
|
||||
"ueb-icon-same-node",
|
||||
/** @type {LinkRetrieval} */
|
||||
(s, d) => "Both are on the same node."
|
||||
)
|
||||
static TYPES_INCOMPATIBLE = _ => new GraphLinkMessage(
|
||||
"ueb-icon-types-incompatible",
|
||||
/** @type {LinkRetrieval} */
|
||||
(s, d) => `${s.getType()} is not compatible with ${d.getType()}.`
|
||||
)
|
||||
|
||||
/** @type {String} */
|
||||
icon
|
||||
/** @type {String} */
|
||||
message
|
||||
/** @type {GraphLink} */
|
||||
linkElement
|
||||
|
||||
constructor(icon, message) {
|
||||
super({}, new LinkMessageTemplate())
|
||||
this.icon = icon
|
||||
this.message = message
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
customElements.define(GraphLinkMessage.tagName, GraphLinkMessage)
|
||||
Reference in New Issue
Block a user