@overdoser/react-toolkit 0.11.0 → 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/AGENTS.md +2 -2
- package/CHANGELOG.md +94 -0
- package/components/Draggable/Draggable.d.ts +1 -1
- package/components/Draggable/Draggable.js +94 -84
- package/components/Timeline/GanttTimeline.d.ts +10 -0
- package/components/Timeline/GanttTimeline.js +193 -189
- package/components/Timeline/HistoryTimeline.d.ts +10 -0
- package/components/Timeline/HistoryTimeline.js +197 -193
- package/components/Timeline/Timeline.module.scss.js +114 -100
- package/components/Timeline/TimelineShared.d.ts +23 -2
- package/components/Timeline/TimelineShared.js +200 -127
- package/components/Timeline/TraceEventDetails.d.ts +92 -0
- package/components/Timeline/TraceEventDetails.js +181 -0
- package/components/Timeline/TraceTimeline.d.ts +34 -47
- package/components/Timeline/TraceTimeline.js +631 -612
- package/components/Timeline/TraceTimeline.module.scss.js +162 -144
- package/components/Timeline/demoData.d.ts +14 -0
- package/components/Timeline/index.d.ts +6 -1
- package/components/Timeline/timelineCore.d.ts +3 -2
- package/components/Timeline/timelineCore.js +41 -36
- package/components/Timeline/traceEvent.d.ts +128 -0
- package/components/Timeline/traceEvent.js +64 -0
- package/components/Timeline/useTimeline.d.ts +11 -0
- package/components/Timeline/useTimeline.js +36 -32
- package/index.css +1 -1
- package/index.d.ts +2 -2
- package/index.js +61 -55
- package/index.layered.css +1 -1
- package/llms.txt +36 -5
- package/manifest.json +653 -166
- package/package.json +1 -1
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
const s = /* @__PURE__ */ new Set([
|
|
2
|
+
"id",
|
|
3
|
+
"service",
|
|
4
|
+
"source",
|
|
5
|
+
"op",
|
|
6
|
+
"kind",
|
|
7
|
+
"level",
|
|
8
|
+
"message",
|
|
9
|
+
"payload",
|
|
10
|
+
"details",
|
|
11
|
+
"requestId",
|
|
12
|
+
"method",
|
|
13
|
+
"url",
|
|
14
|
+
"label",
|
|
15
|
+
"query",
|
|
16
|
+
"reqHeaders",
|
|
17
|
+
"reqBody",
|
|
18
|
+
"status",
|
|
19
|
+
"resHeaders",
|
|
20
|
+
"resBody",
|
|
21
|
+
"start",
|
|
22
|
+
"end"
|
|
23
|
+
]), o = [
|
|
24
|
+
"method",
|
|
25
|
+
"url",
|
|
26
|
+
"status",
|
|
27
|
+
"query",
|
|
28
|
+
"reqHeaders",
|
|
29
|
+
"reqBody",
|
|
30
|
+
"resHeaders",
|
|
31
|
+
"resBody"
|
|
32
|
+
], n = (e) => e.kind ? e.kind === "request" : o.some((r) => e[r] != null), u = (e) => e.op || e.requestId || e.reqHeaders && e.reqHeaders["x-request-id"] || e.id, i = (e) => e.source || (n(e) ? "client" : ""), l = (e) => {
|
|
33
|
+
const r = i(e);
|
|
34
|
+
return r ? r + " → " + e.service : e.service;
|
|
35
|
+
}, d = (e) => typeof e == "string" || typeof e == "number" || typeof e == "boolean", a = (e) => {
|
|
36
|
+
if (typeof e == "string") return e;
|
|
37
|
+
try {
|
|
38
|
+
return JSON.stringify(e, null, 2) ?? String(e);
|
|
39
|
+
} catch {
|
|
40
|
+
return String(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
function c(e, r) {
|
|
44
|
+
return r ? { text: n(e) ? "pending" : "ongoing", tone: "pending" } : typeof e.status == "number" ? { text: String(e.status), tone: e.status >= 400 ? "error" : "ok" } : e.level ? {
|
|
45
|
+
text: e.level,
|
|
46
|
+
tone: e.level === "error" ? "error" : e.level === "warning" ? "warn" : e.level === "success" ? "ok" : "pending"
|
|
47
|
+
} : null;
|
|
48
|
+
}
|
|
49
|
+
function f(e, r) {
|
|
50
|
+
return Object.keys(e).filter(
|
|
51
|
+
(t) => !s.has(t) && !r?.includes(t) && e[t] !== void 0 && typeof e[t] != "function"
|
|
52
|
+
).map((t) => ({ label: t, value: e[t] }));
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
s as KNOWN_KEYS,
|
|
56
|
+
c as badgeOf,
|
|
57
|
+
f as extraFieldsOf,
|
|
58
|
+
d as isInline,
|
|
59
|
+
n as isRequestEvent,
|
|
60
|
+
u as ridOf,
|
|
61
|
+
l as routeOf,
|
|
62
|
+
i as srcOf,
|
|
63
|
+
a as toText
|
|
64
|
+
};
|
|
@@ -30,6 +30,17 @@ export declare function animateScrollTo(el: HTMLElement, target: {
|
|
|
30
30
|
left?: number;
|
|
31
31
|
top?: number;
|
|
32
32
|
}, duration?: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* How the wheel interacts with timeline zoom. `'ctrl'` (the timelines'
|
|
35
|
+
* default) zooms only while Ctrl/Cmd is held — plain scrolling passes
|
|
36
|
+
* through to the page, and trackpad pinch keeps zooming since browsers
|
|
37
|
+
* report it as a `ctrlKey` wheel. `'free'` zooms on any wheel/trackpad
|
|
38
|
+
* scroll over the canvas, and `'none'` never wheel-zooms (the toolbar zoom
|
|
39
|
+
* buttons still work).
|
|
40
|
+
*/
|
|
41
|
+
export type TimelineWheelZoom = 'free' | 'ctrl' | 'none';
|
|
42
|
+
/** True when a wheel event should zoom under the given mode. */
|
|
43
|
+
export declare function wheelZoomAllowed(mode: TimelineWheelZoom, e: WheelEvent): boolean;
|
|
33
44
|
/**
|
|
34
45
|
* Attach a non-passive wheel listener (plain mouse wheel zooms; the default
|
|
35
46
|
* scroll must be preventable, which React's synthetic onWheel cannot do).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
function
|
|
1
|
+
import { useState as y, useEffect as v, useRef as h, useCallback as p } from "react";
|
|
2
|
+
function W(e) {
|
|
3
3
|
const n = h(null), o = h(!1), r = p(
|
|
4
4
|
(i) => {
|
|
5
5
|
const c = e.current;
|
|
@@ -8,21 +8,21 @@ function b(e) {
|
|
|
8
8
|
[e]
|
|
9
9
|
), t = p(
|
|
10
10
|
(i) => {
|
|
11
|
-
const c = n.current,
|
|
12
|
-
if (!c || !
|
|
13
|
-
const
|
|
14
|
-
Math.abs(
|
|
11
|
+
const c = n.current, u = e.current;
|
|
12
|
+
if (!c || !u) return;
|
|
13
|
+
const d = i.clientX - c.x, f = i.clientY - c.y;
|
|
14
|
+
Math.abs(d) + Math.abs(f) > 5 && (c.moved = !0), u.scrollLeft = c.l - d, u.scrollTop = c.t - f;
|
|
15
15
|
},
|
|
16
16
|
[e]
|
|
17
17
|
), s = p(() => {
|
|
18
18
|
n.current && n.current.moved && (o.current = !0, setTimeout(() => {
|
|
19
19
|
o.current = !1;
|
|
20
20
|
}, 60)), n.current = null;
|
|
21
|
-
}, []),
|
|
22
|
-
return { onPointerDown: r, onPointerMove: t, onPointerUp: s, wasDragSuppressed:
|
|
21
|
+
}, []), l = p(() => o.current, []);
|
|
22
|
+
return { onPointerDown: r, onPointerMove: t, onPointerUp: s, wasDragSuppressed: l };
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
const [o, r] =
|
|
24
|
+
function b(e, n = 1100) {
|
|
25
|
+
const [o, r] = y(n);
|
|
26
26
|
return v(() => {
|
|
27
27
|
const t = e.current;
|
|
28
28
|
if (!t) return;
|
|
@@ -32,50 +32,54 @@ function y(e, n = 1100) {
|
|
|
32
32
|
return s.observe(t), t.clientWidth && r(t.clientWidth), () => s.disconnect();
|
|
33
33
|
}, [e]), o;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
36
|
-
const [o, r] =
|
|
35
|
+
function A(e, n = 450) {
|
|
36
|
+
const [o, r] = y(() => Date.now());
|
|
37
37
|
return v(() => {
|
|
38
38
|
if (!e) return;
|
|
39
39
|
const t = setInterval(() => r(Date.now()), n);
|
|
40
40
|
return () => clearInterval(t);
|
|
41
41
|
}, [e, n]), e ? o : Date.now();
|
|
42
42
|
}
|
|
43
|
-
const
|
|
44
|
-
function
|
|
45
|
-
const r =
|
|
43
|
+
const w = /* @__PURE__ */ new WeakMap();
|
|
44
|
+
function D(e, n, o = 900) {
|
|
45
|
+
const r = w.get(e);
|
|
46
46
|
r != null && cancelAnimationFrame(r);
|
|
47
|
-
const t = e.scrollLeft, s = e.scrollTop,
|
|
48
|
-
if (!
|
|
47
|
+
const t = e.scrollLeft, s = e.scrollTop, l = n.left != null ? n.left - t : 0, i = n.top != null ? n.top - s : 0;
|
|
48
|
+
if (!l && !i) return;
|
|
49
49
|
if (typeof window < "u" && typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches || o <= 0) {
|
|
50
50
|
n.left != null && (e.scrollLeft = n.left), n.top != null && (e.scrollTop = n.top);
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
const
|
|
53
|
+
const u = performance.now(), d = (m) => 1 - Math.pow(1 - m, 3);
|
|
54
54
|
let f = !1;
|
|
55
|
-
const
|
|
56
|
-
f = !0, e.removeEventListener("wheel",
|
|
55
|
+
const a = () => {
|
|
56
|
+
f = !0, e.removeEventListener("wheel", a), e.removeEventListener("pointerdown", a), w.delete(e);
|
|
57
57
|
};
|
|
58
|
-
e.addEventListener("wheel",
|
|
59
|
-
const L = (
|
|
58
|
+
e.addEventListener("wheel", a, { once: !0 }), e.addEventListener("pointerdown", a, { once: !0 });
|
|
59
|
+
const L = (m) => {
|
|
60
60
|
if (f) return;
|
|
61
|
-
const T = Math.min(1, (
|
|
62
|
-
n.left != null && (e.scrollLeft = t +
|
|
61
|
+
const T = Math.min(1, (m - u) / o), M = d(T);
|
|
62
|
+
n.left != null && (e.scrollLeft = t + l * M), n.top != null && (e.scrollTop = s + i * M), T < 1 ? w.set(e, requestAnimationFrame(L)) : a();
|
|
63
63
|
};
|
|
64
|
-
|
|
64
|
+
w.set(e, requestAnimationFrame(L));
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function x(e, n) {
|
|
67
|
+
return e === "free" || e === "ctrl" && (n.ctrlKey || n.metaKey);
|
|
68
|
+
}
|
|
69
|
+
function P(e, n, o) {
|
|
67
70
|
const r = h(n);
|
|
68
71
|
r.current = n, v(() => {
|
|
69
72
|
const t = e.current;
|
|
70
73
|
if (!t) return;
|
|
71
|
-
const s = (
|
|
74
|
+
const s = (l) => r.current(l);
|
|
72
75
|
return t.addEventListener("wheel", s, { passive: !1 }), () => t.removeEventListener("wheel", s);
|
|
73
76
|
}, [e, o]);
|
|
74
77
|
}
|
|
75
78
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
D as animateScrollTo,
|
|
80
|
+
b as useContainerWidth,
|
|
81
|
+
A as useNowTicker,
|
|
82
|
+
W as useTimelinePan,
|
|
83
|
+
P as useWheelZoom,
|
|
84
|
+
x as wheelZoomAllowed
|
|
81
85
|
};
|