@aquera/nile-visualization 2.9.37 → 2.9.39

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.
@@ -230,48 +230,6 @@ let NileKpiChart = class NileKpiChart extends NileElement {
230
230
  this._onSparklineMouseLeave = () => {
231
231
  this._hideTip();
232
232
  };
233
- // ── Value / Gauge hover handlers ─────────────────────────────────────────
234
- this._onValueEnter = (e) => {
235
- const rect = e.currentTarget.getBoundingClientRect();
236
- const rawNum = this.parseNumericValue(this.value);
237
- const full = rawNum != null ? this.formatValue(rawNum).full : String(this.value ?? '');
238
- const prefix = this.prefix ?? '';
239
- const suffix = this.suffix ?? '';
240
- this._showTip(`${prefix}${full}${suffix}`.trim(), rect.left + rect.width / 2, rect.top);
241
- };
242
- this._onDescEnter = (e) => {
243
- const el = e.currentTarget;
244
- if (el.scrollWidth <= el.clientWidth)
245
- return;
246
- const rect = el.getBoundingClientRect();
247
- this._showTip(this.description ?? '', rect.left + rect.width / 2, rect.top);
248
- };
249
- this._onLabelEnter = (e) => {
250
- const el = e.currentTarget;
251
- if (el.scrollWidth <= el.clientWidth)
252
- return;
253
- const rect = el.getBoundingClientRect();
254
- this._showTip(this.label ?? '', rect.left + rect.width / 2, rect.top);
255
- };
256
- this._onTrendEnter = (e) => {
257
- const el = e.currentTarget;
258
- // Only show a tooltip when the trend is actually clipped/ellipsized.
259
- const hasEllipsis = getComputedStyle(el).textOverflow === 'ellipsis';
260
- if (!hasEllipsis)
261
- return;
262
- if (el.scrollWidth <= el.clientWidth + 2)
263
- return;
264
- const rect = el.getBoundingClientRect();
265
- const dir = this.trendDirection;
266
- const arrow = dir === 'up' ? '▲' : dir === 'down' ? '▼' : '–';
267
- const pct = this.trendValue !== null ? `${Math.abs(this.trendValue).toFixed(1)}%` : '';
268
- const text = `${arrow} ${pct}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
269
- this._showTip(text, rect.left + rect.width / 2, rect.top);
270
- };
271
- this._onInfoEnter = (e) => {
272
- const rect = e.currentTarget.getBoundingClientRect();
273
- this._showTip(this.valueInfo, rect.left + rect.width / 2, rect.top, true);
274
- };
275
233
  this._onGaugeEnter = (e) => {
276
234
  const rect = e.currentTarget.getBoundingClientRect();
277
235
  this._showTip(this.getTooltipContent(), rect.left + rect.width / 2, rect.top + rect.height / 2);
@@ -297,9 +255,8 @@ let NileKpiChart = class NileKpiChart extends NileElement {
297
255
  document.body.appendChild(marker);
298
256
  this._markerEl = marker;
299
257
  }
300
- /** `force` bypasses `tooltipEnabled` — for the value info icon, whose only job is the tooltip. */
301
- _showTip(text, x, y, force = false) {
302
- if (!this._tipEl || (!this.tooltipEnabled && !force))
258
+ _showTip(text, x, y) {
259
+ if (!this._tipEl || !this.tooltipEnabled)
303
260
  return;
304
261
  this._tipEl.textContent = text;
305
262
  this._tipEl.style.left = `${x}px`;
@@ -728,11 +685,13 @@ let NileKpiChart = class NileKpiChart extends NileElement {
728
685
  this.initGauge();
729
686
  this.setupResizeObserver();
730
687
  requestAnimationFrame(() => this._reconcileFit());
688
+ void document.fonts?.ready.then(() => this._syncTruncationTips());
731
689
  }
732
690
  updated(changedProperties) {
733
691
  const hasValue = this.value !== '' && this.value !== null && this.value !== undefined;
734
692
  this.toggleAttribute('has-value', hasValue);
735
693
  this.toggleAttribute('has-sparkline', this.sparkline.length > 0);
694
+ this._syncTruncationTips();
736
695
  if (changedProperties.has('config') && this.config) {
737
696
  this.applyConfig(this.config);
738
697
  return;
@@ -859,6 +818,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
859
818
  this._reconcileFit();
860
819
  this.syncSparklineChartSize();
861
820
  this.syncGaugeChartSize();
821
+ this._syncTruncationTips();
862
822
  });
863
823
  this.resizeObserver.observe(this);
864
824
  if (this.sparklineContainer)
@@ -1106,28 +1066,54 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1106
1066
  this.destroySparkline();
1107
1067
  this.destroyGauge();
1108
1068
  }
1069
+ _valueTooltipText() {
1070
+ const rawNum = this.parseNumericValue(this.value);
1071
+ const full = rawNum != null ? this.formatValue(rawNum).full : String(this.value ?? '');
1072
+ return `${this.prefix ?? ''}${full}${this.suffix ?? ''}`.trim();
1073
+ }
1074
+ _trendTooltipText() {
1075
+ const dir = this.trendDirection;
1076
+ const arrow = dir === 'up' ? '▲' : dir === 'down' ? '▼' : '–';
1077
+ const pct = this.trendValue !== null ? `${Math.abs(this.trendValue).toFixed(1)}%` : '';
1078
+ return `${arrow} ${pct}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
1079
+ }
1080
+ _syncTruncationTips() {
1081
+ const root = this.shadowRoot;
1082
+ if (!root)
1083
+ return;
1084
+ root.querySelectorAll('nile-lite-tooltip[data-kpi-tip]').forEach(tip => {
1085
+ const el = tip.firstElementChild;
1086
+ if (!el)
1087
+ return;
1088
+ const truncated = tip.dataset['kpiTip'] === 'trend'
1089
+ ? getComputedStyle(el).textOverflow === 'ellipsis' && el.scrollWidth > el.clientWidth + 2
1090
+ : el.scrollWidth > el.clientWidth;
1091
+ const disabled = !this.tooltipEnabled || !truncated;
1092
+ if (tip.disabled !== disabled)
1093
+ tip.disabled = disabled;
1094
+ });
1095
+ }
1109
1096
  // ── Render ───────────────────────────────────────────────────────────────
1110
1097
  renderValueInfo() {
1111
1098
  if (!this.valueInfo)
1112
1099
  return nothing;
1113
1100
  const [vertical, side] = (typeof this.valueInfoPlacement === 'string' ? this.valueInfoPlacement : 'top-right').split('-');
1114
- return html `<span
1115
- class="kpi-info kpi-info--${vertical === 'bottom' || vertical === 'center' ? vertical : 'top'} kpi-info--${side === 'left' ? 'left' : 'right'}"
1101
+ return html `<nile-lite-tooltip
1102
+ class="kpi-info-tip kpi-info--${vertical === 'bottom' || vertical === 'center' ? vertical : 'top'} kpi-info--${side === 'left' ? 'left' : 'right'}"
1103
+ content=${this.valueInfo}
1104
+ placement="top"
1105
+ ><span
1106
+ class="kpi-info"
1116
1107
  part="value-info"
1117
1108
  role="img"
1118
1109
  tabindex="0"
1119
1110
  aria-label=${this.valueInfo}
1120
- @mouseenter=${this._onInfoEnter}
1121
- @mouseleave=${this._onTipLeave}
1122
- @focus=${this._onInfoEnter}
1123
- @blur=${this._onTipLeave}
1124
- @keydown=${this._onTrendKeydown}
1125
1111
  ><nile-glyph
1126
1112
  name=${this.valueInfoIcon || 'ng-info-circle'}
1127
1113
  method=${this.valueInfoIconMethod || 'stroke'}
1128
1114
  size=${ifDefined(this.valueInfoIconSize === '' || this.valueInfoIconSize == null ? undefined : this.valueInfoIconSize)}
1129
1115
  color=${this.valueInfoIconColor || 'currentColor'}
1130
- ></nile-glyph></span>`;
1116
+ ></nile-glyph></span></nile-lite-tooltip>`;
1131
1117
  }
1132
1118
  renderTrend() {
1133
1119
  if (this.trendValue === null)
@@ -1135,17 +1121,11 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1135
1121
  const dir = this.trendDirection;
1136
1122
  const formatted = Math.abs(this.trendValue).toFixed(1) + '%';
1137
1123
  const trendAriaLabel = `Trend ${dir === 'up' ? 'up' : dir === 'down' ? 'down' : 'neutral'} ${formatted}${this.trendLabel ? ' ' + this.trendLabel : ''}`.trim();
1138
- return html `
1139
- <span
1124
+ return html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="trend" content=${this._trendTooltipText()} placement="top" disabled><span
1140
1125
  class="kpi-trend kpi-trend--${dir}"
1141
1126
  tabindex="0"
1142
1127
  role="button"
1143
1128
  aria-label=${trendAriaLabel}
1144
- @mouseenter=${this._onTrendEnter}
1145
- @mouseleave=${this._onTipLeave}
1146
- @focus=${this._onTrendEnter}
1147
- @blur=${this._onTipLeave}
1148
- @keydown=${this._onTrendKeydown}
1149
1129
  >
1150
1130
  <span class="kpi-trend-arrow">
1151
1131
  ${dir === 'up'
@@ -1155,8 +1135,7 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1155
1135
  : html `<svg viewBox="0 0 12 12"><path d="M2 6.5h8" stroke="currentColor" stroke-width="1.5" fill="none"/></svg>`}
1156
1136
  </span>
1157
1137
  <span class="kpi-trend-value">${formatted}</span>${this.trendLabel ? html ` <span class="kpi-trend-label">${this.trendLabel}</span>` : nothing}
1158
- </span>
1159
- `;
1138
+ </span></nile-lite-tooltip>`;
1160
1139
  }
1161
1140
  /**
1162
1141
  * The projected-value line. Rendered only when `forecastValue` is set, so a
@@ -1193,17 +1172,18 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1193
1172
  const displayValue = fmt ? fmt.display : String(this.value ?? '');
1194
1173
  const showTooltip = !!fmt && fmt.display !== fmt.full;
1195
1174
  const infoLeft = typeof this.valueInfoPlacement === 'string' && this.valueInfoPlacement.endsWith('-left');
1175
+ const valueEl = html `<h2
1176
+ class="kpi-value"
1177
+ tabindex=${showTooltip ? '0' : nothing}
1178
+ >
1179
+ ${this.prefix ? html `<span class="kpi-prefix">${this.prefix}</span>` : nothing}${displayValue}${this.suffix ? html `<span class="kpi-suffix">${this.suffix}</span>` : nothing}
1180
+ </h2>`;
1196
1181
  return html `
1197
1182
  <div class="kpi ${isGauge ? 'kpi--gauge' : ''}">
1198
- ${this.label ? html `<p
1183
+ ${this.label ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="label" content=${this.label} placement="top" disabled><p
1199
1184
  class="kpi-label"
1200
1185
  tabindex="0"
1201
- @mouseenter=${this._onLabelEnter}
1202
- @mouseleave=${this._onTipLeave}
1203
- @focus=${this._onLabelEnter}
1204
- @blur=${this._onTipLeave}
1205
- @keydown=${this._onTrendKeydown}
1206
- >${this.label}</p>` : nothing}
1186
+ >${this.label}</p></nile-lite-tooltip>` : nothing}
1207
1187
 
1208
1188
  ${isGauge ? html `
1209
1189
  <div class="kpi-gauge-slot">
@@ -1225,17 +1205,9 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1225
1205
  ${!isGauge ? html `
1226
1206
  <span class="kpi-value-group">
1227
1207
  ${infoLeft ? this.renderValueInfo() : nothing}
1228
- <h2
1229
- class="kpi-value"
1230
- tabindex=${showTooltip ? '0' : nothing}
1231
- @mouseenter=${showTooltip ? this._onValueEnter : nothing}
1232
- @mouseleave=${showTooltip ? this._onTipLeave : nothing}
1233
- @focus=${showTooltip ? this._onValueEnter : nothing}
1234
- @blur=${showTooltip ? this._onTipLeave : nothing}
1235
- @keydown=${showTooltip ? this._onTrendKeydown : nothing}
1236
- >
1237
- ${this.prefix ? html `<span class="kpi-prefix">${this.prefix}</span>` : nothing}${displayValue}${this.suffix ? html `<span class="kpi-suffix">${this.suffix}</span>` : nothing}
1238
- </h2>
1208
+ ${showTooltip
1209
+ ? html `<nile-lite-tooltip class="kpi-tip" content=${this._valueTooltipText()} placement="top" ?disabled=${!this.tooltipEnabled}>${valueEl}</nile-lite-tooltip>`
1210
+ : valueEl}
1239
1211
  ${infoLeft ? nothing : this.renderValueInfo()}
1240
1212
  </span>
1241
1213
  ` : nothing}
@@ -1246,15 +1218,10 @@ let NileKpiChart = class NileKpiChart extends NileElement {
1246
1218
 
1247
1219
  ${this.renderForecast()}
1248
1220
 
1249
- ${this.description ? html `<p
1221
+ ${this.description ? html `<nile-lite-tooltip class="kpi-tip" data-kpi-tip="description" content=${this.description} placement="top" disabled><p
1250
1222
  class="kpi-description"
1251
1223
  tabindex="0"
1252
- @mouseenter=${this._onDescEnter}
1253
- @mouseleave=${this._onTipLeave}
1254
- @focus=${this._onDescEnter}
1255
- @blur=${this._onTipLeave}
1256
- @keydown=${this._onTrendKeydown}
1257
- >${this.description}</p>` : nothing}
1224
+ >${this.description}</p></nile-lite-tooltip>` : nothing}
1258
1225
 
1259
1226
  ${this.sparkline.length && !isGauge ? html `<div class="kpi-sparkline"></div>` : nothing}
1260
1227
  </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aquera/nile-visualization",
3
- "version": "2.9.37",
3
+ "version": "2.9.39",
4
4
  "description": "A visualization Library for the Nile Design System",
5
5
  "license": "MIT",
6
6
  "author": "Aquera Inc",
@@ -68,11 +68,12 @@
68
68
  "echarts": "^6.1.0"
69
69
  },
70
70
  "peerDependencies": {
71
- "highcharts": "12.5.0",
71
+ "highcharts": "13.1.1",
72
72
  "@aquera/nile-data-grid": ">=0.1.0",
73
73
  "@aquera/nile-elements": ">=0.1.0"
74
74
  },
75
75
  "devDependencies": {
76
+ "@aquera/nile-glyph": "^1.0.13",
76
77
  "@rollup/plugin-babel": "^6.0.3",
77
78
  "@rollup/plugin-commonjs": "^25.0.3",
78
79
  "@rollup/plugin-node-resolve": "^15.0.1",