@lilt-ui/charts 0.1.0 → 0.3.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.
Files changed (68) hide show
  1. package/CHANGELOG.md +69 -0
  2. package/README.md +120 -0
  3. package/dist/analysis-BJRmXHOB.js +62 -0
  4. package/dist/cards/area-chart-card.d.ts +10 -1
  5. package/dist/cards/box-plot-card.d.ts +30 -0
  6. package/dist/cards/cartesian-card.d.ts +86 -6
  7. package/dist/cards/chart-card.d.ts +12 -1
  8. package/dist/cards/line-chart-card.d.ts +10 -1
  9. package/dist/cards/range-chart-card.d.ts +28 -0
  10. package/dist/cartesian-card-Dcd0ZnQL.js +7004 -0
  11. package/dist/chart-context.d.ts +18 -0
  12. package/dist/chart-data-CCwLQeXa.js +44 -0
  13. package/dist/chart.d.ts +3 -1
  14. package/dist/data.js +3 -2
  15. package/dist/engine/box.d.ts +18 -0
  16. package/dist/engine/domains.d.ts +2 -0
  17. package/dist/engine/geometry.d.ts +2 -1
  18. package/dist/engine/normalize.d.ts +2 -4
  19. package/dist/engine/ranges.d.ts +59 -0
  20. package/dist/finance/candle-geometry.d.ts +55 -0
  21. package/dist/finance/candles.d.ts +18 -0
  22. package/dist/finance/cards/candlestick-chart-card.d.ts +41 -0
  23. package/dist/finance/cards/depth-chart-card.d.ts +32 -0
  24. package/dist/finance/cards/indicator-chart-card.d.ts +52 -0
  25. package/dist/finance/cards/pane.d.ts +24 -0
  26. package/dist/finance/cards/portfolio-chart-card.d.ts +22 -0
  27. package/dist/finance/cards/price-chart-card.d.ts +27 -0
  28. package/dist/finance/index.d.ts +17 -0
  29. package/dist/finance/indicators.d.ts +65 -0
  30. package/dist/finance/order-book.d.ts +26 -0
  31. package/dist/finance.d.ts +2 -0
  32. package/dist/finance.js +1158 -0
  33. package/dist/index.d.ts +14 -4
  34. package/dist/index.js +2239 -8793
  35. package/dist/interaction/axis-cursor.d.ts +12 -2
  36. package/dist/interaction/chart-sync.d.ts +11 -1
  37. package/dist/interaction/field-values.d.ts +12 -0
  38. package/dist/interaction/inspection-layer.d.ts +10 -1
  39. package/dist/interaction/pin-glyphs.d.ts +8 -0
  40. package/dist/interaction/pin-marker.d.ts +9 -1
  41. package/dist/marks/contract.d.ts +49 -0
  42. package/dist/marks/use-range-mark.d.ts +19 -0
  43. package/dist/model/cartesian-model.d.ts +3 -3
  44. package/dist/primitives/annotations.d.ts +1 -1
  45. package/dist/primitives/axis-segments.d.ts +23 -0
  46. package/dist/primitives/box-plot.d.ts +4 -0
  47. package/dist/primitives/error-bar.d.ts +4 -0
  48. package/dist/primitives/interval-band.d.ts +2 -2
  49. package/dist/primitives/range-bar.d.ts +4 -0
  50. package/dist/report-context-Cz0AYdV2.js +895 -0
  51. package/dist/styles.css +1 -1
  52. package/dist/types.d.ts +114 -16
  53. package/dist/watch/board/board-state.d.ts +74 -0
  54. package/dist/watch/board/board-toast.d.ts +19 -0
  55. package/dist/watch/board/chart-board.d.ts +97 -0
  56. package/dist/watch/board/report-context.d.ts +3 -0
  57. package/dist/watch/engine/describe.d.ts +9 -0
  58. package/dist/watch/engine/explain.d.ts +48 -0
  59. package/dist/watch/engine/normal.d.ts +114 -0
  60. package/dist/watch/engine/robust.d.ts +7 -0
  61. package/dist/watch/engine/rules.d.ts +22 -0
  62. package/dist/watch/engine/status.d.ts +39 -0
  63. package/dist/watch/index.d.ts +14 -0
  64. package/dist/watch/normal-layer.d.ts +18 -0
  65. package/dist/watch.d.ts +2 -0
  66. package/dist/watch.js +628 -0
  67. package/package.json +16 -2
  68. package/dist/analysis-BLLWEKBw.js +0 -105
package/dist/watch.js ADDED
@@ -0,0 +1,628 @@
1
+ "use client";
2
+ import { S as e, a as t, i as n, l as r, n as i, o as a, r as o, s, t as c, y as l } from "./report-context-Cz0AYdV2.js";
3
+ import { Children as u, createContext as d, isValidElement as f, useCallback as p, useContext as m, useEffect as h, useMemo as g, useReducer as ee, useRef as _, useState as v } from "react";
4
+ import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
5
+ import { AnimatePresence as S, motion as te } from "motion/react";
6
+ import { createPortal as C } from "react-dom";
7
+ //#region src/watch/engine/rules.ts
8
+ function w({ 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 T({ 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 E = (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 D(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 ?? E(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 = O(n, t);
78
+ return r === n ? e : {
79
+ ...e,
80
+ [t.id]: r
81
+ };
82
+ }
83
+ function O(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
+ ...E(e.id, e.order),
130
+ pinned: e.pinned
131
+ } : e;
132
+ default: return e;
133
+ }
134
+ }
135
+ var k = {
136
+ active: 1,
137
+ acknowledged: 2,
138
+ cleared: 3,
139
+ normal: 4
140
+ }, A = (e) => e === "critical" ? 0 : 1;
141
+ function j(e) {
142
+ return Object.values(e).sort((e, t) => {
143
+ let n = e.pinned ? 0 : k[e.alarm], r = t.pinned ? 0 : k[t.alarm];
144
+ if (n !== r) return n - r;
145
+ if (n === 1 || n === 2) {
146
+ let n = A(e.severity) - A(t.severity);
147
+ if (n !== 0) return n;
148
+ let r = M(e) - M(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 M = (e) => e.sinceAt ?? e.raisedAt ?? Infinity, N = 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(), N);
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 C(/* @__PURE__ */ b("div", {
175
+ "data-lilt-chart": "",
176
+ className: "lilt-toast-region",
177
+ children: /* @__PURE__ */ b(S, { children: d ? /* @__PURE__ */ x(te.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__ */ b("span", {
202
+ className: "lilt-toast__text",
203
+ children: e.length === 1 ? /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b("strong", { children: d.title }), d.reason ? /* @__PURE__ */ b("span", {
204
+ className: "lilt-toast__reason",
205
+ children: d.reason
206
+ }) : null] }) : /* @__PURE__ */ x("strong", { children: [e.length, " charts need attention"] })
207
+ }),
208
+ /* @__PURE__ */ b("button", {
209
+ type: "button",
210
+ className: "lilt-toast__view",
211
+ onClick: n,
212
+ children: "View"
213
+ }),
214
+ /* @__PURE__ */ b("button", {
215
+ type: "button",
216
+ className: "lilt-card-badge__clear",
217
+ "aria-label": "Dismiss",
218
+ onClick: r,
219
+ children: /* @__PURE__ */ b("svg", {
220
+ "aria-hidden": "true",
221
+ viewBox: "0 0 16 16",
222
+ fill: "none",
223
+ children: /* @__PURE__ */ b("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__ */ b(y, { children: e });
239
+ }
240
+ var P = d(null), ie = d(null);
241
+ function F() {
242
+ let e = m(P);
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(P), t = m(ie);
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 ae = 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: d = "auto", className: m, style: y }) {
268
+ let S = g(() => u.toArray(t).flatMap((e) => f(e) && e.type === re ? [e.props] : []), [t]), C = g(() => new Map(S.map((e) => [e.id, e.title])), [S]), [w, T] = ee(D, S, (e) => e.reduce((e, t, n) => D(e, {
269
+ type: "register",
270
+ id: t.id,
271
+ order: n
272
+ }), {})), E = S.map((e) => e.id).join("\0");
273
+ h(() => {
274
+ let e = new Set(S.map((e) => e.id));
275
+ S.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 O = j(w), k = O.join("\0"), [A, M] = v(O), [N, F] = v(!1), I = _(void 0), L = () => {
286
+ clearTimeout(I.current), F(!0);
287
+ }, R = () => {
288
+ clearTimeout(I.current), I.current = setTimeout(() => F(!1), ae);
289
+ };
290
+ h(() => () => clearTimeout(I.current), []), h(() => {
291
+ N || M(O);
292
+ }, [N, k]);
293
+ let z = [...A.filter((e) => w[e]), ...O.filter((e) => !A.includes(e))], B = z.join("\0") !== k, fe = p(() => M(j(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 V = e(d), H = _(/* @__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 H.current.forEach((t) => e.observe(t)), () => e.disconnect();
315
+ }, [E]);
316
+ let [U, me] = v(null), he = _(V);
317
+ he.current = V;
318
+ let W = p((e) => {
319
+ let t = H.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 (!U) return;
327
+ let e = setTimeout(() => me(null), 1600);
328
+ return () => clearTimeout(e);
329
+ }, [U]);
330
+ let [ge, G] = v([]), K = _(null), q = _(0);
331
+ h(() => {
332
+ let e = () => {
333
+ K.current !== null && (document.title = K.current), K.current = null, q.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), J = _({
345
+ onEvent: o,
346
+ titles: C,
347
+ toast: s
348
+ });
349
+ J.current = {
350
+ onEvent: o,
351
+ titles: C,
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 = ce(o, a);
361
+ if (!s) continue;
362
+ let c = J.current.titles.get(a.id) ?? a.id;
363
+ J.current.onEvent?.({
364
+ type: s,
365
+ id: a.id,
366
+ title: c,
367
+ item: a,
368
+ show: () => W(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
+ }), J.current.toast) {
382
+ if (r.length || i.size) {
383
+ let e = new Set(r.map((e) => e.id));
384
+ G((t) => [...t.filter((t) => !e.has(t.id) && !i.has(t.id)), ...r].sort((e, t) => se(e.severity) - se(t.severity)));
385
+ }
386
+ r.length && document.visibilityState === "hidden" && (K.current ??= document.title, q.current += r.length, document.title = `(${q.current}) ${K.current}`);
387
+ }
388
+ }, [w, W]);
389
+ let Y = i ? `lilt-board:${i}` : null, X = _(null), [be, xe] = v(() => /* @__PURE__ */ new Set()), Z = g(() => a ?? le(), [a]);
390
+ h(() => {
391
+ if (!Y || !Z) return;
392
+ let e = Z.get(Y);
393
+ try {
394
+ X.current = e === null ? null : new Set(JSON.parse(e));
395
+ } catch {
396
+ X.current = null;
397
+ }
398
+ }, [Y, Z]);
399
+ let Q = (e) => `${e.id}@${e.sinceAt ?? e.since ?? ""}`, Se = Object.values(w).filter((e) => e.alarm !== "normal" && e.alarm !== "cleared").map(Q).sort().join("\0");
400
+ h(() => {
401
+ if (!Y || !Z) return;
402
+ let e = X.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(Q(t))).map((e) => e.id)));
404
+ let n = () => Z.set(Y, JSON.stringify(t.map(Q))), 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
+ Se,
412
+ Y,
413
+ Z
414
+ ]);
415
+ let Ce = p((e) => T({
416
+ type: "acknowledge",
417
+ id: e,
418
+ now: Date.now()
419
+ }), []), we = p((e, t) => T({
420
+ type: "pin",
421
+ id: e,
422
+ pinned: t
423
+ }), []), Te = g(() => ({
424
+ state: w,
425
+ titles: C,
426
+ fresh: be,
427
+ acknowledge: Ce,
428
+ pin: we,
429
+ pending: B,
430
+ apply: fe
431
+ }), [
432
+ w,
433
+ C,
434
+ be,
435
+ Ce,
436
+ we,
437
+ B,
438
+ fe
439
+ ]), Ee = new Map(S.map((e) => [e.id, e])), $ = ge.filter((e) => w[e.id]);
440
+ return /* @__PURE__ */ x(P.Provider, {
441
+ value: Te,
442
+ children: [/* @__PURE__ */ x("section", {
443
+ "data-lilt-chart": "",
444
+ className: ["lilt-board", m].filter(Boolean).join(" "),
445
+ style: y,
446
+ "aria-label": n,
447
+ onPointerEnter: L,
448
+ onPointerLeave: R,
449
+ onFocus: L,
450
+ onBlur: (e) => {
451
+ e.currentTarget.contains(e.relatedTarget) || R();
452
+ },
453
+ children: [
454
+ c ? /* @__PURE__ */ b(de, {}) : null,
455
+ /* @__PURE__ */ b("div", {
456
+ className: "lilt-board__grid",
457
+ children: z.map((e) => {
458
+ let t = Ee.get(e), n = w[e];
459
+ return !t || !n ? null : /* @__PURE__ */ b(te.div, {
460
+ ref: (t) => {
461
+ t ? H.current.set(e, t) : H.current.delete(e);
462
+ },
463
+ role: "group",
464
+ "aria-label": t.title,
465
+ tabIndex: -1,
466
+ "data-board-item": e,
467
+ "data-flash": U === e || void 0,
468
+ layout: !V && "position",
469
+ transition: {
470
+ type: "spring",
471
+ stiffness: 420,
472
+ damping: 40,
473
+ mass: .9
474
+ },
475
+ className: "lilt-board__item",
476
+ "data-alarm": n.alarm,
477
+ "data-severity": n.severity ?? void 0,
478
+ "data-pinned": n.pinned || void 0,
479
+ style: t.span === 2 ? { gridColumn: "span 2" } : void 0,
480
+ children: /* @__PURE__ */ b(ie.Provider, {
481
+ value: e,
482
+ children: /* @__PURE__ */ b(ue, {
483
+ item: n,
484
+ status: l,
485
+ children: /* @__PURE__ */ b(oe, {
486
+ id: e,
487
+ dispatch: T,
488
+ children: t.children
489
+ })
490
+ })
491
+ })
492
+ }, e);
493
+ })
494
+ }),
495
+ /* @__PURE__ */ b("div", {
496
+ className: "lilt-chart__sr-only",
497
+ "aria-live": "polite",
498
+ children: _e.polite
499
+ }),
500
+ /* @__PURE__ */ b("div", {
501
+ className: "lilt-chart__sr-only",
502
+ "aria-live": "assertive",
503
+ children: _e.assertive
504
+ })
505
+ ]
506
+ }), s ? /* @__PURE__ */ b(ne, {
507
+ alerts: $,
508
+ reducedMotion: V,
509
+ onView: () => {
510
+ $[0] && W($[0].id), G([]);
511
+ },
512
+ onDismiss: () => G([])
513
+ }) : null]
514
+ });
515
+ }
516
+ function oe({ id: e, dispatch: t, children: n }) {
517
+ let r = p((n) => t({
518
+ type: "report",
519
+ id: e,
520
+ report: n,
521
+ now: Date.now()
522
+ }), [t, e]);
523
+ return /* @__PURE__ */ b(c.Provider, {
524
+ value: r,
525
+ children: n
526
+ });
527
+ }
528
+ var se = (e) => e === "critical" ? 0 : 1;
529
+ function ce(e, t) {
530
+ return e.alarm === t.alarm ? t.alarm === "active" && e.severity === "warning" && t.severity === "critical" ? "escalated" : null : {
531
+ active: e.alarm === "acknowledged" ? "escalated" : "raised",
532
+ acknowledged: "acknowledged",
533
+ cleared: "cleared"
534
+ }[t.alarm] ?? null;
535
+ }
536
+ function le() {
537
+ return typeof window > "u" ? null : {
538
+ get: (e) => {
539
+ try {
540
+ return window.localStorage.getItem(e);
541
+ } catch {
542
+ return null;
543
+ }
544
+ },
545
+ set: (e, t) => {
546
+ try {
547
+ window.localStorage.setItem(e, t);
548
+ } catch {}
549
+ }
550
+ };
551
+ }
552
+ function ue({ item: e, status: t, children: n }) {
553
+ let i = t && (e.alarm !== "normal" || e.pinned), a = g(() => ({
554
+ badge: i ? /* @__PURE__ */ b(z, {}) : void 0,
555
+ tone: e.alarm === "active" ? e.severity : null,
556
+ handle: t && !i ? /* @__PURE__ */ b(B, {}) : void 0
557
+ }), [
558
+ i,
559
+ t,
560
+ e.alarm,
561
+ e.severity
562
+ ]);
563
+ return /* @__PURE__ */ b(r.Provider, {
564
+ value: a,
565
+ children: n
566
+ });
567
+ }
568
+ var R = new Intl.DateTimeFormat(void 0, {
569
+ hour: "numeric",
570
+ minute: "2-digit"
571
+ });
572
+ function z() {
573
+ let { item: e, title: t, fresh: n, acknowledge: r, pin: i } = I(), a = e.alarm === "active" ? "Needs attention" : e.alarm === "acknowledged" ? `Seen ${R.format(e.acknowledgedAt)}` : e.alarm === "cleared" ? "Back to normal" : "Pinned";
574
+ return /* @__PURE__ */ x("span", {
575
+ className: "lilt-board-tab",
576
+ "data-alarm": e.alarm,
577
+ "data-severity": e.severity ?? void 0,
578
+ children: [/* @__PURE__ */ x("span", {
579
+ className: "lilt-board-tab__state",
580
+ children: [a, n ? /* @__PURE__ */ b("span", {
581
+ className: "lilt-board-tab__new",
582
+ children: "· New"
583
+ }) : null]
584
+ }), /* @__PURE__ */ x("span", {
585
+ className: "lilt-board-tab__actions",
586
+ children: [e.alarm === "active" ? /* @__PURE__ */ b("button", {
587
+ type: "button",
588
+ className: "lilt-board-tab__action",
589
+ onClick: r,
590
+ children: "Acknowledge"
591
+ }) : null, /* @__PURE__ */ b("button", {
592
+ type: "button",
593
+ className: "lilt-card-badge__clear lilt-board-tab__pin",
594
+ "aria-pressed": e.pinned,
595
+ "aria-label": e.pinned ? `Unpin ${t}` : `Pin ${t}`,
596
+ title: e.pinned ? "Unpin" : "Keep at the top",
597
+ onClick: () => i(!e.pinned),
598
+ children: /* @__PURE__ */ b(l, { release: e.pinned })
599
+ })]
600
+ })]
601
+ });
602
+ }
603
+ function B() {
604
+ let { title: e, pin: t } = I();
605
+ return /* @__PURE__ */ b("button", {
606
+ type: "button",
607
+ className: "lilt-board-handle",
608
+ "aria-pressed": !1,
609
+ "aria-label": `Pin ${e}`,
610
+ title: "Keep at the top",
611
+ onClick: () => t(!0),
612
+ children: /* @__PURE__ */ b(l, {})
613
+ });
614
+ }
615
+ function de() {
616
+ let { pending: e, apply: t } = F();
617
+ return e ? /* @__PURE__ */ b("div", {
618
+ className: "lilt-board__toolbar",
619
+ children: /* @__PURE__ */ b("button", {
620
+ type: "button",
621
+ className: "lilt-board__apply",
622
+ onClick: t,
623
+ children: "Order changed · Show"
624
+ })
625
+ }) : null;
626
+ }
627
+ //#endregion
628
+ export { re as BoardItem, z as BoardItemTab, de as BoardToolbar, L as ChartBoard, D as boardReducer, i as describeExplanation, t as describeFlag, s as evaluateNormal, o as explainDeviation, n as explainReadings, w as flatline, T as jump, j as rankBoard, a as trackNormalStatus, F as useBoard, I as useBoardItem };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lilt-ui/charts",
3
- "version": "0.1.0",
4
- "description": "Beautiful, key-typed React chart cards with linked hover, targets, forecasts, and calm motion.",
3
+ "version": "0.3.0",
4
+ "description": "Beautiful, key-typed React chart cards with linked hover, targets, forecasts, finance charts, and calm motion.",
5
5
  "keywords": [
6
6
  "react",
7
7
  "charts",
@@ -12,6 +12,9 @@
12
12
  "bar-chart",
13
13
  "line-chart",
14
14
  "sparkline",
15
+ "candlestick",
16
+ "finance",
17
+ "box-plot",
15
18
  "typescript"
16
19
  ],
17
20
  "author": "Lilt UI",
@@ -32,6 +35,16 @@
32
35
  "import": "./dist/data.js",
33
36
  "default": "./dist/data.js"
34
37
  },
38
+ "./finance": {
39
+ "types": "./dist/finance/index.d.ts",
40
+ "import": "./dist/finance.js",
41
+ "default": "./dist/finance.js"
42
+ },
43
+ "./watch": {
44
+ "types": "./dist/watch/index.d.ts",
45
+ "import": "./dist/watch.js",
46
+ "default": "./dist/watch.js"
47
+ },
35
48
  "./styles.css": "./dist/styles.css",
36
49
  "./package.json": "./package.json"
37
50
  },
@@ -39,6 +52,7 @@
39
52
  "dist",
40
53
  "media",
41
54
  "README.md",
55
+ "CHANGELOG.md",
42
56
  "LICENSE",
43
57
  "THIRD_PARTY_NOTICES.md"
44
58
  ],