@record-evolution/widget-switch 1.0.1 → 1.0.3

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/package.json CHANGED
@@ -2,14 +2,15 @@
2
2
  "name": "@record-evolution/widget-switch",
3
3
  "description": "IronFlock Widget widget-switch",
4
4
  "license": "MIT",
5
- "author": "widget-switch",
6
- "version": "1.0.1",
5
+ "author": "Record Evolution GmbH",
6
+ "version": "1.0.3",
7
7
  "engines": {
8
8
  "node": "18.18.2",
9
9
  "npm": ">=10.0.2"
10
10
  },
11
11
  "type": "module",
12
12
  "main": "dist/widget-switch.js",
13
+ "module": "dist/widget-switch.js",
13
14
  "types": "dist/src/widget-switch.d.ts",
14
15
  "files": [
15
16
  "dist",
@@ -18,8 +19,8 @@
18
19
  "scripts": {
19
20
  "analyze": "cem analyze --litelement",
20
21
  "start": "concurrently -k -r \"npm run watch\" \"wds\"",
21
- "build": "rollup -c rollup.config.js",
22
- "watch": "rollup -w -c rollup.config.js",
22
+ "build": "node rename-material-package.js && rollup -c rollup.config.js",
23
+ "watch": "node rename-material-package.js && rollup -w -c rollup.config.js",
23
24
  "link": "npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-switch",
24
25
  "unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-switch && npm i @record-evolution/widget-switch",
25
26
  "types": "cat src/definition-schema.json | json2ts > src/definition-schema.d.ts",
@@ -27,8 +28,8 @@
27
28
  "release": "npm run build && npm run types && npm version patch --tag-version-prefix='' && git push && git push --tag"
28
29
  },
29
30
  "dependencies": {
30
- "@material/web": "^2.3.0",
31
- "lit": "^3.3.0"
31
+ "@material/web": "^2.4.0",
32
+ "lit": "^3.3.1"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@custom-elements-manifest/analyzer": "^0.10.4",
@@ -5,8 +5,8 @@
5
5
  {
6
6
  "label": "Lamp",
7
7
  "stateMap": {
8
- "on": ">1",
9
- "off": "<=1"
8
+ "on": ">=1",
9
+ "off": "<1"
10
10
  },
11
11
  "styling": {
12
12
  "labelColor": "#000000",
@@ -20,12 +20,11 @@ export type ONValues = string;
20
20
  */
21
21
  export type OFFValues = string;
22
22
  /**
23
- * This should be an ISO String date like 2023-11-04T22:47:52.351152+00:00. Will only be used to detect age of data.
23
+ * Is not strictly required, but is strongly recommended to be connected to the backend column that represents the switch state. This keeps the switch state consistent with the backend data.
24
24
  */
25
- export type Timestamp = string;
26
- export type Value = string;
25
+ export type SwitchState = string;
27
26
  /**
28
- * The action topic that is called when clicking the switch. The arguments will be True for ON and False for OFF. Refer to the app documentation for available topics to call.
27
+ * The action topic that is called when clicking the switch. The arguments will be True for ON and False for OFF. Refer to your chosen apps documentation for available topics to call.
29
28
  */
30
29
  export type ActionTopic = string;
31
30
  /**
@@ -36,8 +35,7 @@ export type SplitDataBy = string;
36
35
  * The data for the switch state.
37
36
  */
38
37
  export type SwitchStateData = {
39
- tsp?: Timestamp;
40
- value?: Value;
38
+ value?: SwitchState;
41
39
  actionApp?: ActionApp;
42
40
  actionDevice?: ActionDeviceTarget;
43
41
  actionTopic?: ActionTopic;
@@ -75,21 +75,17 @@
75
75
  "items": {
76
76
  "type": "object",
77
77
  "properties": {
78
- "tsp": {
79
- "title": "Timestamp",
80
- "description": "This should be an ISO String date like 2023-11-04T22:47:52.351152+00:00. Will only be used to detect age of data.",
81
- "type": "string",
82
- "order": 1
83
- },
84
78
  "value": {
85
- "title": "Value",
79
+ "title": "Switch State",
86
80
  "type": "string",
87
- "required": true,
81
+ "description": "Is not strictly required, but is strongly recommended to be connected to the backend column that represents the switch state. This keeps the switch state consistent with the backend data.",
82
+ "required": false,
88
83
  "order": 2
89
84
  },
90
85
  "actionApp": {
91
86
  "title": "Action App",
92
87
  "description": "The app that should handle the click on the switch.",
88
+ "dataDrivenDisabled": true,
93
89
  "type": "actionApp",
94
90
  "order": 3
95
91
  },
@@ -101,7 +97,7 @@
101
97
  },
102
98
  "actionTopic": {
103
99
  "title": "Action Topic",
104
- "description": "The action topic that is called when clicking the switch. The arguments will be True for ON and False for OFF. Refer to the app documentation for available topics to call.",
100
+ "description": "The action topic that is called when clicking the switch. The arguments will be True for ON and False for OFF. Refer to your chosen apps documentation for available topics to call.",
105
101
  "type": "string",
106
102
  "order": 5
107
103
  },
@@ -99,7 +99,9 @@ export class WidgetSwitch extends LitElement {
99
99
  const prefix = piv ?? ''
100
100
  const label = ds.label ?? ''
101
101
  const value =
102
- distincts.length === 1 ? ds.data?.[0] : ds.data?.filter((d) => d.pivot === piv)?.[0]
102
+ distincts.length === 1
103
+ ? ds.data?.at(-1)
104
+ : ds.data?.filter((d) => d.pivot === piv)?.at(-1)
103
105
  const pds: Dataseries = {
104
106
  label: prefix + (!!prefix && !!label ? ' - ' : '') + label,
105
107
  actionApp: value?.actionApp,
@@ -178,7 +180,6 @@ export class WidgetSwitch extends LitElement {
178
180
  actionTopic: switchEl?.actionTopic,
179
181
  label: switchEl?.label
180
182
  }
181
- console.log('Action Submit', payload)
182
183
  this.dispatchEvent(
183
184
  new CustomEvent('action-submit', {
184
185
  detail: payload,
@@ -276,7 +277,6 @@ export class WidgetSwitch extends LitElement {
276
277
  </p>
277
278
  </header>
278
279
 
279
- <div class="paging no-data" ?active=${!this.dataSets.size}>No Data</div>
280
280
  <div class="value-container">
281
281
  ${repeat(
282
282
  [...this.dataSets.entries()].sort(),
@@ -286,7 +286,7 @@ export class WidgetSwitch extends LitElement {
286
286
  <div class="switch" label="${label}">
287
287
  ${label}
288
288
  <label
289
- ><md-switch
289
+ ><mdif3-switch
290
290
  aria-label="${label}"
291
291
  ?selected="${!!ds.selected}"
292
292
  .actionApp="${ds?.actionApp}"
@@ -294,7 +294,7 @@ export class WidgetSwitch extends LitElement {
294
294
  .actionTopic="${ds?.actionTopic}"
295
295
  .label="${label}"
296
296
  @change="${this.handleActionSubmit}"
297
- ></md-switch
297
+ ></mdif3-switch
298
298
  ></label>
299
299
  </div>
300
300
  `