@openremote/or-attribute-picker 1.8.0-snapshot.20250725070921 → 1.8.0-snapshot.20250725120000

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.
@@ -1,29 +1,170 @@
1
- var __decorate=this&&this.__decorate||function(t,e,o,r){var i,n=arguments.length,s=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,o):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,o,r);else for(var a=t.length-1;a>=0;a--)(i=t[a])&&(s=(n<3?i(s):n>3?i(e,o,s):i(e,o))||s);return n>3&&s&&Object.defineProperty(e,o,s),s},__awaiter=this&&this.__awaiter||function(t,e,o,r){return new(o||(o=Promise))(function(i,n){function s(t){try{l(r.next(t))}catch(t){n(t)}}function a(t){try{l(r.throw(t))}catch(t){n(t)}}function l(t){var e;t.done?i(t.value):((e=t.value)instanceof o?e:new o(function(t){t(e)})).then(s,a)}l((r=r.apply(t,e||[])).next())})};import{html as t,unsafeCSS as e}from"lit";import{property as o,query as r}from"lit/decorators.js";import"@openremote/or-asset-tree";import"@openremote/or-translate";import"@openremote/or-mwc-components/or-mwc-input";import"@openremote/or-mwc-components/or-mwc-list";import{InputType as i}from"@openremote/or-mwc-components/or-mwc-input";import{i18next as n}from"@openremote/or-translate";import{DefaultColor2 as s,DefaultColor4 as a,DefaultColor5 as l,Util as c}from"@openremote/core";import{OrMwcDialog as p}from"@openremote/or-mwc-components/or-mwc-dialog";import{when as u}from"lit/directives/when.js";import{ListType as m}from"@openremote/or-mwc-components/or-mwc-list";export class AttributePickerPickedEvent extends CustomEvent{}export class AttributePicker extends p{constructor(){super(...arguments),this.multiSelect=!1,this.showOnlyDatapointAttrs=!1,this.showOnlyRuleStateAttrs=!1}connectedCallback(){super.connectedCallback(),this.heading=n.t("selectAttributes"),this._setDialogContent(),this._setDialogActions(),this.dismissAction=null,this.styles=this._getStyles()}setShowOnlyDatapointAttrs(t){return this.showOnlyDatapointAttrs=t,this}setShowOnlyRuleStateAttrs(t){return this.showOnlyRuleStateAttrs=t,this}setMultiSelect(t){return this.multiSelect=t,this}setOpen(t){return super.setOpen(t),this}setHeading(t){return super.setHeading(t),this}setContent(t){throw Error("Cannot modify attribute picker content")}setActions(t){throw Error("Cannot modify attribute picker actions")}setDismissAction(t){throw Error("Cannot modify attribute picker dismiss action")}setStyles(t){throw Error("Cannot modify attribute picker styles")}setAvatar(t){throw Error("Cannot modify attribute picker avatar setting")}_updateDialogContent(){this._setDialogContent()}_updateDialogActions(){this._setDialogActions()}_getAttributesTemplate(e,o,r){return __awaiter(this,arguments,void 0,function*(e,o,r,s=!1,a){let l=Math.max((null==e?void 0:e.length)||0,(null==o?void 0:o.length)||0),p=[];for(let t=0;t<l;t++)p.push({text:c.getAttributeLabel(null==e?void 0:e[t],null==o?void 0:o[t],void 0,!0),value:(null==e?void 0:e[t].name)||(null==o?void 0:o[t].name)});return t`
2
- ${u(s,()=>t`
3
- <or-mwc-list id="attribute-selector" .type="${m.MULTI_CHECKBOX}" .listItems="${p}" .values="${r}"
4
- @or-mwc-list-changed="${t=>null==a?void 0:a(t.detail.map(t=>t.value))}"
5
- </or-mwc-list>
6
- `,()=>t`
7
- <or-mwc-input id="attribute-selector" .type="${i.LIST}" .options="${null==p?void 0:p.map(t=>[t,t.text])}"
8
- style="display:flex;" .label="${n.t("attribute")}"
9
- @or-mwc-input-changed="${t=>null==a?void 0:a([t.detail.value.value])}"
10
- ></or-mwc-input>
11
- `)}
12
- `})}_getStyles(){return`
13
- .attributes-header {
14
- line-height: 48px;
15
- padding: 0 15px;
16
- background-color: ${e(s)};
17
- font-weight: bold;
18
- border-bottom: 1px solid ${e(s)};
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
- footer.mdc-dialog__actions {
21
- border-top: 1px solid ${e(l)};
22
- }
23
- #header {
24
- background-color: ${e(a)} !important;
25
- }
26
- #dialog-content {
27
- padding: 0;
28
- }
29
- `}}__decorate([o({type:Boolean})],AttributePicker.prototype,"multiSelect",void 0),__decorate([o({type:Boolean})],AttributePicker.prototype,"showOnlyDatapointAttrs",void 0),__decorate([o({type:Boolean})],AttributePicker.prototype,"showOnlyRuleStateAttrs",void 0),__decorate([r("#add-btn")],AttributePicker.prototype,"addBtn",void 0);
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||function(t,e,r,i){var c,o=arguments.length,a=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,r,i);else for(var s=t.length-1;s>=0;s--)(c=t[s])&&(a=(o<3?c(a):o>3?c(e,r,a):c(e,r))||a);return o>3&&a&&Object.defineProperty(e,r,a),a};import{customElement as t}from"lit/decorators.js";import{OrAssetAttributePicker as e,OrAssetAttributePickerPickedEvent as r}from"./asset-attribute-picker";export class OrAttributePickerPickedEvent extends r{}let OrAttributePicker=class extends e{};OrAttributePicker=__decorate([t("or-attribute-picker")],OrAttributePicker);export*from"./asset-attribute-picker";export*from"./assettype-attribute-picker";export{OrAttributePicker};
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.20250725070921",
3
+ "version": "1.8.0-snapshot.20250725120000",
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.20250725070921",
22
- "@openremote/or-asset-tree": "1.8.0-snapshot.20250725070921",
23
- "@openremote/or-mwc-components": "1.8.0-snapshot.20250725070921",
24
- "@openremote/or-translate": "1.8.0-snapshot.20250725070921",
21
+ "@openremote/core": "1.8.0-snapshot.20250725120000",
22
+ "@openremote/or-asset-tree": "1.8.0-snapshot.20250725120000",
23
+ "@openremote/or-mwc-components": "1.8.0-snapshot.20250725120000",
24
+ "@openremote/or-translate": "1.8.0-snapshot.20250725120000",
25
25
  "lit": "^2.0.2"
26
26
  },
27
27
  "devDependencies": {
28
- "@openremote/util": "1.8.0-snapshot.20250725070921"
28
+ "@openremote/util": "1.8.0-snapshot.20250725120000"
29
29
  },
30
30
  "publishConfig": {
31
31
  "access": "public"