@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.64 → 2.0.0-next.65

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.
Files changed (33) hide show
  1. package/bundle/openbridge-webcomponents.bundle.js +66 -58
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +45 -187
  4. package/dist/components/navigation-item/navigation-item.d.ts +7 -7
  5. package/dist/components/navigation-item/navigation-item.d.ts.map +1 -1
  6. package/dist/components/navigation-item/navigation-item.js +3 -15
  7. package/dist/components/navigation-item/navigation-item.js.map +1 -1
  8. package/dist/components/navigation-item-group/navigation-item-group.d.ts +8 -7
  9. package/dist/components/navigation-item-group/navigation-item-group.d.ts.map +1 -1
  10. package/dist/components/navigation-item-group/navigation-item-group.js +3 -15
  11. package/dist/components/navigation-item-group/navigation-item-group.js.map +1 -1
  12. package/dist/components/navigation-menu/navigation-menu.d.ts +2 -2
  13. package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
  14. package/dist/components/tree-navigation-group/tree-navigation-group.d.ts +10 -10
  15. package/dist/components/tree-navigation-group/tree-navigation-group.d.ts.map +1 -1
  16. package/dist/components/tree-navigation-group/tree-navigation-group.js +3 -15
  17. package/dist/components/tree-navigation-group/tree-navigation-group.js.map +1 -1
  18. package/dist/components/tree-navigation-item/tree-navigation-item.css.js +13 -0
  19. package/dist/components/tree-navigation-item/tree-navigation-item.css.js.map +1 -1
  20. package/dist/components/tree-navigation-item/tree-navigation-item.d.ts +59 -8
  21. package/dist/components/tree-navigation-item/tree-navigation-item.d.ts.map +1 -1
  22. package/dist/components/tree-navigation-item/tree-navigation-item.js +46 -17
  23. package/dist/components/tree-navigation-item/tree-navigation-item.js.map +1 -1
  24. package/package.json +1 -1
  25. package/src/components/navigation-item/navigation-item.ts +8 -12
  26. package/src/components/navigation-item-group/navigation-item-group.ts +9 -12
  27. package/src/components/navigation-menu/navigation-menu.stories.ts +34 -6
  28. package/src/components/navigation-menu/navigation-menu.ts +2 -2
  29. package/src/components/tree-navigation/tree-navigation.stories.ts +154 -9
  30. package/src/components/tree-navigation-group/tree-navigation-group.ts +11 -15
  31. package/src/components/tree-navigation-item/tree-navigation-item.css +12 -0
  32. package/src/components/tree-navigation-item/tree-navigation-item.stories.ts +38 -15
  33. package/src/components/tree-navigation-item/tree-navigation-item.ts +98 -17
@@ -8,7 +8,7 @@ import '../../icons/icon-chevron-right-google.js';
8
8
  import '../../icons/icon-alert-header-aggregated-iec.js';
9
9
  import '../../icons/icon-alert-header-group-iec.js';
10
10
  import '../badge/badge.js';
11
- import {BadgeType} from '../badge/badge.js';
11
+ import {AlertType, ALERT_SEVERITY_PRIORITY} from '../../types.js';
12
12
 
13
13
  /**
14
14
  * Guide line drawn for one indentation column. Normally computed by
@@ -42,6 +42,39 @@ export enum TreeTerminalType {
42
42
  groupHeader = 'group-header',
43
43
  }
44
44
 
45
+ /**
46
+ * Per-severity alert counts for a tree row's trailing badge(s). Each `count*`
47
+ * is the number of active alerts of that severity at or beneath the row — the
48
+ * level severities `level-critical`, `level-high`, `level-medium`, `level-low`,
49
+ * and `level-diagnostic`, plus the IEC severities `alarm`, `warning`, and
50
+ * `caution`. Badges are ordered and aggregated by the shared
51
+ * `ALERT_SEVERITY_PRIORITY` ranking, most to least severe.
52
+ *
53
+ * Set `aggregate` to collapse the counts into a single badge showing the total,
54
+ * styled as the highest category present; otherwise one badge is rendered per
55
+ * non-zero count.
56
+ */
57
+ export interface TreeNavigationItemAlerts {
58
+ /** Collapse all counts into one badge: total count, highest-severity style. */
59
+ aggregate?: boolean;
60
+ /** Number of level-critical alerts. */
61
+ countLevelCritical?: number;
62
+ /** Number of alarm alerts. */
63
+ countAlarm?: number;
64
+ /** Number of level-high alerts. */
65
+ countLevelHigh?: number;
66
+ /** Number of warning alerts. */
67
+ countWarning?: number;
68
+ /** Number of level-medium alerts. */
69
+ countLevelMedium?: number;
70
+ /** Number of caution alerts. */
71
+ countCaution?: number;
72
+ /** Number of level-low alerts. */
73
+ countLevelLow?: number;
74
+ /** Number of level-diagnostic alerts. */
75
+ countLevelDiagnostic?: number;
76
+ }
77
+
45
78
  /**
46
79
  * `<obc-tree-navigation-item>` – A single row in a tree- or file-explorer-style
47
80
  * navigation list, with indentation guide lines, an optional expand/collapse
@@ -66,8 +99,12 @@ export enum TreeTerminalType {
66
99
  * aggregated or grouped alerts.
67
100
  * - **Leading icon:** Provide an icon via the `icon` slot (shown when
68
101
  * `hasLeadingIcon`).
69
- * - **Alert badge:** A trailing counter badge (e.g. an alarm count), toggled with
70
- * `hasAlertBadge` and configured via `alertCount` and `alertType`.
102
+ * - **Alert badges:** Trailing counter badges driven by the `alerts` object — a
103
+ * per-severity count map with one field per level severity (critical, high,
104
+ * medium, low, diagnostic). By default each non-zero count renders its own
105
+ * badge, ordered most to least severe by `ALERT_SEVERITY_PRIORITY`; set
106
+ * `alerts.aggregate` to instead show a single badge with the combined total,
107
+ * styled as the highest category present.
71
108
  * - **Checked state:** `checked` highlights the current selection using the
72
109
  * amplified elevation style. A checked row is the current item and is not
73
110
  * re-selectable — it shows no hover/pressed feedback and fires no `click` or
@@ -142,14 +179,17 @@ export class ObcTreeNavigationItem extends LitElement {
142
179
  */
143
180
  @property({type: String}) terminalType: string = TreeTerminalType.regular;
144
181
 
145
- /** Whether a trailing alert counter badge is shown. */
146
- @property({type: Boolean}) hasAlertBadge = false;
147
-
148
- /** The number shown in the alert badge when `hasAlertBadge` is true. */
149
- @property({type: Number}) alertCount = 0;
150
-
151
- /** The severity/type of the alert badge. One of the `obc-badge` types (default `alarm`). */
152
- @property({type: String}) alertType: string = BadgeType.alarm;
182
+ /**
183
+ * Per-severity alert counts for the row's trailing badge(s). Omit (or leave
184
+ * every count at 0) for a row with no alerts. See {@link TreeNavigationItemAlerts}.
185
+ *
186
+ * - When `aggregate` is true, a single badge is shown: its number is the sum
187
+ * of all counts and its severity is the highest category present
188
+ * (critical alarm warning caution).
189
+ * - Otherwise one badge is shown per count greater than 0, ordered most to
190
+ * least severe and spaced by the alert-counter spacing token.
191
+ */
192
+ @property({type: Object}) alerts?: TreeNavigationItemAlerts;
153
193
 
154
194
  /**
155
195
  * The URL to navigate to when the row is activated. If set, the row renders as
@@ -164,6 +204,42 @@ export class ObcTreeNavigationItem extends LitElement {
164
204
  this.wrapperElement?.focus(options);
165
205
  }
166
206
 
207
+ /**
208
+ * The badge(s) to render from `alerts`, as `{type, count}` pairs already in
209
+ * severity order, ranked by `ALERT_SEVERITY_PRIORITY`.
210
+ *
211
+ * - No `alerts`, or every count 0 → no badges.
212
+ * - `aggregate` → a single pair: the summed count typed as the highest
213
+ * category that has any alerts.
214
+ * - Otherwise → one pair per count greater than 0.
215
+ */
216
+ private get alertBadges(): {type: AlertType; count: number}[] {
217
+ const alerts = this.alerts;
218
+ if (!alerts) return [];
219
+ const countByType: Partial<Record<AlertType, number>> = {
220
+ [AlertType.LevelCritical]: alerts.countLevelCritical ?? 0,
221
+ [AlertType.Alarm]: alerts.countAlarm ?? 0,
222
+ [AlertType.LevelHigh]: alerts.countLevelHigh ?? 0,
223
+ [AlertType.Warning]: alerts.countWarning ?? 0,
224
+ [AlertType.LevelMedium]: alerts.countLevelMedium ?? 0,
225
+ [AlertType.Caution]: alerts.countCaution ?? 0,
226
+ [AlertType.LevelLow]: alerts.countLevelLow ?? 0,
227
+ [AlertType.LevelDiagnostic]: alerts.countLevelDiagnostic ?? 0,
228
+ };
229
+ // Order (and, when aggregating, rank) by the shared severity priority,
230
+ // keeping only the severities this component exposes.
231
+ const ranked = ALERT_SEVERITY_PRIORITY.filter(
232
+ (type) => type in countByType
233
+ ).map((type) => ({type, count: countByType[type] ?? 0}));
234
+ if (alerts.aggregate) {
235
+ const total = ranked.reduce((sum, b) => sum + b.count, 0);
236
+ const highest = ranked.find((b) => b.count > 0);
237
+ if (!highest) return [];
238
+ return [{type: highest.type, count: total}];
239
+ }
240
+ return ranked.filter((b) => b.count > 0);
241
+ }
242
+
167
243
  /** A root-level row has no ancestor columns, so it draws no connector lines. */
168
244
  private get isRoot(): boolean {
169
245
  return this.branches.length === 0;
@@ -283,12 +359,17 @@ export class ObcTreeNavigationItem extends LitElement {
283
359
  : nothing}
284
360
  <span part="label" class="label">${this.label}</span>
285
361
  </div>
286
- ${this.hasAlertBadge
287
- ? html`<obc-badge
288
- class="alert-badge"
289
- .type=${this.alertType}
290
- .number=${this.alertCount}
291
- ></obc-badge>`
362
+ ${this.alertBadges.length > 0
363
+ ? html`<div class="alert-badges">
364
+ ${this.alertBadges.map(
365
+ (badge) =>
366
+ html`<obc-badge
367
+ class="alert-badge"
368
+ .type=${badge.type}
369
+ .number=${badge.count}
370
+ ></obc-badge>`
371
+ )}
372
+ </div>`
292
373
  : nothing}
293
374
  </div>
294
375
  </div>