@record-evolution/widget-overlay 1.0.11 → 1.0.13

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,6 +1,20 @@
1
1
  {
2
- "title": "Input Data",
2
+ "title": "Image Overlay Configuration",
3
3
  "description": "An image overlay widget for displaying data-driven annotations on top of background images. Use this widget to create visual dashboards that combine a schematic, floor plan, process diagram, or photo with real-time data overlays. Supports two overlay types: progress bars showing fill levels and text pins displaying values. Overlays are positioned using relative coordinates (0-1) so they scale with the image. Ideal for factory floor visualizations, building management systems, process monitoring, or any scenario where data should be shown in spatial context on a reference image.",
4
+ "aiSelection": {
5
+ "dataShape": "A background image plus pins placed on it by relative coordinates (relXPos / relYPos in 0-1, so they scale with the image). Each pin binds one live value, drawn either as a progress bar (progressPins) or as text (textPins).",
6
+ "useWhen": [
7
+ "Values only make sense in their spatial context — tank levels on a process diagram, room temperatures on a floor plan, station output on a line layout.",
8
+ "A photo or schematic already exists and should be annotated with live readings.",
9
+ "Fill levels should be shown in place as progress bars against a picture of the plant."
10
+ ],
11
+ "notFor": [
12
+ "Positions on the earth rather than on a picture — use widget-mapbox.",
13
+ "A standard industrial component (tank, pump, valve, meter) that the platform can already draw and animate — use widget-scada, which needs no background image.",
14
+ "An image with no data on it — use widget-image.",
15
+ "Values compared against each other rather than placed in space — use widget-linechart, widget-value or widget-gauge."
16
+ ]
17
+ },
4
18
  "type": "object",
5
19
  "properties": {
6
20
  "title": {
@@ -2,25 +2,36 @@ import { html, css, LitElement, PropertyValues, nothing } from 'lit'
2
2
  import { property, query, state } from 'lit/decorators.js'
3
3
  import { styleMap } from 'lit/directives/style-map.js'
4
4
  import { unsafeSVG } from 'lit/directives/unsafe-svg.js'
5
- import {
6
- InputData,
7
- Modifier,
8
- Overlay,
9
- ProgressItem,
10
- ProgressOverlay,
11
- TextItem,
12
- TextOverlay
13
- } from './definition-schema.js'
5
+ import { ImageOverlayConfiguration, Overlays } from './definition-schema.js'
14
6
  import { repeat } from 'lit/directives/repeat.js'
15
7
  import './linear-progress.js'
16
8
 
9
+ // Views over the generated schema types. json-schema-to-typescript names the
10
+ // layer array `Overlays` and gives its pin arrays no names of their own, so the
11
+ // per-layer and per-pin types the component works with are derived here.
12
+ type Overlay = Overlays[number]
13
+ type TextOverlay = Overlay
14
+ type ProgressOverlay = Overlay
15
+ type TextItem = NonNullable<Overlay['textPins']>[number]
16
+ type ProgressItem = NonNullable<Overlay['progressPins']>[number]
17
+
18
+ // Not schema data: the scaling factor and letterbox offsets of the background
19
+ // image inside the widget, recomputed by getModifier() on every resize.
20
+ type Modifier = {
21
+ scaler: number
22
+ xOffset: number
23
+ yOffset: number
24
+ visibleWidth: number
25
+ visibleHeight: number
26
+ }
27
+
17
28
  type Theme = {
18
29
  theme_name: string
19
30
  theme_object: any
20
31
  }
21
32
  export class WidgetImage extends LitElement {
22
33
  @property({ type: Object })
23
- inputData?: InputData
34
+ inputData?: ImageOverlayConfiguration
24
35
 
25
36
  @property({ type: Object })
26
37
  theme?: Theme
@@ -62,12 +73,9 @@ export class WidgetImage extends LitElement {
62
73
  }
63
74
 
64
75
  registerTheme(theme?: Theme) {
65
- const cssTextColor = getComputedStyle(this).getPropertyValue('--re-text-color').trim()
66
- const cssBgColor = getComputedStyle(this).getPropertyValue('--re-tile-background-color').trim()
67
- this.themeBgColor = cssBgColor || this.theme?.theme_object?.backgroundColor
68
- this.themeTitleColor = cssTextColor || this.theme?.theme_object?.title?.textStyle?.color
69
- this.themeSubtitleColor =
70
- cssTextColor || this.theme?.theme_object?.title?.subtextStyle?.color || this.themeTitleColor
76
+ this.themeBgColor = `var(--re-tile-background-color, ${this.theme?.theme_object?.backgroundColor || 'transparent'})`
77
+ this.themeTitleColor = `var(--re-text-color, ${this.theme?.theme_object?.title?.textStyle?.color || 'inherit'})`
78
+ this.themeSubtitleColor = `var(--re-text-color, ${this.theme?.theme_object?.title?.subtextStyle?.color || this.theme?.theme_object?.title?.textStyle?.color || 'inherit'})`
71
79
  }
72
80
 
73
81
  private handleFileChange(ev: Event) {