@overdoser/react-toolkit 0.8.1 → 0.9.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 (34) hide show
  1. package/AGENTS.md +6 -0
  2. package/CHANGELOG.md +84 -0
  3. package/components/Drawer/Drawer.js +88 -83
  4. package/components/Timeline/GanttTimeline.d.ts +144 -0
  5. package/components/Timeline/GanttTimeline.js +305 -0
  6. package/components/Timeline/GanttTimeline.module.scss.js +55 -0
  7. package/components/Timeline/HistoryTimeline.d.ts +184 -0
  8. package/components/Timeline/HistoryTimeline.js +445 -0
  9. package/components/Timeline/HistoryTimeline.module.scss.js +59 -0
  10. package/components/Timeline/Timeline.module.scss.js +111 -0
  11. package/components/Timeline/TimelineShared.d.ts +79 -0
  12. package/components/Timeline/TimelineShared.js +173 -0
  13. package/components/Timeline/TraceTimeline.d.ts +180 -0
  14. package/components/Timeline/TraceTimeline.js +511 -0
  15. package/components/Timeline/TraceTimeline.module.scss.js +105 -0
  16. package/components/Timeline/demoData.d.ts +42 -0
  17. package/components/Timeline/historyLayout.d.ts +82 -0
  18. package/components/Timeline/historyLayout.js +264 -0
  19. package/components/Timeline/index.d.ts +7 -0
  20. package/components/Timeline/timelineCore.d.ts +90 -0
  21. package/components/Timeline/timelineCore.js +135 -0
  22. package/components/Timeline/traceLayout.d.ts +72 -0
  23. package/components/Timeline/traceLayout.js +92 -0
  24. package/components/Timeline/useTimeline.d.ts +39 -0
  25. package/components/Timeline/useTimeline.js +81 -0
  26. package/components/inputs/Select/Select.js +158 -154
  27. package/index.css +1 -1
  28. package/index.d.ts +2 -0
  29. package/index.js +93 -87
  30. package/index.layered.css +1 -1
  31. package/llms.txt +113 -0
  32. package/manifest.json +323 -0
  33. package/package.json +1 -1
  34. package/recipes/live-timeline-feed.tsx +147 -0
@@ -0,0 +1,79 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { DraggablePosition } from '../Draggable';
3
+ /** Legend entry: colored dot + name. */
4
+ export interface TimelineLegendItem {
5
+ name: string;
6
+ color: string;
7
+ }
8
+ export declare function TimelineLegend({ items, className, }: {
9
+ items: TimelineLegendItem[];
10
+ className?: string;
11
+ }): import("react/jsx-runtime").JSX.Element | null;
12
+ export declare function TimelineZoomControls({ zoomPct, fitActive, onZoomIn, onZoomOut, onFit, hint, children, className, }: {
13
+ zoomPct: string;
14
+ fitActive: boolean;
15
+ onZoomIn: () => void;
16
+ onZoomOut: () => void;
17
+ onFit: () => void;
18
+ hint?: string;
19
+ children?: ReactNode;
20
+ className?: string;
21
+ }): import("react/jsx-runtime").JSX.Element;
22
+ export declare function TimelineSegmented<T extends string>({ value, options, onChange, }: {
23
+ value: T;
24
+ options: {
25
+ value: T;
26
+ label: string;
27
+ title?: string;
28
+ }[];
29
+ onChange: (v: T) => void;
30
+ }): import("react/jsx-runtime").JSX.Element;
31
+ /**
32
+ * Where the summary panel sits: docked beside the timeline (`'left'` /
33
+ * `'right'`), as a full-width block (`'top'` / `'bottom'`), or `'floating'` —
34
+ * a draggable palette over the timeline (grab it by its header).
35
+ */
36
+ export type TimelineSummaryPlacement = 'left' | 'right' | 'top' | 'bottom' | 'floating';
37
+ /** One dense row of the summary panel. */
38
+ export interface TimelineSummaryItem {
39
+ id: string;
40
+ /** Chronological number, zero-padded (`'01'`…). */
41
+ number: string;
42
+ label: ReactNode;
43
+ color: string;
44
+ /** Small right-aligned time text. */
45
+ time?: string;
46
+ /** Currently visible in the timeline viewport (band highlight). */
47
+ inView: boolean;
48
+ /** Open in the detail panel. */
49
+ selected?: boolean;
50
+ }
51
+ /**
52
+ * Dense one-line-per-event summary of the whole timeline. Rows currently
53
+ * visible in the timeline viewport carry a contiguous highlight band; while
54
+ * the timeline is panned the panel auto-scrolls to keep the band centered
55
+ * (suppressed while the pointer is over the panel so it can be scrolled
56
+ * independently). Clicking a row asks the timeline to scroll to that event.
57
+ */
58
+ export declare function TimelineSummary({ heading, items, onPick, placement, floatingDefaultPosition, className, }: {
59
+ heading?: ReactNode;
60
+ items: TimelineSummaryItem[];
61
+ onPick: (id: string) => void;
62
+ placement?: TimelineSummaryPlacement;
63
+ /** Floating placement: initial offset from the anchored top-left corner. */
64
+ floatingDefaultPosition?: DraggablePosition;
65
+ className?: string;
66
+ }): import("react/jsx-runtime").JSX.Element;
67
+ /** Fixed dark tooltip; positioned by the caller, opacity-only fade. */
68
+ export declare function TimelineTooltip({ x, y, children, className, style, }: {
69
+ x: number;
70
+ y: number;
71
+ children: ReactNode;
72
+ className?: string;
73
+ style?: CSSProperties;
74
+ }): import("react/jsx-runtime").JSX.Element;
75
+ /** Text with keyword-matched substrings wrapped in highlight marks. */
76
+ export declare function HighlightText({ text, query }: {
77
+ text: unknown;
78
+ query?: string;
79
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,173 @@
1
+ import { jsxs as u, Fragment as N, jsx as n } from "react/jsx-runtime";
2
+ import { useRef as C, useEffect as B } from "react";
3
+ import m from "clsx";
4
+ import e from "./Timeline.module.scss.js";
5
+ import { highlightParts as z } from "./timelineCore.js";
6
+ import { Draggable as H } from "../Draggable/Draggable.js";
7
+ function S({
8
+ items: l,
9
+ className: s
10
+ }) {
11
+ return l.length ? /* @__PURE__ */ n("div", { className: m(e.legend, s), children: l.map((r) => /* @__PURE__ */ u("span", { className: e.legendItem, children: [
12
+ /* @__PURE__ */ n("span", { className: e.legendDot, style: { background: r.color } }),
13
+ r.name
14
+ ] }, r.name)) }) : null;
15
+ }
16
+ function V({
17
+ zoomPct: l,
18
+ fitActive: s,
19
+ onZoomIn: r,
20
+ onZoomOut: t,
21
+ onFit: i,
22
+ hint: h,
23
+ children: f,
24
+ className: d
25
+ }) {
26
+ return /* @__PURE__ */ u("div", { className: m(e.controls, d), children: [
27
+ f,
28
+ /* @__PURE__ */ n("button", { type: "button", className: e.zoomBtn, title: "Zoom out", onClick: t, children: "−" }),
29
+ /* @__PURE__ */ n("span", { className: e.zoomPct, children: l }),
30
+ /* @__PURE__ */ n("button", { type: "button", className: e.zoomBtn, title: "Zoom in", onClick: r, children: "+" }),
31
+ /* @__PURE__ */ n(
32
+ "button",
33
+ {
34
+ type: "button",
35
+ className: m(e.fitBtn, s && e.fitBtnActive),
36
+ onClick: i,
37
+ children: "Fit"
38
+ }
39
+ ),
40
+ h ? /* @__PURE__ */ n("span", { className: e.controlsHint, children: h }) : null
41
+ ] });
42
+ }
43
+ function A({
44
+ value: l,
45
+ options: s,
46
+ onChange: r
47
+ }) {
48
+ return /* @__PURE__ */ n("div", { className: e.segmented, children: s.map((t) => /* @__PURE__ */ n(
49
+ "button",
50
+ {
51
+ type: "button",
52
+ title: t.title,
53
+ className: m(e.segmentedBtn, t.value === l && e.segmentedBtnActive),
54
+ onClick: () => r(t.value),
55
+ children: t.label
56
+ },
57
+ t.value
58
+ )) });
59
+ }
60
+ function M({
61
+ heading: l = "Events",
62
+ items: s,
63
+ onPick: r,
64
+ placement: t = "left",
65
+ floatingDefaultPosition: i,
66
+ className: h
67
+ }) {
68
+ const f = C(null), d = C(!1), p = t === "floating", b = t === "top" || t === "bottom";
69
+ let c = -1, y = -1;
70
+ s.forEach((a, o) => {
71
+ a.inView && (c < 0 && (c = o), y = o);
72
+ });
73
+ const v = c === 0 && y === s.length - 1;
74
+ B(() => {
75
+ const a = f.current;
76
+ if (!a || d.current || c < 0 || v) return;
77
+ const o = a.querySelectorAll("[data-timeline-summary-row]"), k = o[c], g = o[y];
78
+ if (!k || !g) return;
79
+ const x = (k.offsetTop + g.offsetTop + g.offsetHeight) / 2;
80
+ a.scrollTop = Math.max(0, x - a.clientHeight / 2);
81
+ }, [c, y, v]);
82
+ const w = /* @__PURE__ */ u(N, { children: [
83
+ /* @__PURE__ */ u("span", { children: [
84
+ p && /* @__PURE__ */ n("span", { className: e.summaryGrip, "aria-hidden": !0, children: "⠿" }),
85
+ l
86
+ ] }),
87
+ /* @__PURE__ */ n("span", { className: e.summaryCount, children: s.length })
88
+ ] }), T = /* @__PURE__ */ u(
89
+ "div",
90
+ {
91
+ className: m(
92
+ e.summary,
93
+ b && e.summaryHorizontal,
94
+ t === "top" && e.summaryTop,
95
+ t === "bottom" && e.summaryBottom,
96
+ p && e.summaryFloatingCard,
97
+ h
98
+ ),
99
+ onMouseEnter: () => {
100
+ d.current = !0;
101
+ },
102
+ onMouseLeave: () => {
103
+ d.current = !1;
104
+ },
105
+ children: [
106
+ p ? /* @__PURE__ */ n(H.Handle, { className: m(e.summaryHeader, e.summaryHandle), children: w }) : /* @__PURE__ */ n("div", { className: e.summaryHeader, children: w }),
107
+ /* @__PURE__ */ n(
108
+ "div",
109
+ {
110
+ ref: f,
111
+ className: m(e.summaryList, b && e.summaryListGrid),
112
+ children: s.map((a) => /* @__PURE__ */ u(
113
+ "div",
114
+ {
115
+ "data-timeline-summary-row": !0,
116
+ role: "button",
117
+ tabIndex: 0,
118
+ className: m(
119
+ e.summaryRow,
120
+ a.inView && e.summaryRowInView,
121
+ a.selected && e.summaryRowSelected
122
+ ),
123
+ onClick: () => r(a.id),
124
+ onKeyDown: (o) => {
125
+ (o.key === "Enter" || o.key === " ") && (o.preventDefault(), r(a.id));
126
+ },
127
+ children: [
128
+ /* @__PURE__ */ n("span", { className: e.summaryNum, children: a.number }),
129
+ /* @__PURE__ */ n("span", { className: e.summaryDot, style: { background: a.color } }),
130
+ /* @__PURE__ */ n("span", { className: e.summaryLabel, children: a.label }),
131
+ a.time && /* @__PURE__ */ n("span", { className: e.summaryTime, children: a.time })
132
+ ]
133
+ },
134
+ a.id
135
+ ))
136
+ }
137
+ )
138
+ ]
139
+ }
140
+ );
141
+ return p ? /* @__PURE__ */ n(
142
+ H,
143
+ {
144
+ className: e.summaryFloating,
145
+ bounds: "viewport",
146
+ defaultPosition: i ?? { x: 0, y: 0 },
147
+ children: T
148
+ }
149
+ ) : T;
150
+ }
151
+ function Z({
152
+ x: l,
153
+ y: s,
154
+ children: r,
155
+ className: t,
156
+ style: i
157
+ }) {
158
+ return /* @__PURE__ */ n("div", { className: m(e.tooltip, t), style: { left: l, top: s, ...i }, children: r });
159
+ }
160
+ function j({ text: l, query: s }) {
161
+ const r = z(l, s);
162
+ return r.length === 1 && !r[0].hit ? /* @__PURE__ */ n(N, { children: r[0].t }) : /* @__PURE__ */ n(N, { children: r.map(
163
+ (t, i) => t.hit ? /* @__PURE__ */ n("span", { className: e.mark, children: t.t }, i) : /* @__PURE__ */ n("span", { children: t.t }, i)
164
+ ) });
165
+ }
166
+ export {
167
+ j as HighlightText,
168
+ S as TimelineLegend,
169
+ A as TimelineSegmented,
170
+ M as TimelineSummary,
171
+ Z as TimelineTooltip,
172
+ V as TimelineZoomControls
173
+ };
@@ -0,0 +1,180 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { TimelineSummaryPlacement } from './TimelineShared';
3
+ import { DraggablePosition } from '../Draggable';
4
+ /**
5
+ * One request/response (or custom) event on the trace. Only `id`, `service`
6
+ * and `start` are required — everything else enriches the chip, tooltip and
7
+ * detail panel when present. Extra fields are allowed and participate in
8
+ * keyword matching.
9
+ */
10
+ export interface TraceTimelineEvent {
11
+ /** Stable identifier. */
12
+ id: string;
13
+ /** Target component/service the event belongs to (colors the bar). */
14
+ service: string;
15
+ /** Caller shown as the chip's origin badge. @default 'client' */
16
+ source?: string;
17
+ /** Friendly operation id, bold in the chip (e.g. `create_manifest`). */
18
+ op?: string;
19
+ /** Technical request id (fallback chip label; shown in the detail panel). */
20
+ requestId?: string;
21
+ /** HTTP method for the detail panel badge. */
22
+ method?: string;
23
+ /** Full URL (detail panel + tooltip). */
24
+ url?: string;
25
+ /** Short label for the tooltip. Defaults to `method + path`. */
26
+ label?: string;
27
+ /** Query parameters (detail panel). */
28
+ query?: Record<string, string>;
29
+ /** Request headers (detail panel; `x-request-id` is surfaced). */
30
+ reqHeaders?: Record<string, string>;
31
+ /** Request body, pretty-printed as JSON in the detail panel. */
32
+ reqBody?: unknown;
33
+ /** Response status; `>= 400` renders as an error badge. */
34
+ status?: number;
35
+ /** Response headers (detail panel). */
36
+ resHeaders?: Record<string, string>;
37
+ /** Response body, pretty-printed as JSON in the detail panel. */
38
+ resBody?: unknown;
39
+ /** Start time, epoch ms (UTC display). */
40
+ start: number;
41
+ /** End time, epoch ms. `null`/`undefined` while in flight (bar grows live). */
42
+ end?: number | null;
43
+ [extra: string]: unknown;
44
+ }
45
+ export interface TraceTimelineClasses {
46
+ root: string;
47
+ toolbar: string;
48
+ legend: string;
49
+ card: string;
50
+ scroller: string;
51
+ axis: string;
52
+ bar: string;
53
+ chip: string;
54
+ summary: string;
55
+ search: string;
56
+ drawer: string;
57
+ tooltip: string;
58
+ footnote: string;
59
+ }
60
+ /** Context handed to the TraceTimeline render-prop slots. */
61
+ export interface TraceTimelineItemContext {
62
+ /** Resolved service color. */
63
+ color: string;
64
+ /** True while the event has no end (in flight). */
65
+ pending: boolean;
66
+ /** Duration so far, ms. */
67
+ durationMs: number;
68
+ }
69
+ export interface TraceTimelineProps {
70
+ /**
71
+ * Events sharing one trace (e.g. all events of one manifest). The component
72
+ * imposes no correlation rule — pass whatever set belongs together;
73
+ * filtering/grouping is the consumer's concern. Pushing a new array with an
74
+ * event's `end`/`status`/response fields filled completes it in place.
75
+ */
76
+ events: TraceTimelineEvent[];
77
+ /** Toolbar title (e.g. `MAN-2481 — Big Buck Bunny`). */
78
+ title?: ReactNode;
79
+ /** Toolbar meta. Defaults to `N events · span · times in UTC`. */
80
+ meta?: ReactNode;
81
+ /**
82
+ * Controlled keyword highlight: case-insensitive AND over
83
+ * whitespace-separated tokens against each event's JSON. Matches get an
84
+ * amber wash + ring and marked substrings; non-matches dim. When set, the
85
+ * built-in search box reflects it — pair with `onHighlightChange` (or use
86
+ * `defaultHighlight` for uncontrolled).
87
+ */
88
+ highlight?: string;
89
+ /** Initial keyword for the built-in search box (uncontrolled). */
90
+ defaultHighlight?: string;
91
+ /** Fired when the keyword changes via the built-in box or `renderSearch`. */
92
+ onHighlightChange?: (value: string) => void;
93
+ /** Built-in "Highlight keyword…" box in the toolbar. @default true */
94
+ showSearch?: boolean;
95
+ /** Replace the built-in search box with a custom element in the toolbar. */
96
+ renderSearch?: (api: {
97
+ value: string;
98
+ setValue: (value: string) => void;
99
+ }) => ReactNode;
100
+ /**
101
+ * Seeds the service→color assignment order (first entries get the first
102
+ * palette slots, keeping colors stable across traces). Services found in
103
+ * `events` but not listed here are appended in order of appearance.
104
+ */
105
+ services?: string[];
106
+ /** Explicit service→color overrides (any CSS color). */
107
+ serviceColors?: Record<string, string>;
108
+ /** Tighter chip rows and 20px bars. @default false */
109
+ compactRows?: boolean;
110
+ /** Vertical gridlines under each axis tick. @default true */
111
+ showGridlines?: boolean;
112
+ /** Toolbar row with the zoom −/%/+/Fit controls. @default true */
113
+ showControls?: boolean;
114
+ /** Colored dot + name legend for the services present. @default true */
115
+ showLegend?: boolean;
116
+ /**
117
+ * Dense one-line-per-event summary panel beside the timeline: all events
118
+ * numbered chronologically from `01`, a highlight band over the events
119
+ * currently visible in the viewport (auto-follows drag-panning), and
120
+ * click-to-navigate — the timeline smooth-scrolls (~1s, decelerating) to
121
+ * center the picked event. The panel scrolls independently.
122
+ * @default false
123
+ */
124
+ showSummary?: boolean;
125
+ /**
126
+ * Where the summary panel sits: docked `'left'`/`'right'` of the timeline,
127
+ * full-width `'top'`/`'bottom'`, or `'floating'` — a draggable palette over
128
+ * the timeline, grabbed by its header. @default 'left'
129
+ */
130
+ summaryPlacement?: TimelineSummaryPlacement;
131
+ /** Floating summary: initial offset from the component's top-left corner. */
132
+ summaryDefaultPosition?: DraggablePosition;
133
+ /** Max height of the scrollable canvas. @default '80vh' */
134
+ maxHeight?: number | string;
135
+ /** Controlled id of the event open in the detail panel (`null` = closed). */
136
+ selectedEventId?: string | null;
137
+ /** Initially open event (uncontrolled). */
138
+ defaultSelectedEventId?: string | null;
139
+ /** Fired when an event is opened (event) or closed (`null`). */
140
+ onEventSelect?: (event: TraceTimelineEvent | null) => void;
141
+ /**
142
+ * Replace the description chip's inner content (default: origin → target
143
+ * badges, operation id, start ISO). The chip box width is still estimated
144
+ * from the default text, so keep custom content roughly equivalent in size.
145
+ */
146
+ renderChip?: (event: TraceTimelineEvent, ctx: TraceTimelineItemContext) => ReactNode;
147
+ /** Replace the tooltip content. Return `null` to suppress it for that event. */
148
+ renderTooltip?: (event: TraceTimelineEvent, ctx: TraceTimelineItemContext) => ReactNode;
149
+ /** Replace the request/response detail panel content; the panel shell is kept. */
150
+ renderDetails?: (event: TraceTimelineEvent, api: {
151
+ close: () => void;
152
+ pending: boolean;
153
+ }) => ReactNode;
154
+ /** Override class names on internal elements. */
155
+ classes?: Partial<TraceTimelineClasses>;
156
+ className?: string;
157
+ style?: CSSProperties;
158
+ }
159
+ /**
160
+ * Request/response trace timeline: all events of one correlated flow (a
161
+ * "manifest", an order, a saga…) as duration bars on a single proportional
162
+ * time band, packed into sub-rows when they overlap. Each event gets a
163
+ * collision-free description chip (`Origin → Target`, operation id, start
164
+ * ISO) placed by the handoff's 3-pass nudging algorithm. UTC two-rail sticky
165
+ * axis with cursor timestamp chip, day-change date labels and a sticky
166
+ * current-date marker; wheel-zoom, drag-pan, fit-to-width; keyword
167
+ * highlighting; in-flight events render dashed with a "now" line and grow
168
+ * live; clicking opens a request/response detail side panel.
169
+ *
170
+ * @example
171
+ * ```tsx
172
+ * <TraceTimeline
173
+ * title="MAN-2481 — Big Buck Bunny"
174
+ * events={eventsOfSelectedManifest}
175
+ * highlight={keyword}
176
+ * onEventSelect={(ev) => console.log(ev?.id)}
177
+ * />
178
+ * ```
179
+ */
180
+ export declare const TraceTimeline: import('react').ForwardRefExoticComponent<TraceTimelineProps & import('react').RefAttributes<HTMLDivElement>>;