tekivex-ui 2.5.2 → 2.5.3
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/dist/TkxForm-DSMDo2Ol.js +388 -0
- package/dist/TkxForm-DwV_n-eE.cjs +12 -0
- package/dist/headless.cjs +1 -1
- package/dist/headless.js +396 -195
- package/dist/i18n.cjs +1 -0
- package/dist/i18n.js +757 -0
- package/dist/index.cjs +27 -22
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4994 -5089
- package/dist/quantum.cjs +91 -0
- package/dist/quantum.js +2312 -0
- package/dist/realtime.cjs +25 -0
- package/dist/realtime.js +944 -0
- package/dist/security-C369oOWH.cjs +1 -0
- package/dist/security-CzAmaMqa.js +97 -0
- package/dist/src/components/TkxDataGrid.d.ts +9 -1
- package/dist/src/components/TkxDataGrid.d.ts.map +1 -1
- package/dist/src/components/TkxDropdown.d.ts +41 -0
- package/dist/src/components/TkxDropdown.d.ts.map +1 -0
- package/dist/src/components/TkxLiveFeed.d.ts +891 -0
- package/dist/src/components/TkxLiveFeed.d.ts.map +1 -0
- package/dist/src/components/TkxLiveLog.d.ts +892 -0
- package/dist/src/components/TkxLiveLog.d.ts.map +1 -0
- package/dist/src/components/TkxLiveMetrics.d.ts +24 -0
- package/dist/src/components/TkxLiveMetrics.d.ts.map +1 -0
- package/dist/src/components/TkxPlayground.d.ts +15 -0
- package/dist/src/components/TkxPlayground.d.ts.map +1 -0
- package/dist/src/components/TkxQuantumForm.d.ts +20 -0
- package/dist/src/components/TkxQuantumForm.d.ts.map +1 -0
- package/dist/src/components/TkxRealTimeChart.d.ts +27 -0
- package/dist/src/components/TkxRealTimeChart.d.ts.map +1 -0
- package/dist/src/components/TkxTable.d.ts +11 -1
- package/dist/src/components/TkxTable.d.ts.map +1 -1
- package/dist/src/components/TkxThemeBuilder.d.ts +9 -0
- package/dist/src/components/TkxThemeBuilder.d.ts.map +1 -0
- package/dist/src/components/index.d.ts +1 -0
- package/dist/src/components/index.d.ts.map +1 -1
- package/dist/src/engine/index.d.ts +2 -0
- package/dist/src/engine/index.d.ts.map +1 -1
- package/dist/src/engine/quantum-ai.d.ts +201 -0
- package/dist/src/engine/quantum-ai.d.ts.map +1 -0
- package/dist/src/engine/tkx.d.ts.map +1 -1
- package/dist/src/headless/index.d.ts +6 -0
- package/dist/src/headless/index.d.ts.map +1 -1
- package/dist/src/headless/useInfiniteQuery.d.ts +35 -0
- package/dist/src/headless/useInfiniteQuery.d.ts.map +1 -0
- package/dist/src/headless/useSSE.d.ts +36 -0
- package/dist/src/headless/useSSE.d.ts.map +1 -0
- package/dist/src/headless/useWebSocket.d.ts +33 -0
- package/dist/src/headless/useWebSocket.d.ts.map +1 -0
- package/dist/src/quantum/index.d.ts +9 -0
- package/dist/src/quantum/index.d.ts.map +1 -0
- package/dist/src/realtime/index.d.ts +9 -0
- package/dist/src/realtime/index.d.ts.map +1 -0
- package/dist/{TkxForm-BWK4LqY3.js → tkx-BJ10JtMv.js} +372 -721
- package/dist/tkx-BeNyC0w7.cjs +4 -0
- package/package.json +16 -1
- package/src/components/TkxDataGrid.tsx +72 -0
- package/src/components/TkxDropdown.tsx +802 -0
- package/src/components/TkxLiveFeed.tsx +329 -0
- package/src/components/TkxLiveLog.tsx +470 -0
- package/src/components/TkxLiveMetrics.tsx +291 -0
- package/src/components/TkxPlayground.tsx +736 -0
- package/src/components/TkxQuantumForm.tsx +592 -0
- package/src/components/TkxRealTimeChart.tsx +381 -0
- package/src/components/TkxTable.tsx +351 -77
- package/src/components/TkxThemeBuilder.tsx +685 -0
- package/src/components/index.ts +4 -0
- package/src/engine/index.ts +2 -0
- package/src/engine/quantum-ai.ts +1045 -0
- package/src/engine/tkx.ts +95 -4
- package/src/headless/index.ts +6 -0
- package/src/headless/useInfiniteQuery.ts +153 -0
- package/src/headless/useSSE.ts +165 -0
- package/src/headless/useWebSocket.ts +229 -0
- package/src/quantum/index.ts +39 -0
- package/src/realtime/index.ts +21 -0
- package/dist/TkxForm-ljQjX7KD.cjs +0 -15
package/dist/realtime.js
ADDED
|
@@ -0,0 +1,944 @@
|
|
|
1
|
+
import { useRef as D, useState as C, useMemo as Q, useEffect as V, useCallback as K, createElement as n } from "react";
|
|
2
|
+
import { u as tt } from "./index-eT_U4qB2.js";
|
|
3
|
+
import { s as z } from "./security-CzAmaMqa.js";
|
|
4
|
+
const _ = 64, ut = 5;
|
|
5
|
+
let ft = !1;
|
|
6
|
+
function It() {
|
|
7
|
+
if (ft || typeof document > "u") return;
|
|
8
|
+
ft = !0;
|
|
9
|
+
const t = document.createElement("style");
|
|
10
|
+
t.id = "tkx-live-feed-styles", t.textContent = `
|
|
11
|
+
@keyframes tkx-feed-slide-in {
|
|
12
|
+
from { transform: translateY(-20px); opacity: 0; }
|
|
13
|
+
to { transform: translateY(0); opacity: 1; }
|
|
14
|
+
}
|
|
15
|
+
.tkx-feed-item-new {
|
|
16
|
+
animation: tkx-feed-slide-in 0.25s ease-out both;
|
|
17
|
+
}
|
|
18
|
+
`.trim(), document.head.appendChild(t);
|
|
19
|
+
}
|
|
20
|
+
function zt(t) {
|
|
21
|
+
const e = Date.now() - t;
|
|
22
|
+
return e < 1e4 ? "just now" : e < 6e4 ? `${Math.floor(e / 1e3)}s ago` : e < 36e5 ? `${Math.floor(e / 6e4)}m ago` : e < 864e5 ? `${Math.floor(e / 36e5)}h ago` : `${Math.floor(e / 864e5)}d ago`;
|
|
23
|
+
}
|
|
24
|
+
function Lt(t, e) {
|
|
25
|
+
switch (t) {
|
|
26
|
+
case "info":
|
|
27
|
+
return e.info;
|
|
28
|
+
case "success":
|
|
29
|
+
return e.success;
|
|
30
|
+
case "warning":
|
|
31
|
+
return e.warning;
|
|
32
|
+
case "error":
|
|
33
|
+
return e.danger;
|
|
34
|
+
default:
|
|
35
|
+
return e.border;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function Rt(t) {
|
|
39
|
+
return t ? t.split(" ").map((e) => e[0] ?? "").slice(0, 2).join("").toUpperCase() : "?";
|
|
40
|
+
}
|
|
41
|
+
function Nt({ item: t, isNew: e, showTimestamps: o, onItemClick: r, renderItem: c, theme: s, style: f }) {
|
|
42
|
+
const u = Lt(t.type, s);
|
|
43
|
+
if (c)
|
|
44
|
+
return n("div", { style: f, className: e ? "tkx-feed-item-new" : void 0 }, c(t));
|
|
45
|
+
const x = {
|
|
46
|
+
...f,
|
|
47
|
+
display: "flex",
|
|
48
|
+
alignItems: "center",
|
|
49
|
+
gap: 10,
|
|
50
|
+
padding: "0 12px",
|
|
51
|
+
borderLeft: `3px solid ${u}`,
|
|
52
|
+
cursor: r ? "pointer" : "default",
|
|
53
|
+
boxSizing: "border-box",
|
|
54
|
+
height: _,
|
|
55
|
+
background: s.surface,
|
|
56
|
+
transition: "background 0.15s"
|
|
57
|
+
};
|
|
58
|
+
return n(
|
|
59
|
+
"div",
|
|
60
|
+
{
|
|
61
|
+
style: x,
|
|
62
|
+
className: e ? "tkx-feed-item-new" : void 0,
|
|
63
|
+
onClick: r ? () => r(t) : void 0,
|
|
64
|
+
role: r ? "button" : void 0,
|
|
65
|
+
tabIndex: r ? 0 : void 0,
|
|
66
|
+
onKeyDown: r ? (a) => {
|
|
67
|
+
(a.key === "Enter" || a.key === " ") && r(t);
|
|
68
|
+
} : void 0
|
|
69
|
+
},
|
|
70
|
+
// Avatar
|
|
71
|
+
n(
|
|
72
|
+
"div",
|
|
73
|
+
{
|
|
74
|
+
style: {
|
|
75
|
+
width: 36,
|
|
76
|
+
height: 36,
|
|
77
|
+
borderRadius: "50%",
|
|
78
|
+
background: u,
|
|
79
|
+
display: "flex",
|
|
80
|
+
alignItems: "center",
|
|
81
|
+
justifyContent: "center",
|
|
82
|
+
fontSize: 13,
|
|
83
|
+
fontWeight: 700,
|
|
84
|
+
color: s.bg,
|
|
85
|
+
flexShrink: 0,
|
|
86
|
+
overflow: "hidden"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
t.avatar ? n("img", { src: t.avatar, alt: t.author ?? "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : Rt(t.author)
|
|
90
|
+
),
|
|
91
|
+
// Body
|
|
92
|
+
n(
|
|
93
|
+
"div",
|
|
94
|
+
{ style: { flex: 1, minWidth: 0 } },
|
|
95
|
+
n(
|
|
96
|
+
"div",
|
|
97
|
+
{ style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 } },
|
|
98
|
+
t.author && n("span", { style: { fontWeight: 600, fontSize: 13, color: s.text } }, z(t.author)),
|
|
99
|
+
t.meta && n("span", { style: { fontSize: 11, color: s.textMuted, background: s.surfaceAlt, borderRadius: 4, padding: "1px 5px" } }, z(t.meta))
|
|
100
|
+
),
|
|
101
|
+
n(
|
|
102
|
+
"div",
|
|
103
|
+
{ style: { fontSize: 13, color: s.text, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" } },
|
|
104
|
+
z(t.content)
|
|
105
|
+
)
|
|
106
|
+
),
|
|
107
|
+
// Timestamp
|
|
108
|
+
o && n(
|
|
109
|
+
"div",
|
|
110
|
+
{ style: { fontSize: 11, color: s.textMuted, flexShrink: 0 } },
|
|
111
|
+
zt(t.timestamp)
|
|
112
|
+
)
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
function qt({
|
|
116
|
+
items: t,
|
|
117
|
+
maxItems: e = 100,
|
|
118
|
+
height: o = 400,
|
|
119
|
+
autoScroll: r = !0,
|
|
120
|
+
showTimestamps: c = !0,
|
|
121
|
+
onItemClick: s,
|
|
122
|
+
emptyMessage: f = "No activity yet.",
|
|
123
|
+
pauseOnHover: u = !0,
|
|
124
|
+
renderItem: x
|
|
125
|
+
}) {
|
|
126
|
+
const a = tt();
|
|
127
|
+
It();
|
|
128
|
+
const m = D(null), [v, k] = C(0), [b, y] = C(!1), [W, E] = C(/* @__PURE__ */ new Set()), B = D([]), L = Q(
|
|
129
|
+
() => t.slice(-e),
|
|
130
|
+
[t, e]
|
|
131
|
+
), $ = typeof o == "number" ? o : 400, w = L.length * _;
|
|
132
|
+
V(() => {
|
|
133
|
+
const I = new Set(B.current.map((N) => N.id)), S = L.filter((N) => !I.has(N.id)).map((N) => N.id);
|
|
134
|
+
if (S.length > 0) {
|
|
135
|
+
E((j) => {
|
|
136
|
+
const F = new Set(j);
|
|
137
|
+
return S.forEach((A) => F.add(A)), F;
|
|
138
|
+
});
|
|
139
|
+
const N = window.setTimeout(() => {
|
|
140
|
+
E((j) => {
|
|
141
|
+
const F = new Set(j);
|
|
142
|
+
return S.forEach((A) => F.delete(A)), F;
|
|
143
|
+
});
|
|
144
|
+
}, 400);
|
|
145
|
+
return () => clearTimeout(N);
|
|
146
|
+
}
|
|
147
|
+
}, [L]), V(() => {
|
|
148
|
+
B.current = L;
|
|
149
|
+
}, [L]);
|
|
150
|
+
const P = r && !(u && b);
|
|
151
|
+
V(() => {
|
|
152
|
+
if (!P || !m.current) return;
|
|
153
|
+
const I = m.current;
|
|
154
|
+
(I.scrollHeight - I.scrollTop - I.clientHeight < _ * 3 || L.length <= 5) && (I.scrollTop = I.scrollHeight);
|
|
155
|
+
}, [L.length, P]);
|
|
156
|
+
const Y = K(() => {
|
|
157
|
+
m.current && k(m.current.scrollTop);
|
|
158
|
+
}, []), H = Math.max(0, Math.floor(v / _) - ut), g = Math.min(
|
|
159
|
+
L.length - 1,
|
|
160
|
+
Math.ceil((v + $) / _) + ut
|
|
161
|
+
), T = {
|
|
162
|
+
position: "relative",
|
|
163
|
+
overflow: "auto",
|
|
164
|
+
height: typeof o == "number" ? `${o}px` : o,
|
|
165
|
+
background: a.bg,
|
|
166
|
+
border: `1px solid ${a.border}`,
|
|
167
|
+
borderRadius: 8,
|
|
168
|
+
boxSizing: "border-box"
|
|
169
|
+
}, G = {
|
|
170
|
+
position: "relative",
|
|
171
|
+
height: w,
|
|
172
|
+
minHeight: "100%"
|
|
173
|
+
};
|
|
174
|
+
if (L.length === 0)
|
|
175
|
+
return n(
|
|
176
|
+
"div",
|
|
177
|
+
{ style: { ...T, display: "flex", alignItems: "center", justifyContent: "center" } },
|
|
178
|
+
n("span", { style: { color: a.textMuted, fontSize: 14 } }, z(f))
|
|
179
|
+
);
|
|
180
|
+
const R = [];
|
|
181
|
+
for (let I = H; I <= g; I++) {
|
|
182
|
+
const S = L[I];
|
|
183
|
+
S && R.push(
|
|
184
|
+
n(Nt, {
|
|
185
|
+
key: S.id,
|
|
186
|
+
item: S,
|
|
187
|
+
isNew: W.has(S.id),
|
|
188
|
+
showTimestamps: c,
|
|
189
|
+
onItemClick: s,
|
|
190
|
+
renderItem: x,
|
|
191
|
+
theme: a,
|
|
192
|
+
style: {
|
|
193
|
+
position: "absolute",
|
|
194
|
+
top: I * _,
|
|
195
|
+
left: 0,
|
|
196
|
+
right: 0
|
|
197
|
+
}
|
|
198
|
+
})
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
return n(
|
|
202
|
+
"div",
|
|
203
|
+
{
|
|
204
|
+
ref: m,
|
|
205
|
+
style: T,
|
|
206
|
+
onScroll: Y,
|
|
207
|
+
onMouseEnter: u ? () => y(!0) : void 0,
|
|
208
|
+
onMouseLeave: u ? () => y(!1) : void 0,
|
|
209
|
+
"aria-label": "Live feed",
|
|
210
|
+
role: "feed"
|
|
211
|
+
},
|
|
212
|
+
n("div", { style: G }, ...R)
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
let pt = !1;
|
|
216
|
+
function Et() {
|
|
217
|
+
if (pt || typeof document > "u") return;
|
|
218
|
+
pt = !0;
|
|
219
|
+
const t = document.createElement("style");
|
|
220
|
+
t.id = "tkx-live-metrics-styles", t.textContent = `
|
|
221
|
+
@keyframes tkx-metric-pulse {
|
|
222
|
+
0% { opacity: 1; }
|
|
223
|
+
40% { opacity: 0.4; }
|
|
224
|
+
100% { opacity: 1; }
|
|
225
|
+
}
|
|
226
|
+
@keyframes tkx-metric-shimmer {
|
|
227
|
+
0% { background-position: -200% 0; }
|
|
228
|
+
100% { background-position: 200% 0; }
|
|
229
|
+
}
|
|
230
|
+
.tkx-metric-shimmer {
|
|
231
|
+
animation: tkx-metric-shimmer 0.6s ease-in-out;
|
|
232
|
+
}
|
|
233
|
+
`.trim(), document.head.appendChild(t);
|
|
234
|
+
}
|
|
235
|
+
function gt(t, e) {
|
|
236
|
+
if (typeof t == "string") return t;
|
|
237
|
+
const o = t >= 1e6 ? `${(t / 1e6).toFixed(1)}M` : t >= 1e3 ? `${(t / 1e3).toFixed(1)}k` : String(Number.isInteger(t) ? t : t.toFixed(2));
|
|
238
|
+
return e ? `${o}${e}` : o;
|
|
239
|
+
}
|
|
240
|
+
function Wt(t, e) {
|
|
241
|
+
switch (t) {
|
|
242
|
+
case "warning":
|
|
243
|
+
return e.warning;
|
|
244
|
+
case "critical":
|
|
245
|
+
return e.danger;
|
|
246
|
+
default:
|
|
247
|
+
return e.primary;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
function Ct(t, e, o) {
|
|
251
|
+
const [r, c] = C(t), s = D(t), f = D(null), u = D(null);
|
|
252
|
+
return V(() => {
|
|
253
|
+
if (!o) {
|
|
254
|
+
c(t);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
const x = s.current;
|
|
258
|
+
if (x === t) return;
|
|
259
|
+
f.current = null;
|
|
260
|
+
const a = (m) => {
|
|
261
|
+
f.current === null && (f.current = m);
|
|
262
|
+
const v = m - f.current, k = Math.min(v / e, 1), b = 1 - Math.pow(1 - k, 3);
|
|
263
|
+
c(x + (t - x) * b), k < 1 ? u.current = requestAnimationFrame(a) : s.current = t;
|
|
264
|
+
};
|
|
265
|
+
return u.current = requestAnimationFrame(a), () => {
|
|
266
|
+
u.current !== null && cancelAnimationFrame(u.current);
|
|
267
|
+
};
|
|
268
|
+
}, [t, e, o]), r;
|
|
269
|
+
}
|
|
270
|
+
function Ht({ data: t, color: e }) {
|
|
271
|
+
if (t.length < 2) return null;
|
|
272
|
+
const o = 80, r = 24, c = Math.min(...t), f = Math.max(...t) - c || 1, u = t.map((x, a) => {
|
|
273
|
+
const m = a / (t.length - 1) * o, v = r - (x - c) / f * (r - 2) - 1;
|
|
274
|
+
return `${m.toFixed(1)},${v.toFixed(1)}`;
|
|
275
|
+
});
|
|
276
|
+
return n(
|
|
277
|
+
"svg",
|
|
278
|
+
{ width: o, height: r, viewBox: `0 0 ${o} ${r}`, "aria-hidden": "true" },
|
|
279
|
+
n("polyline", {
|
|
280
|
+
points: u.join(" "),
|
|
281
|
+
fill: "none",
|
|
282
|
+
stroke: e,
|
|
283
|
+
strokeWidth: 1.5,
|
|
284
|
+
strokeLinejoin: "round",
|
|
285
|
+
strokeLinecap: "round"
|
|
286
|
+
})
|
|
287
|
+
);
|
|
288
|
+
}
|
|
289
|
+
function Ft({ trend: t, theme: e }) {
|
|
290
|
+
return t === "up" ? n("span", { style: { color: e.success, fontSize: 14, fontWeight: 700 } }, "▲") : t === "down" ? n("span", { style: { color: e.danger, fontSize: 14, fontWeight: 700 } }, "▼") : n("span", { style: { color: e.textMuted, fontSize: 14 } }, "→");
|
|
291
|
+
}
|
|
292
|
+
function At({ metric: t, animate: e, onMetricClick: o, theme: r }) {
|
|
293
|
+
const c = t.color ?? Wt(t.status, r), s = typeof t.value == "number" ? t.value : NaN, f = Ct(isNaN(s) ? 0 : s, 600, e && !isNaN(s)), [u, x] = C(!1), a = D(t.value);
|
|
294
|
+
V(() => {
|
|
295
|
+
if (a.current !== t.value) {
|
|
296
|
+
a.current = t.value, x(!0);
|
|
297
|
+
const y = window.setTimeout(() => x(!1), 700);
|
|
298
|
+
return () => clearTimeout(y);
|
|
299
|
+
}
|
|
300
|
+
}, [t.value]);
|
|
301
|
+
const m = t.previousValue !== void 0 && t.previousValue !== s, v = {
|
|
302
|
+
background: r.surface,
|
|
303
|
+
border: `1px solid ${r.border}`,
|
|
304
|
+
borderLeft: `4px solid ${c}`,
|
|
305
|
+
borderRadius: 8,
|
|
306
|
+
padding: "14px 16px",
|
|
307
|
+
cursor: o ? "pointer" : "default",
|
|
308
|
+
position: "relative",
|
|
309
|
+
overflow: "hidden",
|
|
310
|
+
boxSizing: "border-box"
|
|
311
|
+
}, k = u ? {
|
|
312
|
+
position: "absolute",
|
|
313
|
+
inset: 0,
|
|
314
|
+
background: `linear-gradient(90deg, transparent 0%, ${c}22 50%, transparent 100%)`,
|
|
315
|
+
backgroundSize: "200% 100%",
|
|
316
|
+
animation: "tkx-metric-shimmer 0.6s ease-in-out",
|
|
317
|
+
pointerEvents: "none"
|
|
318
|
+
} : {}, b = isNaN(s) ? z(String(t.value)) : gt(f, t.unit);
|
|
319
|
+
return n(
|
|
320
|
+
"div",
|
|
321
|
+
{
|
|
322
|
+
style: v,
|
|
323
|
+
className: u ? "tkx-metric-shimmer" : void 0,
|
|
324
|
+
onClick: o ? () => o(t) : void 0,
|
|
325
|
+
role: o ? "button" : void 0,
|
|
326
|
+
tabIndex: o ? 0 : void 0
|
|
327
|
+
},
|
|
328
|
+
// Shimmer overlay
|
|
329
|
+
u && n("div", { style: k }),
|
|
330
|
+
// Label
|
|
331
|
+
n("div", { style: { fontSize: 12, color: r.textMuted, marginBottom: 6, fontWeight: 500, letterSpacing: "0.03em" } }, z(t.label)),
|
|
332
|
+
// Value row
|
|
333
|
+
n(
|
|
334
|
+
"div",
|
|
335
|
+
{ style: { display: "flex", alignItems: "flex-end", gap: 6, marginBottom: 6 } },
|
|
336
|
+
n("span", { style: { fontSize: 28, fontWeight: 700, color: r.text, lineHeight: 1 } }, b),
|
|
337
|
+
t.unit && isNaN(s) && n("span", { style: { fontSize: 14, color: r.textMuted, marginBottom: 2 } }, z(t.unit))
|
|
338
|
+
),
|
|
339
|
+
// Trend row
|
|
340
|
+
(t.trend || t.trendValue) && n(
|
|
341
|
+
"div",
|
|
342
|
+
{ style: { display: "flex", alignItems: "center", gap: 4, marginBottom: t.sparkline ? 8 : 0 } },
|
|
343
|
+
t.trend && n(Ft, { trend: t.trend, theme: r }),
|
|
344
|
+
t.trendValue && n("span", { style: { fontSize: 12, color: r.textMuted } }, z(t.trendValue))
|
|
345
|
+
),
|
|
346
|
+
// Previous value
|
|
347
|
+
m && n(
|
|
348
|
+
"div",
|
|
349
|
+
{ style: { fontSize: 11, color: r.textMuted, marginTop: 2 } },
|
|
350
|
+
`was ${gt(t.previousValue)}`
|
|
351
|
+
),
|
|
352
|
+
// Sparkline
|
|
353
|
+
t.sparkline && t.sparkline.length >= 2 && n(
|
|
354
|
+
"div",
|
|
355
|
+
{ style: { marginTop: 8 } },
|
|
356
|
+
n(Ht, { data: t.sparkline, color: c })
|
|
357
|
+
)
|
|
358
|
+
);
|
|
359
|
+
}
|
|
360
|
+
function Jt({
|
|
361
|
+
metrics: t,
|
|
362
|
+
columns: e = 3,
|
|
363
|
+
animate: o = !0,
|
|
364
|
+
onMetricClick: r
|
|
365
|
+
}) {
|
|
366
|
+
const c = tt();
|
|
367
|
+
Et();
|
|
368
|
+
const s = {
|
|
369
|
+
display: "grid",
|
|
370
|
+
gridTemplateColumns: `repeat(${e}, minmax(0, 1fr))`,
|
|
371
|
+
gap: 16
|
|
372
|
+
};
|
|
373
|
+
return n(
|
|
374
|
+
"div",
|
|
375
|
+
{ style: s },
|
|
376
|
+
...t.map(
|
|
377
|
+
(f) => n(At, {
|
|
378
|
+
key: f.id,
|
|
379
|
+
metric: f,
|
|
380
|
+
animate: o,
|
|
381
|
+
onMetricClick: r,
|
|
382
|
+
theme: c
|
|
383
|
+
})
|
|
384
|
+
)
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
function xt(t) {
|
|
388
|
+
const e = new Date(t), o = String(e.getHours()).padStart(2, "0"), r = String(e.getMinutes()).padStart(2, "0"), c = String(e.getSeconds()).padStart(2, "0");
|
|
389
|
+
return `${o}:${r}:${c}`;
|
|
390
|
+
}
|
|
391
|
+
function ht(t) {
|
|
392
|
+
return Math.abs(t) >= 1e6 ? `${(t / 1e6).toFixed(1)}M` : Math.abs(t) >= 1e3 ? `${(t / 1e3).toFixed(1)}k` : Number.isInteger(t) ? String(t) : t.toFixed(2);
|
|
393
|
+
}
|
|
394
|
+
function Zt({
|
|
395
|
+
data: t,
|
|
396
|
+
maxPoints: e = 60,
|
|
397
|
+
height: o = 200,
|
|
398
|
+
width: r = "100%",
|
|
399
|
+
color: c,
|
|
400
|
+
fill: s = !0,
|
|
401
|
+
showGrid: f = !0,
|
|
402
|
+
showLabels: u = !0,
|
|
403
|
+
showTooltip: x = !0,
|
|
404
|
+
label: a,
|
|
405
|
+
unit: m,
|
|
406
|
+
animate: v = !0,
|
|
407
|
+
yMin: k,
|
|
408
|
+
yMax: b
|
|
409
|
+
}) {
|
|
410
|
+
const y = tt(), W = c ?? y.primary, E = D(null), [B, L] = C(600), [$, w] = C(null), [P, Y] = C(0), H = D(t.length);
|
|
411
|
+
V(() => {
|
|
412
|
+
if (!E.current) return;
|
|
413
|
+
const i = new ResizeObserver((h) => {
|
|
414
|
+
const O = h[0];
|
|
415
|
+
O && L(O.contentRect.width);
|
|
416
|
+
});
|
|
417
|
+
return i.observe(E.current), L(E.current.offsetWidth), () => i.disconnect();
|
|
418
|
+
}, []);
|
|
419
|
+
const g = Q(
|
|
420
|
+
() => t.slice(-e),
|
|
421
|
+
[t, e]
|
|
422
|
+
);
|
|
423
|
+
V(() => {
|
|
424
|
+
g.length > H.current && Y((i) => i + 1), H.current = g.length;
|
|
425
|
+
}, [g.length]);
|
|
426
|
+
const T = u ? 48 : 12, G = 12, R = a ? 28 : 12, I = 28, S = Math.max(B - T - G, 1), N = Math.max(o - R - I, 1), j = g.length ? Math.min(...g.map((i) => i.value)) : 0, F = g.length ? Math.max(...g.map((i) => i.value)) : 1, A = F - j || 1, d = k !== void 0 ? k : j - A * 0.1, p = (b !== void 0 ? b : F + A * 0.1) - d || 1;
|
|
427
|
+
function M(i) {
|
|
428
|
+
return g.length < 2 ? S / 2 : i / (g.length - 1) * S;
|
|
429
|
+
}
|
|
430
|
+
function X(i) {
|
|
431
|
+
return N - (i - d) / p * N;
|
|
432
|
+
}
|
|
433
|
+
const q = g.length >= 2 ? g.map((i, h) => `${h === 0 ? "M" : "L"}${M(h).toFixed(2)},${X(i.value).toFixed(2)}`).join(" ") : "", at = q ? `${q} L${M(g.length - 1).toFixed(2)},${N} L${M(0).toFixed(2)},${N} Z` : "", et = 4, nt = [];
|
|
434
|
+
for (let i = 0; i <= et; i++)
|
|
435
|
+
nt.push(i);
|
|
436
|
+
const bt = nt.map((i) => {
|
|
437
|
+
const h = d + i / et * p;
|
|
438
|
+
return { y: X(h), text: ht(h) };
|
|
439
|
+
}), ot = Math.min(4, g.length), St = ot > 0 ? Array.from(
|
|
440
|
+
{ length: ot },
|
|
441
|
+
(i, h) => Math.round(h / Math.max(ot - 1, 1) * (g.length - 1))
|
|
442
|
+
) : [], kt = K(
|
|
443
|
+
(i) => {
|
|
444
|
+
if (!x || g.length === 0) return;
|
|
445
|
+
const h = i.currentTarget.getBoundingClientRect(), O = i.clientX - h.left - T;
|
|
446
|
+
let U = 0, lt = 1 / 0;
|
|
447
|
+
g.forEach((Gt, ct) => {
|
|
448
|
+
const dt = Math.abs(M(ct) - O);
|
|
449
|
+
dt < lt && (lt = dt, U = ct);
|
|
450
|
+
});
|
|
451
|
+
const st = g[U];
|
|
452
|
+
if (!st) return;
|
|
453
|
+
const $t = M(U) + T, Tt = X(st.value) + R;
|
|
454
|
+
w({ x: $t, y: Tt, point: st });
|
|
455
|
+
},
|
|
456
|
+
[g, x, T, R]
|
|
457
|
+
), wt = K(() => w(null), []), rt = B, J = o, it = `tkx-chart-clip-${P}`, Mt = {
|
|
458
|
+
position: "relative",
|
|
459
|
+
width: typeof r == "number" ? `${r}px` : r,
|
|
460
|
+
background: y.surface,
|
|
461
|
+
border: `1px solid ${y.border}`,
|
|
462
|
+
borderRadius: 8,
|
|
463
|
+
overflow: "hidden",
|
|
464
|
+
boxSizing: "border-box"
|
|
465
|
+
};
|
|
466
|
+
return n(
|
|
467
|
+
"div",
|
|
468
|
+
{ ref: E, style: Mt },
|
|
469
|
+
n(
|
|
470
|
+
"svg",
|
|
471
|
+
{
|
|
472
|
+
width: rt,
|
|
473
|
+
height: J,
|
|
474
|
+
viewBox: `0 0 ${rt} ${J}`,
|
|
475
|
+
onMouseMove: kt,
|
|
476
|
+
onMouseLeave: wt,
|
|
477
|
+
style: { display: "block", userSelect: "none" },
|
|
478
|
+
"aria-label": a ? z(a) : "Real-time chart"
|
|
479
|
+
},
|
|
480
|
+
// Defs: clip for animation
|
|
481
|
+
v && g.length >= 2 && n(
|
|
482
|
+
"defs",
|
|
483
|
+
null,
|
|
484
|
+
n(
|
|
485
|
+
"clipPath",
|
|
486
|
+
{ id: it },
|
|
487
|
+
n(
|
|
488
|
+
"rect",
|
|
489
|
+
{
|
|
490
|
+
x: 0,
|
|
491
|
+
y: 0,
|
|
492
|
+
width: S,
|
|
493
|
+
height: J
|
|
494
|
+
},
|
|
495
|
+
n("animate", {
|
|
496
|
+
attributeName: "width",
|
|
497
|
+
from: Math.max(0, S - S / Math.max(g.length - 1, 1)),
|
|
498
|
+
to: S,
|
|
499
|
+
dur: "0.3s",
|
|
500
|
+
fill: "freeze"
|
|
501
|
+
})
|
|
502
|
+
)
|
|
503
|
+
)
|
|
504
|
+
),
|
|
505
|
+
// Chart title
|
|
506
|
+
a && n(
|
|
507
|
+
"text",
|
|
508
|
+
{
|
|
509
|
+
x: T,
|
|
510
|
+
y: 18,
|
|
511
|
+
fill: y.textMuted,
|
|
512
|
+
fontSize: 12,
|
|
513
|
+
fontWeight: 500
|
|
514
|
+
},
|
|
515
|
+
z(a)
|
|
516
|
+
),
|
|
517
|
+
// Grid lines
|
|
518
|
+
f && nt.map((i) => {
|
|
519
|
+
const h = X(d + i / et * p) + R;
|
|
520
|
+
return n("line", {
|
|
521
|
+
key: `grid-${i}`,
|
|
522
|
+
x1: T,
|
|
523
|
+
y1: h,
|
|
524
|
+
x2: T + S,
|
|
525
|
+
y2: h,
|
|
526
|
+
stroke: y.border,
|
|
527
|
+
strokeWidth: 1,
|
|
528
|
+
strokeDasharray: "4 4"
|
|
529
|
+
});
|
|
530
|
+
}),
|
|
531
|
+
// Y axis labels
|
|
532
|
+
u && bt.map((i, h) => n(
|
|
533
|
+
"text",
|
|
534
|
+
{
|
|
535
|
+
key: `yl-${h}`,
|
|
536
|
+
x: T - 4,
|
|
537
|
+
y: i.y + R + 4,
|
|
538
|
+
fill: y.textMuted,
|
|
539
|
+
fontSize: 10,
|
|
540
|
+
textAnchor: "end"
|
|
541
|
+
},
|
|
542
|
+
i.text
|
|
543
|
+
)),
|
|
544
|
+
// Y axis unit
|
|
545
|
+
m && n(
|
|
546
|
+
"text",
|
|
547
|
+
{ x: 4, y: R + 10, fill: y.textMuted, fontSize: 9 },
|
|
548
|
+
z(m)
|
|
549
|
+
),
|
|
550
|
+
// Area fill
|
|
551
|
+
s && at && n("path", {
|
|
552
|
+
d: at,
|
|
553
|
+
fill: `${W}22`,
|
|
554
|
+
clipPath: v ? `url(#${it})` : void 0,
|
|
555
|
+
transform: `translate(${T}, ${R})`
|
|
556
|
+
}),
|
|
557
|
+
// Data line
|
|
558
|
+
q && n("path", {
|
|
559
|
+
d: q,
|
|
560
|
+
fill: "none",
|
|
561
|
+
stroke: W,
|
|
562
|
+
strokeWidth: 2,
|
|
563
|
+
strokeLinejoin: "round",
|
|
564
|
+
strokeLinecap: "round",
|
|
565
|
+
clipPath: v ? `url(#${it})` : void 0,
|
|
566
|
+
transform: `translate(${T}, ${R})`
|
|
567
|
+
}),
|
|
568
|
+
// X axis labels
|
|
569
|
+
St.map((i) => {
|
|
570
|
+
const h = g[i];
|
|
571
|
+
return h ? n(
|
|
572
|
+
"text",
|
|
573
|
+
{
|
|
574
|
+
key: `xl-${i}`,
|
|
575
|
+
x: T + M(i),
|
|
576
|
+
y: J - 8,
|
|
577
|
+
fill: y.textMuted,
|
|
578
|
+
fontSize: 9,
|
|
579
|
+
textAnchor: "middle"
|
|
580
|
+
},
|
|
581
|
+
xt(h.timestamp)
|
|
582
|
+
) : null;
|
|
583
|
+
}),
|
|
584
|
+
// Tooltip vertical line
|
|
585
|
+
$ && n("line", {
|
|
586
|
+
x1: $.x,
|
|
587
|
+
y1: R,
|
|
588
|
+
x2: $.x,
|
|
589
|
+
y2: R + N,
|
|
590
|
+
stroke: W,
|
|
591
|
+
strokeWidth: 1,
|
|
592
|
+
strokeDasharray: "3 3",
|
|
593
|
+
opacity: 0.6
|
|
594
|
+
}),
|
|
595
|
+
// Tooltip dot
|
|
596
|
+
$ && n("circle", {
|
|
597
|
+
cx: $.x,
|
|
598
|
+
cy: $.y,
|
|
599
|
+
r: 4,
|
|
600
|
+
fill: W,
|
|
601
|
+
stroke: y.surface,
|
|
602
|
+
strokeWidth: 2
|
|
603
|
+
}),
|
|
604
|
+
// Tooltip box
|
|
605
|
+
$ && (() => {
|
|
606
|
+
const i = Math.min($.x + 8, rt - 100), h = Math.max($.y - 36, 4), O = `${ht($.point.value)}${m || ""}`, U = xt($.point.timestamp);
|
|
607
|
+
return n(
|
|
608
|
+
"g",
|
|
609
|
+
null,
|
|
610
|
+
n("rect", {
|
|
611
|
+
x: i - 4,
|
|
612
|
+
y: h - 2,
|
|
613
|
+
width: 90,
|
|
614
|
+
height: 34,
|
|
615
|
+
rx: 4,
|
|
616
|
+
fill: y.surfaceAlt,
|
|
617
|
+
stroke: y.border,
|
|
618
|
+
strokeWidth: 1
|
|
619
|
+
}),
|
|
620
|
+
n("text", { x: i, y: h + 11, fill: y.text, fontSize: 12, fontWeight: 700 }, O),
|
|
621
|
+
n("text", { x: i, y: h + 26, fill: y.textMuted, fontSize: 10 }, U)
|
|
622
|
+
);
|
|
623
|
+
})()
|
|
624
|
+
)
|
|
625
|
+
);
|
|
626
|
+
}
|
|
627
|
+
const Z = 28, yt = 8, mt = {
|
|
628
|
+
debug: 0,
|
|
629
|
+
info: 1,
|
|
630
|
+
warn: 2,
|
|
631
|
+
error: 3,
|
|
632
|
+
fatal: 4
|
|
633
|
+
};
|
|
634
|
+
let vt = !1;
|
|
635
|
+
function Dt() {
|
|
636
|
+
if (vt || typeof document > "u") return;
|
|
637
|
+
vt = !0;
|
|
638
|
+
const t = document.createElement("style");
|
|
639
|
+
t.id = "tkx-live-log-styles", t.textContent = `
|
|
640
|
+
.tkx-log-row:hover { filter: brightness(1.12); }
|
|
641
|
+
.tkx-log-highlight { background: #ffbe0b55; border-radius: 2px; padding: 0 1px; }
|
|
642
|
+
`.trim(), document.head.appendChild(t);
|
|
643
|
+
}
|
|
644
|
+
function jt(t) {
|
|
645
|
+
const e = new Date(t), o = String(e.getHours()).padStart(2, "0"), r = String(e.getMinutes()).padStart(2, "0"), c = String(e.getSeconds()).padStart(2, "0"), s = String(e.getMilliseconds()).padStart(3, "0");
|
|
646
|
+
return `${o}:${r}:${c}.${s}`;
|
|
647
|
+
}
|
|
648
|
+
function Bt(t, e) {
|
|
649
|
+
switch (t) {
|
|
650
|
+
case "debug":
|
|
651
|
+
return e.textMuted;
|
|
652
|
+
case "info":
|
|
653
|
+
return e.info;
|
|
654
|
+
case "warn":
|
|
655
|
+
return e.warning;
|
|
656
|
+
case "error":
|
|
657
|
+
return e.danger;
|
|
658
|
+
case "fatal":
|
|
659
|
+
return e.danger;
|
|
660
|
+
default:
|
|
661
|
+
return e.textMuted;
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
function Vt(t, e) {
|
|
665
|
+
return t === "fatal" ? `${e.danger}22` : "transparent";
|
|
666
|
+
}
|
|
667
|
+
function Ot(t) {
|
|
668
|
+
return `[${t.toUpperCase().padEnd(5)}]`;
|
|
669
|
+
}
|
|
670
|
+
function Pt(t, e) {
|
|
671
|
+
if (!e) return [t];
|
|
672
|
+
const o = z(t), r = z(e);
|
|
673
|
+
if (!r) return [o];
|
|
674
|
+
try {
|
|
675
|
+
const c = new RegExp(`(${r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})`, "gi");
|
|
676
|
+
return o.split(c).map(
|
|
677
|
+
(f, u) => c.test(f) ? n("mark", { key: u, className: "tkx-log-highlight" }, f) : f
|
|
678
|
+
);
|
|
679
|
+
} catch {
|
|
680
|
+
return [o];
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
function Yt({
|
|
684
|
+
entry: t,
|
|
685
|
+
showLevel: e,
|
|
686
|
+
showTimestamp: o,
|
|
687
|
+
showSource: r,
|
|
688
|
+
searchQuery: c,
|
|
689
|
+
monospace: s,
|
|
690
|
+
isExpanded: f,
|
|
691
|
+
onToggle: u,
|
|
692
|
+
onEntryClick: x,
|
|
693
|
+
theme: a,
|
|
694
|
+
style: m
|
|
695
|
+
}) {
|
|
696
|
+
const v = Bt(t.level, a), k = Vt(t.level, a), b = t.metadata && Object.keys(t.metadata).length > 0, y = {
|
|
697
|
+
...m,
|
|
698
|
+
display: "flex",
|
|
699
|
+
alignItems: "center",
|
|
700
|
+
gap: 6,
|
|
701
|
+
padding: "0 10px",
|
|
702
|
+
fontSize: 12,
|
|
703
|
+
fontFamily: s ? '"JetBrains Mono", "Fira Mono", Consolas, monospace' : "inherit",
|
|
704
|
+
cursor: b || x ? "pointer" : "default",
|
|
705
|
+
background: k,
|
|
706
|
+
boxSizing: "border-box",
|
|
707
|
+
height: Z,
|
|
708
|
+
overflow: "hidden",
|
|
709
|
+
whiteSpace: "nowrap",
|
|
710
|
+
borderBottom: `1px solid ${a.border}22`
|
|
711
|
+
};
|
|
712
|
+
return n(
|
|
713
|
+
"div",
|
|
714
|
+
{
|
|
715
|
+
style: y,
|
|
716
|
+
className: "tkx-log-row",
|
|
717
|
+
onClick: () => {
|
|
718
|
+
b && u(), x && x(t);
|
|
719
|
+
},
|
|
720
|
+
role: b ? "button" : void 0,
|
|
721
|
+
tabIndex: b ? 0 : void 0,
|
|
722
|
+
onKeyDown: b ? (E) => {
|
|
723
|
+
(E.key === "Enter" || E.key === " ") && u();
|
|
724
|
+
} : void 0,
|
|
725
|
+
"aria-expanded": b ? f : void 0
|
|
726
|
+
},
|
|
727
|
+
// Timestamp
|
|
728
|
+
o && n(
|
|
729
|
+
"span",
|
|
730
|
+
{ style: { color: a.textMuted, flexShrink: 0, minWidth: 84 } },
|
|
731
|
+
jt(t.timestamp)
|
|
732
|
+
),
|
|
733
|
+
// Level badge
|
|
734
|
+
e && n(
|
|
735
|
+
"span",
|
|
736
|
+
{
|
|
737
|
+
style: {
|
|
738
|
+
color: v,
|
|
739
|
+
flexShrink: 0,
|
|
740
|
+
fontWeight: t.level === "fatal" ? 700 : 500,
|
|
741
|
+
minWidth: 56
|
|
742
|
+
}
|
|
743
|
+
},
|
|
744
|
+
Ot(t.level)
|
|
745
|
+
),
|
|
746
|
+
// Source badge
|
|
747
|
+
r && t.source && n(
|
|
748
|
+
"span",
|
|
749
|
+
{
|
|
750
|
+
style: {
|
|
751
|
+
background: a.surfaceAlt,
|
|
752
|
+
border: `1px solid ${a.border}`,
|
|
753
|
+
borderRadius: 10,
|
|
754
|
+
padding: "0 5px",
|
|
755
|
+
fontSize: 10,
|
|
756
|
+
color: a.textMuted,
|
|
757
|
+
flexShrink: 0,
|
|
758
|
+
maxWidth: 80,
|
|
759
|
+
overflow: "hidden",
|
|
760
|
+
textOverflow: "ellipsis"
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
z(t.source)
|
|
764
|
+
),
|
|
765
|
+
// Message
|
|
766
|
+
n(
|
|
767
|
+
"span",
|
|
768
|
+
{ style: { flex: 1, color: a.text, overflow: "hidden", textOverflow: "ellipsis" } },
|
|
769
|
+
...Pt(t.message, c)
|
|
770
|
+
),
|
|
771
|
+
// Expand indicator
|
|
772
|
+
b && n(
|
|
773
|
+
"span",
|
|
774
|
+
{ style: { color: a.textMuted, fontSize: 10, flexShrink: 0 } },
|
|
775
|
+
f ? "▲" : "▼"
|
|
776
|
+
)
|
|
777
|
+
);
|
|
778
|
+
}
|
|
779
|
+
function _t({ metadata: t, theme: e, style: o }) {
|
|
780
|
+
const r = {
|
|
781
|
+
...o,
|
|
782
|
+
background: e.surfaceAlt,
|
|
783
|
+
borderBottom: `1px solid ${e.border}`,
|
|
784
|
+
padding: "6px 10px 6px 56px",
|
|
785
|
+
display: "flex",
|
|
786
|
+
flexWrap: "wrap",
|
|
787
|
+
gap: 6,
|
|
788
|
+
boxSizing: "border-box"
|
|
789
|
+
};
|
|
790
|
+
return n(
|
|
791
|
+
"div",
|
|
792
|
+
{ style: r },
|
|
793
|
+
...Object.entries(t).map(
|
|
794
|
+
([c, s]) => n(
|
|
795
|
+
"span",
|
|
796
|
+
{
|
|
797
|
+
key: c,
|
|
798
|
+
style: {
|
|
799
|
+
fontSize: 11,
|
|
800
|
+
fontFamily: "monospace",
|
|
801
|
+
color: e.textMuted,
|
|
802
|
+
background: e.surface,
|
|
803
|
+
border: `1px solid ${e.border}`,
|
|
804
|
+
borderRadius: 4,
|
|
805
|
+
padding: "1px 6px"
|
|
806
|
+
}
|
|
807
|
+
},
|
|
808
|
+
n("span", { style: { color: e.info } }, `${z(c)}: `),
|
|
809
|
+
z(String(s))
|
|
810
|
+
)
|
|
811
|
+
)
|
|
812
|
+
);
|
|
813
|
+
}
|
|
814
|
+
function Qt({
|
|
815
|
+
entries: t,
|
|
816
|
+
maxEntries: e = 500,
|
|
817
|
+
height: o = 400,
|
|
818
|
+
autoScroll: r = !0,
|
|
819
|
+
showLevel: c = !0,
|
|
820
|
+
showTimestamp: s = !0,
|
|
821
|
+
showSource: f = !0,
|
|
822
|
+
filterLevel: u,
|
|
823
|
+
searchQuery: x = "",
|
|
824
|
+
monospace: a = !0,
|
|
825
|
+
onEntryClick: m
|
|
826
|
+
}) {
|
|
827
|
+
const v = tt();
|
|
828
|
+
Dt();
|
|
829
|
+
const k = D(null), [b, y] = C(0), [W, E] = C(/* @__PURE__ */ new Set()), [B, L] = C(!1), $ = D(t.length), w = Q(() => {
|
|
830
|
+
let d = t.slice(-e);
|
|
831
|
+
if (u !== void 0) {
|
|
832
|
+
const l = mt[u];
|
|
833
|
+
d = d.filter((p) => mt[p.level] >= l);
|
|
834
|
+
}
|
|
835
|
+
if (x) {
|
|
836
|
+
const l = x.toLowerCase();
|
|
837
|
+
d = d.filter(
|
|
838
|
+
(p) => p.message.toLowerCase().includes(l) || (p.source ?? "").toLowerCase().includes(l)
|
|
839
|
+
);
|
|
840
|
+
}
|
|
841
|
+
return d;
|
|
842
|
+
}, [t, e, u, x]), P = typeof o == "number" ? o : 400, Y = 40, H = Q(() => {
|
|
843
|
+
const d = [];
|
|
844
|
+
let l = 0;
|
|
845
|
+
for (const p of w)
|
|
846
|
+
d.push(l), l += Z + (W.has(p.id) ? Y : 0);
|
|
847
|
+
return d.push(l), d;
|
|
848
|
+
}, [w, W]), g = H[H.length - 1] ?? 0;
|
|
849
|
+
V(() => {
|
|
850
|
+
!r || B || w.length !== $.current && ($.current = w.length, k.current && (k.current.scrollTop = k.current.scrollHeight));
|
|
851
|
+
}, [w.length, r, B]);
|
|
852
|
+
const T = K(() => {
|
|
853
|
+
if (!k.current) return;
|
|
854
|
+
const d = k.current, l = d.scrollHeight - d.scrollTop - d.clientHeight < Z * 2;
|
|
855
|
+
L(!l), y(d.scrollTop);
|
|
856
|
+
}, []), G = K((d) => {
|
|
857
|
+
E((l) => {
|
|
858
|
+
const p = new Set(l);
|
|
859
|
+
return p.has(d) ? p.delete(d) : p.add(d), p;
|
|
860
|
+
});
|
|
861
|
+
}, []);
|
|
862
|
+
function R(d) {
|
|
863
|
+
let l = 0, p = w.length - 1;
|
|
864
|
+
for (; l < p; ) {
|
|
865
|
+
const M = l + p >> 1;
|
|
866
|
+
(H[M + 1] ?? 0) <= d ? l = M + 1 : p = M;
|
|
867
|
+
}
|
|
868
|
+
return Math.max(0, l - yt);
|
|
869
|
+
}
|
|
870
|
+
function I(d) {
|
|
871
|
+
let l = 0, p = w.length - 1;
|
|
872
|
+
for (; l < p; ) {
|
|
873
|
+
const M = l + p + 1 >> 1;
|
|
874
|
+
(H[M] ?? 0) >= d + P ? p = M - 1 : l = M;
|
|
875
|
+
}
|
|
876
|
+
return Math.min(w.length - 1, l + yt);
|
|
877
|
+
}
|
|
878
|
+
const S = w.length > 0 ? R(b) : 0, N = w.length > 0 ? I(b) : -1, j = {
|
|
879
|
+
position: "relative",
|
|
880
|
+
overflow: "auto",
|
|
881
|
+
height: typeof o == "number" ? `${o}px` : o,
|
|
882
|
+
background: v.bg,
|
|
883
|
+
border: `1px solid ${v.border}`,
|
|
884
|
+
borderRadius: 8,
|
|
885
|
+
boxSizing: "border-box"
|
|
886
|
+
}, F = {
|
|
887
|
+
position: "relative",
|
|
888
|
+
height: g,
|
|
889
|
+
minHeight: "100%"
|
|
890
|
+
};
|
|
891
|
+
if (w.length === 0)
|
|
892
|
+
return n(
|
|
893
|
+
"div",
|
|
894
|
+
{ style: { ...j, display: "flex", alignItems: "center", justifyContent: "center" } },
|
|
895
|
+
n("span", { style: { color: v.textMuted, fontSize: 13, fontFamily: "monospace" } }, "No log entries.")
|
|
896
|
+
);
|
|
897
|
+
const A = [];
|
|
898
|
+
for (let d = S; d <= N; d++) {
|
|
899
|
+
const l = w[d];
|
|
900
|
+
if (!l) continue;
|
|
901
|
+
const p = H[d] ?? 0, M = W.has(l.id);
|
|
902
|
+
A.push(
|
|
903
|
+
n(Yt, {
|
|
904
|
+
key: l.id,
|
|
905
|
+
entry: l,
|
|
906
|
+
showLevel: c,
|
|
907
|
+
showTimestamp: s,
|
|
908
|
+
showSource: f,
|
|
909
|
+
searchQuery: x,
|
|
910
|
+
monospace: a,
|
|
911
|
+
isExpanded: M,
|
|
912
|
+
onToggle: () => G(l.id),
|
|
913
|
+
onEntryClick: m,
|
|
914
|
+
theme: v,
|
|
915
|
+
style: { position: "absolute", top: p, left: 0, right: 0 }
|
|
916
|
+
})
|
|
917
|
+
), M && l.metadata && Object.keys(l.metadata).length > 0 && A.push(
|
|
918
|
+
n(_t, {
|
|
919
|
+
key: `${l.id}-meta`,
|
|
920
|
+
metadata: l.metadata,
|
|
921
|
+
theme: v,
|
|
922
|
+
style: { position: "absolute", top: p + Z, left: 0, right: 0, height: Y }
|
|
923
|
+
})
|
|
924
|
+
);
|
|
925
|
+
}
|
|
926
|
+
return n(
|
|
927
|
+
"div",
|
|
928
|
+
{
|
|
929
|
+
ref: k,
|
|
930
|
+
style: j,
|
|
931
|
+
onScroll: T,
|
|
932
|
+
role: "log",
|
|
933
|
+
"aria-live": "polite",
|
|
934
|
+
"aria-label": "Log viewer"
|
|
935
|
+
},
|
|
936
|
+
n("div", { style: F }, ...A)
|
|
937
|
+
);
|
|
938
|
+
}
|
|
939
|
+
export {
|
|
940
|
+
qt as TkxLiveFeed,
|
|
941
|
+
Qt as TkxLiveLog,
|
|
942
|
+
Jt as TkxLiveMetrics,
|
|
943
|
+
Zt as TkxRealTimeChart
|
|
944
|
+
};
|