@umriss-ui/alarms 0.0.0-stage → 0.47.0
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/CHANGELOG.md +22 -0
- package/LICENSE +20 -0
- package/README.md +41 -2
- package/dist/alarms.css +1 -0
- package/dist/alarms.js +599 -0
- package/dist/index.d.ts +516 -0
- package/dist/styles.d.ts +1 -0
- package/docs/llms-full.md +2584 -0
- package/package.json +90 -3
package/dist/alarms.js
ADDED
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import "./alarms.css";
|
|
3
|
+
import { jsx as i, jsxs as p, Fragment as Ae } from "react/jsx-runtime";
|
|
4
|
+
import { useState as L, useMemo as $, useRef as U, useEffect as ze } from "react";
|
|
5
|
+
import { DEFAULT_WORDING as xe, useWording as ee, useFormats as Se, useDensityFor as Be, Badge as P, Checkbox as qe, Button as R, Menu as Ee, MenuItem as $e, Popover as We, Tooltip as Ue, VisuallyHidden as Ce, ConfirmDialog as He, useFreshness as Ie, FormField as re, RadioGroup as Ne, Input as Ke } from "@umriss-ui/core";
|
|
6
|
+
import { tableModel as Ve, useTable as Ge } from "@umriss-ui/table";
|
|
7
|
+
const H = ["critical", "high", "medium", "low"], Ye = (e) => H.indexOf(e), de = (e) => e === "active-unacknowledged" || e === "active-acknowledged", ae = (e) => e === "active-acknowledged" || e === "resolved-acknowledged", Je = (e) => e === "resolved-acknowledged";
|
|
8
|
+
function Qe(e, a) {
|
|
9
|
+
switch (a) {
|
|
10
|
+
case "raised":
|
|
11
|
+
return "active-unacknowledged";
|
|
12
|
+
case "acknowledged":
|
|
13
|
+
return de(e) ? "active-acknowledged" : "resolved-acknowledged";
|
|
14
|
+
case "resolved":
|
|
15
|
+
return ae(e) ? "resolved-acknowledged" : "resolved-unacknowledged";
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const Xe = [
|
|
19
|
+
"in-service",
|
|
20
|
+
"snoozed",
|
|
21
|
+
"suppressed",
|
|
22
|
+
"disabled"
|
|
23
|
+
], Z = (e) => e !== "in-service";
|
|
24
|
+
function Ze(e, a) {
|
|
25
|
+
return e.availability === "snoozed" ? a >= e.snooze.until ? "in-service" : "snoozed" : e.availability ?? "in-service";
|
|
26
|
+
}
|
|
27
|
+
function ue(e, a) {
|
|
28
|
+
return e.availability === "snoozed" && a >= e.snooze.until && de(e.lifecycle) ? "active-unacknowledged" : e.lifecycle;
|
|
29
|
+
}
|
|
30
|
+
function Qa(e, a, t, r) {
|
|
31
|
+
return e.availability === "disabled" || e.availability === "suppressed" ? e : { ...e, availability: "snoozed", snooze: r === void 0 ? { until: a, by: t } : { until: a, by: t, reason: r } };
|
|
32
|
+
}
|
|
33
|
+
function Xa(e) {
|
|
34
|
+
return e.availability !== "snoozed" ? e : { ...e, availability: "in-service", snooze: void 0 };
|
|
35
|
+
}
|
|
36
|
+
function Za(e) {
|
|
37
|
+
return e.availability === "disabled" || e.availability === "suppressed" ? e : { ...e, availability: "disabled", snooze: void 0 };
|
|
38
|
+
}
|
|
39
|
+
function ja(e) {
|
|
40
|
+
return e.availability !== "disabled" ? e : { ...e, availability: "in-service" };
|
|
41
|
+
}
|
|
42
|
+
const en = (e, a) => e.direction === "upper" ? a <= e.returnTo : a >= e.returnTo, fe = (e, a, t) => e > t - a && e <= t, je = (e, a, t) => e.reduce((r, s) => r + (fe(s, a, t) ? 1 : 0), 0);
|
|
43
|
+
function ea(e, a, t) {
|
|
44
|
+
const r = /* @__PURE__ */ new Map();
|
|
45
|
+
for (const s of e)
|
|
46
|
+
fe(s.raised, a, t) && r.set(s.type, (r.get(s.type) ?? 0) + 1);
|
|
47
|
+
return r;
|
|
48
|
+
}
|
|
49
|
+
const me = 6e5, Fe = (e, a) => e.raised !== a.raised ? e.raised < a.raised : (e.sequence ?? 1 / 0) < (a.sequence ?? 1 / 0);
|
|
50
|
+
function aa(e) {
|
|
51
|
+
let a = e[0];
|
|
52
|
+
for (const t of e) Fe(t, a) && (a = t);
|
|
53
|
+
return a;
|
|
54
|
+
}
|
|
55
|
+
function na(e) {
|
|
56
|
+
let a = Number.POSITIVE_INFINITY;
|
|
57
|
+
for (const t of e) t < a && (a = t);
|
|
58
|
+
return a;
|
|
59
|
+
}
|
|
60
|
+
function la(e) {
|
|
61
|
+
let a = Number.NEGATIVE_INFINITY;
|
|
62
|
+
for (const t of e) t > a && (a = t);
|
|
63
|
+
return a;
|
|
64
|
+
}
|
|
65
|
+
function ta(e, a, t) {
|
|
66
|
+
const r = e.filter((o) => fe(o.raised, a.windowMs, t));
|
|
67
|
+
if (r.length < a.atLeast) return null;
|
|
68
|
+
const s = r.map((o) => o.raised);
|
|
69
|
+
return {
|
|
70
|
+
// No spread: a flood is the case with many elements, and an argument list
|
|
71
|
+
// of that size blows the call stack at some point. A loop cannot.
|
|
72
|
+
from: na(s),
|
|
73
|
+
to: la(s),
|
|
74
|
+
count: r.length,
|
|
75
|
+
alarms: r.map((o) => o.id),
|
|
76
|
+
first: aa(r).id
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
function X(e, a, t = Number.NEGATIVE_INFINITY) {
|
|
80
|
+
const r = new Set(a);
|
|
81
|
+
return e.reduce(
|
|
82
|
+
(s, o) => s + (r.has(o.id) && !ae(ue(o, t)) ? 1 : 0),
|
|
83
|
+
0
|
|
84
|
+
);
|
|
85
|
+
}
|
|
86
|
+
function an(e, a, t) {
|
|
87
|
+
const r = new Set(a);
|
|
88
|
+
let s = 0;
|
|
89
|
+
return { alarms: e.map((h) => {
|
|
90
|
+
const b = ue(h, t);
|
|
91
|
+
return !r.has(h.id) || ae(b) ? h : (s += 1, { ...h.availability === "snoozed" && t >= h.snooze.until ? { ...h, availability: "in-service", snooze: void 0 } : h, lifecycle: Qe(b, "acknowledged"), acknowledgedAt: t });
|
|
92
|
+
}), count: s };
|
|
93
|
+
}
|
|
94
|
+
const ia = (e) => [
|
|
95
|
+
{
|
|
96
|
+
id: "type",
|
|
97
|
+
label: e.alarmColumnAlarm,
|
|
98
|
+
value: (a) => a.type.label,
|
|
99
|
+
searchable: !0,
|
|
100
|
+
hideable: !1
|
|
101
|
+
},
|
|
102
|
+
{ id: "lifecycle", label: e.alarmColumnLifecycleState, value: (a) => a.lifecycle, searchable: !0 },
|
|
103
|
+
/* The rank, like the priority: the column exists for the first level of the
|
|
104
|
+
order. */
|
|
105
|
+
{ id: "availability", label: e.alarmColumnAvailability, value: (a) => Xe.indexOf(a.availability) },
|
|
106
|
+
{ id: "priority", label: e.alarmColumnPriority, value: (a) => a.rank },
|
|
107
|
+
/* A column of its own instead of a glance at the lifecycle state: the second
|
|
108
|
+
level of the order asks only about the acknowledgement and expressly not
|
|
109
|
+
about whether the alarm is still active. Otherwise the fleeting alarm
|
|
110
|
+
falls back down again. */
|
|
111
|
+
{ id: "acknowledgement", label: e.alarmColumnAcknowledgement, value: (a) => ae(a.lifecycle) ? 1 : 0 },
|
|
112
|
+
{ id: "raised", label: e.alarmColumnRaised, value: (a) => a.alarm.raised },
|
|
113
|
+
{ id: "age", label: e.alarmColumnAge, value: (a) => a.age },
|
|
114
|
+
{ id: "frequency", label: e.alarmColumnFrequency, value: (a) => a.frequency }
|
|
115
|
+
], ra = ia(xe), sa = [
|
|
116
|
+
{ column: "availability", direction: "asc" },
|
|
117
|
+
{ column: "priority", direction: "asc" },
|
|
118
|
+
{ column: "acknowledgement", direction: "asc" },
|
|
119
|
+
{ column: "raised", direction: "desc" }
|
|
120
|
+
], oa = (e) => ({
|
|
121
|
+
id: e,
|
|
122
|
+
label: e,
|
|
123
|
+
priority: "high"
|
|
124
|
+
});
|
|
125
|
+
function nn(e, a = {}) {
|
|
126
|
+
const {
|
|
127
|
+
alarms: t,
|
|
128
|
+
types: r,
|
|
129
|
+
asOf: s,
|
|
130
|
+
chatter: o,
|
|
131
|
+
flood: h,
|
|
132
|
+
keepDone: b = !1,
|
|
133
|
+
columns: c = ra
|
|
134
|
+
} = e, g = new Map(r.map((n) => [n.id, n])), _ = ea(t, o?.windowMs ?? 1 / 0, s), d = h ? ta(t, h, s) : null, N = new Set(d?.alarms ?? []), k = /* @__PURE__ */ new Map();
|
|
135
|
+
for (const n of t) {
|
|
136
|
+
if (n.group === void 0) continue;
|
|
137
|
+
const f = k.get(n.group);
|
|
138
|
+
(f === void 0 || Fe(n, f)) && k.set(n.group, n);
|
|
139
|
+
}
|
|
140
|
+
const O = t.filter((n) => b || !Je(n.lifecycle)).map((n) => {
|
|
141
|
+
const f = g.get(n.type) ?? oa(n.type), S = _.get(n.type) ?? 0;
|
|
142
|
+
return {
|
|
143
|
+
id: n.id,
|
|
144
|
+
alarm: n,
|
|
145
|
+
type: f,
|
|
146
|
+
lifecycle: ue(n, s),
|
|
147
|
+
availability: Ze(n, s),
|
|
148
|
+
priority: f.priority,
|
|
149
|
+
rank: Ye(f.priority),
|
|
150
|
+
age: s - n.raised,
|
|
151
|
+
duration: (n.resolved ?? s) - n.raised,
|
|
152
|
+
frequency: S,
|
|
153
|
+
chatters: o !== void 0 && S >= o.atLeast,
|
|
154
|
+
inFlood: N.has(n.id),
|
|
155
|
+
firstOut: n.group !== void 0 && k.get(n.group) === n
|
|
156
|
+
};
|
|
157
|
+
}), y = Ve(O, c, {
|
|
158
|
+
...a,
|
|
159
|
+
sort: a.sort === void 0 ? sa : a.sort
|
|
160
|
+
});
|
|
161
|
+
return {
|
|
162
|
+
...y,
|
|
163
|
+
flood: d,
|
|
164
|
+
rate: je(t.map((n) => n.raised), me, s),
|
|
165
|
+
activeUnacknowledged: y.filtered.reduce(
|
|
166
|
+
(n, f) => n + (f.lifecycle === "active-unacknowledged" && !Z(f.availability) ? 1 : 0),
|
|
167
|
+
0
|
|
168
|
+
),
|
|
169
|
+
unacknowledgedByPriority: y.filtered.reduce(
|
|
170
|
+
(n, f) => (f.lifecycle === "active-unacknowledged" && !Z(f.availability) && (n[f.priority] += 1), n),
|
|
171
|
+
{ critical: 0, high: 0, medium: 0, low: 0 }
|
|
172
|
+
),
|
|
173
|
+
hiddenAlarms: y.filtered.reduce(
|
|
174
|
+
(n, f) => n + (Z(f.availability) ? 1 : 0),
|
|
175
|
+
0
|
|
176
|
+
)
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
const ca = "_mark_1l90g_7", da = "_shape_1l90g_33 _text_18806_22", se = {
|
|
180
|
+
mark: ca,
|
|
181
|
+
shape: da
|
|
182
|
+
};
|
|
183
|
+
function j(e, a) {
|
|
184
|
+
return [a.alarmPriorityCritical, a.alarmPriorityHigh, a.alarmPriorityMedium, a.alarmPriorityLow][H.indexOf(e)];
|
|
185
|
+
}
|
|
186
|
+
function oe({ priority: e, lifecycle: a, availability: t = "in-service", className: r, ref: s, "aria-label": o, ...h }) {
|
|
187
|
+
const b = ee(), c = H.indexOf(e) + 1, g = t === "in-service";
|
|
188
|
+
return /* @__PURE__ */ i(
|
|
189
|
+
"span",
|
|
190
|
+
{
|
|
191
|
+
role: "img",
|
|
192
|
+
...h,
|
|
193
|
+
ref: s,
|
|
194
|
+
"aria-label": o ?? b.alarmPriorityName(c, j(e, b)),
|
|
195
|
+
className: r ? `${se.mark} ${r}` : se.mark,
|
|
196
|
+
"data-priority": e,
|
|
197
|
+
"data-neutral": g ? void 0 : "",
|
|
198
|
+
"data-flashing": g && a === "active-unacknowledged" ? "" : void 0,
|
|
199
|
+
children: /* @__PURE__ */ i("span", { className: se.shape, "aria-hidden": "true", children: c })
|
|
200
|
+
}
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
const ua = "_list_17n9u_4 _text_18806_22", fa = "_bar_17n9u_12", ma = "_heading_17n9u_19", ha = "_filler_17n9u_25", ya = "_asOf_17n9u_29", va = "_live_17n9u_46", ba = "_alarm_17n9u_54", pa = "_label_17n9u_59", ga = "_counter_17n9u_63", _a = "_state_17n9u_70", ka = "_lifecycle_17n9u_74", wa = "_hidden_17n9u_80", Na = "_hiddenLabel_17n9u_87", Aa = "_availability_17n9u_93", za = "_priority_17n9u_98", Sa = "_empty_17n9u_104", Ca = "_row_17n9u_112", Ia = "_snoozePanel_17n9u_132 _text_18806_22", Fa = "_snoozeForm_17n9u_143", u = {
|
|
204
|
+
list: ua,
|
|
205
|
+
bar: fa,
|
|
206
|
+
heading: ma,
|
|
207
|
+
filler: ha,
|
|
208
|
+
asOf: ya,
|
|
209
|
+
live: va,
|
|
210
|
+
alarm: ba,
|
|
211
|
+
label: pa,
|
|
212
|
+
counter: ga,
|
|
213
|
+
state: _a,
|
|
214
|
+
lifecycle: ka,
|
|
215
|
+
hidden: wa,
|
|
216
|
+
hiddenLabel: Na,
|
|
217
|
+
availability: Aa,
|
|
218
|
+
priority: za,
|
|
219
|
+
empty: Sa,
|
|
220
|
+
row: Ca,
|
|
221
|
+
snoozePanel: Ia,
|
|
222
|
+
snoozeForm: Fa
|
|
223
|
+
};
|
|
224
|
+
function La({
|
|
225
|
+
durations: e,
|
|
226
|
+
reasons: a,
|
|
227
|
+
required: t,
|
|
228
|
+
askReason: r,
|
|
229
|
+
onConfirm: s
|
|
230
|
+
}) {
|
|
231
|
+
const o = ee(), [h, b] = L(String(e[0])), [c, g] = L(""), [_, d] = L(null), N = U(null);
|
|
232
|
+
ze(() => N.current?.querySelector("input:checked")?.focus(), []);
|
|
233
|
+
const k = _ ?? c.trim(), O = t && k === "";
|
|
234
|
+
return /* @__PURE__ */ p(
|
|
235
|
+
"form",
|
|
236
|
+
{
|
|
237
|
+
className: u.snoozeForm,
|
|
238
|
+
onSubmit: (y) => {
|
|
239
|
+
y.preventDefault(), O || s(Number(h), k);
|
|
240
|
+
},
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ i(re, { label: o.alarmSnoozeDuration, children: /* @__PURE__ */ i(
|
|
243
|
+
Ne,
|
|
244
|
+
{
|
|
245
|
+
ref: N,
|
|
246
|
+
value: h,
|
|
247
|
+
onChange: b,
|
|
248
|
+
options: e.map((y) => ({ value: String(y), label: ce(y, o) }))
|
|
249
|
+
}
|
|
250
|
+
) }),
|
|
251
|
+
a.length > 0 && /* @__PURE__ */ i(re, { label: o.alarmSnoozeReason, required: t, children: /* @__PURE__ */ i(
|
|
252
|
+
Ne,
|
|
253
|
+
{
|
|
254
|
+
value: _,
|
|
255
|
+
onChange: (y) => {
|
|
256
|
+
d(y), g("");
|
|
257
|
+
},
|
|
258
|
+
options: a.map((y) => ({ value: y, label: y }))
|
|
259
|
+
}
|
|
260
|
+
) }),
|
|
261
|
+
r && /* @__PURE__ */ i(re, { label: a.length > 0 ? o.alarmSnoozeOtherReason : o.alarmSnoozeReason, required: t && a.length === 0, children: /* @__PURE__ */ i(
|
|
262
|
+
Ke,
|
|
263
|
+
{
|
|
264
|
+
value: c,
|
|
265
|
+
onChange: (y) => {
|
|
266
|
+
g(y.currentTarget.value), d(null);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
) }),
|
|
270
|
+
/* @__PURE__ */ i(R, { type: "submit", variant: "primary", size: "sm", disabled: O, children: o.alarmSnooze })
|
|
271
|
+
]
|
|
272
|
+
}
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
function Oa(e, a) {
|
|
276
|
+
switch (e) {
|
|
277
|
+
case "active-unacknowledged":
|
|
278
|
+
return a.alarmLifecycleActiveUnacknowledged;
|
|
279
|
+
case "active-acknowledged":
|
|
280
|
+
return a.alarmLifecycleActiveAcknowledged;
|
|
281
|
+
case "resolved-unacknowledged":
|
|
282
|
+
return a.alarmLifecycleResolvedUnacknowledged;
|
|
283
|
+
default:
|
|
284
|
+
return a.alarmLifecycleResolvedAcknowledged;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function Da(e, a, t) {
|
|
288
|
+
switch (e.availability) {
|
|
289
|
+
case "snoozed": {
|
|
290
|
+
const r = e.alarm.snooze;
|
|
291
|
+
if (!r) return null;
|
|
292
|
+
const s = new Date(r.until), o = new Date(e.alarm.raised + e.age), b = s.toDateString() === o.toDateString() ? t.time(s, !1) : t.dateTime(s, !1);
|
|
293
|
+
return { short: de(e.lifecycle) ? a.alarmAvailabilitySnoozedUntil(b) : a.alarmAvailabilitySnoozedShort, full: a.alarmAvailabilitySnoozed(b, r.by, r.reason?.trim() || void 0) };
|
|
294
|
+
}
|
|
295
|
+
case "suppressed":
|
|
296
|
+
return { short: a.alarmAvailabilitySuppressed, full: a.alarmAvailabilitySuppressed };
|
|
297
|
+
case "disabled":
|
|
298
|
+
return { short: a.alarmAvailabilityDisabled, full: a.alarmAvailabilityDisabled };
|
|
299
|
+
default:
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
function ce(e, a) {
|
|
304
|
+
const t = Math.max(0, Math.floor(e / 6e4)), r = Math.floor(t / 60), s = t % 60, o = [];
|
|
305
|
+
return r > 0 && o.push(a.hoursShort(r)), (r === 0 || s > 0) && o.push(a.minutesShort(s)), o.join(" ");
|
|
306
|
+
}
|
|
307
|
+
const Ma = 2e3;
|
|
308
|
+
function ln(e) {
|
|
309
|
+
const { asOf: a, freshness: t, ...r } = e;
|
|
310
|
+
return a === void 0 || t === void 0 ? /* @__PURE__ */ i(Le, { ...r, freshness: null }) : /* @__PURE__ */ i(Pa, { ...r, asOf: a, ages: t });
|
|
311
|
+
}
|
|
312
|
+
function Pa({
|
|
313
|
+
asOf: e,
|
|
314
|
+
ages: a,
|
|
315
|
+
...t
|
|
316
|
+
}) {
|
|
317
|
+
const r = Ie(e, a);
|
|
318
|
+
return /* @__PURE__ */ i(Le, { ...t, freshness: r });
|
|
319
|
+
}
|
|
320
|
+
function Le({
|
|
321
|
+
view: e,
|
|
322
|
+
selection: a,
|
|
323
|
+
onAcknowledge: t,
|
|
324
|
+
onSnooze: r,
|
|
325
|
+
snoozeDurations: s,
|
|
326
|
+
snoozeReason: o,
|
|
327
|
+
snoozeReasons: h,
|
|
328
|
+
onUnsnooze: b,
|
|
329
|
+
density: c,
|
|
330
|
+
maxHeight: g,
|
|
331
|
+
className: _,
|
|
332
|
+
freshness: d,
|
|
333
|
+
hiddenOnly: N = !1,
|
|
334
|
+
onHiddenOnlyChange: k,
|
|
335
|
+
onKeyDown: O,
|
|
336
|
+
...y
|
|
337
|
+
}) {
|
|
338
|
+
const n = ee(), f = Se(), S = d !== null, he = d?.freshness === "lost", [C, A] = L(null), { Table: K, Column: T } = Ge(e.visible, { rowKey: (l) => l.id, selection: a }), x = $(() => e.filtered.map((l) => l.alarm), [e.filtered]), D = $(() => a === void 0 ? [] : e.filtered.map((l) => l.id).filter((l) => a.selected.has(l)), [e.filtered, a]), V = e.filtered[0], w = V === void 0 ? 0 : V.alarm.raised + V.age, ne = $(() => X(x, D, w), [x, D, w]), ye = $(() => e.filtered.map((l) => l.id), [e.filtered]), De = $(() => X(x, ye, w), [x, ye, w]), ve = () => {
|
|
339
|
+
const l = D.length > 0;
|
|
340
|
+
let m = D;
|
|
341
|
+
if (!l) {
|
|
342
|
+
const z = te.current?.querySelector("table")?.parentElement?.getBoundingClientRect();
|
|
343
|
+
m = Array.from(te.current?.querySelectorAll("tr[data-alarm-id]") ?? []).filter((q) => {
|
|
344
|
+
const W = q.getBoundingClientRect();
|
|
345
|
+
return z !== void 0 && W.bottom > z.top && W.top < z.bottom && W.bottom > 0 && W.top < window.innerHeight;
|
|
346
|
+
}).map((q) => q.dataset.alarmId);
|
|
347
|
+
}
|
|
348
|
+
const v = X(x, m, w);
|
|
349
|
+
v > 0 && le({ ids: m, count: v, selected: l });
|
|
350
|
+
}, B = $(() => e.filtered.filter((l) => a?.selected.has(l.id)), [e.filtered, a]), I = (B.length > 0 || C === null ? B : e.filtered.filter((l) => l.id === C)).filter((l) => l.availability === "in-service" || l.availability === "snoozed"), G = B.filter((l) => l.availability === "snoozed"), Me = Be(c, "compact"), be = r !== void 0 && s !== void 0 && s.length > 0, pe = o !== void 0 || (h?.length ?? 0) > 0, ge = n.alarmHidden(e.hiddenAlarms), Y = U(null), [_e, J] = L(!1), [Pe, ke] = L(0), Q = U(null), [M, le] = L(null), te = U(null), [ie, Re] = L({ at: w, count: e.activeUnacknowledged });
|
|
351
|
+
ie.count !== e.activeUnacknowledged && (V === void 0 || w - ie.at >= Ma) && Re({ at: w, count: e.activeUnacknowledged });
|
|
352
|
+
const Te = (l) => {
|
|
353
|
+
if (O?.(l), l.defaultPrevented || l.ctrlKey || l.altKey || l.metaKey) return;
|
|
354
|
+
const m = l.target, v = m.closest("table tr[data-alarm-id]")?.dataset.alarmId;
|
|
355
|
+
if (v === void 0 || m.closest('input:not([type="checkbox"]), textarea, select, [contenteditable="true"]')) return;
|
|
356
|
+
const z = l.key.toLowerCase();
|
|
357
|
+
if (z === "a" && t !== void 0)
|
|
358
|
+
l.preventDefault(), l.shiftKey ? ve() : X(x, [v], w) > 0 && t([v]);
|
|
359
|
+
else if (z === "s" && !l.shiftKey && a !== void 0 && be) {
|
|
360
|
+
const q = e.filtered.find((E) => E.id === v);
|
|
361
|
+
if (!(B.length > 0 ? B : q === void 0 ? [] : [q]).some((E) => E.availability === "in-service" || E.availability === "snoozed")) return;
|
|
362
|
+
l.preventDefault(), Q.current = m.closest("td, th"), A(B.length > 0 ? null : v), ke((E) => E + 1), J(!0);
|
|
363
|
+
}
|
|
364
|
+
}, we = () => {
|
|
365
|
+
J(!1), A(null), Q.current?.focus();
|
|
366
|
+
};
|
|
367
|
+
return /* @__PURE__ */ p("div", { className: [u.list, _].filter(Boolean).join(" "), ...y, onKeyDown: Te, children: [
|
|
368
|
+
/* @__PURE__ */ p("div", { className: u.bar, children: [
|
|
369
|
+
/* @__PURE__ */ i("span", { className: u.heading, children: n.alarmList }),
|
|
370
|
+
e.flood !== null && /* @__PURE__ */ i(P, { tone: "warning", children: n.alarmFloodHint(e.rate, me / 6e4) }),
|
|
371
|
+
S && d !== null && /* @__PURE__ */ p("span", { className: u.asOf, "data-freshness": d.freshness, children: [
|
|
372
|
+
d.freshness === "lost" ? n.freshnessDisconnected : d.freshness === "stale" ? n.freshnessStale : n.freshnessFresh,
|
|
373
|
+
d.age !== null && ` · ${f.relative(d.age)}`
|
|
374
|
+
] }),
|
|
375
|
+
k !== void 0 && (e.hiddenAlarms > 0 || N) ? /* @__PURE__ */ i(
|
|
376
|
+
qe,
|
|
377
|
+
{
|
|
378
|
+
className: u.hidden,
|
|
379
|
+
checked: N,
|
|
380
|
+
onChange: (l) => k(l.currentTarget.checked),
|
|
381
|
+
label: /* @__PURE__ */ i("span", { className: u.hiddenLabel, children: ge })
|
|
382
|
+
}
|
|
383
|
+
) : e.hiddenAlarms > 0 && /* @__PURE__ */ i("span", { className: u.hidden, children: ge }),
|
|
384
|
+
/* @__PURE__ */ i("span", { className: u.filler }),
|
|
385
|
+
a !== void 0 && b !== void 0 && /* @__PURE__ */ i(R, { size: "sm", disabled: G.length === 0, onClick: () => b(G.map((l) => l.id)), children: G.length === 0 ? n.alarmUnsnooze : n.alarmUnsnoozeMany(G.length) }),
|
|
386
|
+
a !== void 0 && r !== void 0 && s !== void 0 && be && /* @__PURE__ */ p(Ae, { children: [
|
|
387
|
+
pe ? /* @__PURE__ */ i(
|
|
388
|
+
R,
|
|
389
|
+
{
|
|
390
|
+
ref: Y,
|
|
391
|
+
size: "sm",
|
|
392
|
+
disabled: I.length === 0,
|
|
393
|
+
"aria-haspopup": "dialog",
|
|
394
|
+
"aria-expanded": _e,
|
|
395
|
+
onClick: () => {
|
|
396
|
+
Q.current = Y.current, ke((l) => l + 1), J(!0);
|
|
397
|
+
},
|
|
398
|
+
children: I.length === 0 ? n.alarmSnooze : n.alarmSnoozeMany(I.length)
|
|
399
|
+
}
|
|
400
|
+
) : /* @__PURE__ */ i(
|
|
401
|
+
Ee,
|
|
402
|
+
{
|
|
403
|
+
align: "end",
|
|
404
|
+
trigger: /* @__PURE__ */ i(R, { ref: Y, size: "sm", disabled: I.length === 0, children: I.length === 0 ? n.alarmSnooze : n.alarmSnoozeMany(I.length) }),
|
|
405
|
+
children: s.map((l) => /* @__PURE__ */ i($e, { onSelect: () => r(I.map((m) => m.id), w + l), children: ce(l, n) }, l))
|
|
406
|
+
}
|
|
407
|
+
),
|
|
408
|
+
/* @__PURE__ */ i(
|
|
409
|
+
We,
|
|
410
|
+
{
|
|
411
|
+
open: _e,
|
|
412
|
+
onOpenChange: (l) => l ? J(!0) : we(),
|
|
413
|
+
anchorRef: Y,
|
|
414
|
+
focusRef: Q,
|
|
415
|
+
align: "end",
|
|
416
|
+
role: "dialog",
|
|
417
|
+
"aria-label": n.alarmSnoozeMany(I.length),
|
|
418
|
+
className: u.snoozePanel,
|
|
419
|
+
children: /* @__PURE__ */ i(
|
|
420
|
+
La,
|
|
421
|
+
{
|
|
422
|
+
durations: s,
|
|
423
|
+
reasons: h ?? [],
|
|
424
|
+
required: o === "required",
|
|
425
|
+
askReason: pe,
|
|
426
|
+
onConfirm: (l, m) => {
|
|
427
|
+
const v = I.map((z) => z.id);
|
|
428
|
+
we(), r(v, w + l, m === "" ? void 0 : m);
|
|
429
|
+
}
|
|
430
|
+
},
|
|
431
|
+
Pe
|
|
432
|
+
)
|
|
433
|
+
}
|
|
434
|
+
)
|
|
435
|
+
] }),
|
|
436
|
+
a !== void 0 && t !== void 0 && /* @__PURE__ */ i(
|
|
437
|
+
R,
|
|
438
|
+
{
|
|
439
|
+
variant: "primary",
|
|
440
|
+
size: "sm",
|
|
441
|
+
disabled: D.length > 0 ? ne === 0 : De === 0,
|
|
442
|
+
onClick: () => D.length > 0 ? t(D) : ve(),
|
|
443
|
+
children: ne === 0 ? n.alarmAcknowledge : n.alarmAcknowledgeMany(ne)
|
|
444
|
+
}
|
|
445
|
+
)
|
|
446
|
+
] }),
|
|
447
|
+
/* @__PURE__ */ i("div", { "aria-live": "polite", "aria-atomic": "true", className: u.live, children: n.alarmActiveUnacknowledged(ie.count) }),
|
|
448
|
+
/* @__PURE__ */ i("div", { ref: te, children: /* @__PURE__ */ p(
|
|
449
|
+
K,
|
|
450
|
+
{
|
|
451
|
+
grid: !0,
|
|
452
|
+
"aria-label": n.alarmList,
|
|
453
|
+
selectable: a !== void 0,
|
|
454
|
+
density: Me,
|
|
455
|
+
maxHeight: g,
|
|
456
|
+
stickyHeader: !0,
|
|
457
|
+
rowProps: (l) => ({
|
|
458
|
+
className: u.row,
|
|
459
|
+
"data-alarm-id": l.id,
|
|
460
|
+
"data-lifecycle": l.lifecycle,
|
|
461
|
+
"data-priority": l.priority,
|
|
462
|
+
"data-availability": l.availability
|
|
463
|
+
}),
|
|
464
|
+
empty: /* @__PURE__ */ i("span", { className: u.empty, children: he ? n.alarmNoneDisconnected : n.alarmNone }),
|
|
465
|
+
children: [
|
|
466
|
+
/* @__PURE__ */ i(T, { id: "type", label: n.alarmColumnAlarm, value: (l) => l.type.label, rowHeader: !0, sortable: !1, children: (l, m) => /* @__PURE__ */ p("span", { className: u.alarm, children: [
|
|
467
|
+
/* @__PURE__ */ i("span", { className: u.label, children: l }),
|
|
468
|
+
m.firstOut && /* @__PURE__ */ i(P, { className: u.counter, children: n.alarmFirstOut }),
|
|
469
|
+
e.flood?.first === m.id && /* @__PURE__ */ i(P, { className: u.counter, children: n.alarmFirstInFlood }),
|
|
470
|
+
m.chatters && /* @__PURE__ */ i(P, { tone: "warning", pill: !0, className: u.counter, children: n.alarmChatterHint(m.frequency) })
|
|
471
|
+
] }) }),
|
|
472
|
+
/* @__PURE__ */ i(T, { value: "lifecycle", label: n.alarmColumnLifecycleState, sortable: !1, children: (l, m) => {
|
|
473
|
+
const v = Da(m, n, f), z = v === null ? null : v.short === v.full ? /* @__PURE__ */ i(P, { className: u.availability, children: v.short }) : /* @__PURE__ */ i(Ue, { content: v.full, children: /* @__PURE__ */ p(P, { className: u.availability, children: [
|
|
474
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", children: v.short }),
|
|
475
|
+
/* @__PURE__ */ i(Ce, { children: v.full })
|
|
476
|
+
] }) });
|
|
477
|
+
return /* @__PURE__ */ p("span", { className: u.state, children: [
|
|
478
|
+
z,
|
|
479
|
+
/* @__PURE__ */ i("span", { className: u.lifecycle, children: Oa(l, n) })
|
|
480
|
+
] });
|
|
481
|
+
} }),
|
|
482
|
+
/* @__PURE__ */ i(T, { value: "priority", label: n.alarmColumnPriority, sortable: !1, children: (l, m) => /* @__PURE__ */ p("span", { className: u.priority, children: [
|
|
483
|
+
/* @__PURE__ */ i(oe, { priority: l, lifecycle: m.lifecycle, availability: m.availability }),
|
|
484
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", children: j(l, n) })
|
|
485
|
+
] }) }),
|
|
486
|
+
/* @__PURE__ */ i(
|
|
487
|
+
T,
|
|
488
|
+
{
|
|
489
|
+
id: "raised",
|
|
490
|
+
label: n.alarmColumnRaised,
|
|
491
|
+
value: (l) => new Date(l.alarm.raised),
|
|
492
|
+
format: "dateTimeWithSeconds",
|
|
493
|
+
numeric: !0,
|
|
494
|
+
sortable: !1
|
|
495
|
+
}
|
|
496
|
+
),
|
|
497
|
+
/* @__PURE__ */ i(T, { value: "duration", label: n.alarmColumnDuration, sortable: !1, children: (l) => /* @__PURE__ */ i("span", { className: u.state, children: ce(l, n) }) }),
|
|
498
|
+
/* @__PURE__ */ i(T, { value: "frequency", label: n.alarmColumnFrequency, format: "count", sortable: !1 })
|
|
499
|
+
]
|
|
500
|
+
}
|
|
501
|
+
) }),
|
|
502
|
+
/* @__PURE__ */ i(
|
|
503
|
+
He,
|
|
504
|
+
{
|
|
505
|
+
open: M !== null,
|
|
506
|
+
onClose: () => le(null),
|
|
507
|
+
onConfirm: () => {
|
|
508
|
+
M !== null && t?.(M.ids), le(null);
|
|
509
|
+
},
|
|
510
|
+
title: M === null ? "" : M.selected ? n.alarmAcknowledgeSelected(M.count) : n.alarmAcknowledgeInView(M.count),
|
|
511
|
+
confirmLabel: n.alarmAcknowledgeConfirm,
|
|
512
|
+
cancelLabel: n.alarmAcknowledgeCancel
|
|
513
|
+
}
|
|
514
|
+
)
|
|
515
|
+
] });
|
|
516
|
+
}
|
|
517
|
+
const Ra = "_banner_13ro2_4 _text_18806_22", Ta = "_worst_13ro2_18", xa = "_time_13ro2_25", Ba = "_more_13ro2_26", qa = "_asOf_13ro2_27", Ea = "_counts_13ro2_41", $a = "_count_13ro2_41", Wa = "_none_13ro2_55", F = {
|
|
518
|
+
banner: Ra,
|
|
519
|
+
worst: Ta,
|
|
520
|
+
time: xa,
|
|
521
|
+
more: Ba,
|
|
522
|
+
asOf: qa,
|
|
523
|
+
counts: Ea,
|
|
524
|
+
count: $a,
|
|
525
|
+
none: Wa
|
|
526
|
+
}, Ua = (e) => e.lifecycle === "active-unacknowledged" && !Z(e.availability);
|
|
527
|
+
function tn({ asOf: e, freshness: a, ...t }) {
|
|
528
|
+
return e === void 0 || a === void 0 ? /* @__PURE__ */ i(Oe, { ...t, reading: null }) : /* @__PURE__ */ i(Ha, { ...t, asOf: e, ages: a });
|
|
529
|
+
}
|
|
530
|
+
function Ha({ asOf: e, ages: a, ...t }) {
|
|
531
|
+
return /* @__PURE__ */ i(Oe, { ...t, reading: Ie(e, a) });
|
|
532
|
+
}
|
|
533
|
+
function Oe({
|
|
534
|
+
view: e,
|
|
535
|
+
onAcknowledge: a,
|
|
536
|
+
onOpen: t,
|
|
537
|
+
onAnnunciate: r,
|
|
538
|
+
reading: s,
|
|
539
|
+
className: o,
|
|
540
|
+
ref: h,
|
|
541
|
+
...b
|
|
542
|
+
}) {
|
|
543
|
+
const c = ee(), g = Se(), _ = e.filtered.filter(Ua), d = _.reduce((n, f) => n === void 0 || f.rank < n.rank ? f : n, void 0), N = s?.freshness === "lost", k = U(null), [O, y] = L("");
|
|
544
|
+
return ze(() => {
|
|
545
|
+
const n = new Set(_.map((A) => A.id)), f = d?.rank ?? 1 / 0, S = k.current;
|
|
546
|
+
if (k.current = { ids: n, rank: f }, S === null) return;
|
|
547
|
+
const C = _.filter((A) => !S.ids.has(A.id)).reduce((A, K) => A === void 0 || K.rank < A.rank ? K : A, void 0);
|
|
548
|
+
C !== void 0 ? (r?.({ kind: "new", priority: C.priority }), C.rank < S.rank && y(`${c.alarmBannerAlert(j(C.priority, c).toLowerCase(), C.type.label)} ${g.time(new Date(C.alarm.raised), !0)}`)) : S.ids.size > 0 && n.size === 0 && r?.({ kind: "cleared" });
|
|
549
|
+
}, [e]), /* @__PURE__ */ p("section", { "aria-label": c.alarmBanner, ...b, ref: h, className: o ? `${F.banner} ${o}` : F.banner, children: [
|
|
550
|
+
d === void 0 ? /* @__PURE__ */ i("span", { className: F.none, "data-lost": N ? "" : void 0, children: N ? c.alarmBannerDisconnected : c.alarmBannerNone }) : /* @__PURE__ */ p(Ae, { children: [
|
|
551
|
+
/* @__PURE__ */ p("span", { className: F.worst, children: [
|
|
552
|
+
/* @__PURE__ */ i(oe, { priority: d.priority, lifecycle: d.lifecycle, availability: d.availability }),
|
|
553
|
+
/* @__PURE__ */ i("span", { children: d.type.label }),
|
|
554
|
+
/* @__PURE__ */ i("span", { className: F.time, children: g.time(new Date(d.alarm.raised), !0) })
|
|
555
|
+
] }),
|
|
556
|
+
_.length > 1 && /* @__PURE__ */ i("span", { className: F.more, children: c.alarmBannerMore(_.length - 1) }),
|
|
557
|
+
/* @__PURE__ */ i("span", { className: F.counts, children: H.filter((n) => e.unacknowledgedByPriority[n] > 0).map((n) => /* @__PURE__ */ p("span", { role: "group", className: F.count, "aria-label": `${c.alarmPriorityName(H.indexOf(n) + 1, j(n, c))}: ${e.unacknowledgedByPriority[n]}`, children: [
|
|
558
|
+
/* @__PURE__ */ i(oe, { priority: n, lifecycle: "active-unacknowledged", "aria-hidden": "true", role: "presentation" }),
|
|
559
|
+
/* @__PURE__ */ i("span", { "aria-hidden": "true", children: e.unacknowledgedByPriority[n] })
|
|
560
|
+
] }, n)) })
|
|
561
|
+
] }),
|
|
562
|
+
e.flood !== null && /* @__PURE__ */ i(P, { tone: "warning", children: c.alarmFloodHint(e.rate, me / 6e4) }),
|
|
563
|
+
s !== null && /* @__PURE__ */ p("span", { className: F.asOf, "data-freshness": s.freshness, children: [
|
|
564
|
+
s.freshness === "lost" ? c.freshnessDisconnected : s.freshness === "stale" ? c.freshnessStale : c.freshnessFresh,
|
|
565
|
+
s.age !== null && ` · ${g.relative(s.age)}`
|
|
566
|
+
] }),
|
|
567
|
+
d !== void 0 && a !== void 0 && /* @__PURE__ */ i(R, { size: "sm", onClick: () => a([d.id]), children: c.alarmAcknowledge }),
|
|
568
|
+
t !== void 0 && /* @__PURE__ */ i(R, { size: "sm", variant: "ghost", onClick: t, children: c.alarmBannerOpen }),
|
|
569
|
+
/* @__PURE__ */ i(Ce, { role: "alert", children: O })
|
|
570
|
+
] });
|
|
571
|
+
}
|
|
572
|
+
export {
|
|
573
|
+
ra as ALARM_COLUMNS,
|
|
574
|
+
Xe as AVAILABILITIES,
|
|
575
|
+
tn as AlarmBanner,
|
|
576
|
+
ln as AlarmList,
|
|
577
|
+
sa as DEFAULT_ORDER,
|
|
578
|
+
H as PRIORITIES,
|
|
579
|
+
oe as PriorityMark,
|
|
580
|
+
an as acknowledge,
|
|
581
|
+
ia as alarmColumns,
|
|
582
|
+
nn as alarmModel,
|
|
583
|
+
Ze as availabilityAt,
|
|
584
|
+
X as countAcknowledgeable,
|
|
585
|
+
je as countInWindow,
|
|
586
|
+
ta as detectFlood,
|
|
587
|
+
Za as disable,
|
|
588
|
+
ja as enable,
|
|
589
|
+
ea as frequencyByType,
|
|
590
|
+
en as hasReturned,
|
|
591
|
+
ae as isAcknowledged,
|
|
592
|
+
de as isActive,
|
|
593
|
+
Je as isDone,
|
|
594
|
+
Z as isHidden,
|
|
595
|
+
Qe as nextLifecycleState,
|
|
596
|
+
Ye as priorityRank,
|
|
597
|
+
Qa as snooze,
|
|
598
|
+
Xa as unsnooze
|
|
599
|
+
};
|