@record-evolution/widget-switch 1.0.5 → 1.1.2
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 +92 -68
- package/dist/widget-switch.js +180 -3025
- package/dist/widget-switch.js.map +1 -1
- package/package.json +15 -29
- package/src/default-data.json +10 -20
- package/src/definition-schema.d.ts +34 -46
- package/src/definition-schema.json +29 -47
- package/src/widget-switch.ts +71 -38
- package/dist/src/widget-switch.d.ts +0 -38
- package/dist/tsconfig.tsbuildinfo +0 -1
package/package.json
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
"description": "IronFlock Widget widget-switch",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Record Evolution GmbH",
|
|
6
|
-
"version": "1.
|
|
6
|
+
"version": "1.1.2",
|
|
7
7
|
"engines": {
|
|
8
|
-
"node": "
|
|
8
|
+
"node": ">=24.9.0",
|
|
9
9
|
"npm": ">=10.0.2"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
@@ -19,42 +19,28 @@
|
|
|
19
19
|
],
|
|
20
20
|
"scripts": {
|
|
21
21
|
"analyze": "cem analyze --litelement",
|
|
22
|
-
"start": "
|
|
23
|
-
"build": "
|
|
24
|
-
"watch": "
|
|
25
|
-
"link": "npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-switch",
|
|
22
|
+
"start": "vite",
|
|
23
|
+
"build": "vite build",
|
|
24
|
+
"watch": "vite build --watch",
|
|
25
|
+
"link": "npm run build && npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-switch",
|
|
26
26
|
"unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-switch && npm i @record-evolution/widget-switch",
|
|
27
|
-
"types": "cat src/definition-schema.json | json2ts > src/definition-schema.d.ts",
|
|
28
|
-
"start:build": "npm run build && es-dev-server --root-dir dist --app-index index.html --compatibility none --open",
|
|
27
|
+
"types": "cat src/definition-schema.json | json2ts --style.tabWidth=4 > src/definition-schema.d.ts",
|
|
29
28
|
"release": "npm run build && npm run types && npm version patch --tag-version-prefix='' && git push && git push --tag && npm run build"
|
|
30
29
|
},
|
|
31
30
|
"dependencies": {
|
|
32
|
-
"
|
|
33
|
-
"
|
|
31
|
+
"lit": "^3.3.2",
|
|
32
|
+
"tslib": "^2.8.1"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"@material/web": "^2.4.1"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@custom-elements-manifest/analyzer": "^0.10.4",
|
|
37
|
-
"@
|
|
38
|
-
"@rollup/plugin-commonjs": "^28.0.6",
|
|
39
|
-
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
39
|
+
"@material/web": "^2.4.1",
|
|
40
40
|
"@rollup/plugin-replace": "^6.0.2",
|
|
41
|
-
"@rollup/plugin-typescript": "^12.1.3",
|
|
42
|
-
"@typescript-eslint/eslint-plugin": "^8.34.1",
|
|
43
|
-
"@typescript-eslint/parser": "^8.34.1",
|
|
44
|
-
"@web/dev-server": "^0.4.6",
|
|
45
|
-
"concurrently": "^9.1.2",
|
|
46
|
-
"deepmerge": "^4.3.1",
|
|
47
|
-
"es-dev-server": "^2.1.0",
|
|
48
|
-
"eslint": "^9.29.0",
|
|
49
|
-
"eslint-config-prettier": "^10.1.5",
|
|
50
|
-
"husky": "^9.1.7",
|
|
51
41
|
"json-schema-to-typescript": "^15.0.4",
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"rimraf": "^6.0.1",
|
|
55
|
-
"rollup": "^4.43.0",
|
|
56
|
-
"tslib": "^2.8.1",
|
|
57
|
-
"typescript": "^5.8.3"
|
|
42
|
+
"typescript": "5.9.3",
|
|
43
|
+
"vite": "^7.3.0"
|
|
58
44
|
},
|
|
59
45
|
"repository": {
|
|
60
46
|
"type": "git",
|
package/src/default-data.json
CHANGED
|
@@ -8,19 +8,14 @@
|
|
|
8
8
|
"on": ">=1",
|
|
9
9
|
"off": "<1"
|
|
10
10
|
},
|
|
11
|
+
"value": 1,
|
|
12
|
+
"actionApp": "machineControlApp",
|
|
13
|
+
"actionDevice": 1,
|
|
14
|
+
"actionTopic": "lamp",
|
|
11
15
|
"styling": {
|
|
12
16
|
"labelColor": "#000000",
|
|
13
17
|
"valueColor": "#00cc66"
|
|
14
|
-
}
|
|
15
|
-
"data": [
|
|
16
|
-
{
|
|
17
|
-
"tsp": "2025-07-15T10:00:00.000Z",
|
|
18
|
-
"value": 1,
|
|
19
|
-
"actionApp": "machineControlApp",
|
|
20
|
-
"actionDevice": 1,
|
|
21
|
-
"actionTopic": "lamp"
|
|
22
|
-
}
|
|
23
|
-
]
|
|
18
|
+
}
|
|
24
19
|
},
|
|
25
20
|
{
|
|
26
21
|
"label": "Cooling",
|
|
@@ -28,19 +23,14 @@
|
|
|
28
23
|
"on": "COOL_ON,1",
|
|
29
24
|
"off": "COOL_OFF,0"
|
|
30
25
|
},
|
|
26
|
+
"value": "COOL_ON",
|
|
27
|
+
"actionApp": "coolingSystemApp",
|
|
28
|
+
"actionDevice": 1,
|
|
29
|
+
"actionTopic": "cooling",
|
|
31
30
|
"styling": {
|
|
32
31
|
"labelColor": "#0033cc",
|
|
33
32
|
"valueColor": "#0099ff"
|
|
34
|
-
}
|
|
35
|
-
"data": [
|
|
36
|
-
{
|
|
37
|
-
"tsp": "2025-07-15T10:05:00.000Z",
|
|
38
|
-
"value": "COOL_ON",
|
|
39
|
-
"actionApp": "coolingSystemApp",
|
|
40
|
-
"actionDevice": 1,
|
|
41
|
-
"actionTopic": "cooling"
|
|
42
|
-
}
|
|
43
|
-
]
|
|
33
|
+
}
|
|
44
34
|
}
|
|
45
35
|
]
|
|
46
36
|
}
|
|
@@ -20,70 +20,58 @@ export type ONValues = string;
|
|
|
20
20
|
*/
|
|
21
21
|
export type OFFValues = string;
|
|
22
22
|
/**
|
|
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
|
|
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 visual state consistent with its physical state.
|
|
24
24
|
*/
|
|
25
25
|
export type SwitchState = string;
|
|
26
26
|
/**
|
|
27
|
-
* The action topic that is called when clicking the switch. The arguments will be True for ON and False for OFF. Refer to
|
|
27
|
+
* The action topic that is called at the selected app at the selected device when clicking the switch. The arguments will be True for 'ON' and False for 'OFF'. Refer to the documentation of the app for available topics to call.
|
|
28
28
|
*/
|
|
29
|
-
export type
|
|
30
|
-
/**
|
|
31
|
-
* You can specify a column in the input data to autogenerate dataseries for each distinct entry in this column. E.g. if you have a table with columns [city, timestamp, temperature] and specify 'city' as split column, then you will get a value field for each city.
|
|
32
|
-
*/
|
|
33
|
-
export type SplitDataBy = string;
|
|
34
|
-
/**
|
|
35
|
-
* The data for the switch state.
|
|
36
|
-
*/
|
|
37
|
-
export type SwitchStateData = {
|
|
38
|
-
value?: SwitchState;
|
|
39
|
-
actionApp?: ActionApp;
|
|
40
|
-
actionDevice?: ActionDeviceTarget;
|
|
41
|
-
actionTopic?: ActionTopic;
|
|
42
|
-
pivot?: SplitDataBy;
|
|
43
|
-
[k: string]: unknown;
|
|
44
|
-
}[];
|
|
29
|
+
export type ActionAppTopic = string;
|
|
45
30
|
export type Switches = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
label?: Label;
|
|
32
|
+
stateMap?: StateMap;
|
|
33
|
+
value?: SwitchState;
|
|
34
|
+
actionDevice?: ActionDeviceTarget;
|
|
35
|
+
actionApp?: ActionApp;
|
|
36
|
+
actionTopic?: ActionAppTopic;
|
|
37
|
+
styling?: Styling;
|
|
38
|
+
[k: string]: unknown;
|
|
51
39
|
}[];
|
|
52
40
|
|
|
53
41
|
export interface InputData {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
title?: Title;
|
|
43
|
+
subTitle?: Subtitle;
|
|
44
|
+
dataseries?: Switches;
|
|
45
|
+
[k: string]: unknown;
|
|
58
46
|
}
|
|
59
47
|
/**
|
|
60
48
|
* Specify the values for the ON and OFF states. Any value that does not match to either an ON or OFF state will be considered as UNKNOWN.
|
|
61
49
|
*/
|
|
62
50
|
export interface StateMap {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
on?: ONValues;
|
|
52
|
+
off?: OFFValues;
|
|
53
|
+
[k: string]: unknown;
|
|
66
54
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
export interface LabelColor {
|
|
73
|
-
[k: string]: unknown;
|
|
74
|
-
}
|
|
75
|
-
export interface ValueColor {
|
|
76
|
-
[k: string]: unknown;
|
|
55
|
+
/**
|
|
56
|
+
* The device that should handle the click on the switch. The 'Device ID' column can be used here when using data driven mode.
|
|
57
|
+
*/
|
|
58
|
+
export interface ActionDeviceTarget {
|
|
59
|
+
[k: string]: unknown;
|
|
77
60
|
}
|
|
78
61
|
/**
|
|
79
62
|
* The app that should handle the click on the switch.
|
|
80
63
|
*/
|
|
81
64
|
export interface ActionApp {
|
|
82
|
-
|
|
65
|
+
[k: string]: unknown;
|
|
83
66
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
67
|
+
export interface Styling {
|
|
68
|
+
labelColor?: LabelColor;
|
|
69
|
+
valueColor?: ValueColor;
|
|
70
|
+
[k: string]: unknown;
|
|
71
|
+
}
|
|
72
|
+
export interface LabelColor {
|
|
73
|
+
[k: string]: unknown;
|
|
74
|
+
}
|
|
75
|
+
export interface ValueColor {
|
|
76
|
+
[k: string]: unknown;
|
|
89
77
|
}
|
|
@@ -15,8 +15,7 @@
|
|
|
15
15
|
"dataseries": {
|
|
16
16
|
"title": "Switches",
|
|
17
17
|
"type": "array",
|
|
18
|
-
"
|
|
19
|
-
"order": 2,
|
|
18
|
+
"order": 3,
|
|
20
19
|
"items": {
|
|
21
20
|
"type": "object",
|
|
22
21
|
"properties": {
|
|
@@ -31,7 +30,7 @@
|
|
|
31
30
|
"description": "Specify the values for the ON and OFF states. Any value that does not match to either an ON or OFF state will be considered as UNKNOWN.",
|
|
32
31
|
"type": "object",
|
|
33
32
|
"required": true,
|
|
34
|
-
"order":
|
|
33
|
+
"order": 2,
|
|
35
34
|
"properties": {
|
|
36
35
|
"on": {
|
|
37
36
|
"title": "ON Values",
|
|
@@ -47,11 +46,37 @@
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
},
|
|
49
|
+
"value": {
|
|
50
|
+
"title": "Switch State",
|
|
51
|
+
"type": "string",
|
|
52
|
+
"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 visual state consistent with its physical state.",
|
|
53
|
+
"required": false,
|
|
54
|
+
"order": 3
|
|
55
|
+
},
|
|
56
|
+
"actionDevice": {
|
|
57
|
+
"title": "Action Device Target",
|
|
58
|
+
"description": "The device that should handle the click on the switch. The 'Device ID' column can be used here when using data driven mode.",
|
|
59
|
+
"type": "actionDevice",
|
|
60
|
+
"order": 4
|
|
61
|
+
},
|
|
62
|
+
"actionApp": {
|
|
63
|
+
"title": "Action App",
|
|
64
|
+
"description": "The app that should handle the click on the switch.",
|
|
65
|
+
"dataDrivenDisabled": true,
|
|
66
|
+
"type": "actionApp",
|
|
67
|
+
"order": 5
|
|
68
|
+
},
|
|
69
|
+
"actionTopic": {
|
|
70
|
+
"title": "Action App Topic",
|
|
71
|
+
"description": "The action topic that is called at the selected app at the selected device when clicking the switch. The arguments will be True for 'ON' and False for 'OFF'. Refer to the documentation of the app for available topics to call.",
|
|
72
|
+
"type": "string",
|
|
73
|
+
"order": 6
|
|
74
|
+
},
|
|
50
75
|
"styling": {
|
|
51
76
|
"title": "Styling",
|
|
52
77
|
"description": "",
|
|
53
78
|
"type": "object",
|
|
54
|
-
"order":
|
|
79
|
+
"order": 9,
|
|
55
80
|
"properties": {
|
|
56
81
|
"labelColor": {
|
|
57
82
|
"title": "Label Color",
|
|
@@ -66,49 +91,6 @@
|
|
|
66
91
|
"order": 5
|
|
67
92
|
}
|
|
68
93
|
}
|
|
69
|
-
},
|
|
70
|
-
"data": {
|
|
71
|
-
"title": "Switch State Data",
|
|
72
|
-
"description": "The data for the switch state.",
|
|
73
|
-
"type": "array",
|
|
74
|
-
"order": 4,
|
|
75
|
-
"items": {
|
|
76
|
-
"type": "object",
|
|
77
|
-
"properties": {
|
|
78
|
-
"value": {
|
|
79
|
-
"title": "Switch State",
|
|
80
|
-
"type": "string",
|
|
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,
|
|
83
|
-
"order": 2
|
|
84
|
-
},
|
|
85
|
-
"actionApp": {
|
|
86
|
-
"title": "Action App",
|
|
87
|
-
"description": "The app that should handle the click on the switch.",
|
|
88
|
-
"dataDrivenDisabled": true,
|
|
89
|
-
"type": "actionApp",
|
|
90
|
-
"order": 3
|
|
91
|
-
},
|
|
92
|
-
"actionDevice": {
|
|
93
|
-
"title": "Action Device Target",
|
|
94
|
-
"description": "The device that should handele the click on the switch. The 'Device ID' column can be used here when using data driven mode.",
|
|
95
|
-
"type": "actionDevice",
|
|
96
|
-
"order": 4
|
|
97
|
-
},
|
|
98
|
-
"actionTopic": {
|
|
99
|
-
"title": "Action Topic",
|
|
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.",
|
|
101
|
-
"type": "string",
|
|
102
|
-
"order": 5
|
|
103
|
-
},
|
|
104
|
-
"pivot": {
|
|
105
|
-
"title": "Split Data by",
|
|
106
|
-
"description": "You can specify a column in the input data to autogenerate dataseries for each distinct entry in this column. E.g. if you have a table with columns [city, timestamp, temperature] and specify 'city' as split column, then you will get a value field for each city.",
|
|
107
|
-
"type": "string",
|
|
108
|
-
"order": 6
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
94
|
}
|
|
113
95
|
}
|
|
114
96
|
}
|
package/src/widget-switch.ts
CHANGED
|
@@ -6,7 +6,6 @@ import '@material/web/switch/switch.js'
|
|
|
6
6
|
import { MdSwitch } from '@material/web/switch/switch.js'
|
|
7
7
|
|
|
8
8
|
type Dataseries = Exclude<InputData['dataseries'], undefined>[number] & { needleValue?: number }
|
|
9
|
-
type Data = Exclude<Dataseries['data'], undefined>[number]
|
|
10
9
|
type Theme = {
|
|
11
10
|
theme_name: string
|
|
12
11
|
theme_object: any
|
|
@@ -28,6 +27,7 @@ export class WidgetSwitch extends LitElement {
|
|
|
28
27
|
@state() private themeBgColor?: string
|
|
29
28
|
@state() private themeTitleColor?: string
|
|
30
29
|
@state() private themeSubtitleColor?: string
|
|
30
|
+
@state() private themePrimaryColor?: string
|
|
31
31
|
|
|
32
32
|
version: string = 'versionplaceholder'
|
|
33
33
|
|
|
@@ -74,10 +74,12 @@ export class WidgetSwitch extends LitElement {
|
|
|
74
74
|
registerTheme(theme?: Theme) {
|
|
75
75
|
const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
|
|
76
76
|
const cssBgColor = getComputedStyle(this).getPropertyValue('--re-tile-background-color').trim()
|
|
77
|
+
const cssPrimaryColor = getComputedStyle(this).getPropertyValue('--re-primary-color').trim()
|
|
77
78
|
this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor
|
|
78
79
|
this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color
|
|
79
80
|
this.themeSubtitleColor =
|
|
80
81
|
cssTextColor || this.theme?.theme_object?.title?.subtextStyle?.color || this.themeTitleColor
|
|
82
|
+
this.themePrimaryColor = cssPrimaryColor || this.theme?.theme_object?.color?.[0] || '#5470c6'
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
applyData() {}
|
|
@@ -90,83 +92,79 @@ export class WidgetSwitch extends LitElement {
|
|
|
90
92
|
this.dataSets = new Map()
|
|
91
93
|
this.inputData?.dataseries
|
|
92
94
|
// ?.sort((a, b) => a.order - b.order)
|
|
93
|
-
?.forEach((ds) => {
|
|
95
|
+
?.forEach((ds, idx) => {
|
|
94
96
|
// pivot data
|
|
95
|
-
const distincts = [...new Set(ds.data?.map((d: Data) => d.pivot))].sort() as string[]
|
|
96
97
|
ds.selected = undefined
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
selected: this.isSelected(ds, value)
|
|
112
|
-
}
|
|
113
|
-
this.dataSets.set(pds.label ?? '', pds)
|
|
114
|
-
})
|
|
98
|
+
let label = ds.label
|
|
99
|
+
if (this.dataSets.has(label ?? '')) {
|
|
100
|
+
label += '-' + idx
|
|
101
|
+
}
|
|
102
|
+
const pds: Dataseries = {
|
|
103
|
+
label: label,
|
|
104
|
+
actionApp: ds?.actionApp,
|
|
105
|
+
actionDevice: ds?.actionDevice,
|
|
106
|
+
actionTopic: ds?.actionTopic,
|
|
107
|
+
multiChart: ds.multiChart,
|
|
108
|
+
styling: ds.styling,
|
|
109
|
+
selected: this.isSelected(ds)
|
|
110
|
+
}
|
|
111
|
+
this.dataSets.set(pds.label ?? '', pds)
|
|
115
112
|
})
|
|
116
113
|
// console.log('Value Datasets', this.dataSets)
|
|
117
114
|
}
|
|
118
115
|
|
|
119
|
-
isSelected(ds: Dataseries
|
|
120
|
-
|
|
116
|
+
isSelected(ds: Dataseries): boolean | undefined {
|
|
117
|
+
const value = ds.value
|
|
118
|
+
if (value === undefined) return undefined
|
|
121
119
|
const on = ds?.stateMap?.on
|
|
122
120
|
if (on?.startsWith('<=')) {
|
|
123
|
-
const val = parseFloat(value
|
|
121
|
+
const val = parseFloat(value ?? '')
|
|
124
122
|
const comp = parseFloat(on.substring(2))
|
|
125
123
|
return isNaN(val) || isNaN(comp) ? undefined : val <= comp
|
|
126
124
|
}
|
|
127
125
|
if (on?.startsWith('<')) {
|
|
128
|
-
const val = parseFloat(value
|
|
126
|
+
const val = parseFloat(value ?? '')
|
|
129
127
|
const comp = parseFloat(on.substring(1))
|
|
130
128
|
return isNaN(val) || isNaN(comp) ? undefined : val < comp
|
|
131
129
|
}
|
|
132
130
|
if (on?.startsWith('>=')) {
|
|
133
|
-
const val = parseFloat(value
|
|
131
|
+
const val = parseFloat(value ?? '')
|
|
134
132
|
const comp = parseFloat(on.substring(2))
|
|
135
133
|
return isNaN(val) || isNaN(comp) ? undefined : val >= comp
|
|
136
134
|
}
|
|
137
135
|
if (on?.startsWith('>')) {
|
|
138
|
-
const val = parseFloat(value
|
|
136
|
+
const val = parseFloat(value ?? '')
|
|
139
137
|
const comp = parseFloat(on.substring(1))
|
|
140
138
|
return isNaN(val) || isNaN(comp) ? undefined : val > comp
|
|
141
139
|
}
|
|
142
140
|
|
|
143
141
|
const off = ds?.stateMap?.off
|
|
144
142
|
if (off?.startsWith('<=')) {
|
|
145
|
-
const val = parseFloat(value
|
|
143
|
+
const val = parseFloat(value ?? '')
|
|
146
144
|
const comp = parseFloat(off.substring(2))
|
|
147
145
|
return isNaN(val) || isNaN(comp) ? undefined : val > comp
|
|
148
146
|
}
|
|
149
147
|
if (off?.startsWith('<')) {
|
|
150
|
-
const val = parseFloat(value
|
|
148
|
+
const val = parseFloat(value ?? '')
|
|
151
149
|
const comp = parseFloat(off.substring(1))
|
|
152
150
|
return isNaN(val) || isNaN(comp) ? undefined : val <= comp
|
|
153
151
|
}
|
|
154
152
|
if (off?.startsWith('>=')) {
|
|
155
|
-
const val = parseFloat(value
|
|
153
|
+
const val = parseFloat(value ?? '')
|
|
156
154
|
const comp = parseFloat(off.substring(2))
|
|
157
155
|
return isNaN(val) || isNaN(comp) ? undefined : val < comp
|
|
158
156
|
}
|
|
159
157
|
if (off?.startsWith('>')) {
|
|
160
|
-
const val = parseFloat(value
|
|
158
|
+
const val = parseFloat(value ?? '')
|
|
161
159
|
const comp = parseFloat(off.substring(1))
|
|
162
160
|
return isNaN(val) || isNaN(comp) ? undefined : val <= comp
|
|
163
161
|
}
|
|
164
162
|
|
|
165
163
|
const onValues = on?.split(',').map((v) => v.trim().replace('"', '').replace("'", '')) ?? []
|
|
166
|
-
if (onValues.includes(String(value
|
|
164
|
+
if (onValues.includes(String(value) ?? '')) return true
|
|
167
165
|
|
|
168
166
|
const offValues = off?.split(',').map((v) => v.trim().replace('"', '').replace("'", '')) ?? []
|
|
169
|
-
if (offValues.includes(String(value
|
|
167
|
+
if (offValues.includes(String(value) ?? '')) return false
|
|
170
168
|
|
|
171
169
|
return undefined
|
|
172
170
|
}
|
|
@@ -207,7 +205,7 @@ export class WidgetSwitch extends LitElement {
|
|
|
207
205
|
flex-direction: column;
|
|
208
206
|
height: 100%;
|
|
209
207
|
width: 100%;
|
|
210
|
-
padding:
|
|
208
|
+
padding: 2cqh 2cqw;
|
|
211
209
|
box-sizing: border-box;
|
|
212
210
|
}
|
|
213
211
|
|
|
@@ -246,7 +244,40 @@ export class WidgetSwitch extends LitElement {
|
|
|
246
244
|
align-items: center;
|
|
247
245
|
gap: 12px;
|
|
248
246
|
box-sizing: border-box;
|
|
249
|
-
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
md-switch {
|
|
250
|
+
--md-switch-selected-handle-color: var(--switch-primary-color, #5470c6);
|
|
251
|
+
--md-switch-selected-hover-handle-color: var(--switch-primary-color, #5470c6);
|
|
252
|
+
--md-switch-selected-focus-handle-color: var(--switch-primary-color, #5470c6);
|
|
253
|
+
--md-switch-selected-pressed-handle-color: var(--switch-primary-color, #5470c6);
|
|
254
|
+
--md-switch-selected-track-color: color-mix(
|
|
255
|
+
in srgb,
|
|
256
|
+
var(--switch-primary-color, #5470c6) 40%,
|
|
257
|
+
transparent
|
|
258
|
+
);
|
|
259
|
+
--md-switch-selected-hover-track-color: color-mix(
|
|
260
|
+
in srgb,
|
|
261
|
+
var(--switch-primary-color, #5470c6) 50%,
|
|
262
|
+
transparent
|
|
263
|
+
);
|
|
264
|
+
--md-switch-selected-focus-track-color: color-mix(
|
|
265
|
+
in srgb,
|
|
266
|
+
var(--switch-primary-color, #5470c6) 50%,
|
|
267
|
+
transparent
|
|
268
|
+
);
|
|
269
|
+
--md-switch-selected-pressed-track-color: color-mix(
|
|
270
|
+
in srgb,
|
|
271
|
+
var(--switch-primary-color, #5470c6) 50%,
|
|
272
|
+
transparent
|
|
273
|
+
);
|
|
274
|
+
--md-switch-unselected-handle-color: var(--switch-text-color, #464646);
|
|
275
|
+
--md-switch-unselected-track-color: color-mix(
|
|
276
|
+
in srgb,
|
|
277
|
+
var(--switch-text-color, #464646) 20%,
|
|
278
|
+
transparent
|
|
279
|
+
);
|
|
280
|
+
--md-switch-unselected-track-outline-color: var(--switch-text-color, #464646);
|
|
250
281
|
}
|
|
251
282
|
|
|
252
283
|
.no-data {
|
|
@@ -264,7 +295,9 @@ export class WidgetSwitch extends LitElement {
|
|
|
264
295
|
return html`
|
|
265
296
|
<div
|
|
266
297
|
class="wrapper"
|
|
267
|
-
style="background-color: ${this.themeBgColor}; color: ${this
|
|
298
|
+
style="background-color: ${this.themeBgColor}; color: ${this
|
|
299
|
+
.themeTitleColor}; --switch-primary-color: ${this
|
|
300
|
+
.themePrimaryColor}; --switch-text-color: ${this.themeTitleColor}"
|
|
268
301
|
>
|
|
269
302
|
<header>
|
|
270
303
|
<h3 class="paging" ?active=${this.inputData?.title}>${this.inputData?.title}</h3>
|
|
@@ -286,7 +319,7 @@ export class WidgetSwitch extends LitElement {
|
|
|
286
319
|
<div class="switch" label="${label}">
|
|
287
320
|
${label}
|
|
288
321
|
<label
|
|
289
|
-
><
|
|
322
|
+
><md-switch
|
|
290
323
|
aria-label="${label}"
|
|
291
324
|
?selected="${!!ds.selected}"
|
|
292
325
|
.actionApp="${ds?.actionApp}"
|
|
@@ -294,7 +327,7 @@ export class WidgetSwitch extends LitElement {
|
|
|
294
327
|
.actionTopic="${ds?.actionTopic}"
|
|
295
328
|
.label="${label}"
|
|
296
329
|
@change="${this.handleActionSubmit}"
|
|
297
|
-
></
|
|
330
|
+
></md-switch
|
|
298
331
|
></label>
|
|
299
332
|
</div>
|
|
300
333
|
`
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { LitElement, PropertyValueMap } from 'lit';
|
|
2
|
-
import { InputData } from './definition-schema.js';
|
|
3
|
-
import '@material/web/switch/switch.js';
|
|
4
|
-
type Dataseries = Exclude<InputData['dataseries'], undefined>[number] & {
|
|
5
|
-
needleValue?: number;
|
|
6
|
-
};
|
|
7
|
-
type Data = Exclude<Dataseries['data'], undefined>[number];
|
|
8
|
-
type Theme = {
|
|
9
|
-
theme_name: string;
|
|
10
|
-
theme_object: any;
|
|
11
|
-
};
|
|
12
|
-
export declare class WidgetSwitch extends LitElement {
|
|
13
|
-
inputData?: InputData;
|
|
14
|
-
theme?: Theme;
|
|
15
|
-
private dataSets;
|
|
16
|
-
private textActive;
|
|
17
|
-
private themeBgColor?;
|
|
18
|
-
private themeTitleColor?;
|
|
19
|
-
private themeSubtitleColor?;
|
|
20
|
-
version: string;
|
|
21
|
-
private resizeObserver;
|
|
22
|
-
valueContainer?: HTMLDivElement;
|
|
23
|
-
boxes?: HTMLDivElement[];
|
|
24
|
-
origWidth: number;
|
|
25
|
-
origHeight: number;
|
|
26
|
-
constructor();
|
|
27
|
-
disconnectedCallback(): void;
|
|
28
|
-
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>): void;
|
|
29
|
-
update(changedProperties: Map<string, any>): void;
|
|
30
|
-
registerTheme(theme?: Theme): void;
|
|
31
|
-
applyData(): void;
|
|
32
|
-
transformData(): Promise<void>;
|
|
33
|
-
isSelected(ds: Dataseries, value?: Data): boolean | undefined;
|
|
34
|
-
handleActionSubmit(e: any): void;
|
|
35
|
-
static styles: import("lit").CSSResult;
|
|
36
|
-
render(): import("lit-html").TemplateResult<1>;
|
|
37
|
-
}
|
|
38
|
-
export {};
|