@oicl/openbridge-webcomponents 2.0.0-next.153 → 2.0.0-next.155

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 +438 -238
  2. package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
  3. package/custom-elements.json +260 -50
  4. package/dist/components/alert-list-details-experimental/alert-list-details-experimental.css.js +3 -7
  5. package/dist/components/alert-list-details-experimental/alert-list-details-experimental.css.js.map +1 -1
  6. package/dist/components/alert-list-details-experimental/alert-list-details-experimental.d.ts +133 -14
  7. package/dist/components/alert-list-details-experimental/alert-list-details-experimental.d.ts.map +1 -1
  8. package/dist/components/alert-list-details-experimental/alert-list-details-experimental.js +330 -233
  9. package/dist/components/alert-list-details-experimental/alert-list-details-experimental.js.map +1 -1
  10. package/dist/components/table/table.d.ts.map +1 -1
  11. package/dist/components/table/table.js +10 -2
  12. package/dist/components/table/table.js.map +1 -1
  13. package/dist/components/user-button/user-button.css.js +68 -1
  14. package/dist/components/user-button/user-button.css.js.map +1 -1
  15. package/dist/components/user-button/user-button.d.ts +12 -1
  16. package/dist/components/user-button/user-button.d.ts.map +1 -1
  17. package/dist/components/user-button/user-button.js +12 -3
  18. package/dist/components/user-button/user-button.js.map +1 -1
  19. package/dist/components/user-menu/user-menu.css.js +15 -0
  20. package/dist/components/user-menu/user-menu.css.js.map +1 -1
  21. package/dist/components/user-menu/user-menu.d.ts +30 -2
  22. package/dist/components/user-menu/user-menu.d.ts.map +1 -1
  23. package/dist/components/user-menu/user-menu.js +34 -2
  24. package/dist/components/user-menu/user-menu.js.map +1 -1
  25. package/dist/generated/locales/es-419.d.ts +1 -0
  26. package/dist/generated/locales/es-419.d.ts.map +1 -1
  27. package/dist/generated/locales/es-419.js +1 -0
  28. package/dist/generated/locales/es-419.js.map +1 -1
  29. package/dist/generated/locales/fi-FI.d.ts +1 -0
  30. package/dist/generated/locales/fi-FI.d.ts.map +1 -1
  31. package/dist/generated/locales/fi-FI.js +1 -0
  32. package/dist/generated/locales/fi-FI.js.map +1 -1
  33. package/package.json +2 -2
@@ -3,6 +3,7 @@ import { customElement } from "../../decorator.js";
3
3
  import compentStyle from "./alert-list-details-experimental.css.js";
4
4
  import { msg } from "@lit/localize";
5
5
  import { property, query, state } from "lit/decorators.js";
6
+ import { repeat } from "lit/directives/repeat.js";
6
7
  import "../icon-button/icon-button.js";
7
8
  import "../button/button.js";
8
9
  import "../../icons/icon-silence-iec.js";
@@ -14,7 +15,7 @@ import "../../icons/icon-unacknowledged.js";
14
15
  import "../../icons/icon-alarm-noack-iec.js";
15
16
  import "../../icons/icon-warning-noack-iec.js";
16
17
  import "../alert-icon/alert-icon.js";
17
- import { isAcknowledged, isActive, comparePriorityAlerts, isShelved, isBlocked } from "../../types.js";
18
+ import { comparePriorityAlerts, isAcknowledged, isActive, isShelved, isBlocked } from "../../types.js";
18
19
  import { requiresAcknowledgement, usesAlarmNoAckIcon, excludedFromUnackedFilter } from "../../alert-severity.js";
19
20
  import { ObcTableCellType } from "../table/table.js";
20
21
  import "../scrollbar/scrollbar.js";
@@ -28,16 +29,16 @@ var __decorateClass = (decorators, target, key, kind) => {
28
29
  if (kind && result) __defProp(target, key, result);
29
30
  return result;
30
31
  };
31
- var AlertListMode = /* @__PURE__ */ ((AlertListMode2) => {
32
- AlertListMode2["UNACKED"] = "unacked";
33
- AlertListMode2["ALL"] = "all";
34
- AlertListMode2["SHELVED"] = "shelved";
35
- AlertListMode2["BLOCKED"] = "blocked";
36
- AlertListMode2["RECTIFIED"] = "rectified";
37
- return AlertListMode2;
38
- })(AlertListMode || {});
39
- function getAlertListModeData(selectedMode) {
40
- if (selectedMode === "all")
32
+ var FilterModes = /* @__PURE__ */ ((FilterModes2) => {
33
+ FilterModes2["UNACKED"] = "unacked";
34
+ FilterModes2["ALL"] = "all";
35
+ FilterModes2["SHELVED"] = "shelved";
36
+ FilterModes2["BLOCKED"] = "blocked";
37
+ FilterModes2["RECTIFIED"] = "rectified";
38
+ return FilterModes2;
39
+ })(FilterModes || {});
40
+ function getFilterModeData(filterMode) {
41
+ if (filterMode === "all")
41
42
  return {
42
43
  name: "all",
43
44
  title: msg("All"),
@@ -45,7 +46,7 @@ function getAlertListModeData(selectedMode) {
45
46
  emptyIcon: html`<obi-alerts></obi-alerts>`,
46
47
  filter: (alert) => !isShelved(alert) && isActive(alert)
47
48
  };
48
- else if (selectedMode === "unacked")
49
+ else if (filterMode === "unacked")
49
50
  return {
50
51
  name: "unacked",
51
52
  title: msg("Unacked"),
@@ -53,7 +54,7 @@ function getAlertListModeData(selectedMode) {
53
54
  emptyIcon: html`<obi-unacknowledged></obi-unacknowledged>`,
54
55
  filter: (alert) => !isAcknowledged(alert) && isActive(alert) && !excludedFromUnackedFilter(alert.type) && !isShelved(alert)
55
56
  };
56
- else if (selectedMode === "shelved")
57
+ else if (filterMode === "shelved")
57
58
  return {
58
59
  name: "shelved",
59
60
  title: msg("Shelved"),
@@ -61,7 +62,7 @@ function getAlertListModeData(selectedMode) {
61
62
  emptyIcon: html`<obi-alerts-shelf></obi-alerts-shelf>`,
62
63
  filter: (alert) => isShelved(alert)
63
64
  };
64
- else if (selectedMode === "blocked")
65
+ else if (filterMode === "blocked")
65
66
  return {
66
67
  name: "blocked",
67
68
  title: msg("Blocked"),
@@ -69,7 +70,7 @@ function getAlertListModeData(selectedMode) {
69
70
  emptyIcon: html`<obi-alerts-active></obi-alerts-active>`,
70
71
  filter: (alert) => isBlocked(alert)
71
72
  };
72
- else if (selectedMode === "rectified")
73
+ else if (filterMode === "rectified")
73
74
  return {
74
75
  name: "rectified",
75
76
  title: msg("Rectified"),
@@ -77,22 +78,216 @@ function getAlertListModeData(selectedMode) {
77
78
  emptyIcon: html`<obi-alarm-rectified-iec></obi-alarm-rectified-iec>`,
78
79
  filter: (alert) => !isActive(alert)
79
80
  };
80
- else throw new Error("Invalid selected mode");
81
+ else throw new Error("Invalid filter mode");
81
82
  }
82
83
  function canAckFilter(filter) {
83
84
  return (alert) => !isAcknowledged(alert) && !alert.noAck && !excludedFromUnackedFilter(alert.type) && filter(alert);
84
85
  }
86
+ function alertListCellSlotName(columnKey, rowId) {
87
+ return `cell-${encodeURIComponent(columnKey)}:${rowId}`;
88
+ }
89
+ function statusColumn(options = {}) {
90
+ return {
91
+ key: "status",
92
+ label: "Status",
93
+ sortDirection: "desc",
94
+ compare: comparePriorityAlerts,
95
+ cell: (alert) => ({
96
+ type: ObcTableCellType.Regular,
97
+ largeIcon: true,
98
+ text: alert.text,
99
+ title: alert.source,
100
+ noWrap: true,
101
+ icon: html`<obc-alert-icon
102
+ .type=${alert.type}
103
+ .acknowledged=${isAcknowledged(alert)}
104
+ .active=${isActive(alert)}
105
+ ></obc-alert-icon>`
106
+ }),
107
+ ...options
108
+ };
109
+ }
110
+ function ackColumn(options = {}) {
111
+ return {
112
+ key: "ack",
113
+ label: "ACK-status",
114
+ cell: (alert) => {
115
+ if (isAcknowledged(alert) || !isActive(alert) || !requiresAcknowledgement(alert.type)) {
116
+ return { type: ObcTableCellType.Regular };
117
+ }
118
+ if (alert.noAck) {
119
+ const icon = usesAlarmNoAckIcon(alert.type) ? html`<obi-alarm-noack-iec usecsscolor></obi-alarm-noack-iec>` : html`<obi-warning-noack-iec usecsscolor></obi-warning-noack-iec>`;
120
+ return {
121
+ type: ObcTableCellType.Regular,
122
+ largeIcon: true,
123
+ icon,
124
+ align: "center"
125
+ };
126
+ }
127
+ return { type: ObcTableCellType.Button, text: msg("ACK") };
128
+ },
129
+ ...options
130
+ };
131
+ }
132
+ function timeColumn({
133
+ formatter = (time) => time.toLocaleTimeString(void 0, { hour12: false }),
134
+ ...options
135
+ } = {}) {
136
+ return {
137
+ key: "time",
138
+ label: "Activated",
139
+ compare: (a, b) => new Date(a.time).getTime() - new Date(b.time).getTime(),
140
+ cell: (alert) => ({
141
+ type: ObcTableCellType.Regular,
142
+ text: formatter(alert.time),
143
+ align: "center",
144
+ neutral: true
145
+ }),
146
+ ...options
147
+ };
148
+ }
149
+ function tagIdColumn(options = {}) {
150
+ return {
151
+ key: "tagId",
152
+ label: "Tag ID",
153
+ compare: (a, b) => a.tagId.localeCompare(b.tagId),
154
+ cell: (alert) => ({
155
+ type: ObcTableCellType.Regular,
156
+ text: "#" + alert.tagId,
157
+ align: "right"
158
+ }),
159
+ ...options
160
+ };
161
+ }
162
+ function isSlotColumn(column) {
163
+ return "slot" in column && column.slot === true;
164
+ }
165
+ function parentRowIdOf(rowId) {
166
+ const separatorIndex = rowId.lastIndexOf("/");
167
+ return separatorIndex === -1 ? void 0 : rowId.slice(0, separatorIndex);
168
+ }
169
+ const TABLE_KEY_PREFIX = "column-";
170
+ function walkAlertRows(alerts, isExpanded) {
171
+ const alertIds = new Set(alerts.map((alert) => alert.id));
172
+ const membersByGroupId = /* @__PURE__ */ new Map();
173
+ const roots = [];
174
+ for (const alert of alerts) {
175
+ const groupIds = (alert.memberOf ?? []).filter(
176
+ (groupId) => groupId !== alert.id && alertIds.has(groupId)
177
+ );
178
+ if (groupIds.length === 0) {
179
+ roots.push(alert);
180
+ continue;
181
+ }
182
+ for (const groupId of groupIds) {
183
+ const members = membersByGroupId.get(groupId) ?? [];
184
+ members.push(alert);
185
+ membersByGroupId.set(groupId, members);
186
+ }
187
+ }
188
+ const reachable = /* @__PURE__ */ new Set();
189
+ const markReachable = (alert) => {
190
+ if (reachable.has(alert.id)) {
191
+ return;
192
+ }
193
+ reachable.add(alert.id);
194
+ for (const member of membersByGroupId.get(alert.id) ?? []) {
195
+ markReachable(member);
196
+ }
197
+ };
198
+ roots.forEach(markReachable);
199
+ for (const alert of alerts) {
200
+ if (!reachable.has(alert.id)) {
201
+ roots.push(alert);
202
+ markReachable(alert);
203
+ }
204
+ }
205
+ const rows = [];
206
+ const visit = (alert, level, parentRowId, ancestors) => {
207
+ const segment = encodeURIComponent(alert.id);
208
+ const rowId = parentRowId === void 0 ? segment : `${parentRowId}/${segment}`;
209
+ const members = membersByGroupId.get(alert.id) ?? [];
210
+ const expandableMembers = members.filter(
211
+ (member) => !ancestors.has(member.id)
212
+ );
213
+ rows.push({
214
+ rowId,
215
+ parentRowId,
216
+ alert,
217
+ level,
218
+ expandable: expandableMembers.length > 0
219
+ });
220
+ if (!isExpanded(rowId)) {
221
+ return;
222
+ }
223
+ const nextAncestors = new Set(ancestors).add(alert.id);
224
+ for (const member of expandableMembers) {
225
+ visit(member, level + 1, rowId, nextAncestors);
226
+ }
227
+ };
228
+ for (const alert of roots) {
229
+ visit(alert, 0, void 0, /* @__PURE__ */ new Set());
230
+ }
231
+ return rows;
232
+ }
233
+ function getAlertRows(alerts, filterMode) {
234
+ const { filter } = getFilterModeData(filterMode);
235
+ return walkAlertRows(alerts.filter(filter), () => true);
236
+ }
85
237
  let ObcAlertListDetailsExperimental = class extends LitElement {
86
238
  constructor() {
87
239
  super(...arguments);
88
- this.selectedMode = "all";
240
+ this.filterMode = "all";
89
241
  this.alerts = [];
90
- this.showTime = false;
91
- this.timeFormatter = (time) => time.toLocaleTimeString(void 0, { hour12: false });
92
- this.small = false;
242
+ this.columns = [
243
+ statusColumn(),
244
+ ackColumn({ dividerRight: true }),
245
+ tagIdColumn()
246
+ ];
247
+ this.showHeader = true;
93
248
  this.defaultExpanded = true;
94
249
  this.expansionOverrides = /* @__PURE__ */ new Map();
95
250
  this.alertByRowId = /* @__PURE__ */ new Map();
251
+ this.allRowIds = /* @__PURE__ */ new Set();
252
+ this._cellSlots = [];
253
+ this.cellSlotsChanged = false;
254
+ }
255
+ /** Slot of every cell in a slot column, rows in collapsed groups included. */
256
+ get cellSlots() {
257
+ return this._cellSlots;
258
+ }
259
+ willUpdate(changed) {
260
+ if (!changed.has("alerts") && !changed.has("columns") && !changed.has("filterMode")) {
261
+ return;
262
+ }
263
+ const rows = getAlertRows(this.alerts, this.filterMode);
264
+ this.allRowIds = new Set(rows.map((row) => row.rowId));
265
+ const slotColumns = this.columns.filter(isSlotColumn);
266
+ const next = getAlertRows(this.alerts, this.filterMode).flatMap(
267
+ (row) => slotColumns.map((column) => ({
268
+ name: alertListCellSlotName(column.key, row.rowId),
269
+ alert: row.alert,
270
+ rowId: row.rowId,
271
+ columnKey: column.key
272
+ }))
273
+ );
274
+ const unchanged = next.length === this._cellSlots.length && next.every(
275
+ (slot, index) => slot.name === this._cellSlots[index].name && slot.alert === this._cellSlots[index].alert
276
+ );
277
+ if (!unchanged) {
278
+ this._cellSlots = next;
279
+ this.cellSlotsChanged = true;
280
+ }
281
+ }
282
+ updated() {
283
+ if (this.cellSlotsChanged) {
284
+ this.cellSlotsChanged = false;
285
+ this.dispatchEvent(
286
+ new CustomEvent("cell-slots-change", {
287
+ detail: this._cellSlots
288
+ })
289
+ );
290
+ }
96
291
  }
97
292
  getVisibleAlerts() {
98
293
  const seen = /* @__PURE__ */ new Set();
@@ -105,19 +300,27 @@ let ObcAlertListDetailsExperimental = class extends LitElement {
105
300
  });
106
301
  }
107
302
  onRowClick(e) {
108
- const row = this.alertByRowId.get(e.detail.row.id);
109
- if (row) {
303
+ const rowId = e.detail.row.id;
304
+ const alert = this.alertByRowId.get(rowId);
305
+ if (alert) {
110
306
  this.dispatchEvent(
111
- new CustomEvent("row-click", { detail: { alert: row } })
307
+ new CustomEvent("row-click", {
308
+ detail: { alert, rowId }
309
+ })
112
310
  );
113
311
  }
114
312
  }
115
313
  onCellButtonClick(e) {
116
- const row = this.alertByRowId.get(e.detail.rowId);
117
- if (row) {
314
+ const { rowId, columnKey } = e.detail;
315
+ const alert = this.alertByRowId.get(rowId);
316
+ if (alert) {
118
317
  this.dispatchEvent(
119
- new CustomEvent("ack-click", {
120
- detail: { alert: row },
318
+ new CustomEvent("cell-click", {
319
+ detail: {
320
+ alert,
321
+ columnKey: columnKey.slice(TABLE_KEY_PREFIX.length),
322
+ rowId
323
+ },
121
324
  bubbles: false
122
325
  })
123
326
  );
@@ -131,226 +334,114 @@ let ObcAlertListDetailsExperimental = class extends LitElement {
131
334
  isExpanded(rowId) {
132
335
  return this.expansionOverrides.get(rowId) ?? this.defaultExpanded;
133
336
  }
134
- get columns() {
135
- if (this.small) {
136
- const columns = [
137
- {
138
- label: "Status",
139
- key: "status",
140
- sortDirection: "desc",
141
- sortable: true,
142
- compareFunction: (_a, _b, aRow, bRow) => {
143
- const aAlert = this.alertByRowId.get(aRow.id);
144
- const bAlert = this.alertByRowId.get(bRow.id);
145
- if (aAlert && bAlert) {
146
- return comparePriorityAlerts(aAlert, bAlert);
147
- }
148
- return 0;
149
- }
150
- }
151
- ];
152
- if (this.showTime) {
153
- columns.push({
154
- label: "Activated",
155
- key: "time"
156
- });
337
+ compareRows(compare, aRow, bRow) {
338
+ const aAlert = this.alertByRowId.get(aRow.id);
339
+ const bAlert = this.alertByRowId.get(bRow.id);
340
+ return aAlert && bAlert ? compare(aAlert, bAlert) : 0;
341
+ }
342
+ get tableColumns() {
343
+ return this.columns.map((column) => {
344
+ const base = {
345
+ label: column.label,
346
+ key: TABLE_KEY_PREFIX + column.key,
347
+ dividerRight: column.dividerRight
348
+ };
349
+ if (isSlotColumn(column)) {
350
+ return {
351
+ ...base,
352
+ renderCell: (_value, row) => html`<slot
353
+ name=${alertListCellSlotName(column.key, row.id)}
354
+ ></slot>`
355
+ };
157
356
  }
158
- columns.push({
159
- label: "ACK-status",
160
- key: "action"
161
- });
162
- return columns;
163
- } else {
164
- const columns = [
165
- {
166
- label: "Status",
167
- key: "status",
168
- sortDirection: "desc",
169
- sortable: true,
170
- compareFunction: (_a, _b, aRow, bRow) => {
171
- const aAlert = this.alertByRowId.get(aRow.id);
172
- const bAlert = this.alertByRowId.get(bRow.id);
173
- if (aAlert && bAlert) {
174
- return comparePriorityAlerts(aAlert, bAlert);
175
- }
176
- return 0;
177
- }
178
- },
179
- {
180
- label: "ACK-status",
181
- key: "action",
182
- dividerRight: true
183
- }
184
- ];
185
- if (this.showTime) {
186
- columns.push({
187
- label: "Activated",
188
- key: "time",
357
+ const { compare } = column;
358
+ if (compare) {
359
+ return {
360
+ ...base,
189
361
  sortable: true,
190
- compareFunction: (_a, _b, aRow, bRow) => {
191
- const aAlert = this.alertByRowId.get(aRow.id);
192
- const bAlert = this.alertByRowId.get(bRow.id);
193
- if (aAlert && bAlert) {
194
- const aTime = new Date(aAlert.time);
195
- const bTime = new Date(bAlert.time);
196
- return aTime.getTime() - bTime.getTime();
197
- }
198
- return 0;
199
- }
200
- });
362
+ sortDirection: column.sortDirection,
363
+ compareFunction: (_a, _b, aRow, bRow) => this.compareRows(compare, aRow, bRow)
364
+ };
201
365
  }
202
- columns.push({
203
- label: "Tag ID",
204
- key: "tagId",
205
- sortable: true,
206
- compareFunction: (a, b) => {
207
- const aText = a?.type === ObcTableCellType.Regular ? String(a.text ?? "") : "";
208
- const bText = b?.type === ObcTableCellType.Regular ? String(b.text ?? "") : "";
209
- return aText.localeCompare(bText);
210
- }
211
- });
212
- return columns;
213
- }
366
+ return base;
367
+ });
214
368
  }
215
- get metadata() {
216
- return getAlertListModeData(this.selectedMode);
369
+ get gridColumns() {
370
+ const columnTracks = this.columns.map(
371
+ (column, index) => column.width ?? (index === 0 ? "1fr" : "min-content")
372
+ );
373
+ return [...columnTracks, "min-content"].join(" ");
217
374
  }
218
- get filteredAlerts() {
219
- return this.alerts.filter(this.metadata.filter);
375
+ get metadata() {
376
+ return getFilterModeData(this.filterMode);
220
377
  }
221
378
  buildVisibleRows() {
222
- const alerts = this.filteredAlerts;
223
- const alertIds = new Set(alerts.map((alert) => alert.id));
224
- const membersByGroupId = /* @__PURE__ */ new Map();
225
- const roots = [];
226
- for (const alert of alerts) {
227
- const groupIds = (alert.memberOf ?? []).filter(
228
- (groupId) => groupId !== alert.id && alertIds.has(groupId)
229
- );
230
- if (groupIds.length === 0) {
231
- roots.push(alert);
232
- continue;
233
- }
234
- for (const groupId of groupIds) {
235
- const members = membersByGroupId.get(groupId) ?? [];
236
- members.push(alert);
237
- membersByGroupId.set(groupId, members);
238
- }
239
- }
240
- const reachable = /* @__PURE__ */ new Set();
241
- const markReachable = (alert) => {
242
- if (reachable.has(alert.id)) {
243
- return;
244
- }
245
- reachable.add(alert.id);
246
- for (const member of membersByGroupId.get(alert.id) ?? []) {
247
- markReachable(member);
248
- }
249
- };
250
- roots.forEach(markReachable);
251
- for (const alert of alerts) {
252
- if (!reachable.has(alert.id)) {
253
- roots.push(alert);
254
- markReachable(alert);
255
- }
379
+ const rows = walkAlertRows(
380
+ this.alerts.filter(this.metadata.filter),
381
+ (rowId) => this.isExpanded(rowId)
382
+ );
383
+ this.alertByRowId = new Map(rows.map((row) => [row.rowId, row.alert]));
384
+ const highlightedRowId = this.highlightedRowId();
385
+ return rows.map((row) => ({
386
+ ...this.buildRowCells(row.alert),
387
+ id: row.rowId,
388
+ parentId: row.parentRowId,
389
+ level: row.level,
390
+ expandable: row.expandable,
391
+ expanded: this.isExpanded(row.rowId),
392
+ selected: row.rowId === highlightedRowId
393
+ }));
394
+ }
395
+ /** The selected row, or the nearest visible group row when a collapsed group hides it. */
396
+ highlightedRowId() {
397
+ if (this.selectedRowId === void 0 || !this.allRowIds.has(this.selectedRowId)) {
398
+ return void 0;
256
399
  }
257
- const rows = [];
258
- this.alertByRowId = /* @__PURE__ */ new Map();
259
- const visit = (alert, level, parentRowId, ancestors) => {
260
- const segment = encodeURIComponent(alert.id);
261
- const rowId = parentRowId === void 0 ? segment : `${parentRowId}/${segment}`;
262
- const members = membersByGroupId.get(alert.id) ?? [];
263
- const expandableMembers = members.filter(
264
- (member) => !ancestors.has(member.id)
265
- );
266
- const expanded = this.isExpanded(rowId);
267
- this.alertByRowId.set(rowId, alert);
268
- rows.push({
269
- ...this.buildRowCells(alert),
270
- id: rowId,
271
- parentId: parentRowId,
272
- level,
273
- expandable: expandableMembers.length > 0,
274
- expanded
275
- });
276
- if (!expanded) {
277
- return;
278
- }
279
- const nextAncestors = new Set(ancestors).add(alert.id);
280
- for (const member of expandableMembers) {
281
- visit(member, level + 1, rowId, nextAncestors);
282
- }
283
- };
284
- for (const alert of roots) {
285
- visit(alert, 0, void 0, /* @__PURE__ */ new Set());
400
+ let rowId = this.selectedRowId;
401
+ while (rowId !== void 0 && !this.alertByRowId.has(rowId)) {
402
+ rowId = parentRowIdOf(rowId);
286
403
  }
287
- return rows;
404
+ return rowId;
288
405
  }
289
406
  buildRowCells(alert) {
290
- let action = {
291
- type: ObcTableCellType.Regular
292
- };
293
- if (!isAcknowledged(alert) && isActive(alert) && requiresAcknowledgement(alert.type)) {
294
- if (alert.noAck) {
295
- const icon = usesAlarmNoAckIcon(alert.type) ? html`<obi-alarm-noack-iec usecsscolor></obi-alarm-noack-iec>` : html`<obi-warning-noack-iec usecsscolor></obi-warning-noack-iec>`;
296
- action = {
297
- type: ObcTableCellType.Regular,
298
- largeIcon: true,
299
- icon,
300
- align: "center"
301
- };
302
- } else {
303
- action = {
304
- type: ObcTableCellType.Button,
305
- text: msg("ACK")
306
- };
307
- }
407
+ const cells = {};
408
+ for (const column of this.columns) {
409
+ cells[TABLE_KEY_PREFIX + column.key] = isSlotColumn(column) ? (
410
+ // obc-table skips renderCell for an undefined value.
411
+ { type: ObcTableCellType.Regular }
412
+ ) : column.cell(alert);
308
413
  }
309
- const status = {
310
- type: ObcTableCellType.Regular,
311
- largeIcon: true,
312
- text: alert.text,
313
- title: alert.source,
314
- noWrap: true,
315
- icon: html`<obc-alert-icon
316
- .type=${alert.type}
317
- .acknowledged=${isAcknowledged(alert)}
318
- .active=${isActive(alert)}
319
- ></obc-alert-icon>`
320
- };
321
- const time = this.showTime ? {
322
- type: ObcTableCellType.Regular,
323
- text: this.timeFormatter(alert.time),
324
- align: "center",
325
- neutral: true
326
- } : void 0;
327
- const tagId = this.small ? void 0 : {
328
- type: ObcTableCellType.Regular,
329
- text: "#" + alert.id,
330
- align: "right"
331
- };
332
- return {
333
- status,
334
- time,
335
- action,
336
- tagId
337
- };
414
+ return cells;
415
+ }
416
+ slotNames(rows) {
417
+ const slotColumns = this.columns.filter(isSlotColumn);
418
+ return rows.flatMap(
419
+ (row) => slotColumns.map((column) => alertListCellSlotName(column.key, row.id))
420
+ );
338
421
  }
339
422
  render() {
340
423
  const selectedList = this.metadata;
341
424
  const data = this.buildVisibleRows();
342
425
  return html`
343
- <div class="wrapper ${this.small ? "small" : ""}">
426
+ <div class="wrapper">
344
427
  ${data.length > 0 ? html` <obc-table
345
428
  class="alert-list"
429
+ style="--alert-list-grid-columns: ${this.gridColumns}"
346
430
  .data=${data}
347
- .columns=${this.columns}
431
+ .columns=${this.tableColumns}
348
432
  .striped=${true}
349
- .showHeader=${!this.small}
433
+ .showHeader=${this.showHeader}
350
434
  @row-click=${this.onRowClick}
351
435
  @cell-button-click=${this.onCellButtonClick}
352
436
  @expand-toggle=${this.onExpandToggle}
353
- ></obc-table>
437
+ >
438
+ ${repeat(
439
+ this.slotNames(data),
440
+ (name) => name,
441
+ // Forwards the host's slot into the one obc-table renders in the cell.
442
+ (name) => html`<slot name=${name} slot=${name}></slot>`
443
+ )}
444
+ </obc-table>
354
445
  <div class="spacer"></div>` : html` <div class="empty-list">
355
446
  <div class="icon">${selectedList.emptyIcon}</div>
356
447
  <div class="empty-title">${selectedList.emptyTitle}</div>
@@ -362,22 +453,22 @@ let ObcAlertListDetailsExperimental = class extends LitElement {
362
453
  ObcAlertListDetailsExperimental.styles = unsafeCSS(compentStyle);
363
454
  __decorateClass([
364
455
  property({ type: String })
365
- ], ObcAlertListDetailsExperimental.prototype, "selectedMode", 2);
456
+ ], ObcAlertListDetailsExperimental.prototype, "filterMode", 2);
366
457
  __decorateClass([
367
458
  property({ type: Array })
368
459
  ], ObcAlertListDetailsExperimental.prototype, "alerts", 2);
369
460
  __decorateClass([
370
- property({ type: Boolean })
371
- ], ObcAlertListDetailsExperimental.prototype, "showTime", 2);
372
- __decorateClass([
373
- property({ attribute: false })
374
- ], ObcAlertListDetailsExperimental.prototype, "timeFormatter", 2);
461
+ property({ type: Array, attribute: false })
462
+ ], ObcAlertListDetailsExperimental.prototype, "columns", 2);
375
463
  __decorateClass([
376
- property({ type: Boolean })
377
- ], ObcAlertListDetailsExperimental.prototype, "small", 2);
464
+ property({ type: Boolean, attribute: false })
465
+ ], ObcAlertListDetailsExperimental.prototype, "showHeader", 2);
378
466
  __decorateClass([
379
467
  property({ type: Boolean, attribute: false })
380
468
  ], ObcAlertListDetailsExperimental.prototype, "defaultExpanded", 2);
469
+ __decorateClass([
470
+ property({ type: String })
471
+ ], ObcAlertListDetailsExperimental.prototype, "selectedRowId", 2);
381
472
  __decorateClass([
382
473
  query("obc-table")
383
474
  ], ObcAlertListDetailsExperimental.prototype, "alertList", 2);
@@ -388,9 +479,15 @@ ObcAlertListDetailsExperimental = __decorateClass([
388
479
  customElement("obc-alert-list-details-experimental")
389
480
  ], ObcAlertListDetailsExperimental);
390
481
  export {
391
- AlertListMode,
482
+ FilterModes,
392
483
  ObcAlertListDetailsExperimental,
484
+ ackColumn,
485
+ alertListCellSlotName,
393
486
  canAckFilter,
394
- getAlertListModeData
487
+ getAlertRows,
488
+ getFilterModeData,
489
+ statusColumn,
490
+ tagIdColumn,
491
+ timeColumn
395
492
  };
396
493
  //# sourceMappingURL=alert-list-details-experimental.js.map