@openremote/or-attribute-picker 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 +31 -31
- package/custom-elements.json +19 -19
- package/dist/umd/index.js +616 -616
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.orbundle.js +1311 -1311
- package/dist/umd/index.orbundle.js.map +1 -1
- package/lib/asset-attribute-picker.js +183 -24
- package/lib/assettype-attribute-picker.js +223 -24
- package/lib/assettype-list.js +23 -5
- package/lib/attribute-picker.js +169 -28
- package/lib/index.js +27 -1
- package/package.json +6 -6
package/lib/attribute-picker.js
CHANGED
|
@@ -1,29 +1,170 @@
|
|
|
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
|
+
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 { html, unsafeCSS } from "lit";
|
|
17
|
+
import { property, query } from "lit/decorators.js";
|
|
18
|
+
import "@openremote/or-asset-tree";
|
|
19
|
+
import "@openremote/or-translate";
|
|
20
|
+
import "@openremote/or-mwc-components/or-mwc-input";
|
|
21
|
+
import "@openremote/or-mwc-components/or-mwc-list";
|
|
22
|
+
import { InputType } from "@openremote/or-mwc-components/or-mwc-input";
|
|
23
|
+
import { i18next } from "@openremote/or-translate";
|
|
24
|
+
import { DefaultColor2, DefaultColor4, DefaultColor5, Util } from "@openremote/core";
|
|
25
|
+
import { OrMwcDialog } from "@openremote/or-mwc-components/or-mwc-dialog";
|
|
26
|
+
import { when } from "lit/directives/when.js";
|
|
27
|
+
import { ListType } from "@openremote/or-mwc-components/or-mwc-list";
|
|
28
|
+
export class AttributePickerPickedEvent extends CustomEvent {
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @summary Abstract implementation of the Attribute Picker UI. Wraps around OrMwcDialog and provides some utility properties and functions to inherit.
|
|
32
|
+
*
|
|
33
|
+
* @attribute {boolean} multiSelect - Whether selecting multiple attributes is allowed or not.
|
|
34
|
+
* @attribute {boolean} showOnlyDatapointAttrs - Whether only attributes with the 'STORE_DATAPOINT' meta item should be shown.
|
|
35
|
+
* @attribute {boolean} showOnlyRuleStateAttrs - Whether only attributes with the 'RULE_STATE' meta item should be shown.
|
|
36
|
+
*
|
|
37
|
+
* @remarks This class is abstract
|
|
38
|
+
*/
|
|
39
|
+
export class AttributePicker extends OrMwcDialog {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.multiSelect = false;
|
|
43
|
+
this.showOnlyDatapointAttrs = false;
|
|
44
|
+
this.showOnlyRuleStateAttrs = false;
|
|
45
|
+
}
|
|
46
|
+
connectedCallback() {
|
|
47
|
+
super.connectedCallback();
|
|
48
|
+
this.heading = i18next.t("selectAttributes");
|
|
49
|
+
this._setDialogContent();
|
|
50
|
+
this._setDialogActions();
|
|
51
|
+
this.dismissAction = null;
|
|
52
|
+
this.styles = this._getStyles();
|
|
53
|
+
}
|
|
54
|
+
setShowOnlyDatapointAttrs(showOnlyDatapointAttrs) {
|
|
55
|
+
this.showOnlyDatapointAttrs = showOnlyDatapointAttrs;
|
|
56
|
+
return this;
|
|
57
|
+
}
|
|
58
|
+
setShowOnlyRuleStateAttrs(showOnlyRuleStateAttrs) {
|
|
59
|
+
this.showOnlyRuleStateAttrs = showOnlyRuleStateAttrs;
|
|
60
|
+
return this;
|
|
61
|
+
}
|
|
62
|
+
setMultiSelect(multiSelect) {
|
|
63
|
+
this.multiSelect = multiSelect;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
setOpen(isOpen) {
|
|
67
|
+
super.setOpen(isOpen);
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
setHeading(heading) {
|
|
71
|
+
super.setHeading(heading);
|
|
72
|
+
return this;
|
|
73
|
+
}
|
|
74
|
+
setContent(_content) {
|
|
75
|
+
throw new Error("Cannot modify attribute picker content");
|
|
76
|
+
}
|
|
77
|
+
setActions(_actions) {
|
|
78
|
+
throw new Error("Cannot modify attribute picker actions");
|
|
79
|
+
}
|
|
80
|
+
setDismissAction(_action) {
|
|
81
|
+
throw new Error("Cannot modify attribute picker dismiss action");
|
|
82
|
+
}
|
|
83
|
+
setStyles(_styles) {
|
|
84
|
+
throw new Error("Cannot modify attribute picker styles");
|
|
85
|
+
}
|
|
86
|
+
setAvatar(_avatar) {
|
|
87
|
+
throw new Error("Cannot modify attribute picker avatar setting");
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Convenient function to update the dialog content manually,
|
|
91
|
+
* since updating the UI is handled different for {@link OrMwcDialog}.
|
|
92
|
+
*/
|
|
93
|
+
_updateDialogContent() {
|
|
94
|
+
this._setDialogContent();
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Convenient function to update the dialog actions manually,
|
|
98
|
+
* since updating the UI is handled different for {@link OrMwcDialog}.
|
|
99
|
+
*/
|
|
100
|
+
_updateDialogActions() {
|
|
101
|
+
this._setDialogActions();
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Function that creates the HTML template for selecting attributes.
|
|
105
|
+
* Currently uses {@link OrMwcList} with or without checkboxes, and uses {@link Util.getAttributeLabel} to formulate the text.
|
|
106
|
+
*
|
|
107
|
+
* @remarks TODO: Move this template into a separate component, such as an "or-attribute-list"
|
|
108
|
+
*/
|
|
109
|
+
_getAttributesTemplate(attributes_1, descriptors_1, selectedNames_1) {
|
|
110
|
+
return __awaiter(this, arguments, void 0, function* (attributes, descriptors, selectedNames, multi = false, onSelect) {
|
|
111
|
+
const length = Math.max(((attributes === null || attributes === void 0 ? void 0 : attributes.length) || 0), ((descriptors === null || descriptors === void 0 ? void 0 : descriptors.length) || 0));
|
|
112
|
+
const listItems = [];
|
|
113
|
+
for (let i = 0; i < length; i++) {
|
|
114
|
+
listItems.push({
|
|
115
|
+
text: Util.getAttributeLabel(attributes === null || attributes === void 0 ? void 0 : attributes[i], descriptors === null || descriptors === void 0 ? void 0 : descriptors[i], undefined, true),
|
|
116
|
+
value: ((attributes === null || attributes === void 0 ? void 0 : attributes[i].name) || (descriptors === null || descriptors === void 0 ? void 0 : descriptors[i].name)),
|
|
117
|
+
});
|
|
19
118
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
119
|
+
return html `
|
|
120
|
+
${when(multi, () => html `
|
|
121
|
+
<or-mwc-list id="attribute-selector" .type="${ListType.MULTI_CHECKBOX}" .listItems="${listItems}" .values="${selectedNames}"
|
|
122
|
+
@or-mwc-list-changed="${(ev) => onSelect === null || onSelect === void 0 ? void 0 : onSelect(ev.detail.map(item => item.value))}"
|
|
123
|
+
</or-mwc-list>
|
|
124
|
+
`, () => html `
|
|
125
|
+
<or-mwc-input id="attribute-selector" .type="${InputType.LIST}" .options="${listItems === null || listItems === void 0 ? void 0 : listItems.map(item => ([item, item.text]))}"
|
|
126
|
+
style="display:flex;" .label="${i18next.t("attribute")}"
|
|
127
|
+
@or-mwc-input-changed="${(ev) => onSelect === null || onSelect === void 0 ? void 0 : onSelect([ev.detail.value.value])}"
|
|
128
|
+
></or-mwc-input>
|
|
129
|
+
`)}
|
|
130
|
+
`;
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Simple function that creates the CSS styles for this component
|
|
135
|
+
*/
|
|
136
|
+
_getStyles() {
|
|
137
|
+
// language=css
|
|
138
|
+
return `
|
|
139
|
+
.attributes-header {
|
|
140
|
+
line-height: 48px;
|
|
141
|
+
padding: 0 15px;
|
|
142
|
+
background-color: ${unsafeCSS(DefaultColor2)};
|
|
143
|
+
font-weight: bold;
|
|
144
|
+
border-bottom: 1px solid ${unsafeCSS(DefaultColor2)};
|
|
145
|
+
}
|
|
146
|
+
footer.mdc-dialog__actions {
|
|
147
|
+
border-top: 1px solid ${unsafeCSS(DefaultColor5)};
|
|
148
|
+
}
|
|
149
|
+
#header {
|
|
150
|
+
background-color: ${unsafeCSS(DefaultColor4)} !important;
|
|
151
|
+
}
|
|
152
|
+
#dialog-content {
|
|
153
|
+
padding: 0;
|
|
154
|
+
}
|
|
155
|
+
`;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
__decorate([
|
|
159
|
+
property({ type: Boolean })
|
|
160
|
+
], AttributePicker.prototype, "multiSelect", void 0);
|
|
161
|
+
__decorate([
|
|
162
|
+
property({ type: Boolean })
|
|
163
|
+
], AttributePicker.prototype, "showOnlyDatapointAttrs", void 0);
|
|
164
|
+
__decorate([
|
|
165
|
+
property({ type: Boolean })
|
|
166
|
+
], AttributePicker.prototype, "showOnlyRuleStateAttrs", void 0);
|
|
167
|
+
__decorate([
|
|
168
|
+
query("#add-btn")
|
|
169
|
+
], AttributePicker.prototype, "addBtn", void 0);
|
|
170
|
+
//# sourceMappingURL=attribute-picker.js.map
|
package/lib/index.js
CHANGED
|
@@ -1 +1,27 @@
|
|
|
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 { customElement } from "lit/decorators.js";
|
|
8
|
+
import { OrAssetAttributePicker, OrAssetAttributePickerPickedEvent } from "./asset-attribute-picker";
|
|
9
|
+
/**
|
|
10
|
+
* {@link CustomEvent} that triggers once attributes have been selected, and the user closes the dialog.
|
|
11
|
+
* @deprecated Replaced this class with an abstract {@link OrAssetAttributePickerPickedEvent}, that is inherited by other classes like {@link OrAssetAttributePicker} and {@link OrAssetTypeAttributePicker}.
|
|
12
|
+
*/
|
|
13
|
+
export class OrAttributePickerPickedEvent extends OrAssetAttributePickerPickedEvent {
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Dialog to pick attributes of supplied asset(s).
|
|
17
|
+
* @deprecated Replaced this class with {@link OrAssetAttributePicker}.
|
|
18
|
+
*/
|
|
19
|
+
let OrAttributePicker = class OrAttributePicker extends OrAssetAttributePicker {
|
|
20
|
+
};
|
|
21
|
+
OrAttributePicker = __decorate([
|
|
22
|
+
customElement("or-attribute-picker")
|
|
23
|
+
], OrAttributePicker);
|
|
24
|
+
export { OrAttributePicker };
|
|
25
|
+
export * from "./asset-attribute-picker";
|
|
26
|
+
export * from "./assettype-attribute-picker";
|
|
27
|
+
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openremote/or-attribute-picker",
|
|
3
|
-
"version": "1.8.0-snapshot.
|
|
3
|
+
"version": "1.8.0-snapshot.20250725120001",
|
|
4
4
|
"description": "OpenRemote attribute picker dialog",
|
|
5
5
|
"customElements": "custom-elements.json",
|
|
6
6
|
"main": "dist/umd/index.bundle.js",
|
|
@@ -18,14 +18,14 @@
|
|
|
18
18
|
"author": "OpenRemote",
|
|
19
19
|
"license": "AGPL-3.0-or-later",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@openremote/core": "1.8.0-snapshot.
|
|
22
|
-
"@openremote/or-asset-tree": "1.8.0-snapshot.
|
|
23
|
-
"@openremote/or-mwc-components": "1.8.0-snapshot.
|
|
24
|
-
"@openremote/or-translate": "1.8.0-snapshot.
|
|
21
|
+
"@openremote/core": "1.8.0-snapshot.20250725120001",
|
|
22
|
+
"@openremote/or-asset-tree": "1.8.0-snapshot.20250725120001",
|
|
23
|
+
"@openremote/or-mwc-components": "1.8.0-snapshot.20250725120001",
|
|
24
|
+
"@openremote/or-translate": "1.8.0-snapshot.20250725120001",
|
|
25
25
|
"lit": "^2.0.2"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@openremote/util": "1.8.0-snapshot.
|
|
28
|
+
"@openremote/util": "1.8.0-snapshot.20250725120001"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|