@openremote/or-rules 1.8.0-snapshot.20250725074716 → 1.8.0-snapshot.20250725120001
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 +61 -24
- package/lib/flow-viewer/components/connection-container.js +35 -1
- package/lib/flow-viewer/components/connection-line.js +117 -28
- package/lib/flow-viewer/components/context-menu.js +140 -45
- package/lib/flow-viewer/components/editor-workspace.js +282 -20
- package/lib/flow-viewer/components/flow-editor.js +160 -47
- package/lib/flow-viewer/components/flow-node-socket.js +146 -31
- package/lib/flow-viewer/components/flow-node.js +192 -29
- package/lib/flow-viewer/components/internal-picker.js +271 -54
- package/lib/flow-viewer/components/node-menu-item.js +132 -32
- package/lib/flow-viewer/components/node-panel.js +104 -60
- package/lib/flow-viewer/components/notification-dialog.js +55 -23
- package/lib/flow-viewer/components/popup-modal.js +113 -54
- package/lib/flow-viewer/components/rule-browser.js +119 -30
- package/lib/flow-viewer/components/selectable-element.js +71 -1
- package/lib/flow-viewer/components/selection-box.js +119 -15
- package/lib/flow-viewer/components/top-bar.js +116 -49
- package/lib/flow-viewer/components/workspace-contextmenu-options.js +128 -5
- package/lib/flow-viewer/components/writable-dropdown.js +51 -5
- package/lib/flow-viewer/converters/node-converter.js +10 -1
- package/lib/flow-viewer/flow-viewer.js +19 -1
- package/lib/flow-viewer/models/camera.js +2 -1
- package/lib/flow-viewer/models/context-menu-button.js +2 -1
- package/lib/flow-viewer/models/light-node-collection.js +2 -1
- package/lib/flow-viewer/models/status.js +8 -1
- package/lib/flow-viewer/node-structure/copy.machine.js +34 -1
- package/lib/flow-viewer/node-structure/identity.assigner.js +10 -1
- package/lib/flow-viewer/node-structure/identity.dom.link.js +4 -1
- package/lib/flow-viewer/node-structure/index.js +5 -1
- package/lib/flow-viewer/node-structure/socket.type.matcher.js +50 -1
- package/lib/flow-viewer/node-structure/utils.js +109 -1
- package/lib/flow-viewer/services/copy-paste-manager.js +59 -1
- package/lib/flow-viewer/services/exporter.js +67 -1
- package/lib/flow-viewer/services/input.js +80 -1
- package/lib/flow-viewer/services/integration.js +27 -1
- package/lib/flow-viewer/services/modal.js +29 -8
- package/lib/flow-viewer/services/project.js +222 -1
- package/lib/flow-viewer/services/shortcuts.js +63 -1
- package/lib/flow-viewer/styles/editor-workspace-style.js +55 -53
- package/lib/flow-viewer/styles/flow-node-style.js +95 -93
- package/lib/flow-viewer/styles/picker-styles.js +31 -29
- package/lib/flow-viewer/utils.js +49 -1
- package/lib/index.js +953 -56
- package/lib/json-viewer/forms/or-rule-form-alarm.js +91 -18
- package/lib/json-viewer/forms/or-rule-form-email-message.js +51 -12
- package/lib/json-viewer/forms/or-rule-form-localized.js +269 -43
- package/lib/json-viewer/forms/or-rule-form-push-notification.js +152 -63
- package/lib/json-viewer/forms/or-rule-form-webhook.js +296 -101
- package/lib/json-viewer/modals/or-rule-alarm-modal.js +173 -17
- package/lib/json-viewer/modals/or-rule-notification-modal.js +196 -11
- package/lib/json-viewer/modals/or-rule-radial-modal.js +142 -17
- package/lib/json-viewer/modals/or-rule-webhook-modal.js +78 -8
- package/lib/json-viewer/or-rule-action-alarm.js +97 -5
- package/lib/json-viewer/or-rule-action-attribute.js +235 -33
- package/lib/json-viewer/or-rule-action-notification.js +465 -56
- package/lib/json-viewer/or-rule-action-webhook.js +49 -18
- package/lib/json-viewer/or-rule-asset-query.js +849 -126
- package/lib/json-viewer/or-rule-condition.js +216 -29
- package/lib/json-viewer/or-rule-json-viewer.js +393 -34
- package/lib/json-viewer/or-rule-then-otherwise.js +609 -113
- package/lib/json-viewer/or-rule-trigger-query.js +227 -57
- package/lib/json-viewer/or-rule-when.js +343 -126
- package/lib/or-rule-group-viewer.js +106 -12
- package/lib/or-rule-text-viewer.js +133 -22
- package/lib/or-rule-tree.js +601 -57
- package/lib/or-rule-validity.js +373 -62
- package/lib/or-rule-viewer.js +361 -81
- package/lib/style.js +89 -64
- package/package.json +11 -11
|
@@ -1,24 +1,61 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
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, css } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { i18next, translate } from "@openremote/or-translate";
|
|
10
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
11
|
+
let ConfirmationDialog = class ConfirmationDialog extends translate(i18next)(LitElement) {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.agreeText = i18next.t("ok");
|
|
15
|
+
this.disagreeText = i18next.t("cancel");
|
|
16
|
+
this.question = i18next.t("areYouSure", "Are you sure?");
|
|
17
|
+
}
|
|
18
|
+
static get styles() {
|
|
19
|
+
return css `
|
|
20
|
+
.question{
|
|
21
|
+
width: 100%;
|
|
22
|
+
padding: 15px 5px 25px 5px;
|
|
23
|
+
text-align: center;
|
|
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 +1,35 @@
|
|
|
1
|
-
var __decorate=this&&this.__decorate
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
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,30 +1,119 @@
|
|
|
1
|
-
var __decorate
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
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 { html, css } from "lit";
|
|
8
|
+
import { customElement, property } from "lit/decorators.js";
|
|
9
|
+
import { IdentityDomLink, IdentityAssigner, NodeUtilities } from "../node-structure";
|
|
10
|
+
import { ResizeObserver } from "resize-observer";
|
|
11
|
+
import { SelectableElement } from "./selectable-element";
|
|
12
|
+
import { project } from "./flow-editor";
|
|
13
|
+
let ConnectionLine = class ConnectionLine extends SelectableElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.fancyLine = true;
|
|
17
|
+
this.curveIntensity = 1;
|
|
18
|
+
this.nodeChanged = () => { this.requestUpdate(); };
|
|
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 ``;
|
|
19
47
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
48
|
+
else {
|
|
49
|
+
this.fromNodeElement.addEventListener("updated", this.nodeChanged);
|
|
50
|
+
this.toNodeElement.addEventListener("updated", this.nodeChanged);
|
|
51
|
+
this.resizeObserver = new ResizeObserver(this.nodeChanged);
|
|
52
|
+
this.resizeObserver.observe(this.fromNodeElement);
|
|
53
|
+
this.resizeObserver.observe(this.toNodeElement);
|
|
23
54
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
55
|
+
}
|
|
56
|
+
const parentSize = this.workspace.clientRect;
|
|
57
|
+
const from = this.fromElement.connectionPosition;
|
|
58
|
+
const to = this.toElement.connectionPosition;
|
|
59
|
+
if (this.fancyLine) {
|
|
60
|
+
const x1 = from.x - parentSize.left;
|
|
61
|
+
const y1 = from.y - parentSize.top;
|
|
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
|
|
@@ -1,49 +1,144 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
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
|
+
var ContextMenu_1;
|
|
8
|
+
import { LitElement, html, css } from "lit";
|
|
9
|
+
import { customElement, property } from "lit/decorators.js";
|
|
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;
|
|
10
91
|
}
|
|
11
|
-
.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
justify-items: start;
|
|
16
|
-
grid-template-rows: 32px;
|
|
17
|
-
grid-template-columns: 32px 220px;
|
|
18
|
-
grid-template-areas:
|
|
19
|
-
"icon label";
|
|
92
|
+
const bounds = this.container.getBoundingClientRect();
|
|
93
|
+
const box = this.getBoundingClientRect();
|
|
94
|
+
if (box.top + box.height > bounds.bottom) {
|
|
95
|
+
this.style.top = box.top - box.height + "px";
|
|
20
96
|
}
|
|
21
|
-
.
|
|
22
|
-
|
|
97
|
+
if (box.left + box.width > bounds.right) {
|
|
98
|
+
this.style.left = bounds.right - box.width + "px";
|
|
23
99
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
100
|
+
}
|
|
101
|
+
render() {
|
|
102
|
+
this.style.display = this.isOpen ? "unset" : "none";
|
|
103
|
+
if (!this.isOpen) {
|
|
104
|
+
return html ``;
|
|
27
105
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
106
|
+
const elements = this.entries.map((e) => {
|
|
107
|
+
switch (e.type) {
|
|
108
|
+
case "button":
|
|
109
|
+
return this.buttonTemplate(e);
|
|
110
|
+
case "separator":
|
|
111
|
+
return this.separatorTemplate();
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
return html `${elements.length > 0 ? elements : html `<div class="context-menu-button muted">...</div>`}`;
|
|
115
|
+
}
|
|
116
|
+
buttonTemplate(button) {
|
|
117
|
+
const action = (e) => {
|
|
118
|
+
if (e.buttons !== 1) {
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
ContextMenu_1.close();
|
|
122
|
+
if (button.action) {
|
|
123
|
+
button.action();
|
|
124
|
+
}
|
|
125
|
+
e.stopImmediatePropagation();
|
|
126
|
+
e.stopPropagation();
|
|
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
|