@record-evolution/widget-value 1.0.11 → 1.0.12
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/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/widget-value.js +63 -44
- package/dist/widget-value.js.map +1 -1
- package/package.json +1 -1
- package/src/widget-value.ts +74 -43
package/src/widget-value.ts
CHANGED
|
@@ -38,17 +38,17 @@ export class WidgetValue extends LitElement {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
protected firstUpdated(_changedProperties: PropertyValueMap<any> | Map<PropertyKey, unknown>) {
|
|
41
|
+
this.valueContainer = this?.shadowRoot?.querySelector('.value-container') as HTMLDivElement
|
|
42
|
+
|
|
43
|
+
this.sizingSetup()
|
|
41
44
|
this.applyInputData()
|
|
42
45
|
}
|
|
43
46
|
|
|
44
47
|
update(changedProperties: Map<string, any>) {
|
|
45
|
-
changedProperties.
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
this.sizingSetup()
|
|
48
|
+
if (changedProperties.has('inputData')) {
|
|
49
|
+
this.sizingSetup()
|
|
50
|
+
this.applyInputData()
|
|
51
|
+
}
|
|
52
52
|
|
|
53
53
|
super.update(changedProperties)
|
|
54
54
|
}
|
|
@@ -56,30 +56,23 @@ export class WidgetValue extends LitElement {
|
|
|
56
56
|
sizingSetup() {
|
|
57
57
|
if (this.origWidth !== 0 && this.origHeight !== 0) return
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
this?.shadowRoot?.querySelectorAll(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
this?.shadowRoot?.querySelectorAll('.current-value') as NodeListOf<HTMLDivElement>
|
|
59
|
+
const boxes = Array.from(
|
|
60
|
+
this?.shadowRoot?.querySelectorAll(
|
|
61
|
+
'.sizing-container > .single-value'
|
|
62
|
+
) as NodeListOf<HTMLDivElement>
|
|
64
63
|
)
|
|
65
|
-
this.labelText = Array.from(
|
|
66
|
-
this?.shadowRoot?.querySelectorAll('.label') as NodeListOf<HTMLDivElement>
|
|
67
|
-
)
|
|
68
|
-
this.valueContainer = this?.shadowRoot?.querySelector('.value-container') as HTMLDivElement
|
|
69
64
|
|
|
70
65
|
this.origWidth =
|
|
71
|
-
|
|
66
|
+
boxes?.map((b) => b.getBoundingClientRect().width).reduce((p, c) => (c > p ? c : p), 0) ?? 0
|
|
72
67
|
this.origHeight =
|
|
73
|
-
|
|
74
|
-
if (this.origWidth > 0) this.origWidth += 16
|
|
75
|
-
if (this.origHeight > 0) this.origHeight += 16
|
|
68
|
+
boxes?.map((b) => b.getBoundingClientRect().height).reduce((p, c) => (c > p ? c : p), 0) ?? 0
|
|
76
69
|
|
|
77
70
|
this.adjustSizes()
|
|
78
71
|
}
|
|
79
72
|
|
|
80
73
|
adjustSizes() {
|
|
81
|
-
const userWidth = this.valueContainer?.getBoundingClientRect().width
|
|
82
|
-
const userHeight = this.valueContainer?.getBoundingClientRect().height
|
|
74
|
+
const userWidth = (this.valueContainer?.getBoundingClientRect().width ?? 32) - 32
|
|
75
|
+
const userHeight = (this.valueContainer?.getBoundingClientRect().height ?? 32) - 32
|
|
83
76
|
const count = this.dataSets.size
|
|
84
77
|
|
|
85
78
|
const width = this.origWidth
|
|
@@ -104,31 +97,44 @@ export class WidgetValue extends LitElement {
|
|
|
104
97
|
const size = m * m * width * height * count
|
|
105
98
|
if (c * m * width < uwgap) fits.push({ r, m, size, width, height, userWidth, userHeight })
|
|
106
99
|
}
|
|
107
|
-
|
|
108
100
|
const maxSize = fits.reduce((p, c) => (c.size < p ? p : c.size), 0)
|
|
109
101
|
const fit = fits.find((f) => f.size === maxSize)
|
|
110
102
|
const modifier = fit?.m ?? 1
|
|
111
103
|
// console.log('FITS', fits, 'modifier', modifier, 'cols',fit?.c, 'rows', fit?.r, 'new size', fit?.size.toFixed(0), 'total space', (userWidth* userHeight).toFixed(0))
|
|
112
104
|
|
|
113
|
-
|
|
105
|
+
const boxes = Array.from(
|
|
106
|
+
this?.shadowRoot?.querySelectorAll(
|
|
107
|
+
'.value-container > .single-value'
|
|
108
|
+
) as NodeListOf<HTMLDivElement>
|
|
109
|
+
)
|
|
110
|
+
|
|
111
|
+
boxes?.forEach((box) =>
|
|
114
112
|
box.setAttribute(
|
|
115
113
|
'style',
|
|
116
114
|
`width:${modifier * width}px; height:${modifier * height}px; padding:${modifier * 6}px`
|
|
117
115
|
)
|
|
118
116
|
)
|
|
119
|
-
|
|
117
|
+
|
|
118
|
+
boxes?.forEach((n) => {
|
|
120
119
|
const label: string | null = n.getAttribute('label')
|
|
121
120
|
const ds: Dataseries | undefined = this.dataSets.get(label ?? '')
|
|
122
|
-
n.
|
|
121
|
+
const numberText = n.querySelector('.current-value') as HTMLDivElement
|
|
122
|
+
numberText.setAttribute(
|
|
123
123
|
'style',
|
|
124
124
|
`font-size: ${32 * modifier}px; ${ds?.valueColor ? 'color: ' + ds?.valueColor : ''}`
|
|
125
125
|
)
|
|
126
126
|
})
|
|
127
127
|
|
|
128
|
-
|
|
128
|
+
boxes?.forEach((n) => {
|
|
129
129
|
const label: string | null = n.getAttribute('label')
|
|
130
130
|
const ds: Dataseries | undefined = this.dataSets.get(label ?? '')
|
|
131
|
-
n.
|
|
131
|
+
const labelText = n.querySelector('.label') as HTMLDivElement
|
|
132
|
+
labelText.setAttribute(
|
|
133
|
+
'style',
|
|
134
|
+
`font-size: ${26 * modifier}px; ${ds?.labelColor ? 'color: ' + ds?.labelColor : ''}`
|
|
135
|
+
)
|
|
136
|
+
const unitText = n.querySelector('.unit') as HTMLDivElement
|
|
137
|
+
unitText.setAttribute(
|
|
132
138
|
'style',
|
|
133
139
|
`font-size: ${26 * modifier}px; ${ds?.labelColor ? 'color: ' + ds?.labelColor : ''}`
|
|
134
140
|
)
|
|
@@ -198,6 +204,7 @@ export class WidgetValue extends LitElement {
|
|
|
198
204
|
display: flex;
|
|
199
205
|
flex-direction: column;
|
|
200
206
|
height: 100%;
|
|
207
|
+
line-height: 0.9;
|
|
201
208
|
width: 100%;
|
|
202
209
|
padding: 16px;
|
|
203
210
|
box-sizing: border-box;
|
|
@@ -237,7 +244,6 @@ export class WidgetValue extends LitElement {
|
|
|
237
244
|
overflow: hidden;
|
|
238
245
|
position: relative;
|
|
239
246
|
align-items: end;
|
|
240
|
-
font-size: 26px;
|
|
241
247
|
padding: 6px;
|
|
242
248
|
box-sizing: border-box;
|
|
243
249
|
/* border-left: 4px solid #ddd; */
|
|
@@ -250,12 +256,25 @@ export class WidgetValue extends LitElement {
|
|
|
250
256
|
color: var(--re-text-color, #000);
|
|
251
257
|
}
|
|
252
258
|
|
|
253
|
-
.label
|
|
259
|
+
.label,
|
|
260
|
+
.unit {
|
|
254
261
|
font-weight: 300;
|
|
255
262
|
font-size: 26px;
|
|
256
263
|
color: var(--re-text-color, #000);
|
|
257
264
|
white-space: nowrap;
|
|
258
265
|
}
|
|
266
|
+
|
|
267
|
+
.sizing-container {
|
|
268
|
+
position: absolute;
|
|
269
|
+
left: 10000px;
|
|
270
|
+
display: flex;
|
|
271
|
+
flex-wrap: wrap;
|
|
272
|
+
align-items: center;
|
|
273
|
+
justify-content: center;
|
|
274
|
+
flex: 1;
|
|
275
|
+
overflow: hidden;
|
|
276
|
+
gap: 12px;
|
|
277
|
+
}
|
|
259
278
|
`
|
|
260
279
|
|
|
261
280
|
render() {
|
|
@@ -269,29 +288,41 @@ export class WidgetValue extends LitElement {
|
|
|
269
288
|
${this.inputData?.settings?.subTitle}
|
|
270
289
|
</p>
|
|
271
290
|
</header>
|
|
272
|
-
<div class="
|
|
291
|
+
<div class="sizing-container">
|
|
273
292
|
${repeat(
|
|
274
|
-
// @ts-ignore
|
|
275
293
|
this.dataSets,
|
|
276
294
|
([label]) => label,
|
|
277
295
|
([label, ds]) => {
|
|
278
296
|
return html`
|
|
279
|
-
<div class="single-value">
|
|
280
|
-
<div class="label paging" ?active=${this.textActive}
|
|
281
|
-
|
|
297
|
+
<div class="single-value" label="${label}">
|
|
298
|
+
<div class="label paging" ?active=${this.textActive}>${label}</div>
|
|
299
|
+
<div class="horizontal">
|
|
300
|
+
<div class="current-value paging" ?active=${this.textActive}>
|
|
301
|
+
${isNaN(ds.needleValue as number)
|
|
302
|
+
? ''
|
|
303
|
+
: (ds.needleValue as number).toFixed(0)}
|
|
304
|
+
</div>
|
|
305
|
+
<div class="unit paging" ?active=${this.textActive}>${ds.unit}</div>
|
|
282
306
|
</div>
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
307
|
+
</div>
|
|
308
|
+
`
|
|
309
|
+
}
|
|
310
|
+
)}
|
|
311
|
+
</div>
|
|
312
|
+
<div class="value-container">
|
|
313
|
+
${repeat(
|
|
314
|
+
this.dataSets,
|
|
315
|
+
([label]) => label,
|
|
316
|
+
([label, ds]) => {
|
|
317
|
+
return html`
|
|
318
|
+
<div class="single-value" label="${label}">
|
|
319
|
+
<div class="label paging" ?active=${this.textActive}>${label}</div>
|
|
320
|
+
<span class="current-value paging" ?active=${this.textActive}>
|
|
288
321
|
${isNaN(ds.needleValue as number)
|
|
289
322
|
? ''
|
|
290
323
|
: (ds.needleValue as number).toFixed(0)}
|
|
291
324
|
</span>
|
|
292
|
-
<span class="
|
|
293
|
-
${ds.unit}
|
|
294
|
-
</span>
|
|
325
|
+
<span class="unit paging" ?active=${this.textActive}>${ds.unit}</span>
|
|
295
326
|
</div>
|
|
296
327
|
`
|
|
297
328
|
}
|