@openremote/or-rules 1.8.0-snapshot.20250725120001 → 1.8.0-snapshot.20250725123024
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -30
- package/custom-elements.json +13 -13
- package/dist/umd/index.bundle.js +4744 -4744
- package/dist/umd/index.bundle.js.map +1 -1
- package/lib/flow-viewer/components/confirmation-dialog.js +24 -61
- package/lib/flow-viewer/components/connection-container.js +1 -35
- package/lib/flow-viewer/components/connection-line.js +28 -117
- package/lib/flow-viewer/components/context-menu.js +45 -140
- package/lib/flow-viewer/components/editor-workspace.js +20 -282
- package/lib/flow-viewer/components/flow-editor.js +47 -160
- package/lib/flow-viewer/components/flow-node-socket.js +31 -146
- package/lib/flow-viewer/components/flow-node.js +29 -192
- package/lib/flow-viewer/components/internal-picker.js +54 -271
- package/lib/flow-viewer/components/node-menu-item.js +32 -132
- package/lib/flow-viewer/components/node-panel.js +60 -104
- package/lib/flow-viewer/components/notification-dialog.js +23 -55
- package/lib/flow-viewer/components/popup-modal.js +54 -113
- package/lib/flow-viewer/components/rule-browser.js +30 -119
- package/lib/flow-viewer/components/selectable-element.js +1 -71
- package/lib/flow-viewer/components/selection-box.js +15 -119
- package/lib/flow-viewer/components/top-bar.js +49 -116
- package/lib/flow-viewer/components/workspace-contextmenu-options.js +5 -128
- package/lib/flow-viewer/components/writable-dropdown.js +5 -51
- package/lib/flow-viewer/converters/node-converter.js +1 -10
- package/lib/flow-viewer/flow-viewer.js +1 -19
- package/lib/flow-viewer/models/camera.js +1 -2
- package/lib/flow-viewer/models/context-menu-button.js +1 -2
- package/lib/flow-viewer/models/light-node-collection.js +1 -2
- package/lib/flow-viewer/models/status.js +1 -8
- package/lib/flow-viewer/node-structure/copy.machine.js +1 -34
- package/lib/flow-viewer/node-structure/identity.assigner.js +1 -10
- package/lib/flow-viewer/node-structure/identity.dom.link.js +1 -4
- package/lib/flow-viewer/node-structure/index.js +1 -5
- package/lib/flow-viewer/node-structure/socket.type.matcher.js +1 -50
- package/lib/flow-viewer/node-structure/utils.js +1 -109
- package/lib/flow-viewer/services/copy-paste-manager.js +1 -59
- package/lib/flow-viewer/services/exporter.js +1 -67
- package/lib/flow-viewer/services/input.js +1 -80
- package/lib/flow-viewer/services/integration.js +1 -27
- package/lib/flow-viewer/services/modal.js +8 -29
- package/lib/flow-viewer/services/project.js +1 -222
- package/lib/flow-viewer/services/shortcuts.js +1 -63
- package/lib/flow-viewer/styles/editor-workspace-style.js +53 -55
- package/lib/flow-viewer/styles/flow-node-style.js +93 -95
- package/lib/flow-viewer/styles/picker-styles.js +29 -31
- package/lib/flow-viewer/utils.js +1 -49
- package/lib/index.js +56 -953
- package/lib/json-viewer/forms/or-rule-form-alarm.js +18 -91
- package/lib/json-viewer/forms/or-rule-form-email-message.js +12 -51
- package/lib/json-viewer/forms/or-rule-form-localized.js +43 -269
- package/lib/json-viewer/forms/or-rule-form-push-notification.js +63 -152
- package/lib/json-viewer/forms/or-rule-form-webhook.js +101 -296
- package/lib/json-viewer/modals/or-rule-alarm-modal.js +17 -173
- package/lib/json-viewer/modals/or-rule-notification-modal.js +11 -196
- package/lib/json-viewer/modals/or-rule-radial-modal.js +17 -142
- package/lib/json-viewer/modals/or-rule-webhook-modal.js +8 -78
- package/lib/json-viewer/or-rule-action-alarm.js +5 -97
- package/lib/json-viewer/or-rule-action-attribute.js +33 -235
- package/lib/json-viewer/or-rule-action-notification.js +56 -465
- package/lib/json-viewer/or-rule-action-webhook.js +18 -49
- package/lib/json-viewer/or-rule-asset-query.js +126 -849
- package/lib/json-viewer/or-rule-condition.js +29 -216
- package/lib/json-viewer/or-rule-json-viewer.js +34 -393
- package/lib/json-viewer/or-rule-then-otherwise.js +113 -609
- package/lib/json-viewer/or-rule-trigger-query.js +57 -227
- package/lib/json-viewer/or-rule-when.js +126 -343
- package/lib/or-rule-group-viewer.js +12 -106
- package/lib/or-rule-text-viewer.js +22 -133
- package/lib/or-rule-tree.js +57 -601
- package/lib/or-rule-validity.js +62 -373
- package/lib/or-rule-viewer.js +81 -361
- package/lib/style.js +64 -89
- package/package.json +11 -11
|
@@ -1,150 +1,35 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { LitElement, html, css } from "lit";
|
|
8
|
-
import { customElement, property, query } from "lit/decorators.js";
|
|
9
|
-
import { IdentityDomLink } from "../node-structure";
|
|
10
|
-
import { Utilities } from "../utils";
|
|
11
|
-
import { i18next, translate } from "@openremote/or-translate";
|
|
12
|
-
import { project } from "./flow-editor";
|
|
13
|
-
let FlowNodeSocket = class FlowNodeSocket extends translate(i18next)(LitElement) {
|
|
14
|
-
constructor() {
|
|
15
|
-
super(...arguments);
|
|
16
|
-
this.renderLabel = false;
|
|
17
|
-
this.identityDeleted = false;
|
|
18
|
-
this.forceUpdate = () => this.requestUpdate();
|
|
19
|
-
}
|
|
20
|
-
get connectionPosition() {
|
|
21
|
-
return Utilities.getCenter(this.circleElem.getBoundingClientRect());
|
|
22
|
-
}
|
|
23
|
-
static get styles() {
|
|
24
|
-
return css `
|
|
25
|
-
:host{
|
|
26
|
-
width: auto;
|
|
27
|
-
height: var(--socket-size);
|
|
28
|
-
margin: 2px;
|
|
29
|
-
display: inline-block;
|
|
30
|
-
}
|
|
31
|
-
.socket{
|
|
32
|
-
background: none;
|
|
33
|
-
height: var(--socket-size);
|
|
34
|
-
width: var(--socket-size);
|
|
35
|
-
border-radius: 100%;
|
|
36
|
-
display: inline-flex;
|
|
37
|
-
justify-content: center;
|
|
38
|
-
align-items: center;
|
|
39
|
-
}
|
|
40
|
-
.socket:hover{
|
|
41
|
-
background: var(--highlight);
|
|
42
|
-
}
|
|
43
|
-
.label{
|
|
44
|
-
display:inline-block;
|
|
45
|
-
vertical-align: top;
|
|
46
|
-
color: rgba(0,0,0,.5);
|
|
47
|
-
}
|
|
48
|
-
.circle{
|
|
49
|
-
box-sizing: border-box;
|
|
50
|
-
background: grey;
|
|
51
|
-
width: var(--socket-display-size);
|
|
52
|
-
height: var(--socket-display-size);
|
|
53
|
-
border-radius: 100%;
|
|
54
|
-
pointer-events: none;
|
|
55
|
-
border: 1px solid rgb(80,80,80);
|
|
56
|
-
}`;
|
|
57
|
-
}
|
|
58
|
-
get socketTypeString() {
|
|
59
|
-
const socketType = this.socket.type.toString().toLowerCase();
|
|
60
|
-
// If the socket type is NUMBER_ARRAY, remove the array part, since we only allow the input of NUMBER into that
|
|
61
|
-
// socket, just multiple ones. Also helps with displaying the correct color.
|
|
62
|
-
return socketType.replace("_array", "");
|
|
63
|
-
}
|
|
64
|
-
disconnectedCallback() {
|
|
65
|
-
this.identityDeleted = delete IdentityDomLink.map[this.socket.id];
|
|
66
|
-
project.removeListener("connectioncreated", this.forceUpdate);
|
|
67
|
-
project.removeListener("connectionremoved", this.forceUpdate);
|
|
68
|
-
project.removeListener("nodeadded", this.forceUpdate);
|
|
69
|
-
project.removeListener("noderemoved", this.forceUpdate);
|
|
70
|
-
project.removeListener("cleared", this.forceUpdate);
|
|
71
|
-
IdentityDomLink.map[this.socket.nodeId].removeEventListener("updated", this.forceUpdate);
|
|
72
|
-
}
|
|
73
|
-
firstUpdated() {
|
|
74
|
-
this.title = Utilities.humanLike(this.socketTypeString);
|
|
75
|
-
this.linkIdentity();
|
|
76
|
-
project.addListener("connectioncreated", this.forceUpdate);
|
|
77
|
-
project.addListener("connectionremoved", this.forceUpdate);
|
|
78
|
-
project.addListener("nodeadded", this.forceUpdate);
|
|
79
|
-
project.addListener("noderemoved", this.forceUpdate);
|
|
80
|
-
project.addListener("cleared", this.forceUpdate);
|
|
81
|
-
IdentityDomLink.map[this.socket.nodeId].addEventListener("updated", this.forceUpdate);
|
|
82
|
-
const isInputSocket = this.side === "input";
|
|
83
|
-
const md = (e) => {
|
|
84
|
-
this.linkIdentity();
|
|
85
|
-
if (e.buttons !== 1) {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
if (project.isCurrentlyConnecting) {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
project.startConnectionDrag(e, this.socket, isInputSocket);
|
|
92
|
-
e.stopPropagation();
|
|
93
|
-
e.stopImmediatePropagation();
|
|
94
|
-
};
|
|
95
|
-
const mu = (e) => {
|
|
96
|
-
project.createUndoSnapshot();
|
|
97
|
-
this.linkIdentity();
|
|
98
|
-
project.endConnectionDrag(e, this.socket, isInputSocket);
|
|
99
|
-
project.notifyChange();
|
|
100
|
-
if (e.buttons !== 1) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
e.stopPropagation();
|
|
104
|
-
e.stopImmediatePropagation();
|
|
105
|
-
};
|
|
106
|
-
this.addEventListener("mousedown", md);
|
|
107
|
-
this.addEventListener("mouseup", mu);
|
|
108
|
-
}
|
|
109
|
-
updated() {
|
|
110
|
-
this.linkIdentity();
|
|
111
|
-
}
|
|
112
|
-
render() {
|
|
113
|
-
const color = `var(--${this.socketTypeString})`;
|
|
114
|
-
const socket = html `<div class="socket">
|
|
115
|
-
<div class="circle" id="circle" style="background: ${color}"></div>
|
|
116
|
-
</div>`;
|
|
117
|
-
if (!this.renderLabel) {
|
|
118
|
-
return socket;
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,i){var r,d=arguments.length,n=d<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(n=(d<3?r(n):d>3?r(t,o,n):r(t,o))||n);return d>3&&n&&Object.defineProperty(t,o,n),n};import{LitElement as e,html as t,css as o}from"lit";import{customElement as i,property as r,query as d}from"lit/decorators.js";import{IdentityDomLink as n}from"../node-structure";import{Utilities as s}from"../utils";import{i18next as c,translate as a}from"@openremote/or-translate";import{project as l}from"./flow-editor";let FlowNodeSocket=class extends a(c)(e){constructor(){super(...arguments),this.renderLabel=!1,this.identityDeleted=!1,this.forceUpdate=()=>this.requestUpdate()}get connectionPosition(){return s.getCenter(this.circleElem.getBoundingClientRect())}static get styles(){return o`
|
|
2
|
+
:host{
|
|
3
|
+
width: auto;
|
|
4
|
+
height: var(--socket-size);
|
|
5
|
+
margin: 2px;
|
|
6
|
+
display: inline-block;
|
|
119
7
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
8
|
+
.socket{
|
|
9
|
+
background: none;
|
|
10
|
+
height: var(--socket-size);
|
|
11
|
+
width: var(--socket-size);
|
|
12
|
+
border-radius: 100%;
|
|
13
|
+
display: inline-flex;
|
|
14
|
+
justify-content: center;
|
|
15
|
+
align-items: center;
|
|
123
16
|
}
|
|
124
|
-
|
|
125
|
-
|
|
17
|
+
.socket:hover{
|
|
18
|
+
background: var(--highlight);
|
|
126
19
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
20
|
+
.label{
|
|
21
|
+
display:inline-block;
|
|
22
|
+
vertical-align: top;
|
|
23
|
+
color: rgba(0,0,0,.5);
|
|
131
24
|
}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
], FlowNodeSocket.prototype, "renderLabel", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
query("#circle")
|
|
145
|
-
], FlowNodeSocket.prototype, "circleElem", void 0);
|
|
146
|
-
FlowNodeSocket = __decorate([
|
|
147
|
-
customElement("flow-node-socket")
|
|
148
|
-
], FlowNodeSocket);
|
|
149
|
-
export { FlowNodeSocket };
|
|
150
|
-
//# sourceMappingURL=flow-node-socket.js.map
|
|
25
|
+
.circle{
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
background: grey;
|
|
28
|
+
width: var(--socket-display-size);
|
|
29
|
+
height: var(--socket-display-size);
|
|
30
|
+
border-radius: 100%;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
border: 1px solid rgb(80,80,80);
|
|
33
|
+
}`}get socketTypeString(){return this.socket.type.toString().toLowerCase().replace("_array","")}disconnectedCallback(){this.identityDeleted=delete n.map[this.socket.id],l.removeListener("connectioncreated",this.forceUpdate),l.removeListener("connectionremoved",this.forceUpdate),l.removeListener("nodeadded",this.forceUpdate),l.removeListener("noderemoved",this.forceUpdate),l.removeListener("cleared",this.forceUpdate),n.map[this.socket.nodeId].removeEventListener("updated",this.forceUpdate)}firstUpdated(){this.title=s.humanLike(this.socketTypeString),this.linkIdentity(),l.addListener("connectioncreated",this.forceUpdate),l.addListener("connectionremoved",this.forceUpdate),l.addListener("nodeadded",this.forceUpdate),l.addListener("noderemoved",this.forceUpdate),l.addListener("cleared",this.forceUpdate),n.map[this.socket.nodeId].addEventListener("updated",this.forceUpdate);let e="input"===this.side;this.addEventListener("mousedown",t=>{this.linkIdentity(),1===t.buttons&&(l.isCurrentlyConnecting||(l.startConnectionDrag(t,this.socket,e),t.stopPropagation(),t.stopImmediatePropagation()))}),this.addEventListener("mouseup",t=>{l.createUndoSnapshot(),this.linkIdentity(),l.endConnectionDrag(t,this.socket,e),l.notifyChange(),1===t.buttons&&(t.stopPropagation(),t.stopImmediatePropagation())})}updated(){this.linkIdentity()}render(){let e=`var(--${this.socketTypeString})`,o=t`<div class="socket">
|
|
34
|
+
<div class="circle" id="circle" style="background: ${e}"></div>
|
|
35
|
+
</div>`;if(!this.renderLabel)return o;let i=t`<div class="label">${c.t(s.humanLike(this.socket.name))}</div>`;return"input"===this.side?t`${o}${i}`:t`${i}${o}`}linkIdentity(){this.identityDeleted||(n.map[this.socket.id]=this)}};__decorate([r({type:Object})],FlowNodeSocket.prototype,"socket",void 0),__decorate([r({type:String})],FlowNodeSocket.prototype,"side",void 0),__decorate([r({type:Boolean})],FlowNodeSocket.prototype,"renderLabel",void 0),__decorate([d("#circle")],FlowNodeSocket.prototype,"circleElem",void 0),FlowNodeSocket=__decorate([i("flow-node-socket")],FlowNodeSocket);export{FlowNodeSocket};
|
|
@@ -1,194 +1,31 @@
|
|
|
1
|
-
var __decorate = (
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
8
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
9
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
10
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
11
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
12
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
13
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
14
|
-
});
|
|
15
|
-
};
|
|
16
|
-
import { css, html } from "lit";
|
|
17
|
-
import { customElement, property } from "lit/decorators.js";
|
|
18
|
-
import { IdentityDomLink } from "../node-structure";
|
|
19
|
-
import { FlowNodeStyle } from "../styles/flow-node-style";
|
|
20
|
-
import { i18next } from "@openremote/or-translate";
|
|
21
|
-
import { nodeConverter } from "../converters/node-converter";
|
|
22
|
-
import { SelectableElement } from "./selectable-element";
|
|
23
|
-
import { newIds, project } from "./flow-editor";
|
|
24
|
-
let FlowNode = class FlowNode extends SelectableElement {
|
|
25
|
-
constructor() {
|
|
26
|
-
super();
|
|
27
|
-
this.frozen = false;
|
|
28
|
-
this.minimal = false;
|
|
29
|
-
this.isBeingDragged = false;
|
|
30
|
-
this.forceUpdate = () => { this.requestUpdate(); };
|
|
31
|
-
this.setTranslate = () => {
|
|
32
|
-
const pos = this.workspace.worldToOffset(this.node.position);
|
|
33
|
-
this.style.transform = `translate(${pos.x}px, ${pos.y}px) scale(${this.workspace.camera.zoom})`;
|
|
34
|
-
this.dispatchEvent(new CustomEvent("updated"));
|
|
35
|
-
};
|
|
36
|
-
this.startDrag = (e) => {
|
|
37
|
-
if (this.frozen) {
|
|
38
|
-
return;
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,i,o){var n,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,i):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,i,o);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(r=(s<3?n(r):s>3?n(t,i,r):n(t,i))||r);return s>3&&r&&Object.defineProperty(t,i,r),r},__awaiter=this&&this.__awaiter||function(e,t,i,o){return new(i||(i=Promise))(function(n,s){function r(e){try{d(o.next(e))}catch(e){s(e)}}function a(e){try{d(o.throw(e))}catch(e){s(e)}}function d(e){var t;e.done?n(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(r,a)}d((o=o.apply(e,t||[])).next())})};import{css as e,html as t}from"lit";import{customElement as i,property as o}from"lit/decorators.js";import{IdentityDomLink as n}from"../node-structure";import{FlowNodeStyle as s}from"../styles/flow-node-style";import{i18next as r}from"@openremote/or-translate";import{nodeConverter as a}from"../converters/node-converter";import{SelectableElement as d}from"./selectable-element";import{newIds as l,project as h}from"./flow-editor";let FlowNode=class extends d{constructor(){super(),this.frozen=!1,this.minimal=!1,this.isBeingDragged=!1,this.forceUpdate=()=>{this.requestUpdate()},this.setTranslate=()=>{let e=this.workspace.worldToOffset(this.node.position);this.style.transform=`translate(${e.x}px, ${e.y}px) scale(${this.workspace.camera.zoom})`,this.dispatchEvent(new CustomEvent("updated"))},this.startDrag=e=>{this.frozen||1===e.buttons&&(h.createUndoSnapshot(),this.bringToFront(),window.addEventListener("mouseup",this.stopDrag),window.addEventListener("mousemove",this.onDrag),this.isBeingDragged=!0)},this.onDrag=e=>{this.node.position={x:this.node.position.x+e.movementX/this.workspace.camera.zoom,y:this.node.position.y+e.movementY/this.workspace.camera.zoom},this.setTranslate()},this.stopDrag=()=>{window.removeEventListener("mouseup",this.stopDrag),window.removeEventListener("mousemove",this.onDrag),this.isBeingDragged=!1,h.notifyChange()},this.linkIdentity=()=>{n.map[this.node.id]=this}}static get styles(){return[s,e`
|
|
2
|
+
.internal-item {
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
align-items: flex-start;
|
|
6
|
+
flex: 0 0 auto;
|
|
39
7
|
}
|
|
40
|
-
|
|
41
|
-
|
|
8
|
+
.internal-title {
|
|
9
|
+
font-size: 0.8em;
|
|
10
|
+
margin-bottom: 0;
|
|
11
|
+
margin-top:3px;
|
|
12
|
+
text-align: left;
|
|
42
13
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
};
|
|
62
|
-
this.linkIdentity = () => {
|
|
63
|
-
IdentityDomLink.map[this.node.id] = this;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
static get styles() {
|
|
67
|
-
return [FlowNodeStyle,
|
|
68
|
-
css `
|
|
69
|
-
.internal-item {
|
|
70
|
-
display: flex;
|
|
71
|
-
flex-direction: column;
|
|
72
|
-
align-items: flex-start;
|
|
73
|
-
flex: 0 0 auto;
|
|
74
|
-
}
|
|
75
|
-
.internal-title {
|
|
76
|
-
font-size: 0.8em;
|
|
77
|
-
margin-bottom: 0;
|
|
78
|
-
margin-top:3px;
|
|
79
|
-
text-align: left;
|
|
80
|
-
}
|
|
81
|
-
`];
|
|
82
|
-
}
|
|
83
|
-
disconnectedCallback() {
|
|
84
|
-
this.workspace.removeEventListener("pan", this.setTranslate);
|
|
85
|
-
this.workspace.removeEventListener("zoom", this.setTranslate);
|
|
86
|
-
project.removeListener("cleared", this.forceUpdate);
|
|
87
|
-
project.removeListener("connectionremoved", this.linkIdentity);
|
|
88
|
-
super.disconnectedCallback();
|
|
89
|
-
}
|
|
90
|
-
bringToFront() {
|
|
91
|
-
if (this.frozen) {
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
this.style.zIndex = `${this.workspace.topNodeZindex++}`;
|
|
95
|
-
}
|
|
96
|
-
firstUpdated() {
|
|
97
|
-
const _super = Object.create(null, {
|
|
98
|
-
firstUpdated: { get: () => super.firstUpdated }
|
|
99
|
-
});
|
|
100
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
101
|
-
_super.firstUpdated.call(this);
|
|
102
|
-
this.linkIdentity();
|
|
103
|
-
this.workspace.addEventListener("pan", this.setTranslate);
|
|
104
|
-
this.workspace.addEventListener("zoom", this.setTranslate);
|
|
105
|
-
project.addListener("cleared", this.forceUpdate);
|
|
106
|
-
project.addListener("connectionremoved", this.linkIdentity);
|
|
107
|
-
this.minimal = (this.node.displayCharacter || "").length !== 0;
|
|
108
|
-
this.bringToFront();
|
|
109
|
-
if (newIds.has(this.node.id)) { // node centering has to keep track of which nodes were created by the user
|
|
110
|
-
yield this.updateComplete;
|
|
111
|
-
yield this.updateComplete;
|
|
112
|
-
const size = this.getBoundingClientRect();
|
|
113
|
-
this.node.position.x -= size.width / 2 / this.workspace.camera.zoom;
|
|
114
|
-
this.node.position.y -= size.height / 2 / this.workspace.camera.zoom;
|
|
115
|
-
this.setTranslate();
|
|
116
|
-
newIds.delete(this.node.id);
|
|
117
|
-
}
|
|
118
|
-
if (this.minimal) {
|
|
119
|
-
this.addEventListener("mousedown", this.startDrag);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
updated() {
|
|
124
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
125
|
-
this.linkIdentity();
|
|
126
|
-
this.dispatchEvent(new CustomEvent("updated"));
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
render() {
|
|
130
|
-
if (this.minimal) {
|
|
131
|
-
this.style.background = `var(--${this.node.type.toLowerCase()}-color)`;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
this.style.background = "";
|
|
135
|
-
}
|
|
136
|
-
this.setTranslate();
|
|
137
|
-
this.style.boxShadow = this.selected ? "var(--highlight) 0 0 0 3px" : "";
|
|
138
|
-
const title = this.minimal ?
|
|
139
|
-
html `<div class="title minimal" ?singlechar="${this.node.displayCharacter.length === 1}">${i18next.t("flow." + this.node.displayCharacter, this.node.displayCharacter)}</div>` :
|
|
140
|
-
html `<div class="title ${this.node.type.toLowerCase()}" @mousedown="${this.startDrag}">${i18next.t("flow." + this.node.name) || "invalid"}</div>`;
|
|
141
|
-
const inputSide = html `<div class="socket-side inputs">${this.node.inputs.map((i) => html `<flow-node-socket ?renderlabel="${!this.minimal}" .socket="${i}" side="input"></flow-node-socket>`)}</div>`;
|
|
142
|
-
const outputSide = html `<div class="socket-side outputs">${this.node.outputs.map((i) => html `<flow-node-socket ?renderlabel="${!this.minimal}" .socket="${i}" side="output"></flow-node-socket>`)}</div>`;
|
|
143
|
-
const spacer = html `<div style="width: 10px"></div>`;
|
|
144
|
-
// Gather the elements between NEW_LINES in distinct groups, that can then be iterated per-group and per-element below. Should help with adding as many internals in any configuration we would like.
|
|
145
|
-
return html `
|
|
146
|
-
${title}
|
|
147
|
-
${this.node.inputs.length > 0 ? inputSide : spacer}
|
|
148
|
-
${(this.minimal) ? null : html `
|
|
149
|
-
<div class="internal-container" style="padding-top: 8px">
|
|
150
|
-
${this.node.internals.reduce((acc, i, index, array) => {
|
|
151
|
-
acc[acc.length - 1].push(i);
|
|
152
|
-
if (i.breakType === "NEW_LINE" /* NodeInternalBreakType.NEW_LINE */ && index < array.length - 1) {
|
|
153
|
-
acc.push([]);
|
|
154
|
-
}
|
|
155
|
-
return acc;
|
|
156
|
-
}, [[]]).map((group) => html `
|
|
157
|
-
<div class="internal-group" style="max-width: fit-content; min-width: fit-content; padding-bottom: 8px;">
|
|
158
|
-
${group.map((i) => html `
|
|
159
|
-
<div class="internal-item" style="display: inline-block">
|
|
160
|
-
<internal-picker style="pointer-events: ${(this.frozen ? "none" : "normal")};" @picked="${() => __awaiter(this, void 0, void 0, function* () {
|
|
161
|
-
this.forceUpdate();
|
|
162
|
-
yield this.updateComplete;
|
|
163
|
-
project.removeInvalidConnections();
|
|
164
|
-
})}" .node="${this.node}" .internalIndex="${this.node.internals.indexOf(i)}"></internal-picker>
|
|
165
|
-
</div>
|
|
166
|
-
`)}
|
|
167
|
-
</div>
|
|
168
|
-
`)}
|
|
169
|
-
</div>`}
|
|
170
|
-
${this.node.outputs.length > 0 ? outputSide : spacer}
|
|
171
|
-
${(this.frozen ? html `<or-icon class="lock-icon ${this.node.type.toLowerCase()}" icon="lock"></or-icon>` : ``)}
|
|
172
|
-
`;
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
__decorate([
|
|
176
|
-
property({ converter: nodeConverter })
|
|
177
|
-
], FlowNode.prototype, "node", void 0);
|
|
178
|
-
__decorate([
|
|
179
|
-
property({ attribute: false })
|
|
180
|
-
], FlowNode.prototype, "workspace", void 0);
|
|
181
|
-
__decorate([
|
|
182
|
-
property({ type: Boolean, reflect: true })
|
|
183
|
-
], FlowNode.prototype, "frozen", void 0);
|
|
184
|
-
__decorate([
|
|
185
|
-
property({ type: Boolean, reflect: true })
|
|
186
|
-
], FlowNode.prototype, "minimal", void 0);
|
|
187
|
-
__decorate([
|
|
188
|
-
property({ attribute: false })
|
|
189
|
-
], FlowNode.prototype, "isBeingDragged", void 0);
|
|
190
|
-
FlowNode = __decorate([
|
|
191
|
-
customElement("flow-node")
|
|
192
|
-
], FlowNode);
|
|
193
|
-
export { FlowNode };
|
|
194
|
-
//# sourceMappingURL=flow-node.js.map
|
|
14
|
+
`]}disconnectedCallback(){this.workspace.removeEventListener("pan",this.setTranslate),this.workspace.removeEventListener("zoom",this.setTranslate),h.removeListener("cleared",this.forceUpdate),h.removeListener("connectionremoved",this.linkIdentity),super.disconnectedCallback()}bringToFront(){this.frozen||(this.style.zIndex=`${this.workspace.topNodeZindex++}`)}firstUpdated(){let e=Object.create(null,{firstUpdated:{get:()=>super.firstUpdated}});return __awaiter(this,void 0,void 0,function*(){if(e.firstUpdated.call(this),this.linkIdentity(),this.workspace.addEventListener("pan",this.setTranslate),this.workspace.addEventListener("zoom",this.setTranslate),h.addListener("cleared",this.forceUpdate),h.addListener("connectionremoved",this.linkIdentity),this.minimal=0!==(this.node.displayCharacter||"").length,this.bringToFront(),l.has(this.node.id)){yield this.updateComplete,yield this.updateComplete;let e=this.getBoundingClientRect();this.node.position.x-=e.width/2/this.workspace.camera.zoom,this.node.position.y-=e.height/2/this.workspace.camera.zoom,this.setTranslate(),l.delete(this.node.id)}this.minimal&&this.addEventListener("mousedown",this.startDrag)})}updated(){return __awaiter(this,void 0,void 0,function*(){this.linkIdentity(),this.dispatchEvent(new CustomEvent("updated"))})}render(){this.minimal?this.style.background=`var(--${this.node.type.toLowerCase()}-color)`:this.style.background="",this.setTranslate(),this.style.boxShadow=this.selected?"var(--highlight) 0 0 0 3px":"";let e=this.minimal?t`<div class="title minimal" ?singlechar="${1===this.node.displayCharacter.length}">${r.t("flow."+this.node.displayCharacter,this.node.displayCharacter)}</div>`:t`<div class="title ${this.node.type.toLowerCase()}" @mousedown="${this.startDrag}">${r.t("flow."+this.node.name)||"invalid"}</div>`,i=t`<div class="socket-side inputs">${this.node.inputs.map(e=>t`<flow-node-socket ?renderlabel="${!this.minimal}" .socket="${e}" side="input"></flow-node-socket>`)}</div>`,o=t`<div class="socket-side outputs">${this.node.outputs.map(e=>t`<flow-node-socket ?renderlabel="${!this.minimal}" .socket="${e}" side="output"></flow-node-socket>`)}</div>`,n=t`<div style="width: 10px"></div>`;return t`
|
|
15
|
+
${e}
|
|
16
|
+
${this.node.inputs.length>0?i:n}
|
|
17
|
+
${this.minimal?null:t`
|
|
18
|
+
<div class="internal-container" style="padding-top: 8px">
|
|
19
|
+
${this.node.internals.reduce((e,t,i,o)=>(e[e.length-1].push(t),"NEW_LINE"===t.breakType&&i<o.length-1&&e.push([]),e),[[]]).map(e=>t`
|
|
20
|
+
<div class="internal-group" style="max-width: fit-content; min-width: fit-content; padding-bottom: 8px;">
|
|
21
|
+
${e.map(e=>t`
|
|
22
|
+
<div class="internal-item" style="display: inline-block">
|
|
23
|
+
<internal-picker style="pointer-events: ${this.frozen?"none":"normal"};" @picked="${()=>__awaiter(this,void 0,void 0,function*(){this.forceUpdate(),yield this.updateComplete,h.removeInvalidConnections()})}" .node="${this.node}" .internalIndex="${this.node.internals.indexOf(e)}"></internal-picker>
|
|
24
|
+
</div>
|
|
25
|
+
`)}
|
|
26
|
+
</div>
|
|
27
|
+
`)}
|
|
28
|
+
</div>`}
|
|
29
|
+
${this.node.outputs.length>0?o:n}
|
|
30
|
+
${this.frozen?t`<or-icon class="lock-icon ${this.node.type.toLowerCase()}" icon="lock"></or-icon>`:""}
|
|
31
|
+
`}};__decorate([o({converter:a})],FlowNode.prototype,"node",void 0),__decorate([o({attribute:!1})],FlowNode.prototype,"workspace",void 0),__decorate([o({type:Boolean,reflect:!0})],FlowNode.prototype,"frozen",void 0),__decorate([o({type:Boolean,reflect:!0})],FlowNode.prototype,"minimal",void 0),__decorate([o({attribute:!1})],FlowNode.prototype,"isBeingDragged",void 0),FlowNode=__decorate([i("flow-node")],FlowNode);export{FlowNode};
|