@openremote/or-rules 1.8.0-snapshot.20250725120002 → 1.8.0-snapshot.20250728102340
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,61 +1,24 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
.container{
|
|
26
|
-
display: flex;
|
|
27
|
-
flex-direction: row;
|
|
28
|
-
justify-content: space-between;
|
|
29
|
-
justify-content: space-evenly;
|
|
30
|
-
justify-content: space-around;
|
|
31
|
-
}`;
|
|
32
|
-
}
|
|
33
|
-
render() {
|
|
34
|
-
return html `
|
|
35
|
-
<div class="question">${this.question}</div>
|
|
36
|
-
<div class="container">
|
|
37
|
-
<or-mwc-input type="${InputType.BUTTON}" unElevated label="${this.agreeText}"
|
|
38
|
-
@or-mwc-input-changed="${() => { this.dispatchEvent(new CustomEvent("agreed")); }}">
|
|
39
|
-
</or-mwc-input>
|
|
40
|
-
|
|
41
|
-
<or-mwc-input type="button" label="${this.disagreeText}"
|
|
42
|
-
@or-mwc-input-changed="${() => { this.dispatchEvent(new CustomEvent("disagreed")); }}">
|
|
43
|
-
</or-mwc-input>
|
|
44
|
-
</div>
|
|
45
|
-
`;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
__decorate([
|
|
49
|
-
property({ type: String })
|
|
50
|
-
], ConfirmationDialog.prototype, "agreeText", void 0);
|
|
51
|
-
__decorate([
|
|
52
|
-
property({ type: String })
|
|
53
|
-
], ConfirmationDialog.prototype, "disagreeText", void 0);
|
|
54
|
-
__decorate([
|
|
55
|
-
property({ type: String })
|
|
56
|
-
], ConfirmationDialog.prototype, "question", void 0);
|
|
57
|
-
ConfirmationDialog = __decorate([
|
|
58
|
-
customElement("confirmation-dialog")
|
|
59
|
-
], ConfirmationDialog);
|
|
60
|
-
export { ConfirmationDialog };
|
|
61
|
-
//# sourceMappingURL=confirmation-dialog.js.map
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,i){var r,n=arguments.length,a=n<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,o,i);else for(var c=e.length-1;c>=0;c--)(r=e[c])&&(a=(n<3?r(a):n>3?r(t,o,a):r(t,o))||a);return n>3&&a&&Object.defineProperty(t,o,a),a};import{LitElement as e,html as t,css as o}from"lit";import{customElement as i,property as r}from"lit/decorators.js";import{i18next as n,translate as a}from"@openremote/or-translate";import{InputType as c}from"@openremote/or-mwc-components/or-mwc-input";let ConfirmationDialog=class extends a(n)(e){constructor(){super(...arguments),this.agreeText=n.t("ok"),this.disagreeText=n.t("cancel"),this.question=n.t("areYouSure","Are you sure?")}static get styles(){return o`
|
|
2
|
+
.question{
|
|
3
|
+
width: 100%;
|
|
4
|
+
padding: 15px 5px 25px 5px;
|
|
5
|
+
text-align: center;
|
|
6
|
+
}
|
|
7
|
+
.container{
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: row;
|
|
10
|
+
justify-content: space-between;
|
|
11
|
+
justify-content: space-evenly;
|
|
12
|
+
justify-content: space-around;
|
|
13
|
+
}`}render(){return t`
|
|
14
|
+
<div class="question">${this.question}</div>
|
|
15
|
+
<div class="container">
|
|
16
|
+
<or-mwc-input type="${c.BUTTON}" unElevated label="${this.agreeText}"
|
|
17
|
+
@or-mwc-input-changed="${()=>{this.dispatchEvent(new CustomEvent("agreed"))}}">
|
|
18
|
+
</or-mwc-input>
|
|
19
|
+
|
|
20
|
+
<or-mwc-input type="button" label="${this.disagreeText}"
|
|
21
|
+
@or-mwc-input-changed="${()=>{this.dispatchEvent(new CustomEvent("disagreed"))}}">
|
|
22
|
+
</or-mwc-input>
|
|
23
|
+
</div>
|
|
24
|
+
`}};__decorate([r({type:String})],ConfirmationDialog.prototype,"agreeText",void 0),__decorate([r({type:String})],ConfirmationDialog.prototype,"disagreeText",void 0),__decorate([r({type:String})],ConfirmationDialog.prototype,"question",void 0),ConfirmationDialog=__decorate([i("confirmation-dialog")],ConfirmationDialog);export{ConfirmationDialog};
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { LitElement, html } from "lit";
|
|
8
|
-
import { customElement, property } from "lit/decorators.js";
|
|
9
|
-
import { repeat } from "lit/directives/repeat.js";
|
|
10
|
-
import { project } from "./flow-editor";
|
|
11
|
-
let ConnectionContainer = class ConnectionContainer extends LitElement {
|
|
12
|
-
constructor() {
|
|
13
|
-
super();
|
|
14
|
-
project.addListener("connectioncreated", () => {
|
|
15
|
-
this.requestUpdate();
|
|
16
|
-
});
|
|
17
|
-
project.addListener("connectionremoved", () => {
|
|
18
|
-
this.requestUpdate();
|
|
19
|
-
});
|
|
20
|
-
project.addListener("cleared", () => {
|
|
21
|
-
this.requestUpdate();
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
render() {
|
|
25
|
-
return html `${repeat(project.connections, (c) => c.from + c.to, (c) => html `<connection-line .workspace="${this.workspace}" .connection="${c}"></connection-line>`)}`;
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
__decorate([
|
|
29
|
-
property({ attribute: false })
|
|
30
|
-
], ConnectionContainer.prototype, "workspace", void 0);
|
|
31
|
-
ConnectionContainer = __decorate([
|
|
32
|
-
customElement("connection-container")
|
|
33
|
-
], ConnectionContainer);
|
|
34
|
-
export { ConnectionContainer };
|
|
35
|
-
//# sourceMappingURL=connection-container.js.map
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,n){var r,i=arguments.length,c=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)c=Reflect.decorate(e,t,o,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(c=(i<3?r(c):i>3?r(t,o,c):r(t,o))||c);return i>3&&c&&Object.defineProperty(t,o,c),c};import{LitElement as e,html as t}from"lit";import{customElement as o,property as n}from"lit/decorators.js";import{repeat as r}from"lit/directives/repeat.js";import{project as i}from"./flow-editor";let ConnectionContainer=class extends e{constructor(){super(),i.addListener("connectioncreated",()=>{this.requestUpdate()}),i.addListener("connectionremoved",()=>{this.requestUpdate()}),i.addListener("cleared",()=>{this.requestUpdate()})}render(){return t`${r(i.connections,e=>e.from+e.to,e=>t`<connection-line .workspace="${this.workspace}" .connection="${e}"></connection-line>`)}`}};__decorate([n({attribute:!1})],ConnectionContainer.prototype,"workspace",void 0),ConnectionContainer=__decorate([o("connection-container")],ConnectionContainer);export{ConnectionContainer};
|
|
@@ -1,119 +1,30 @@
|
|
|
1
|
-
var __decorate = (this && this.
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
this.polylineId = IdentityAssigner.generateIdentity();
|
|
20
|
-
}
|
|
21
|
-
disconnectedCallback() {
|
|
22
|
-
super.disconnectedCallback();
|
|
23
|
-
this.resizeObserver.disconnect();
|
|
24
|
-
project.removeListener("connectionremoved", this.nodeChanged);
|
|
25
|
-
}
|
|
26
|
-
firstUpdated() {
|
|
27
|
-
super.firstUpdated();
|
|
28
|
-
const elem = this.shadowRoot.getElementById(this.polylineId);
|
|
29
|
-
if (elem)
|
|
30
|
-
this.setHandle(elem);
|
|
31
|
-
}
|
|
32
|
-
render() {
|
|
33
|
-
if (this.isInvalid) {
|
|
34
|
-
const fromSocket = NodeUtilities.getSocketFromID(this.connection.from, project.nodes);
|
|
35
|
-
const toSocket = NodeUtilities.getSocketFromID(this.connection.to, project.nodes);
|
|
36
|
-
this.fromNodeElement = IdentityDomLink.map[fromSocket.nodeId];
|
|
37
|
-
this.toNodeElement = IdentityDomLink.map[toSocket.nodeId];
|
|
38
|
-
this.fromElement = IdentityDomLink.map[fromSocket.id];
|
|
39
|
-
this.toElement = IdentityDomLink.map[toSocket.id];
|
|
40
|
-
if (this.isInvalid) {
|
|
41
|
-
console.warn(this.fromNodeElement);
|
|
42
|
-
console.warn(this.toNodeElement);
|
|
43
|
-
console.warn(this.fromElement);
|
|
44
|
-
console.warn(this.toElement);
|
|
45
|
-
console.warn("Attempt to render invalid connection");
|
|
46
|
-
return html ``;
|
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,n){var i,s=arguments.length,r=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,o):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,o,n);else for(var l=e.length-1;l>=0;l--)(i=e[l])&&(r=(s<3?i(r):s>3?i(t,o,r):i(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r};import{html as e,css as t}from"lit";import{customElement as o,property as n}from"lit/decorators.js";import{IdentityDomLink as i,IdentityAssigner as s,NodeUtilities as r}from"../node-structure";import{ResizeObserver as l}from"resize-observer";import{SelectableElement as d}from"./selectable-element";import{project as c}from"./flow-editor";let ConnectionLine=class extends d{constructor(){super(),this.fancyLine=!0,this.curveIntensity=1,this.nodeChanged=()=>{this.requestUpdate()},this.polylineId=s.generateIdentity()}disconnectedCallback(){super.disconnectedCallback(),this.resizeObserver.disconnect(),c.removeListener("connectionremoved",this.nodeChanged)}firstUpdated(){super.firstUpdated();let e=this.shadowRoot.getElementById(this.polylineId);e&&this.setHandle(e)}render(){if(this.isInvalid){let t=r.getSocketFromID(this.connection.from,c.nodes),o=r.getSocketFromID(this.connection.to,c.nodes);if(this.fromNodeElement=i.map[t.nodeId],this.toNodeElement=i.map[o.nodeId],this.fromElement=i.map[t.id],this.toElement=i.map[o.id],this.isInvalid)return console.warn(this.fromNodeElement),console.warn(this.toNodeElement),console.warn(this.fromElement),console.warn(this.toElement),console.warn("Attempt to render invalid connection"),e``;this.fromNodeElement.addEventListener("updated",this.nodeChanged),this.toNodeElement.addEventListener("updated",this.nodeChanged),this.resizeObserver=new l(this.nodeChanged),this.resizeObserver.observe(this.fromNodeElement),this.resizeObserver.observe(this.toNodeElement)}let t=this.workspace.clientRect,o=this.fromElement.connectionPosition,n=this.toElement.connectionPosition;if(this.fancyLine){let i=o.x-t.left,s=o.y-t.top,r=n.x-t.left,l=n.y-t.top,d=this.curveIntensity*(Math.abs(i-r)/2);return e`<svg style="stroke-width: ${this.workspace.camera.zoom*(this.selected?5:3)}px;">
|
|
2
|
+
<path id="${this.polylineId}"
|
|
3
|
+
d="M ${i} ${s} C ${i+d} ${s}, ${r-d} ${l}, ${r} ${l}"
|
|
4
|
+
selected="${this.selected}"
|
|
5
|
+
/>
|
|
6
|
+
</svg>`}return e`<svg style="stroke-width: ${this.workspace.camera.zoom*(this.selected?5:3)}px;"><polyline id="${this.polylineId}"
|
|
7
|
+
selected="${this.selected}"
|
|
8
|
+
points="
|
|
9
|
+
${o.x-t.left}, ${o.y-t.top}
|
|
10
|
+
${n.x-t.left}, ${n.y-t.top}"
|
|
11
|
+
></polyline>
|
|
12
|
+
</svg>`}static get styles(){return t`
|
|
13
|
+
svg{
|
|
14
|
+
fill: none;
|
|
15
|
+
overflow: visible;
|
|
16
|
+
position: absolute;
|
|
17
|
+
pointer-events: none;
|
|
18
|
+
stroke-linejoin: round;
|
|
47
19
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
this.resizeObserver = new ResizeObserver(this.nodeChanged);
|
|
52
|
-
this.resizeObserver.observe(this.fromNodeElement);
|
|
53
|
-
this.resizeObserver.observe(this.toNodeElement);
|
|
20
|
+
path, line{
|
|
21
|
+
position: absolute;
|
|
22
|
+
pointer-events: all;
|
|
54
23
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const x2 = to.x - parentSize.left;
|
|
63
|
-
const y2 = to.y - parentSize.top;
|
|
64
|
-
const intensity = this.curveIntensity * (Math.abs(x1 - x2) / 2);
|
|
65
|
-
// const intensity = 100 * this.workspace.camera.zoom;
|
|
66
|
-
return html `<svg style="stroke-width: ${this.workspace.camera.zoom * (this.selected ? 5 : 3)}px;">
|
|
67
|
-
<path id="${this.polylineId}"
|
|
68
|
-
d="M ${x1} ${y1} C ${x1 + intensity} ${y1}, ${x2 - intensity} ${y2}, ${x2} ${y2}"
|
|
69
|
-
selected="${this.selected}"
|
|
70
|
-
/>
|
|
71
|
-
</svg>`;
|
|
72
|
-
}
|
|
73
|
-
return html `<svg style="stroke-width: ${this.workspace.camera.zoom * (this.selected ? 5 : 3)}px;"><polyline id="${this.polylineId}"
|
|
74
|
-
selected="${this.selected}"
|
|
75
|
-
points="
|
|
76
|
-
${from.x - parentSize.left}, ${from.y - parentSize.top}
|
|
77
|
-
${to.x - parentSize.left}, ${to.y - parentSize.top}"
|
|
78
|
-
></polyline>
|
|
79
|
-
</svg>`;
|
|
80
|
-
}
|
|
81
|
-
static get styles() {
|
|
82
|
-
return css `
|
|
83
|
-
svg{
|
|
84
|
-
fill: none;
|
|
85
|
-
overflow: visible;
|
|
86
|
-
position: absolute;
|
|
87
|
-
pointer-events: none;
|
|
88
|
-
stroke-linejoin: round;
|
|
89
|
-
}
|
|
90
|
-
path, line{
|
|
91
|
-
position: absolute;
|
|
92
|
-
pointer-events: all;
|
|
93
|
-
}
|
|
94
|
-
path:hover, line:hover, path[selected = true], line[selected = true]{
|
|
95
|
-
stroke: var(--highlight);
|
|
96
|
-
}
|
|
97
|
-
text{
|
|
98
|
-
fill: red;
|
|
99
|
-
stroke: none;
|
|
100
|
-
}`;
|
|
101
|
-
}
|
|
102
|
-
get isInvalid() {
|
|
103
|
-
return (!this.fromNodeElement || !this.toNodeElement || !this.fromElement || !this.toElement);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
__decorate([
|
|
107
|
-
property({ attribute: false })
|
|
108
|
-
], ConnectionLine.prototype, "connection", void 0);
|
|
109
|
-
__decorate([
|
|
110
|
-
property({ attribute: false })
|
|
111
|
-
], ConnectionLine.prototype, "workspace", void 0);
|
|
112
|
-
__decorate([
|
|
113
|
-
property({ type: String })
|
|
114
|
-
], ConnectionLine.prototype, "polylineId", void 0);
|
|
115
|
-
ConnectionLine = __decorate([
|
|
116
|
-
customElement("connection-line")
|
|
117
|
-
], ConnectionLine);
|
|
118
|
-
export { ConnectionLine };
|
|
119
|
-
//# sourceMappingURL=connection-line.js.map
|
|
24
|
+
path:hover, line:hover, path[selected = true], line[selected = true]{
|
|
25
|
+
stroke: var(--highlight);
|
|
26
|
+
}
|
|
27
|
+
text{
|
|
28
|
+
fill: red;
|
|
29
|
+
stroke: none;
|
|
30
|
+
}`}get isInvalid(){return!this.fromNodeElement||!this.toNodeElement||!this.fromElement||!this.toElement}};__decorate([n({attribute:!1})],ConnectionLine.prototype,"connection",void 0),__decorate([n({attribute:!1})],ConnectionLine.prototype,"workspace",void 0),__decorate([n({type:String})],ConnectionLine.prototype,"polylineId",void 0),ConnectionLine=__decorate([o("connection-line")],ConnectionLine);export{ConnectionLine};
|
|
@@ -1,144 +1,49 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import { translate, i18next } from "@openremote/or-translate";
|
|
11
|
-
let ContextMenu = ContextMenu_1 = class ContextMenu extends translate(i18next)(LitElement) {
|
|
12
|
-
constructor() {
|
|
13
|
-
super(...arguments);
|
|
14
|
-
this.entries = [];
|
|
15
|
-
this.isOpen = false;
|
|
16
|
-
this.closeCallback = () => {
|
|
17
|
-
ContextMenu_1.close();
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
static get opened() { return ContextMenu_1.main.isOpen; }
|
|
21
|
-
static get styles() {
|
|
22
|
-
return css `
|
|
23
|
-
:host{
|
|
24
|
-
display: inline-block;
|
|
25
|
-
position: fixed;
|
|
26
|
-
background: white;
|
|
27
|
-
outline: 1px solid rgb(200,200,200);
|
|
28
|
-
box-shadow: rgba(0, 0, 0, 0.05) 0 2px 4px;
|
|
29
|
-
font-size: 13px;
|
|
30
|
-
z-index: 1000000;
|
|
31
|
-
}
|
|
32
|
-
.context-menu-button{
|
|
33
|
-
color: rgb(0,0,0);
|
|
34
|
-
display: grid;
|
|
35
|
-
align-items: center;
|
|
36
|
-
justify-items: start;
|
|
37
|
-
grid-template-rows: 32px;
|
|
38
|
-
grid-template-columns: 32px 220px;
|
|
39
|
-
grid-template-areas:
|
|
40
|
-
"icon label";
|
|
41
|
-
}
|
|
42
|
-
.context-menu-button:hover{
|
|
43
|
-
background: whitesmoke;
|
|
44
|
-
}
|
|
45
|
-
.label
|
|
46
|
-
{
|
|
47
|
-
grid-area: label;
|
|
48
|
-
}
|
|
49
|
-
or-icon{
|
|
50
|
-
justify-self: center;
|
|
51
|
-
grid-area: icon;
|
|
52
|
-
height: 16px;
|
|
53
|
-
width: 16px;
|
|
54
|
-
}
|
|
55
|
-
.muted{
|
|
56
|
-
pointer-events: none;
|
|
57
|
-
color: rgb(150,150,150);
|
|
58
|
-
}
|
|
59
|
-
.context-menu-separator{
|
|
60
|
-
--thickness: 1px;
|
|
61
|
-
border: 0;
|
|
62
|
-
height: var(--thickness);
|
|
63
|
-
border-bottom: solid var(--thickness);
|
|
64
|
-
border-color: rgb(234,234,234);
|
|
65
|
-
padding: 0;
|
|
66
|
-
margin: 5px 10px calc(5px - var(--thickness)) 10px;
|
|
67
|
-
}`;
|
|
68
|
-
}
|
|
69
|
-
static open(x, y, container, buttons) {
|
|
70
|
-
ContextMenu_1.main.container = container;
|
|
71
|
-
ContextMenu_1.main.style.top = y + "px";
|
|
72
|
-
ContextMenu_1.main.style.left = x + "px";
|
|
73
|
-
window.addEventListener("mousedown", ContextMenu_1.main.closeCallback);
|
|
74
|
-
window.addEventListener("blur", ContextMenu_1.main.closeCallback);
|
|
75
|
-
window.addEventListener("wheel", ContextMenu_1.main.closeCallback);
|
|
76
|
-
ContextMenu_1.main.entries = buttons;
|
|
77
|
-
ContextMenu_1.main.isOpen = true;
|
|
78
|
-
}
|
|
79
|
-
static close() {
|
|
80
|
-
window.removeEventListener("mousedown", ContextMenu_1.main.closeCallback);
|
|
81
|
-
window.removeEventListener("blur", ContextMenu_1.main.closeCallback);
|
|
82
|
-
window.removeEventListener("wheel", ContextMenu_1.main.closeCallback);
|
|
83
|
-
ContextMenu_1.main.isOpen = false;
|
|
84
|
-
}
|
|
85
|
-
firstUpdated() {
|
|
86
|
-
ContextMenu_1.main = this;
|
|
87
|
-
}
|
|
88
|
-
updated() {
|
|
89
|
-
if (!this.container) {
|
|
90
|
-
return;
|
|
1
|
+
var ContextMenu_1,__decorate=this&&this.__decorate||function(e,t,n,o){var i,r=arguments.length,s=r<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,o);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(s=(r<3?i(s):r>3?i(t,n,s):i(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s};import{LitElement as e,html as t,css as n}from"lit";import{customElement as o,property as i}from"lit/decorators.js";import{translate as r,i18next as s}from"@openremote/or-translate";let ContextMenu=ContextMenu_1=class extends r(s)(e){constructor(){super(...arguments),this.entries=[],this.isOpen=!1,this.closeCallback=()=>{ContextMenu_1.close()}}static get opened(){return ContextMenu_1.main.isOpen}static get styles(){return n`
|
|
2
|
+
:host{
|
|
3
|
+
display: inline-block;
|
|
4
|
+
position: fixed;
|
|
5
|
+
background: white;
|
|
6
|
+
outline: 1px solid rgb(200,200,200);
|
|
7
|
+
box-shadow: rgba(0, 0, 0, 0.05) 0 2px 4px;
|
|
8
|
+
font-size: 13px;
|
|
9
|
+
z-index: 1000000;
|
|
91
10
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
11
|
+
.context-menu-button{
|
|
12
|
+
color: rgb(0,0,0);
|
|
13
|
+
display: grid;
|
|
14
|
+
align-items: center;
|
|
15
|
+
justify-items: start;
|
|
16
|
+
grid-template-rows: 32px;
|
|
17
|
+
grid-template-columns: 32px 220px;
|
|
18
|
+
grid-template-areas:
|
|
19
|
+
"icon label";
|
|
96
20
|
}
|
|
97
|
-
|
|
98
|
-
|
|
21
|
+
.context-menu-button:hover{
|
|
22
|
+
background: whitesmoke;
|
|
99
23
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (!this.isOpen) {
|
|
104
|
-
return html ``;
|
|
24
|
+
.label
|
|
25
|
+
{
|
|
26
|
+
grid-area: label;
|
|
105
27
|
}
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
};
|
|
128
|
-
return html `
|
|
129
|
-
<div class="context-menu-button ${(button.disabled || false) ? `muted` : ``}" @mousedown="${action}">
|
|
130
|
-
${button.icon ? html `<or-icon icon="${button.icon}"></or-icon>` : null}
|
|
131
|
-
<span class="label">${button.label}</span></div>`;
|
|
132
|
-
}
|
|
133
|
-
separatorTemplate() {
|
|
134
|
-
return html `<div class="context-menu-separator"></div>`;
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
__decorate([
|
|
138
|
-
property({ attribute: false })
|
|
139
|
-
], ContextMenu.prototype, "isOpen", void 0);
|
|
140
|
-
ContextMenu = ContextMenu_1 = __decorate([
|
|
141
|
-
customElement("context-menu")
|
|
142
|
-
], ContextMenu);
|
|
143
|
-
export { ContextMenu };
|
|
144
|
-
//# sourceMappingURL=context-menu.js.map
|
|
28
|
+
or-icon{
|
|
29
|
+
justify-self: center;
|
|
30
|
+
grid-area: icon;
|
|
31
|
+
height: 16px;
|
|
32
|
+
width: 16px;
|
|
33
|
+
}
|
|
34
|
+
.muted{
|
|
35
|
+
pointer-events: none;
|
|
36
|
+
color: rgb(150,150,150);
|
|
37
|
+
}
|
|
38
|
+
.context-menu-separator{
|
|
39
|
+
--thickness: 1px;
|
|
40
|
+
border: 0;
|
|
41
|
+
height: var(--thickness);
|
|
42
|
+
border-bottom: solid var(--thickness);
|
|
43
|
+
border-color: rgb(234,234,234);
|
|
44
|
+
padding: 0;
|
|
45
|
+
margin: 5px 10px calc(5px - var(--thickness)) 10px;
|
|
46
|
+
}`}static open(e,t,n,o){ContextMenu_1.main.container=n,ContextMenu_1.main.style.top=t+"px",ContextMenu_1.main.style.left=e+"px",window.addEventListener("mousedown",ContextMenu_1.main.closeCallback),window.addEventListener("blur",ContextMenu_1.main.closeCallback),window.addEventListener("wheel",ContextMenu_1.main.closeCallback),ContextMenu_1.main.entries=o,ContextMenu_1.main.isOpen=!0}static close(){window.removeEventListener("mousedown",ContextMenu_1.main.closeCallback),window.removeEventListener("blur",ContextMenu_1.main.closeCallback),window.removeEventListener("wheel",ContextMenu_1.main.closeCallback),ContextMenu_1.main.isOpen=!1}firstUpdated(){ContextMenu_1.main=this}updated(){if(!this.container)return;let e=this.container.getBoundingClientRect(),t=this.getBoundingClientRect();t.top+t.height>e.bottom&&(this.style.top=t.top-t.height+"px"),t.left+t.width>e.right&&(this.style.left=e.right-t.width+"px")}render(){if(this.style.display=this.isOpen?"unset":"none",!this.isOpen)return t``;let e=this.entries.map(e=>{switch(e.type){case"button":return this.buttonTemplate(e);case"separator":return this.separatorTemplate()}});return t`${e.length>0?e:t`<div class="context-menu-button muted">...</div>`}`}buttonTemplate(e){return t`
|
|
47
|
+
<div class="context-menu-button ${e.disabled||0?"muted":""}" @mousedown="${t=>{1===t.buttons&&(ContextMenu_1.close(),e.action&&e.action(),t.stopImmediatePropagation(),t.stopPropagation())}}">
|
|
48
|
+
${e.icon?t`<or-icon icon="${e.icon}"></or-icon>`:null}
|
|
49
|
+
<span class="label">${e.label}</span></div>`}separatorTemplate(){return t`<div class="context-menu-separator"></div>`}};__decorate([i({attribute:!1})],ContextMenu.prototype,"isOpen",void 0),ContextMenu=ContextMenu_1=__decorate([o("context-menu")],ContextMenu);export{ContextMenu};
|