@record-evolution/widget-value 1.1.7 → 1.1.9

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
@@ -3,7 +3,7 @@
3
3
  "description": "REWidget widget-value",
4
4
  "license": "MIT",
5
5
  "author": "widget-value",
6
- "version": "1.1.7",
6
+ "version": "1.1.9",
7
7
  "engines": {
8
8
  "node": "18.18.2",
9
9
  "npm": ">=10.0.2"
@@ -17,44 +17,41 @@
17
17
  ],
18
18
  "scripts": {
19
19
  "analyze": "cem analyze --litelement",
20
- "start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
20
+ "start": "concurrently -k -r \"npm run watch\" \"wds\"",
21
21
  "build": "rollup -c rollup.config.js",
22
22
  "watch": "rollup -w -c rollup.config.js",
23
23
  "link": "npm link && cd ../RESWARM/frontend && npm link @record-evolution/widget-value",
24
24
  "unlink": "npm unlink --global && cd ../RESWARM/frontend && npm unlink @record-evolution/widget-value && npm i @record-evolution/widget-value",
25
25
  "types": "cat src/definition-schema.json | json2ts > src/definition-schema.d.ts",
26
26
  "start:build": "npm run build && es-dev-server --root-dir dist --app-index index.html --compatibility none --open",
27
- "lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
28
- "format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
29
- "release": "npm version patch --tag-version-prefix='' && git push && git push --tag"
27
+ "release": "npm run build && npm run types && npm version patch --tag-version-prefix='' && git push && git push --tag"
30
28
  },
31
29
  "dependencies": {
32
- "@material/web": "^2.2.0",
33
- "lit": "^3.2.0"
30
+ "lit": "^3.3.0"
34
31
  },
35
32
  "devDependencies": {
36
- "@custom-elements-manifest/analyzer": "^0.10.3",
33
+ "@custom-elements-manifest/analyzer": "^0.10.4",
37
34
  "@rollup/plugin-babel": "^6.0.4",
38
- "@rollup/plugin-commonjs": "^28.0.0",
39
- "@rollup/plugin-node-resolve": "^15.3.0",
40
- "@rollup/plugin-replace": "^6.0.1",
41
- "@rollup/plugin-typescript": "^12.1.0",
42
- "@typescript-eslint/eslint-plugin": "^8.8.0",
43
- "@typescript-eslint/parser": "^8.8.0",
35
+ "@rollup/plugin-commonjs": "^28.0.6",
36
+ "@rollup/plugin-node-resolve": "^16.0.1",
37
+ "@rollup/plugin-replace": "^6.0.2",
38
+ "@rollup/plugin-typescript": "^12.1.3",
39
+ "@typescript-eslint/eslint-plugin": "^8.34.1",
40
+ "@typescript-eslint/parser": "^8.34.1",
44
41
  "@web/dev-server": "^0.4.6",
45
- "concurrently": "^9.0.1",
42
+ "concurrently": "^9.1.2",
46
43
  "deepmerge": "^4.3.1",
47
44
  "es-dev-server": "^2.1.0",
48
- "eslint": "^9.11.1",
49
- "eslint-config-prettier": "^9.1.0",
50
- "husky": "^9.1.6",
51
- "json-schema-to-typescript": "^15.0.2",
52
- "lint-staged": "^15.2.10",
53
- "prettier": "^3.3.3",
45
+ "eslint": "^9.29.0",
46
+ "eslint-config-prettier": "^10.1.5",
47
+ "husky": "^9.1.7",
48
+ "json-schema-to-typescript": "^15.0.4",
49
+ "lint-staged": "^16.1.2",
50
+ "prettier": "^3.5.3",
54
51
  "rimraf": "^6.0.1",
55
- "rollup": "^4.24.0",
56
- "tslib": "^2.7.0",
57
- "typescript": "^5.6.2"
52
+ "rollup": "^4.43.0",
53
+ "tslib": "^2.8.1",
54
+ "typescript": "^5.8.3"
58
55
  },
59
56
  "repository": {
60
57
  "type": "git",
@@ -1,5 +1,6 @@
1
1
  {
2
- "settings": {},
2
+ "title": "Title",
3
+ "subTitle": "Subtitle",
3
4
  "dataseries": [
4
5
  {
5
6
  "label": "Temperature",
@@ -5,22 +5,26 @@ import { InputData } from './definition-schema.js'
5
5
 
6
6
  type Dataseries = Exclude<InputData['dataseries'], undefined>[number] & { needleValue?: number }
7
7
  type Data = Exclude<Dataseries['data'], undefined>[number]
8
-
8
+ type Theme = {
9
+ theme_name: string
10
+ theme_object: any
11
+ }
9
12
  export class WidgetValue extends LitElement {
10
13
  @property({ type: Object })
11
14
  inputData?: InputData
12
15
 
16
+ @property({ type: Object })
17
+ theme?: Theme
18
+
13
19
  @state()
14
20
  private dataSets: Map<string, Dataseries> = new Map()
15
21
 
16
22
  @state()
17
23
  private textActive: boolean = true
18
24
 
19
- @state()
20
- private numberText?: HTMLDivElement[]
21
-
22
- @state()
23
- private labelText?: HTMLDivElement[]
25
+ @state() private themeBgColor?: string
26
+ @state() private themeTitleColor?: string
27
+ @state() private themeSubtitleColor?: string
24
28
 
25
29
  version: string = 'versionplaceholder'
26
30
 
@@ -56,6 +60,15 @@ export class WidgetValue extends LitElement {
56
60
  this.applyInputData()
57
61
  }
58
62
 
63
+ if (changedProperties.has('theme')) {
64
+ const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
65
+ const cssBgColor = getComputedStyle(this).getPropertyValue('--re-background-color').trim()
66
+ this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor
67
+ this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color
68
+ this.themeSubtitleColor =
69
+ cssTextColor || this.theme?.theme_object?.title?.subtextStyle?.color || this.themeTitleColor
70
+ }
71
+
59
72
  super.update(changedProperties)
60
73
  }
61
74
 
@@ -127,7 +140,8 @@ export class WidgetValue extends LitElement {
127
140
  const numberText = n.querySelector('.current-value') as HTMLDivElement
128
141
  numberText.setAttribute(
129
142
  'style',
130
- `font-size: ${32 * modifier}px; ${ds?.styling?.valueColor ? 'color: ' + ds?.styling?.valueColor : ''}`
143
+ `font-size: ${32 * modifier}px;
144
+ color: ${ds?.styling?.valueColor || this.themeTitleColor};`
131
145
  )
132
146
  })
133
147
 
@@ -137,12 +151,14 @@ export class WidgetValue extends LitElement {
137
151
  const labelText = n.querySelector('.label') as HTMLDivElement
138
152
  labelText.setAttribute(
139
153
  'style',
140
- `font-size: ${26 * modifier}px; ${ds?.styling?.labelColor ? 'color: ' + ds?.styling?.labelColor : ''}`
154
+ `font-size: ${26 * modifier}px;
155
+ color: ${ds?.styling?.labelColor || this.themeSubtitleColor};`
141
156
  )
142
157
  const unitText = n.querySelector('.unit') as HTMLDivElement
143
158
  unitText.setAttribute(
144
159
  'style',
145
- `font-size: ${26 * modifier}px; ${ds?.styling?.labelColor ? 'color: ' + ds?.styling?.labelColor : ''}`
160
+ `font-size: ${26 * modifier}px;
161
+ color: ${ds?.styling?.labelColor || this.themeSubtitleColor};`
146
162
  )
147
163
  })
148
164
 
@@ -231,7 +247,6 @@ export class WidgetValue extends LitElement {
231
247
  overflow: hidden;
232
248
  text-overflow: ellipsis;
233
249
  white-space: nowrap;
234
- color: var(--re-text-color, #000) !important;
235
250
  }
236
251
  p {
237
252
  margin: 10px 0 0 0;
@@ -241,7 +256,6 @@ export class WidgetValue extends LitElement {
241
256
  overflow: hidden;
242
257
  text-overflow: ellipsis;
243
258
  white-space: nowrap;
244
- color: var(--re-text-color, #000) !important;
245
259
  }
246
260
 
247
261
  .value-container {
@@ -269,14 +283,12 @@ export class WidgetValue extends LitElement {
269
283
  font-size: 32px;
270
284
  font-weight: 600;
271
285
  white-space: nowrap;
272
- color: var(--re-text-color, #000);
273
286
  }
274
287
 
275
288
  .label,
276
289
  .unit {
277
290
  font-weight: 300;
278
291
  font-size: 26px;
279
- color: var(--re-text-color, #000);
280
292
  white-space: nowrap;
281
293
  }
282
294
 
@@ -295,7 +307,6 @@ export class WidgetValue extends LitElement {
295
307
 
296
308
  .no-data {
297
309
  font-size: 20px;
298
- color: var(--re-text-color, #000);
299
310
  display: flex;
300
311
  height: 100%;
301
312
  width: 100%;
@@ -307,10 +318,19 @@ export class WidgetValue extends LitElement {
307
318
 
308
319
  render() {
309
320
  return html`
310
- <div class="wrapper">
321
+ <div
322
+ class="wrapper"
323
+ style="background-color: ${this.themeBgColor}; color: ${this.themeTitleColor}"
324
+ >
311
325
  <header>
312
326
  <h3 class="paging" ?active=${this.inputData?.title}>${this.inputData?.title}</h3>
313
- <p class="paging" ?active=${this.inputData?.subTitle}>${this.inputData?.subTitle}</p>
327
+ <p
328
+ class="paging"
329
+ ?active=${this.inputData?.subTitle}
330
+ style="color: ${this.themeSubtitleColor}"
331
+ >
332
+ ${this.inputData?.subTitle}
333
+ </p>
314
334
  </header>
315
335
  <div class="sizing-container">
316
336
  ${repeat(
@@ -320,7 +340,11 @@ export class WidgetValue extends LitElement {
320
340
  return html`
321
341
  <div class="single-value" label="${label}">
322
342
  <div class="label paging" ?active=${this.textActive}>${label}</div>
323
- <span class="current-value paging" ?active=${this.textActive}>
343
+ <span
344
+ class="current-value paging"
345
+ ?active=${this.textActive}
346
+ style="color: ${this.themeTitleColor}"
347
+ >
324
348
  ${isNaN(ds.needleValue ?? 0) || ds.needleValue === undefined
325
349
  ? ''
326
350
  : ds.needleValue.toFixed(Math.max(0, ds.precision ?? 0))}
@@ -340,7 +364,11 @@ export class WidgetValue extends LitElement {
340
364
  return html`
341
365
  <div class="single-value" label="${label}">
342
366
  <div class="label paging" ?active=${this.textActive}>${label}</div>
343
- <span class="current-value paging" ?active=${this.textActive}>
367
+ <span
368
+ class="current-value paging"
369
+ ?active=${this.textActive}
370
+ style="color: ${this.themeTitleColor}"
371
+ >
344
372
  ${isNaN(ds.needleValue ?? 0) || ds.needleValue === undefined
345
373
  ? ''
346
374
  : ds.needleValue.toFixed(Math.max(0, ds.precision ?? 0))}