@record-evolution/widget-value 1.1.19 → 1.1.21

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.
@@ -33,7 +33,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
33
33
  * SPDX-License-Identifier: BSD-3-Clause
34
34
  */
35
35
  const t$4 = globalThis,
36
- e$3 = t$4.ShadowRoot && (void 0 === t$4.ShadyCSS || t$4.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
36
+ e$5 = t$4.ShadowRoot && (void 0 === t$4.ShadyCSS || t$4.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
37
37
  s$3 = Symbol(),
38
38
  o$4 = new WeakMap();
39
39
  let n$3 = class n {
@@ -44,7 +44,7 @@ let n$3 = class n {
44
44
  get styleSheet() {
45
45
  let t = this.o;
46
46
  const s = this.t;
47
- if (e$3 && void 0 === t) {
47
+ if (e$5 && void 0 === t) {
48
48
  const e = void 0 !== s && 1 === s.length;
49
49
  e && (t = o$4.get(s)), void 0 === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$4.set(s, t));
50
50
  }
@@ -64,13 +64,13 @@ const r$5 = t => new n$3("string" == typeof t ? t : t + "", void 0, s$3),
64
64
  return new n$3(o, t, s$3);
65
65
  },
66
66
  S$1 = (s, o) => {
67
- if (e$3) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
67
+ if (e$5) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
68
68
  const o = document.createElement("style"),
69
69
  n = t$4.litNonce;
70
70
  void 0 !== n && o.setAttribute("nonce", n), o.textContent = e.cssText, s.appendChild(o);
71
71
  }
72
72
  },
73
- c$3 = e$3 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
73
+ c$3 = e$5 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
74
74
  let e = "";
75
75
  for (const s of t.cssRules) e += s.cssText;
76
76
  return r$5(e);
@@ -83,7 +83,7 @@ const r$5 = t => new n$3("string" == typeof t ? t : t + "", void 0, s$3),
83
83
  */
84
84
  const {
85
85
  is: i$3,
86
- defineProperty: e$2,
86
+ defineProperty: e$4,
87
87
  getOwnPropertyDescriptor: h$1,
88
88
  getOwnPropertyNames: r$4,
89
89
  getOwnPropertySymbols: o$3,
@@ -147,7 +147,7 @@ let y$1 = class y extends HTMLElement {
147
147
  if (s.state && (s.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = true), this.elementProperties.set(t, s), !s.noAccessor) {
148
148
  const i = Symbol(),
149
149
  h = this.getPropertyDescriptor(t, i, s);
150
- void 0 !== h && e$2(this.prototype, t, h);
150
+ void 0 !== h && e$4(this.prototype, t, h);
151
151
  }
152
152
  }
153
153
  static getPropertyDescriptor(t, s, i) {
@@ -354,7 +354,7 @@ const t$3 = globalThis,
354
354
  s$2 = i$2 ? i$2.createPolicy("lit-html", {
355
355
  createHTML: t => t
356
356
  }) : void 0,
357
- e$1 = "$lit$",
357
+ e$3 = "$lit$",
358
358
  h = `lit$${Math.random().toFixed(9).slice(2)}$`,
359
359
  o$2 = "?" + h,
360
360
  n$1 = `<${o$2}>`,
@@ -399,7 +399,7 @@ const V = (t, i) => {
399
399
  y = 0;
400
400
  for (; y < s.length && (c.lastIndex = y, u = c.exec(s), null !== u);) y = c.lastIndex, c === f ? "!--" === u[1] ? c = v$1 : void 0 !== u[1] ? c = _ : void 0 !== u[2] ? ($.test(u[2]) && (r = RegExp("</" + u[2], "g")), c = m$1) : void 0 !== u[3] && (c = m$1) : c === m$1 ? ">" === u[0] ? (c = r ?? f, d = -1) : void 0 === u[1] ? d = -2 : (d = c.lastIndex - u[2].length, a = u[1], c = void 0 === u[3] ? m$1 : '"' === u[3] ? g : p$1) : c === g || c === p$1 ? c = m$1 : c === v$1 || c === _ ? c = f : (c = m$1, r = void 0);
401
401
  const x = c === m$1 && t[i + 1].startsWith("/>") ? " " : "";
402
- l += c === f ? s + n$1 : d >= 0 ? (o.push(a), s.slice(0, d) + e$1 + s.slice(d) + h + x) : s + h + (-2 === d ? i : x);
402
+ l += c === f ? s + n$1 : d >= 0 ? (o.push(a), s.slice(0, d) + e$3 + s.slice(d) + h + x) : s + h + (-2 === d ? i : x);
403
403
  }
404
404
  return [P(t, l + (t[s] || "<?>") + (2 === i ? "</svg>" : 3 === i ? "</math>" : "")), o];
405
405
  };
@@ -421,7 +421,7 @@ class N {
421
421
  }
422
422
  for (; null !== (r = C.nextNode()) && d.length < u;) {
423
423
  if (1 === r.nodeType) {
424
- if (r.hasAttributes()) for (const t of r.getAttributeNames()) if (t.endsWith(e$1)) {
424
+ if (r.hasAttributes()) for (const t of r.getAttributeNames()) if (t.endsWith(e$3)) {
425
425
  const i = v[a++],
426
426
  s = r.getAttribute(t).split(h),
427
427
  e = /([.?@])?(.*)/.exec(i);
@@ -699,7 +699,7 @@ o$1?.({
699
699
  */
700
700
  const t$2 = {
701
701
  CHILD: 2},
702
- e = t => (...e) => ({
702
+ e$2 = t => (...e) => ({
703
703
  _$litDirective$: t,
704
704
  values: e
705
705
  });
@@ -777,7 +777,7 @@ const u = (e, s, t) => {
777
777
  for (let l = s; l <= t; l++) r.set(e[l], l);
778
778
  return r;
779
779
  },
780
- c = e(class extends i {
780
+ c = e$2(class extends i {
781
781
  constructor(e) {
782
782
  if (super(e), e.type !== t$2.CHILD) throw Error("repeat() can only be used in text expressions");
783
783
  }
@@ -908,12 +908,35 @@ function r(r) {
908
908
  });
909
909
  }
910
910
 
911
+ /**
912
+ * @license
913
+ * Copyright 2017 Google LLC
914
+ * SPDX-License-Identifier: BSD-3-Clause
915
+ */
916
+ const e$1 = (e, t, c) => (c.configurable = true, c.enumerable = true, Reflect.decorate && "object" != typeof t && Object.defineProperty(e, t, c), c);
917
+
918
+ /**
919
+ * @license
920
+ * Copyright 2017 Google LLC
921
+ * SPDX-License-Identifier: BSD-3-Clause
922
+ */
923
+ function e(e, r) {
924
+ return (n, s, i) => {
925
+ const o = t => t.renderRoot?.querySelector(e) ?? null;
926
+ return e$1(n, s, {
927
+ get() {
928
+ return o(this);
929
+ }
930
+ });
931
+ };
932
+ }
933
+
911
934
  let WidgetValue = class WidgetValue extends i$1 {
912
935
  constructor() {
913
936
  super();
914
937
  this.dataSets = new Map();
915
938
  this.textActive = true;
916
- this.version = '1.1.19';
939
+ this.version = '1.1.21';
917
940
  this.origWidth = 0;
918
941
  this.origHeight = 0;
919
942
  this.resizeObserver = new ResizeObserver(this.applyData.bind(this));
@@ -926,23 +949,23 @@ let WidgetValue = class WidgetValue extends i$1 {
926
949
  }
927
950
  }
928
951
  firstUpdated(_changedProperties) {
929
- var _a;
930
- this.valueContainer = (_a = this === null || this === void 0 ? void 0 : this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('.value-container');
931
952
  this.registerTheme(this.theme);
932
- this.sizingSetup();
933
- this.transformData();
934
- this.applyData();
935
953
  }
936
954
  update(changedProperties) {
937
955
  if (changedProperties.has('inputData')) {
938
- this.sizingSetup();
939
956
  this.transformData();
957
+ }
958
+ super.update(changedProperties);
959
+ }
960
+ updated(changedProperties) {
961
+ if (changedProperties.has('inputData')) {
962
+ this.sizingSetup();
940
963
  this.applyData();
941
964
  }
942
965
  if (changedProperties.has('theme')) {
943
966
  this.registerTheme(this.theme);
944
967
  }
945
- super.update(changedProperties);
968
+ super.updated(changedProperties);
946
969
  }
947
970
  registerTheme(theme) {
948
971
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
@@ -954,17 +977,32 @@ let WidgetValue = class WidgetValue extends i$1 {
954
977
  cssTextColor || ((_k = (_j = (_h = (_g = this.theme) === null || _g === void 0 ? void 0 : _g.theme_object) === null || _h === void 0 ? void 0 : _h.title) === null || _j === void 0 ? void 0 : _j.subtextStyle) === null || _k === void 0 ? void 0 : _k.color) || this.themeTitleColor;
955
978
  }
956
979
  sizingSetup() {
957
- var _a, _b, _c;
958
- const boxes = Array.from((_a = this === null || this === void 0 ? void 0 : this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.sizing-container > .single-value'));
959
- this.origWidth =
960
- (_b = boxes === null || boxes === void 0 ? void 0 : boxes.map((b) => b.getBoundingClientRect().width).reduce((p, c) => (c > p ? c : p), 0)) !== null && _b !== void 0 ? _b : 0;
961
- this.origHeight =
962
- (_c = boxes === null || boxes === void 0 ? void 0 : boxes.map((b) => b.getBoundingClientRect().height).reduce((p, c) => (c > p ? c : p), 0)) !== null && _c !== void 0 ? _c : 0;
980
+ var _a;
981
+ const boxes = Array.from((_a = this.sizingContainer) === null || _a === void 0 ? void 0 : _a.querySelectorAll('.single-value'));
982
+ let width = 0;
983
+ let height = 0;
984
+ for (const box of boxes) {
985
+ const dims = box.getBoundingClientRect();
986
+ width = Math.max(dims.width, width);
987
+ height = Math.max(dims.height, height);
988
+ }
989
+ if (width < this.origWidth) {
990
+ if (!this.lastLargerWidthTime || Date.now() - this.lastLargerWidthTime > 5000) {
991
+ this.origWidth = width;
992
+ }
993
+ }
994
+ else {
995
+ this.origWidth = width;
996
+ this.lastLargerWidthTime = Date.now();
997
+ }
998
+ this.origHeight = height;
963
999
  }
964
1000
  applyData() {
965
- var _a, _b, _c, _d;
966
- const userWidth = (_a = this.valueContainer) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().width;
967
- const userHeight = (_b = this.valueContainer) === null || _b === void 0 ? void 0 : _b.getBoundingClientRect().height;
1001
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
1002
+ if (!this.valueContainer)
1003
+ return;
1004
+ const userWidth = this.valueContainer.getBoundingClientRect().width;
1005
+ const userHeight = this.valueContainer.getBoundingClientRect().height;
968
1006
  const count = this.dataSets.size;
969
1007
  const width = this.origWidth;
970
1008
  const height = this.origHeight;
@@ -978,7 +1016,7 @@ let WidgetValue = class WidgetValue extends i$1 {
978
1016
  const m = uwgap / width / c;
979
1017
  const size = m * m * width * height * count;
980
1018
  if (r * m * height <= uhgap)
981
- fits.push({ c, m, size, width, height, userWidth, userHeight });
1019
+ fits.push({ r, c, m, size, width, height, userWidth, userHeight });
982
1020
  }
983
1021
  for (let r = 1; r <= count; r++) {
984
1022
  const c = Math.ceil(count / r);
@@ -987,33 +1025,30 @@ let WidgetValue = class WidgetValue extends i$1 {
987
1025
  const m = uhgap / height / r;
988
1026
  const size = m * m * width * height * count;
989
1027
  if (c * m * width <= uwgap)
990
- fits.push({ r, m, size, width, height, userWidth, userHeight });
1028
+ fits.push({ r, c, m, size, width, height, userWidth, userHeight });
991
1029
  }
992
1030
  const maxSize = fits.reduce((p, c) => (c.size < p ? p : c.size), 0);
993
1031
  const fit = fits.find((f) => f.size === maxSize);
994
- const modifier = (_c = fit === null || fit === void 0 ? void 0 : fit.m) !== null && _c !== void 0 ? _c : 1;
1032
+ if (!fit)
1033
+ return;
1034
+ const modifier = (_a = fit.m) !== null && _a !== void 0 ? _a : 1;
995
1035
  // console.log('FITS', fits, 'modifier', modifier, 'cols',fit?.c, 'rows', fit?.r, 'new size', fit?.size.toFixed(0), 'total space', (userWidth* userHeight).toFixed(0))
996
- const boxes = Array.from((_d = this === null || this === void 0 ? void 0 : this.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelectorAll('.value-container > .single-value'));
997
- boxes === null || boxes === void 0 ? void 0 : boxes.forEach((box) => box.setAttribute('style', `width:${modifier * width}px; height:${modifier * height}px; padding:${modifier * 6}px`));
998
- boxes === null || boxes === void 0 ? void 0 : boxes.forEach((n) => {
999
- var _a, _b, _c, _d;
1000
- const label = n.getAttribute('label');
1036
+ const boxes = Array.from((_b = this.valueContainer) === null || _b === void 0 ? void 0 : _b.querySelectorAll('.single-value'));
1037
+ this.valueContainer.style.gridTemplateColumns = `repeat(${fit.c}, 1fr)`;
1038
+ for (const box of boxes) {
1039
+ box.setAttribute('style', `width:${modifier * width}px; height:${modifier * height}px; padding:${modifier * 6}px`);
1040
+ const label = box.getAttribute('label');
1001
1041
  const ds = this.dataSets.get(label !== null && label !== void 0 ? label : '');
1002
- const numberText = n.querySelector('.current-value');
1042
+ const numberText = box.querySelector('.current-value');
1003
1043
  numberText.setAttribute('style', `font-size: ${32 * modifier}px;
1004
- color: ${((_a = ds === null || ds === void 0 ? void 0 : ds.styling) === null || _a === void 0 ? void 0 : _a.valueColor) || ((_d = (_c = (_b = this.theme) === null || _b === void 0 ? void 0 : _b.theme_object) === null || _c === void 0 ? void 0 : _c.color) === null || _d === void 0 ? void 0 : _d[0]) || this.themeTitleColor};`);
1005
- });
1006
- boxes === null || boxes === void 0 ? void 0 : boxes.forEach((n) => {
1007
- var _a, _b, _c, _d, _e, _f, _g, _h;
1008
- const label = n.getAttribute('label');
1009
- const ds = this.dataSets.get(label !== null && label !== void 0 ? label : '');
1010
- const labelText = n.querySelector('.label');
1044
+ color: ${((_c = ds === null || ds === void 0 ? void 0 : ds.styling) === null || _c === void 0 ? void 0 : _c.valueColor) || ((_f = (_e = (_d = this.theme) === null || _d === void 0 ? void 0 : _d.theme_object) === null || _e === void 0 ? void 0 : _e.color) === null || _f === void 0 ? void 0 : _f[0]) || this.themeTitleColor};`);
1045
+ const labelText = box.querySelector('.label');
1011
1046
  labelText.setAttribute('style', `font-size: ${26 * modifier}px;
1012
- color: ${((_a = ds === null || ds === void 0 ? void 0 : ds.styling) === null || _a === void 0 ? void 0 : _a.labelColor) || ((_d = (_c = (_b = this.theme) === null || _b === void 0 ? void 0 : _b.theme_object) === null || _c === void 0 ? void 0 : _c.color) === null || _d === void 0 ? void 0 : _d[1]) || this.themeSubtitleColor};`);
1013
- const unitText = n.querySelector('.unit');
1047
+ color: ${((_g = ds === null || ds === void 0 ? void 0 : ds.styling) === null || _g === void 0 ? void 0 : _g.labelColor) || ((_k = (_j = (_h = this.theme) === null || _h === void 0 ? void 0 : _h.theme_object) === null || _j === void 0 ? void 0 : _j.color) === null || _k === void 0 ? void 0 : _k[1]) || this.themeSubtitleColor};`);
1048
+ const unitText = box.querySelector('.unit');
1014
1049
  unitText.setAttribute('style', `font-size: ${26 * modifier}px;
1015
- color: ${((_e = ds === null || ds === void 0 ? void 0 : ds.styling) === null || _e === void 0 ? void 0 : _e.valueColor) || ((_h = (_g = (_f = this.theme) === null || _f === void 0 ? void 0 : _f.theme_object) === null || _g === void 0 ? void 0 : _g.color) === null || _h === void 0 ? void 0 : _h[0]) || this.themeTitleColor};`);
1016
- });
1050
+ color: ${((_l = ds === null || ds === void 0 ? void 0 : ds.styling) === null || _l === void 0 ? void 0 : _l.valueColor) || ((_p = (_o = (_m = this.theme) === null || _m === void 0 ? void 0 : _m.theme_object) === null || _o === void 0 ? void 0 : _o.color) === null || _p === void 0 ? void 0 : _p[0]) || this.themeTitleColor};`);
1051
+ }
1017
1052
  this.textActive = true;
1018
1053
  }
1019
1054
  async transformData() {
@@ -1028,8 +1063,9 @@ let WidgetValue = class WidgetValue extends i$1 {
1028
1063
  (_b = (_a = this.inputData) === null || _a === void 0 ? void 0 : _a.dataseries) === null || _b === void 0 ? void 0 : _b.forEach((ds) => {
1029
1064
  var _a;
1030
1065
  // pivot data
1031
- const distincts = [...new Set((_a = ds.data) === null || _a === void 0 ? void 0 : _a.map((d) => d.pivot))].sort();
1032
- ds.needleValue = undefined;
1066
+ const distincts = ds.multiChart
1067
+ ? [...new Set((_a = ds.data) === null || _a === void 0 ? void 0 : _a.map((d) => d.pivot))].sort()
1068
+ : [''];
1033
1069
  distincts.forEach((piv) => {
1034
1070
  var _a, _b, _c;
1035
1071
  const prefix = piv !== null && piv !== void 0 ? piv : '';
@@ -1071,9 +1107,6 @@ let WidgetValue = class WidgetValue extends i$1 {
1071
1107
  }
1072
1108
  }
1073
1109
  });
1074
- this.requestUpdate();
1075
- await this.updateComplete;
1076
- // console.log('Value Datasets', this.dataSets)
1077
1110
  }
1078
1111
  render() {
1079
1112
  var _a, _b, _c, _d;
@@ -1115,7 +1148,7 @@ let WidgetValue = class WidgetValue extends i$1 {
1115
1148
  <div class="paging no-data" ?active=${!this.dataSets.size}>No Data</div>
1116
1149
  <div class="value-container">
1117
1150
  ${c([...this.dataSets.entries()].sort(), ([label]) => label, ([label, ds]) => {
1118
- var _a, _b;
1151
+ var _a;
1119
1152
  return x `
1120
1153
  <div class="single-value" label="${label}">
1121
1154
  <div class="label paging" ?active=${this.textActive}>${label}</div>
@@ -1124,9 +1157,11 @@ let WidgetValue = class WidgetValue extends i$1 {
1124
1157
  ?active=${this.textActive}
1125
1158
  style="color: ${this.themeTitleColor}"
1126
1159
  >
1127
- ${isNaN((_a = ds.needleValue) !== null && _a !== void 0 ? _a : 0) || ds.needleValue === undefined
1160
+ ${ds.needleValue === undefined ||
1161
+ ds.needleValue === null ||
1162
+ isNaN(ds.needleValue)
1128
1163
  ? ''
1129
- : ds.needleValue.toFixed(Math.max(0, (_b = ds.precision) !== null && _b !== void 0 ? _b : 0))}
1164
+ : ds.needleValue.toFixed(Math.max(0, (_a = ds.precision) !== null && _a !== void 0 ? _a : 0))}
1130
1165
  <span class="unit paging" ?active=${this.textActive}>${ds.unit}</span>
1131
1166
  </span>
1132
1167
  </div>
@@ -1177,10 +1212,7 @@ WidgetValue.styles = i$4 `
1177
1212
  }
1178
1213
 
1179
1214
  .value-container {
1180
- display: flex;
1181
- flex-wrap: wrap;
1182
- align-items: center;
1183
- justify-content: center;
1215
+ display: grid;
1184
1216
  line-height: 0.9;
1185
1217
  flex: 1;
1186
1218
  overflow: hidden;
@@ -1194,7 +1226,6 @@ WidgetValue.styles = i$4 `
1194
1226
  align-items: end;
1195
1227
  padding: 6px;
1196
1228
  box-sizing: border-box;
1197
- /* border-left: 4px solid #ddd; */
1198
1229
  }
1199
1230
 
1200
1231
  .current-value {
@@ -1212,13 +1243,8 @@ WidgetValue.styles = i$4 `
1212
1243
 
1213
1244
  .sizing-container {
1214
1245
  position: absolute;
1215
- left: 10000px;
1216
- display: flex;
1246
+ left: 100000px;
1217
1247
  line-height: 0.9;
1218
- flex-wrap: wrap;
1219
- align-items: center;
1220
- justify-content: center;
1221
- flex: 1;
1222
1248
  overflow: hidden;
1223
1249
  gap: 12px;
1224
1250
  }
@@ -1254,8 +1280,14 @@ __decorate([
1254
1280
  __decorate([
1255
1281
  r()
1256
1282
  ], WidgetValue.prototype, "themeSubtitleColor", void 0);
1283
+ __decorate([
1284
+ e('.value-container')
1285
+ ], WidgetValue.prototype, "valueContainer", void 0);
1286
+ __decorate([
1287
+ e('.sizing-container')
1288
+ ], WidgetValue.prototype, "sizingContainer", void 0);
1257
1289
  WidgetValue = __decorate([
1258
- t('widget-value-1.1.19')
1290
+ t('widget-value-1.1.21')
1259
1291
  ], WidgetValue);
1260
1292
 
1261
1293
  export { WidgetValue };