@lilt-ui/charts 0.12.1 → 0.13.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 +20 -0
- package/README.md +0 -45
- package/dist/cards/arc-bridges-card.d.ts +17 -0
- package/dist/cards/area-chart-card.d.ts +1 -10
- package/dist/cards/block-city-card.d.ts +21 -0
- package/dist/cards/calendar-heatmap-card.d.ts +31 -1
- package/dist/cards/cartesian-card.d.ts +8 -26
- package/dist/cards/chart-card.d.ts +1 -12
- package/dist/cards/chord-loom-card.d.ts +17 -0
- package/dist/cards/circle-archipelago-card.d.ts +9 -0
- package/dist/cards/cluster-constellation-card.d.ts +16 -0
- package/dist/cards/comparison-forms.d.ts +30 -0
- package/dist/cards/composition-forms.d.ts +10 -0
- package/dist/cards/contour-islands-card.d.ts +25 -0
- package/dist/cards/density-contours.d.ts +3 -0
- package/dist/cards/distribution-forms.d.ts +37 -0
- package/dist/cards/event-helix-card.d.ts +26 -0
- package/dist/cards/helix-ribbons-card.d.ts +14 -0
- package/dist/cards/hex-city-card.d.ts +25 -0
- package/dist/cards/hierarchy-layouts.d.ts +21 -0
- package/dist/cards/horizon-folds-card.d.ts +10 -0
- package/dist/cards/horizontal-bar-chart-card.d.ts +1 -1
- package/dist/cards/intersection-towers-card.d.ts +9 -0
- package/dist/cards/line-chart-card.d.ts +4 -11
- package/dist/cards/link-readings.d.ts +26 -0
- package/dist/cards/marimekko-blocks-card.d.ts +10 -0
- package/dist/cards/observations-card.d.ts +45 -2
- package/dist/cards/parallel-ribbons-card.d.ts +27 -0
- package/dist/cards/prism-grid.d.ts +58 -0
- package/dist/cards/prism.d.ts +42 -0
- package/dist/cards/progress-forms.d.ts +21 -0
- package/dist/cards/rank-ribbons-card.d.ts +22 -0
- package/dist/cards/ridgeline-card.d.ts +24 -0
- package/dist/cards/scatter-chart-card.d.ts +19 -1
- package/dist/cards/sculpted-geometry.d.ts +18 -0
- package/dist/cards/skyline-card.d.ts +12 -0
- package/dist/cards/spatial-composition-layouts.d.ts +14 -0
- package/dist/cards/spatial-geometry.d.ts +34 -0
- package/dist/cards/spatial-hierarchy.d.ts +10 -0
- package/dist/cards/spatial-point-layouts.d.ts +16 -0
- package/dist/cards/spatial-series-layouts.d.ts +12 -0
- package/dist/cards/spiral-year-card.d.ts +17 -0
- package/dist/cards/sunburst-terraces-card.d.ts +10 -0
- package/dist/cards/ternary-prism-card.d.ts +13 -0
- package/dist/cards/terrain-card.d.ts +21 -0
- package/dist/cards/treemap-chart-card.d.ts +3 -1
- package/dist/cards/trend-forms.d.ts +11 -0
- package/dist/cards/voxel-cloud-card.d.ts +16 -0
- package/dist/cards/voxel-waffle-card.d.ts +18 -0
- package/dist/cards/wind-rose-card.d.ts +11 -0
- package/dist/engine/domains.d.ts +0 -1
- package/dist/finance.js +310 -311
- package/dist/index.d.ts +39 -4
- package/dist/index.js +8919 -2948
- package/dist/interaction/comparison-layer.d.ts +3 -1
- package/dist/{skeleton-block-ClcPgFdK.js → skeleton-block-BPoUJvcR.js} +3689 -2959
- package/dist/styles.css +1 -1
- package/package.json +1 -6
- package/dist/report-context-DLA3I57K.js +0 -1100
- package/dist/watch/board/board-state.d.ts +0 -72
- package/dist/watch/board/board-toast.d.ts +0 -19
- package/dist/watch/board/chart-board.d.ts +0 -93
- package/dist/watch/board/report-context.d.ts +0 -3
- package/dist/watch/engine/describe.d.ts +0 -9
- package/dist/watch/engine/explain.d.ts +0 -48
- package/dist/watch/engine/normal.d.ts +0 -114
- package/dist/watch/engine/robust.d.ts +0 -7
- package/dist/watch/engine/rules.d.ts +0 -22
- package/dist/watch/engine/status.d.ts +0 -39
- package/dist/watch/index.d.ts +0 -14
- package/dist/watch/normal-layer.d.ts +0 -18
- package/dist/watch.d.ts +0 -2
- package/dist/watch.js +0 -636
package/dist/watch.js
DELETED
|
@@ -1,636 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { C as e, a as t, b as n, i as r, l as i, n as a, o, r as s, s as c, t as l, w as u } from "./report-context-DLA3I57K.js";
|
|
3
|
-
import { Children as d, createContext as f, isValidElement as ee, useCallback as p, useContext as m, useEffect as h, useMemo as g, useReducer as te, useRef as _, useState as v } from "react";
|
|
4
|
-
import { AnimatePresence as y, m as b } from "motion/react";
|
|
5
|
-
import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
6
|
-
import { createPortal as w } from "react-dom";
|
|
7
|
-
//#region src/watch/engine/rules.ts
|
|
8
|
-
function T({ points: e = 6, severity: t = "warning", message: n = "Value has not changed" } = {}) {
|
|
9
|
-
return {
|
|
10
|
-
severity: t,
|
|
11
|
-
message: n,
|
|
12
|
-
test: (t, { index: n, values: r }) => {
|
|
13
|
-
if (n + 1 < e) return !1;
|
|
14
|
-
let i = r[n];
|
|
15
|
-
if (i == null) return !1;
|
|
16
|
-
for (let t = 1; t < e; t += 1) if (r[n - t] !== i) return !1;
|
|
17
|
-
return !0;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function E({ by: e, direction: t = "both", severity: n = "warning", message: r }) {
|
|
22
|
-
return {
|
|
23
|
-
severity: n,
|
|
24
|
-
message: r ?? (t === "down" ? "Sudden drop" : t === "up" ? "Sudden rise" : "Sudden change"),
|
|
25
|
-
test: (n, { index: r, values: i }) => {
|
|
26
|
-
let a = i[r];
|
|
27
|
-
if (a == null) return !1;
|
|
28
|
-
let o = null;
|
|
29
|
-
for (let e = r - 1; e >= 0; --e) {
|
|
30
|
-
let t = i[e];
|
|
31
|
-
if (t != null) {
|
|
32
|
-
o = t;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
if (o === null || o === 0) return !1;
|
|
37
|
-
let s = (a - o) / Math.abs(o);
|
|
38
|
-
return t === "up" ? s >= e : t === "down" ? s <= -e : Math.abs(s) >= e;
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
//#endregion
|
|
43
|
-
//#region src/watch/board/board-state.ts
|
|
44
|
-
var D = (e, t) => ({
|
|
45
|
-
id: e,
|
|
46
|
-
order: t,
|
|
47
|
-
alarm: "normal",
|
|
48
|
-
pinned: !1,
|
|
49
|
-
severity: null,
|
|
50
|
-
reason: null,
|
|
51
|
-
why: null,
|
|
52
|
-
since: null,
|
|
53
|
-
sinceAt: null,
|
|
54
|
-
score: 0,
|
|
55
|
-
raisedAt: null,
|
|
56
|
-
acknowledgedAt: null,
|
|
57
|
-
clearedAt: null
|
|
58
|
-
});
|
|
59
|
-
function O(e, t) {
|
|
60
|
-
if (t.type === "register") {
|
|
61
|
-
let n = e[t.id];
|
|
62
|
-
return n?.order === t.order ? e : {
|
|
63
|
-
...e,
|
|
64
|
-
[t.id]: {
|
|
65
|
-
...n ?? D(t.id, t.order),
|
|
66
|
-
order: t.order
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
if (t.type === "unregister") {
|
|
71
|
-
if (!e[t.id]) return e;
|
|
72
|
-
let n = { ...e };
|
|
73
|
-
return delete n[t.id], n;
|
|
74
|
-
}
|
|
75
|
-
let n = e[t.id];
|
|
76
|
-
if (!n) return e;
|
|
77
|
-
let r = k(n, t);
|
|
78
|
-
return r === n ? e : {
|
|
79
|
-
...e,
|
|
80
|
-
[t.id]: r
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
function k(e, t) {
|
|
84
|
-
switch (t.type) {
|
|
85
|
-
case "report": {
|
|
86
|
-
let { report: n, now: r } = t;
|
|
87
|
-
if (n?.active) {
|
|
88
|
-
let t = {
|
|
89
|
-
reason: n.reason,
|
|
90
|
-
why: n.why,
|
|
91
|
-
since: n.since,
|
|
92
|
-
sinceAt: n.sinceAt,
|
|
93
|
-
score: n.score
|
|
94
|
-
};
|
|
95
|
-
if (e.alarm === "normal" || e.alarm === "cleared") return {
|
|
96
|
-
...e,
|
|
97
|
-
...t,
|
|
98
|
-
alarm: "active",
|
|
99
|
-
severity: n.severity,
|
|
100
|
-
raisedAt: r,
|
|
101
|
-
acknowledgedAt: null,
|
|
102
|
-
clearedAt: null
|
|
103
|
-
};
|
|
104
|
-
let i = e.severity === "warning" && n.severity === "critical";
|
|
105
|
-
return {
|
|
106
|
-
...e,
|
|
107
|
-
...t,
|
|
108
|
-
severity: i ? "critical" : e.severity,
|
|
109
|
-
alarm: i ? "active" : e.alarm,
|
|
110
|
-
acknowledgedAt: i ? null : e.acknowledgedAt
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
return e.alarm === "active" || e.alarm === "acknowledged" ? {
|
|
114
|
-
...e,
|
|
115
|
-
alarm: "cleared",
|
|
116
|
-
clearedAt: r
|
|
117
|
-
} : e;
|
|
118
|
-
}
|
|
119
|
-
case "acknowledge": return e.alarm === "active" ? {
|
|
120
|
-
...e,
|
|
121
|
-
alarm: "acknowledged",
|
|
122
|
-
acknowledgedAt: t.now
|
|
123
|
-
} : e;
|
|
124
|
-
case "pin": return e.pinned === t.pinned ? e : {
|
|
125
|
-
...e,
|
|
126
|
-
pinned: t.pinned
|
|
127
|
-
};
|
|
128
|
-
case "settle": return e.alarm === "cleared" ? {
|
|
129
|
-
...D(e.id, e.order),
|
|
130
|
-
pinned: e.pinned
|
|
131
|
-
} : e;
|
|
132
|
-
default: return e;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
var A = {
|
|
136
|
-
active: 1,
|
|
137
|
-
acknowledged: 2,
|
|
138
|
-
cleared: 3,
|
|
139
|
-
normal: 4
|
|
140
|
-
}, j = (e) => e === "critical" ? 0 : 1;
|
|
141
|
-
function M(e) {
|
|
142
|
-
return Object.values(e).sort((e, t) => {
|
|
143
|
-
let n = e.pinned ? 0 : A[e.alarm], r = t.pinned ? 0 : A[t.alarm];
|
|
144
|
-
if (n !== r) return n - r;
|
|
145
|
-
if (n === 1 || n === 2) {
|
|
146
|
-
let n = j(e.severity) - j(t.severity);
|
|
147
|
-
if (n !== 0) return n;
|
|
148
|
-
let r = N(e) - N(t);
|
|
149
|
-
if (r !== 0) return r;
|
|
150
|
-
if (e.score !== t.score) return t.score - e.score;
|
|
151
|
-
}
|
|
152
|
-
return e.order - t.order;
|
|
153
|
-
}).map((e) => e.id);
|
|
154
|
-
}
|
|
155
|
-
var N = (e) => e.sinceAt ?? e.raisedAt ?? Infinity, P = 8e3;
|
|
156
|
-
function ne({ alerts: e, reducedMotion: t, onView: n, onDismiss: r }) {
|
|
157
|
-
let [i, a] = v(null);
|
|
158
|
-
h(() => a(document.body), []);
|
|
159
|
-
let [o, s] = v(!1), c = e.some((e) => e.severity === "critical"), l = e.map((e) => `${e.id}:${e.severity}`).join(), u = _(r);
|
|
160
|
-
if (u.current = r, h(() => {
|
|
161
|
-
if (!e.length || c || o) return;
|
|
162
|
-
let t = setTimeout(() => u.current(), P);
|
|
163
|
-
return () => clearTimeout(t);
|
|
164
|
-
}, [
|
|
165
|
-
l,
|
|
166
|
-
c,
|
|
167
|
-
o
|
|
168
|
-
]), !i) return null;
|
|
169
|
-
let d = e[0], f = t ? { opacity: 0 } : {
|
|
170
|
-
opacity: 0,
|
|
171
|
-
y: 16,
|
|
172
|
-
filter: "blur(6px)"
|
|
173
|
-
};
|
|
174
|
-
return w(/* @__PURE__ */ S("div", {
|
|
175
|
-
"data-lilt-chart": "",
|
|
176
|
-
className: "lilt-toast-region",
|
|
177
|
-
children: /* @__PURE__ */ S(y, { children: d ? /* @__PURE__ */ C(b.div, {
|
|
178
|
-
role: "group",
|
|
179
|
-
"aria-label": "Chart alert",
|
|
180
|
-
className: "lilt-toast",
|
|
181
|
-
"data-severity": c ? "critical" : "warning",
|
|
182
|
-
initial: f,
|
|
183
|
-
animate: {
|
|
184
|
-
opacity: 1,
|
|
185
|
-
y: 0,
|
|
186
|
-
filter: "blur(0px)"
|
|
187
|
-
},
|
|
188
|
-
exit: f,
|
|
189
|
-
transition: t ? { duration: 0 } : {
|
|
190
|
-
type: "spring",
|
|
191
|
-
stiffness: 420,
|
|
192
|
-
damping: 34
|
|
193
|
-
},
|
|
194
|
-
onPointerEnter: () => s(!0),
|
|
195
|
-
onPointerLeave: () => s(!1),
|
|
196
|
-
onFocus: () => s(!0),
|
|
197
|
-
onBlur: (e) => {
|
|
198
|
-
e.currentTarget.contains(e.relatedTarget) || s(!1);
|
|
199
|
-
},
|
|
200
|
-
children: [
|
|
201
|
-
/* @__PURE__ */ S("span", {
|
|
202
|
-
className: "lilt-toast__text",
|
|
203
|
-
children: e.length === 1 ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S("strong", { children: d.title }), d.reason ? /* @__PURE__ */ S("span", {
|
|
204
|
-
className: "lilt-toast__reason",
|
|
205
|
-
children: d.reason
|
|
206
|
-
}) : null] }) : /* @__PURE__ */ C("strong", { children: [e.length, " charts need attention"] })
|
|
207
|
-
}),
|
|
208
|
-
/* @__PURE__ */ S("button", {
|
|
209
|
-
type: "button",
|
|
210
|
-
className: "lilt-toast__view",
|
|
211
|
-
onClick: n,
|
|
212
|
-
children: "View"
|
|
213
|
-
}),
|
|
214
|
-
/* @__PURE__ */ S("button", {
|
|
215
|
-
type: "button",
|
|
216
|
-
className: "lilt-card-badge__clear",
|
|
217
|
-
"aria-label": "Dismiss",
|
|
218
|
-
onClick: r,
|
|
219
|
-
children: /* @__PURE__ */ S("svg", {
|
|
220
|
-
"aria-hidden": "true",
|
|
221
|
-
viewBox: "0 0 16 16",
|
|
222
|
-
fill: "none",
|
|
223
|
-
children: /* @__PURE__ */ S("path", {
|
|
224
|
-
d: "m4 4 8 8M12 4l-8 8",
|
|
225
|
-
stroke: "currentColor",
|
|
226
|
-
strokeWidth: "1.5",
|
|
227
|
-
strokeLinecap: "round"
|
|
228
|
-
})
|
|
229
|
-
})
|
|
230
|
-
})
|
|
231
|
-
]
|
|
232
|
-
}, "toast") : null })
|
|
233
|
-
}), i);
|
|
234
|
-
}
|
|
235
|
-
//#endregion
|
|
236
|
-
//#region src/watch/board/chart-board.tsx
|
|
237
|
-
function re({ children: e }) {
|
|
238
|
-
return /* @__PURE__ */ S(x, { children: e });
|
|
239
|
-
}
|
|
240
|
-
var ie = f(null), ae = f(null);
|
|
241
|
-
function F() {
|
|
242
|
-
let e = m(ie);
|
|
243
|
-
if (!e) throw Error("Lilt Charts: useBoard must be used inside a ChartBoard.");
|
|
244
|
-
let t = Object.values(e.state);
|
|
245
|
-
return {
|
|
246
|
-
items: t,
|
|
247
|
-
attention: t.filter((e) => e.alarm === "active"),
|
|
248
|
-
fresh: t.filter((t) => e.fresh.has(t.id)),
|
|
249
|
-
pending: e.pending,
|
|
250
|
-
apply: e.apply,
|
|
251
|
-
acknowledge: e.acknowledge,
|
|
252
|
-
pin: e.pin
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
function I() {
|
|
256
|
-
let e = m(ie), t = m(ae);
|
|
257
|
-
if (!e || !t) throw Error("Lilt Charts: useBoardItem must be used inside a BoardItem.");
|
|
258
|
-
return {
|
|
259
|
-
item: e.state[t],
|
|
260
|
-
title: e.titles.get(t) ?? t,
|
|
261
|
-
fresh: e.fresh.has(t),
|
|
262
|
-
acknowledge: () => e.acknowledge(t),
|
|
263
|
-
pin: (n) => e.pin(t, n)
|
|
264
|
-
};
|
|
265
|
-
}
|
|
266
|
-
var oe = 500;
|
|
267
|
-
function L({ children: t, "aria-label": n, settleAfter: r = 8e3, memory: i, storage: a, onEvent: o, toast: s = !1, toolbar: c = !0, status: l = !0, motion: u = "auto", className: f, style: m }) {
|
|
268
|
-
let y = g(() => d.toArray(t).flatMap((e) => ee(e) && e.type === re ? [e.props] : []), [t]), x = g(() => new Map(y.map((e) => [e.id, e.title])), [y]), [w, T] = te(O, y, (e) => e.reduce((e, t, n) => O(e, {
|
|
269
|
-
type: "register",
|
|
270
|
-
id: t.id,
|
|
271
|
-
order: n
|
|
272
|
-
}), {})), E = y.map((e) => e.id).join("\0");
|
|
273
|
-
h(() => {
|
|
274
|
-
let e = new Set(y.map((e) => e.id));
|
|
275
|
-
y.forEach((e, t) => T({
|
|
276
|
-
type: "register",
|
|
277
|
-
id: e.id,
|
|
278
|
-
order: t
|
|
279
|
-
}));
|
|
280
|
-
for (let t of Object.keys(w)) e.has(t) || T({
|
|
281
|
-
type: "unregister",
|
|
282
|
-
id: t
|
|
283
|
-
});
|
|
284
|
-
}, [E]);
|
|
285
|
-
let D = M(w), k = D.join("\0"), [A, j] = v(D), [N, P] = v(!1), F = _(void 0), I = () => {
|
|
286
|
-
clearTimeout(F.current), P(!0);
|
|
287
|
-
}, L = () => {
|
|
288
|
-
clearTimeout(F.current), F.current = setTimeout(() => P(!1), oe);
|
|
289
|
-
};
|
|
290
|
-
h(() => () => clearTimeout(F.current), []), h(() => {
|
|
291
|
-
N || j(D);
|
|
292
|
-
}, [N, k]);
|
|
293
|
-
let R = [...A.filter((e) => w[e]), ...D.filter((e) => !A.includes(e))], z = R.join("|"), B = R.join("\0") !== k, V = p(() => j(M(w)), [w]);
|
|
294
|
-
h(() => {
|
|
295
|
-
let e = Object.values(w).filter((e) => e.alarm === "cleared" && e.clearedAt !== null).map((e) => setTimeout(() => T({
|
|
296
|
-
type: "settle",
|
|
297
|
-
id: e.id
|
|
298
|
-
}), Math.max(0, e.clearedAt + r - Date.now())));
|
|
299
|
-
return () => e.forEach(clearTimeout);
|
|
300
|
-
}, [w, r]);
|
|
301
|
-
let H = e(u), U = _(/* @__PURE__ */ new Map()), pe = _(/* @__PURE__ */ new Map());
|
|
302
|
-
h(() => {
|
|
303
|
-
if (typeof IntersectionObserver > "u") return;
|
|
304
|
-
let e = new IntersectionObserver((e) => {
|
|
305
|
-
for (let t of e) {
|
|
306
|
-
let e = t.target.dataset.boardItem;
|
|
307
|
-
e && pe.current.set(e, t.intersectionRatio >= .5);
|
|
308
|
-
}
|
|
309
|
-
}, { threshold: [
|
|
310
|
-
0,
|
|
311
|
-
.5,
|
|
312
|
-
1
|
|
313
|
-
] });
|
|
314
|
-
return U.current.forEach((t) => e.observe(t)), () => e.disconnect();
|
|
315
|
-
}, [E]);
|
|
316
|
-
let [W, me] = v(null), he = _(H);
|
|
317
|
-
he.current = H;
|
|
318
|
-
let G = p((e) => {
|
|
319
|
-
let t = U.current.get(e);
|
|
320
|
-
t && (t.scrollIntoView?.({
|
|
321
|
-
behavior: he.current ? "auto" : "smooth",
|
|
322
|
-
block: "center"
|
|
323
|
-
}), t.focus({ preventScroll: !0 }), me(e));
|
|
324
|
-
}, []);
|
|
325
|
-
h(() => {
|
|
326
|
-
if (!W) return;
|
|
327
|
-
let e = setTimeout(() => me(null), 1600);
|
|
328
|
-
return () => clearTimeout(e);
|
|
329
|
-
}, [W]);
|
|
330
|
-
let [ge, K] = v([]), q = _(null), J = _(0);
|
|
331
|
-
h(() => {
|
|
332
|
-
let e = () => {
|
|
333
|
-
q.current !== null && (document.title = q.current), q.current = null, J.current = 0;
|
|
334
|
-
}, t = () => {
|
|
335
|
-
document.visibilityState === "visible" && e();
|
|
336
|
-
};
|
|
337
|
-
return document.addEventListener("visibilitychange", t), () => {
|
|
338
|
-
document.removeEventListener("visibilitychange", t), e();
|
|
339
|
-
};
|
|
340
|
-
}, []);
|
|
341
|
-
let [_e, ve] = v({
|
|
342
|
-
polite: "",
|
|
343
|
-
assertive: ""
|
|
344
|
-
}), ye = _(w), Y = _({
|
|
345
|
-
onEvent: o,
|
|
346
|
-
titles: x,
|
|
347
|
-
toast: s
|
|
348
|
-
});
|
|
349
|
-
Y.current = {
|
|
350
|
-
onEvent: o,
|
|
351
|
-
titles: x,
|
|
352
|
-
toast: s
|
|
353
|
-
}, h(() => {
|
|
354
|
-
let e = ye.current;
|
|
355
|
-
ye.current = w;
|
|
356
|
-
let t = [], n = [], r = [], i = /* @__PURE__ */ new Set();
|
|
357
|
-
for (let a of Object.values(w)) {
|
|
358
|
-
let o = e[a.id];
|
|
359
|
-
if (!o) continue;
|
|
360
|
-
let s = le(o, a);
|
|
361
|
-
if (!s) continue;
|
|
362
|
-
let c = Y.current.titles.get(a.id) ?? a.id;
|
|
363
|
-
Y.current.onEvent?.({
|
|
364
|
-
type: s,
|
|
365
|
-
id: a.id,
|
|
366
|
-
title: c,
|
|
367
|
-
item: a,
|
|
368
|
-
show: () => G(a.id)
|
|
369
|
-
}), s === "raised" || s === "escalated" ? pe.current.get(a.id) || r.push({
|
|
370
|
-
id: a.id,
|
|
371
|
-
title: c,
|
|
372
|
-
reason: a.why ?? a.reason,
|
|
373
|
-
severity: a.severity ?? "warning"
|
|
374
|
-
}) : i.add(a.id);
|
|
375
|
-
let l = a.reason ? `: ${a.reason}${a.since ? ` since ${a.since}` : ""}` : "";
|
|
376
|
-
s === "raised" || s === "escalated" ? (a.severity === "critical" ? n : t).push(`${c} needs attention${l}.${a.why ? ` ${a.why}.` : ""}`) : s === "cleared" && t.push(`${c} is back to normal.`);
|
|
377
|
-
}
|
|
378
|
-
if ((t.length || n.length) && ve({
|
|
379
|
-
polite: t.join(" "),
|
|
380
|
-
assertive: n.join(" ")
|
|
381
|
-
}), Y.current.toast) {
|
|
382
|
-
if (r.length || i.size) {
|
|
383
|
-
let e = new Set(r.map((e) => e.id));
|
|
384
|
-
K((t) => [...t.filter((t) => !e.has(t.id) && !i.has(t.id)), ...r].sort((e, t) => ce(e.severity) - ce(t.severity)));
|
|
385
|
-
}
|
|
386
|
-
r.length && document.visibilityState === "hidden" && (q.current ??= document.title, J.current += r.length, document.title = `(${J.current}) ${q.current}`);
|
|
387
|
-
}
|
|
388
|
-
}, [w, G]);
|
|
389
|
-
let X = i ? `lilt-board:${i}` : null, Z = _(null), [be, xe] = v(() => /* @__PURE__ */ new Set()), Q = g(() => a ?? ue(), [a]);
|
|
390
|
-
h(() => {
|
|
391
|
-
if (!X || !Q) return;
|
|
392
|
-
let e = Q.get(X);
|
|
393
|
-
try {
|
|
394
|
-
Z.current = e === null ? null : new Set(JSON.parse(e));
|
|
395
|
-
} catch {
|
|
396
|
-
Z.current = null;
|
|
397
|
-
}
|
|
398
|
-
}, [X, Q]);
|
|
399
|
-
let Se = (e) => `${e.id}@${e.sinceAt ?? e.since ?? ""}`, Ce = Object.values(w).filter((e) => e.alarm !== "normal" && e.alarm !== "cleared").map(Se).sort().join("\0");
|
|
400
|
-
h(() => {
|
|
401
|
-
if (!X || !Q) return;
|
|
402
|
-
let e = Z.current, t = Object.values(w).filter((e) => e.alarm === "active" || e.alarm === "acknowledged");
|
|
403
|
-
e && xe(new Set(t.filter((t) => t.alarm === "active" && !e.has(Se(t))).map((e) => e.id)));
|
|
404
|
-
let n = () => Q.set(X, JSON.stringify(t.map(Se))), r = () => {
|
|
405
|
-
document.visibilityState === "hidden" && n();
|
|
406
|
-
};
|
|
407
|
-
return window.addEventListener("pagehide", n), document.addEventListener("visibilitychange", r), () => {
|
|
408
|
-
window.removeEventListener("pagehide", n), document.removeEventListener("visibilitychange", r), n();
|
|
409
|
-
};
|
|
410
|
-
}, [
|
|
411
|
-
Ce,
|
|
412
|
-
X,
|
|
413
|
-
Q
|
|
414
|
-
]);
|
|
415
|
-
let we = p((e) => T({
|
|
416
|
-
type: "acknowledge",
|
|
417
|
-
id: e,
|
|
418
|
-
now: Date.now()
|
|
419
|
-
}), []), Te = p((e, t) => T({
|
|
420
|
-
type: "pin",
|
|
421
|
-
id: e,
|
|
422
|
-
pinned: t
|
|
423
|
-
}), []), Ee = g(() => ({
|
|
424
|
-
state: w,
|
|
425
|
-
titles: x,
|
|
426
|
-
fresh: be,
|
|
427
|
-
acknowledge: we,
|
|
428
|
-
pin: Te,
|
|
429
|
-
pending: B,
|
|
430
|
-
apply: V
|
|
431
|
-
}), [
|
|
432
|
-
w,
|
|
433
|
-
x,
|
|
434
|
-
be,
|
|
435
|
-
we,
|
|
436
|
-
Te,
|
|
437
|
-
B,
|
|
438
|
-
V
|
|
439
|
-
]), De = new Map(y.map((e) => [e.id, e])), $ = ge.filter((e) => w[e.id]);
|
|
440
|
-
return /* @__PURE__ */ C(ie.Provider, {
|
|
441
|
-
value: Ee,
|
|
442
|
-
children: [/* @__PURE__ */ C("section", {
|
|
443
|
-
"data-lilt-chart": "",
|
|
444
|
-
className: ["lilt-board", f].filter(Boolean).join(" "),
|
|
445
|
-
style: m,
|
|
446
|
-
"aria-label": n,
|
|
447
|
-
onPointerEnter: I,
|
|
448
|
-
onPointerLeave: L,
|
|
449
|
-
onFocus: I,
|
|
450
|
-
onBlur: (e) => {
|
|
451
|
-
e.currentTarget.contains(e.relatedTarget) || L();
|
|
452
|
-
},
|
|
453
|
-
children: [
|
|
454
|
-
c ? /* @__PURE__ */ S(fe, {}) : null,
|
|
455
|
-
/* @__PURE__ */ S(b.div, {
|
|
456
|
-
layoutRoot: !0,
|
|
457
|
-
className: "lilt-board__grid",
|
|
458
|
-
children: R.map((e) => {
|
|
459
|
-
let t = De.get(e), n = w[e];
|
|
460
|
-
return !t || !n ? null : /* @__PURE__ */ S(b.div, {
|
|
461
|
-
ref: (t) => {
|
|
462
|
-
t ? U.current.set(e, t) : U.current.delete(e);
|
|
463
|
-
},
|
|
464
|
-
role: "group",
|
|
465
|
-
"aria-label": t.title,
|
|
466
|
-
tabIndex: -1,
|
|
467
|
-
"data-board-item": e,
|
|
468
|
-
"data-flash": W === e || void 0,
|
|
469
|
-
layout: !H && "position",
|
|
470
|
-
layoutDependency: z,
|
|
471
|
-
transition: {
|
|
472
|
-
type: "spring",
|
|
473
|
-
stiffness: 420,
|
|
474
|
-
damping: 40,
|
|
475
|
-
mass: .9
|
|
476
|
-
},
|
|
477
|
-
className: "lilt-board__item",
|
|
478
|
-
"data-alarm": n.alarm,
|
|
479
|
-
"data-severity": n.severity ?? void 0,
|
|
480
|
-
"data-pinned": n.pinned || void 0,
|
|
481
|
-
style: t.span === 2 ? { gridColumn: "span 2" } : void 0,
|
|
482
|
-
children: /* @__PURE__ */ S(ae.Provider, {
|
|
483
|
-
value: e,
|
|
484
|
-
children: /* @__PURE__ */ S(de, {
|
|
485
|
-
item: n,
|
|
486
|
-
status: l,
|
|
487
|
-
children: /* @__PURE__ */ S(se, {
|
|
488
|
-
id: e,
|
|
489
|
-
dispatch: T,
|
|
490
|
-
children: t.children
|
|
491
|
-
})
|
|
492
|
-
})
|
|
493
|
-
})
|
|
494
|
-
}, e);
|
|
495
|
-
})
|
|
496
|
-
}),
|
|
497
|
-
/* @__PURE__ */ S("div", {
|
|
498
|
-
className: "lilt-chart__sr-only",
|
|
499
|
-
"aria-live": "polite",
|
|
500
|
-
children: _e.polite
|
|
501
|
-
}),
|
|
502
|
-
/* @__PURE__ */ S("div", {
|
|
503
|
-
className: "lilt-chart__sr-only",
|
|
504
|
-
"aria-live": "assertive",
|
|
505
|
-
children: _e.assertive
|
|
506
|
-
})
|
|
507
|
-
]
|
|
508
|
-
}), s ? /* @__PURE__ */ S(ne, {
|
|
509
|
-
alerts: $,
|
|
510
|
-
reducedMotion: H,
|
|
511
|
-
onView: () => {
|
|
512
|
-
$[0] && G($[0].id), K([]);
|
|
513
|
-
},
|
|
514
|
-
onDismiss: () => K([])
|
|
515
|
-
}) : null]
|
|
516
|
-
});
|
|
517
|
-
}
|
|
518
|
-
function se({ id: e, dispatch: t, children: n }) {
|
|
519
|
-
let r = p((n) => t({
|
|
520
|
-
type: "report",
|
|
521
|
-
id: e,
|
|
522
|
-
report: n,
|
|
523
|
-
now: Date.now()
|
|
524
|
-
}), [t, e]);
|
|
525
|
-
return /* @__PURE__ */ S(l.Provider, {
|
|
526
|
-
value: r,
|
|
527
|
-
children: n
|
|
528
|
-
});
|
|
529
|
-
}
|
|
530
|
-
var ce = (e) => e === "critical" ? 0 : 1;
|
|
531
|
-
function le(e, t) {
|
|
532
|
-
return e.alarm === t.alarm ? t.alarm === "active" && e.severity === "warning" && t.severity === "critical" ? "escalated" : null : {
|
|
533
|
-
active: e.alarm === "acknowledged" ? "escalated" : "raised",
|
|
534
|
-
acknowledged: "acknowledged",
|
|
535
|
-
cleared: "cleared"
|
|
536
|
-
}[t.alarm] ?? null;
|
|
537
|
-
}
|
|
538
|
-
function ue() {
|
|
539
|
-
return typeof window > "u" ? null : {
|
|
540
|
-
get: (e) => {
|
|
541
|
-
try {
|
|
542
|
-
return window.localStorage.getItem(e);
|
|
543
|
-
} catch {
|
|
544
|
-
return null;
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
set: (e, t) => {
|
|
548
|
-
try {
|
|
549
|
-
window.localStorage.setItem(e, t);
|
|
550
|
-
} catch {}
|
|
551
|
-
}
|
|
552
|
-
};
|
|
553
|
-
}
|
|
554
|
-
function de({ item: e, status: t, children: n }) {
|
|
555
|
-
let r = t && (e.alarm !== "normal" || e.pinned), a = g(() => ({
|
|
556
|
-
badge: r ? /* @__PURE__ */ S(z, {}) : void 0,
|
|
557
|
-
tone: e.alarm === "active" ? e.severity : null,
|
|
558
|
-
handle: t && !r ? /* @__PURE__ */ S(B, {}) : void 0
|
|
559
|
-
}), [
|
|
560
|
-
r,
|
|
561
|
-
t,
|
|
562
|
-
e.alarm,
|
|
563
|
-
e.severity
|
|
564
|
-
]);
|
|
565
|
-
return /* @__PURE__ */ S(i.Provider, {
|
|
566
|
-
value: a,
|
|
567
|
-
children: n
|
|
568
|
-
});
|
|
569
|
-
}
|
|
570
|
-
var R = new Intl.DateTimeFormat(void 0, {
|
|
571
|
-
hour: "numeric",
|
|
572
|
-
minute: "2-digit"
|
|
573
|
-
});
|
|
574
|
-
function z() {
|
|
575
|
-
let { item: e, title: t, fresh: r, acknowledge: i, pin: a } = I(), o = e.alarm === "active" ? "Needs attention" : e.alarm === "acknowledged" ? `Seen ${R.format(e.acknowledgedAt)}` : e.alarm === "cleared" ? "Back to normal" : "Pinned";
|
|
576
|
-
return /* @__PURE__ */ C("span", {
|
|
577
|
-
className: "lilt-board-tab",
|
|
578
|
-
"data-alarm": e.alarm,
|
|
579
|
-
"data-severity": e.severity ?? void 0,
|
|
580
|
-
children: [/* @__PURE__ */ C("span", {
|
|
581
|
-
className: "lilt-board-tab__state",
|
|
582
|
-
children: [o, r ? /* @__PURE__ */ S("span", {
|
|
583
|
-
className: "lilt-board-tab__new",
|
|
584
|
-
children: "· New"
|
|
585
|
-
}) : null]
|
|
586
|
-
}), /* @__PURE__ */ C("span", {
|
|
587
|
-
className: "lilt-board-tab__actions",
|
|
588
|
-
children: [e.alarm === "active" ? /* @__PURE__ */ S("button", {
|
|
589
|
-
type: "button",
|
|
590
|
-
className: "lilt-board-tab__action",
|
|
591
|
-
onClick: i,
|
|
592
|
-
children: "Acknowledge"
|
|
593
|
-
}) : null, /* @__PURE__ */ S("button", {
|
|
594
|
-
type: "button",
|
|
595
|
-
className: "lilt-card-badge__clear lilt-board-tab__pin",
|
|
596
|
-
"aria-pressed": e.pinned,
|
|
597
|
-
"aria-label": e.pinned ? `Unpin ${t}` : `Pin ${t}`,
|
|
598
|
-
title: e.pinned ? "Unpin" : "Keep at the top",
|
|
599
|
-
onClick: () => a(!e.pinned),
|
|
600
|
-
children: /* @__PURE__ */ S(n, { release: e.pinned })
|
|
601
|
-
})]
|
|
602
|
-
})]
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
function B() {
|
|
606
|
-
let { title: e, pin: t } = I();
|
|
607
|
-
return /* @__PURE__ */ S("button", {
|
|
608
|
-
type: "button",
|
|
609
|
-
className: "lilt-board-handle",
|
|
610
|
-
"aria-pressed": !1,
|
|
611
|
-
"aria-label": `Pin ${e}`,
|
|
612
|
-
title: "Keep at the top",
|
|
613
|
-
onClick: () => t(!0),
|
|
614
|
-
children: /* @__PURE__ */ S(n, {})
|
|
615
|
-
});
|
|
616
|
-
}
|
|
617
|
-
function fe() {
|
|
618
|
-
let { pending: e, apply: t } = F();
|
|
619
|
-
return e ? /* @__PURE__ */ S("div", {
|
|
620
|
-
className: "lilt-board__toolbar",
|
|
621
|
-
children: /* @__PURE__ */ S("button", {
|
|
622
|
-
type: "button",
|
|
623
|
-
className: "lilt-board__apply",
|
|
624
|
-
onClick: t,
|
|
625
|
-
children: "Order changed · Show"
|
|
626
|
-
})
|
|
627
|
-
}) : null;
|
|
628
|
-
}
|
|
629
|
-
function V(e) {
|
|
630
|
-
return /* @__PURE__ */ S(u, {
|
|
631
|
-
layout: !0,
|
|
632
|
-
children: /* @__PURE__ */ S(L, { ...e })
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
//#endregion
|
|
636
|
-
export { re as BoardItem, z as BoardItemTab, fe as BoardToolbar, V as ChartBoard, O as boardReducer, a as describeExplanation, t as describeFlag, c as evaluateNormal, s as explainDeviation, r as explainReadings, T as flatline, E as jump, M as rankBoard, o as trackNormalStatus, F as useBoard, I as useBoardItem };
|