@overdoser/react-toolkit 0.8.3 → 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 (32) hide show
  1. package/AGENTS.md +6 -0
  2. package/CHANGELOG.md +35 -0
  3. package/components/Timeline/GanttTimeline.d.ts +144 -0
  4. package/components/Timeline/GanttTimeline.js +305 -0
  5. package/components/Timeline/GanttTimeline.module.scss.js +55 -0
  6. package/components/Timeline/HistoryTimeline.d.ts +184 -0
  7. package/components/Timeline/HistoryTimeline.js +445 -0
  8. package/components/Timeline/HistoryTimeline.module.scss.js +59 -0
  9. package/components/Timeline/Timeline.module.scss.js +111 -0
  10. package/components/Timeline/TimelineShared.d.ts +79 -0
  11. package/components/Timeline/TimelineShared.js +173 -0
  12. package/components/Timeline/TraceTimeline.d.ts +180 -0
  13. package/components/Timeline/TraceTimeline.js +511 -0
  14. package/components/Timeline/TraceTimeline.module.scss.js +105 -0
  15. package/components/Timeline/demoData.d.ts +42 -0
  16. package/components/Timeline/historyLayout.d.ts +82 -0
  17. package/components/Timeline/historyLayout.js +264 -0
  18. package/components/Timeline/index.d.ts +7 -0
  19. package/components/Timeline/timelineCore.d.ts +90 -0
  20. package/components/Timeline/timelineCore.js +135 -0
  21. package/components/Timeline/traceLayout.d.ts +72 -0
  22. package/components/Timeline/traceLayout.js +92 -0
  23. package/components/Timeline/useTimeline.d.ts +39 -0
  24. package/components/Timeline/useTimeline.js +81 -0
  25. package/index.css +1 -1
  26. package/index.d.ts +2 -0
  27. package/index.js +93 -87
  28. package/index.layered.css +1 -1
  29. package/llms.txt +113 -0
  30. package/manifest.json +323 -0
  31. package/package.json +1 -1
  32. package/recipes/live-timeline-feed.tsx +147 -0
package/llms.txt CHANGED
@@ -1276,6 +1276,119 @@ Example:
1276
1276
  <Sparkline data={[1, 3, 2, 4, 3, 5, 4]} fill showLastPoint />
1277
1277
  ```
1278
1278
 
1279
+ ### Timelines: TraceTimeline, HistoryTimeline, GanttTimeline
1280
+ Import: `import { TraceTimeline, HistoryTimeline, GanttTimeline } from '@overdoser/react-toolkit'`
1281
+
1282
+ Three event-timeline views sharing one interaction model: wheel-zoom anchored at the cursor, drag-to-pan, a Fit button (default; refits on container resize, e.g. when the detail panel opens), keyword highlighting (case-insensitive AND over whitespace-separated tokens against each item's JSON — matches get an amber wash + marked substrings, non-matches dim; a built-in "Highlight keyword…" box renders in the toolbar by default — hide it with `showSearch={false}`, inject a custom element with `renderSearch({ value, setValue })`, or drive it externally via the controlled `highlight` + `onHighlightChange`, `defaultHighlight` for uncontrolled), hover tooltips, and click-to-open detail side panel (a flex sibling, not a modal — the timeline stays navigable; wraps below on narrow screens).
1283
+
1284
+ **Data flow (all three):** fully controlled — you pass the array; the component does NO filtering, grouping or fetching. Pre-process events (e.g. pick one manifest's/subject's events) on the consumer side and pass new arrays for live feeds. Items whose end time is unset (`end: null`/omitted) render as live (dashed/pulsing) and grow on an internal ~400–500ms ticker until an update supplies `end`. Selection is optionally controllable (`selectedEventId`/`selectedTaskId` + `defaultSelected*` + `onEventSelect`/`onTaskSelect`; the panel re-resolves the selected item from the current array, so an in-flight response fills in live). All three forward ref to the root `div` and accept `className`, `style`, `classes`.
1285
+
1286
+ Theming: `--crk-timeline-1..6` category palette (cycled over services/tags/rows), plus `--crk-timeline-*` chrome tokens (ink, muted, hairline, grid, accent, highlight amber…) defaulting to the design's warm paper palette; `--crk-timeline-font-mono` / `--crk-timeline-font-display` for the data/display fonts.
1287
+
1288
+ **Summary panel (all three):** `showSummary` (default `false`) adds a dense one-line-per-item panel beside the timeline — every item numbered chronologically from `01`, a contiguous highlight band over the items currently visible in the viewport (auto-follows drag-panning by keeping the band centered in the list; suppressed while the pointer is over the panel so it can scroll independently), and click-to-navigate: the timeline smooth-scrolls (~900ms ease-out deceleration, cancelled by user wheel/grab, instant under `prefers-reduced-motion`) to center the picked item. `summaryPlacement` docks it `'left'` (default) / `'right'` of the timeline, renders it full-width `'top'` / `'bottom'` (rows flow into responsive columns), or `'floating'` — a draggable palette anchored over the timeline, grabbed by its header (viewport-bounded, arrow-key movable when the handle is focused); `summaryDefaultPosition?: { x, y }` sets the floating start offset.
1289
+
1290
+ **Customization layers (all three):** (1) `--crk-timeline-*` tokens for colors/fonts; (2) `classes` for per-element class overrides; (3) **render-prop slots to inject custom components** — `renderChip`/`renderCard`/`renderBar`+`renderRowLabel` replace an item's inner content (positioning/geometry stays component-owned), `renderTooltip(item, ctx)` replaces tooltip content (return `null` to suppress it for that item), `renderDetails(item, { close, … })` replaces the side-panel content (the sticky panel shell is kept; call `close()` from your own ✕). Each slot receives a context object (`*ItemContext`: resolved `color`, live flag, `durationMs`, index/number where relevant).
1291
+
1292
+ #### TraceTimeline
1293
+ One correlated request/response flow (a "manifest", an order, a saga) as duration bars on a single proportional time band (UTC display). Overlapping bars pack into vertical sub-rows; each event gets a collision-free description chip (`Origin → Target` tinted badges, bold operation id, start ISO) placed by a 3-pass nudging algorithm (never overlaps another chip; slides with an elbow line or accepts a stem crossing rather than hiding). Sticky two-rail UTC axis: cursor timestamp chip, teal `▸ start` chip for the hovered event, tick clock labels, `YYYY-MM-DD` labels only on day changes, and a sticky current-date label. Events whose interval contains the cursor time get a "hot" ring.
1294
+
1295
+ `TraceTimelineEvent`: `{ id: string; service: string; source?; op?; requestId?; method?; url?; label?; query?: Record<string,string>; reqHeaders?; reqBody?; status?: number; resHeaders?; resBody?; start: number; end?: number | null }` — only `id`, `service`, `start` required; extra fields allowed (searched by `highlight`). `end` unset = in flight (dashed bar, pulsing dot, "now" line, "Awaiting response…" panel).
1296
+
1297
+ Props:
1298
+ - `events: TraceTimelineEvent[]` — one correlated set; correlation key is your concern.
1299
+ - `title?: ReactNode`, `meta?: ReactNode` — toolbar; meta defaults to `N events · span · times in UTC`.
1300
+ - `highlight?: string` (controlled) / `defaultHighlight?: string` / `onHighlightChange?: (value) => void`
1301
+ - `showSearch?: boolean` — default `true` (built-in highlight box in the toolbar); `renderSearch?: ({ value, setValue }) => ReactNode` replaces it.
1302
+ - `services?: string[]` — seeds service→color assignment order (stable colors across traces).
1303
+ - `serviceColors?: Record<string, string>` — explicit color overrides.
1304
+ - `compactRows?: boolean` — default `false`.
1305
+ - `showGridlines?: boolean` — default `true`.
1306
+ - `showControls?: boolean` — default `true` (zoom −/%/+/Fit).
1307
+ - `showLegend?: boolean` — default `true`.
1308
+ - `showSummary?: boolean` — default `false`. Summary panel (see above).
1309
+ - `summaryPlacement?: 'left' | 'right' | 'top' | 'bottom' | 'floating'` — default `'left'`; `summaryDefaultPosition?: { x, y }` for floating.
1310
+ - `maxHeight?: number | string` — default `'80vh'`.
1311
+ - `selectedEventId?: string | null`, `defaultSelectedEventId?`, `onEventSelect?: (ev | null) => void`
1312
+ - `renderChip?: (ev, ctx: TraceTimelineItemContext) => ReactNode` — replace the chip's inner content (chip box width is still estimated from the default text).
1313
+ - `renderTooltip?: (ev, ctx) => ReactNode` — replace tooltip content; return `null` to suppress.
1314
+ - `renderDetails?: (ev, { close, pending }) => ReactNode` — replace the request/response panel content.
1315
+ - `classes?: Partial<TraceTimelineClasses>` where `TraceTimelineClasses = { root, toolbar, legend, card, scroller, axis, bar, chip, summary, search, drawer, tooltip, footnote }`
1316
+
1317
+ Example:
1318
+ ```tsx
1319
+ <TraceTimeline
1320
+ title={`${manifest.id} — ${manifest.title}`}
1321
+ events={manifest.events}
1322
+ services={['Ingest API', 'Transcode', 'Packager']}
1323
+ highlight={keyword}
1324
+ />
1325
+ ```
1326
+
1327
+ #### HistoryTimeline
1328
+ The life of one subject as numbered event cards alternating around a central axis — above/below (horizontal) or left/right (vertical) — with collision-free placement: clustered side split, circles stepping outward in 20px levels, straight or Z-shaped leads, and dense bursts condensing into stacked groups. Three spacing modes: `equal` (index-based), `log` (gap-compressed — bursts stay readable next to huge gaps), `proportional` (linear time, real ticks from seconds to centuries). Fit expands the time axis until the card stacks fit the cross axis without scrolling. Tooltips appear only when they add information (truncated detail or ongoing).
1329
+
1330
+ `HistoryTimelineEvent`: `{ id: string; title: string; detail?; tag?; subject?; start: number; end?: number | null; ongoing?: boolean }` — `end === start`/omitted = instant; `end: null` (or `ongoing: true`) = ongoing (pulsing dot, growing duration badge).
1331
+
1332
+ Props:
1333
+ - `events: HistoryTimelineEvent[]` — one subject's events (you filter).
1334
+ - `subjectName?: ReactNode` — detail-panel subtitle.
1335
+ - `orientation?: 'horizontal' | 'vertical'` (controlled), `defaultOrientation?` (defaults to horizontal, vertical on <700px viewports), `onOrientationChange?`
1336
+ - `spacing?: 'equal' | 'log' | 'proportional'` (controlled), `defaultSpacing?` — default `'equal'`, `onSpacingChange?`
1337
+ - `highlight?: string` (controlled) / `defaultHighlight?: string` / `onHighlightChange?: (value) => void`
1338
+ - `showSearch?: boolean` — default `true`; `renderSearch?: ({ value, setValue }) => ReactNode` replaces the built-in box.
1339
+ - `tagColors?: Record<string, string>` — overrides; known tags map to the palette, unknown tags cycle it.
1340
+ - `showControls?: boolean` — default `true` (orientation + spacing toggles + zoom).
1341
+ - `showLegend?: boolean` — default `true` (tag bullets).
1342
+ - `showSummary?: boolean` — default `false`. Summary panel (see above); numbering matches the card numbers.
1343
+ - `summaryPlacement?: 'left' | 'right' | 'top' | 'bottom' | 'floating'` — default `'left'`; `summaryDefaultPosition?: { x, y }` for floating.
1344
+ - `maxHeight?: number | string` — defaults 84vh (horizontal) / 78vh (vertical).
1345
+ - `selectedEventId?: string | null`, `defaultSelectedEventId?`, `onEventSelect?`
1346
+ - `renderCard?: (ev, ctx: HistoryTimelineItemContext) => ReactNode` — replace the card's inner content (card box size is still computed from the default content, so keep custom content roughly equivalent).
1347
+ - `renderTooltip?: (ev, ctx) => ReactNode` — when set, the tooltip shows for every hover (not only when it adds info); return `null` to suppress.
1348
+ - `renderDetails?: (ev, { close, ongoing }) => ReactNode` — replace the detail panel content.
1349
+ - `classes?: Partial<HistoryTimelineClasses>` where `HistoryTimelineClasses = { root, toolbar, legend, card, scroller, eventCard, dot, summary, search, drawer, tooltip, footnote }`
1350
+
1351
+ Example:
1352
+ ```tsx
1353
+ <HistoryTimeline
1354
+ subjectName="Order ORD-58291"
1355
+ events={orderEvents}
1356
+ defaultSpacing="log"
1357
+ />
1358
+ ```
1359
+
1360
+ #### GanttTimeline
1361
+ Gantt-style task list: rows sorted by start time with a sticky 230px label column (name + `start → end` dates) and sticky time axis; horizontal pill bars proportional to duration, colored by row from the palette. Finished bars are solid (duration text inside when the bar is wide enough, else beside it); running bars (no `end`) are tinted + dashed with a pulsing dot and keep growing; a teal "now" line marks the present.
1362
+
1363
+ `GanttTimelineTask`: `{ id: string; name: string; detail?; owner?; start: number; end?: number | null }` — `end` unset = running.
1364
+
1365
+ Props:
1366
+ - `tasks: GanttTimelineTask[]`
1367
+ - `title?: ReactNode`, `meta?: ReactNode` — meta defaults to `N tasks · span · K running`.
1368
+ - `highlight?: string` (controlled) / `defaultHighlight?: string` / `onHighlightChange?: (value) => void`
1369
+ - `showSearch?: boolean` — default `true`; `renderSearch?: ({ value, setValue }) => ReactNode` replaces the built-in box.
1370
+ - `compactRows?: boolean` — default `false` (42px rows instead of 54px).
1371
+ - `showGridlines?: boolean` — default `true`.
1372
+ - `showControls?: boolean` — default `true`.
1373
+ - `showSummary?: boolean` — default `false`. Summary panel (see above; heading "Tasks").
1374
+ - `summaryPlacement?: 'left' | 'right' | 'top' | 'bottom' | 'floating'` — default `'left'`; `summaryDefaultPosition?: { x, y }` for floating.
1375
+ - `maxHeight?: number | string` — default `'74vh'`.
1376
+ - `selectedTaskId?: string | null`, `defaultSelectedTaskId?`, `onTaskSelect?: (task | null) => void`
1377
+ - `renderRowLabel?: (task, ctx: GanttTimelineItemContext) => ReactNode` — replace the sticky label-column content.
1378
+ - `renderBar?: (task, ctx) => ReactNode` — replace the bar pill's inner content (also suppresses the outside duration text).
1379
+ - `renderTooltip?: (task, ctx) => ReactNode` — replace tooltip content; return `null` to suppress.
1380
+ - `renderDetails?: (task, { close, running }) => ReactNode` — replace the detail panel content.
1381
+ - `classes?: Partial<GanttTimelineClasses>` where `GanttTimelineClasses = { root, toolbar, card, scroller, axis, row, rowLabel, bar, summary, search, drawer, tooltip, footnote }`
1382
+
1383
+ Example:
1384
+ ```tsx
1385
+ <GanttTimeline
1386
+ title="Platform Relaunch — Q3"
1387
+ tasks={tasks}
1388
+ onTaskSelect={(t) => setSelected(t?.id ?? null)}
1389
+ />
1390
+ ```
1391
+
1279
1392
  ## Hooks
1280
1393
 
1281
1394
  ### useClickOutside
package/manifest.json CHANGED
@@ -2605,6 +2605,329 @@
2605
2605
  "type": "string"
2606
2606
  }
2607
2607
  }
2608
+ },
2609
+ "TraceTimeline": {
2610
+ "import": "import { TraceTimeline } from '@overdoser/react-toolkit'",
2611
+ "element": "div",
2612
+ "forwardsRef": true,
2613
+ "behavior": "Request/response trace of one correlated flow on a single proportional UTC time band. Overlapping bars pack into sub-rows; description chips are placed collision-free (3-pass nudging). Wheel-zoom, drag-pan, Fit, keyword highlight, hover tooltip, click-to-open request/response side panel. Fully controlled data: pass the pre-filtered array; the component does no filtering/grouping. Items with an unset end render live (dashed/pulsing) and grow on an internal ticker until an update supplies end.",
2614
+ "props": {
2615
+ "events": {
2616
+ "type": "TraceTimelineEvent[]",
2617
+ "required": true,
2618
+ "notes": "TraceTimelineEvent = { id, service, start, source?, op?, requestId?, method?, url?, label?, query?, reqHeaders?, reqBody?, status?, resHeaders?, resBody?, end?: number|null }. end unset = in flight."
2619
+ },
2620
+ "title": {
2621
+ "type": "ReactNode"
2622
+ },
2623
+ "meta": {
2624
+ "type": "ReactNode",
2625
+ "notes": "Defaults to 'N events · span · times in UTC'."
2626
+ },
2627
+ "highlight": {
2628
+ "type": "string",
2629
+ "notes": "Case-insensitive AND over whitespace tokens vs event JSON; matches glow amber, non-matches dim."
2630
+ },
2631
+ "services": {
2632
+ "type": "string[]",
2633
+ "notes": "Seeds service→color assignment order for stable colors across traces."
2634
+ },
2635
+ "serviceColors": {
2636
+ "type": "Record<string, string>"
2637
+ },
2638
+ "compactRows": {
2639
+ "type": "boolean",
2640
+ "default": false
2641
+ },
2642
+ "showGridlines": {
2643
+ "type": "boolean",
2644
+ "default": true
2645
+ },
2646
+ "showControls": {
2647
+ "type": "boolean",
2648
+ "default": true
2649
+ },
2650
+ "showLegend": {
2651
+ "type": "boolean",
2652
+ "default": true
2653
+ },
2654
+ "showSearch": {
2655
+ "type": "boolean",
2656
+ "default": true,
2657
+ "notes": "Built-in Highlight-keyword box in the toolbar. highlight prop = controlled value (pair with onHighlightChange); defaultHighlight = uncontrolled initial; renderSearch({ value, setValue }) injects a custom element instead."
2658
+ },
2659
+ "showSummary": {
2660
+ "type": "boolean",
2661
+ "default": false,
2662
+ "notes": "Dense one-line-per-item summary panel: items numbered from 01, highlight band over the currently visible viewport (auto-follows panning, scrolls independently), click smooth-scrolls (~1s ease-out) to center the item."
2663
+ },
2664
+ "summaryPlacement": {
2665
+ "type": "enum",
2666
+ "values": [
2667
+ "left",
2668
+ "right",
2669
+ "top",
2670
+ "bottom",
2671
+ "floating"
2672
+ ],
2673
+ "default": "left",
2674
+ "notes": "Dock beside the timeline, render full-width above/below (rows flow into responsive columns), or float as a draggable palette grabbed by its header. summaryDefaultPosition?: { x, y } sets the floating start offset."
2675
+ },
2676
+ "maxHeight": {
2677
+ "type": "number | string",
2678
+ "default": "80vh"
2679
+ },
2680
+ "selectedEventId": {
2681
+ "type": "string | null",
2682
+ "notes": "Controlled detail-panel selection; defaultSelectedEventId for uncontrolled."
2683
+ },
2684
+ "onEventSelect": {
2685
+ "type": "(event: TraceTimelineEvent | null) => void"
2686
+ },
2687
+ "renderChip": {
2688
+ "type": "(event: TraceTimelineEvent, ctx: TraceTimelineItemContext) => ReactNode",
2689
+ "notes": "Replace the chip inner content; chip box width still estimated from default text. ctx = { color, pending, durationMs }."
2690
+ },
2691
+ "renderTooltip": {
2692
+ "type": "(event: TraceTimelineEvent, ctx: TraceTimelineItemContext) => ReactNode",
2693
+ "notes": "Replace tooltip content; return null to suppress."
2694
+ },
2695
+ "renderDetails": {
2696
+ "type": "(event: TraceTimelineEvent, api: { close: () => void; pending: boolean }) => ReactNode",
2697
+ "notes": "Replace the request/response side-panel content; the panel shell is kept."
2698
+ },
2699
+ "classes": {
2700
+ "type": "Partial<TraceTimelineClasses>",
2701
+ "shape": [
2702
+ "root",
2703
+ "toolbar",
2704
+ "legend",
2705
+ "card",
2706
+ "scroller",
2707
+ "axis",
2708
+ "bar",
2709
+ "chip",
2710
+ "summary",
2711
+ "search",
2712
+ "drawer",
2713
+ "tooltip",
2714
+ "footnote"
2715
+ ]
2716
+ }
2717
+ }
2718
+ },
2719
+ "HistoryTimeline": {
2720
+ "import": "import { HistoryTimeline } from '@overdoser/react-toolkit'",
2721
+ "element": "div",
2722
+ "forwardsRef": true,
2723
+ "behavior": "One subject's events as numbered cards alternating around a central axis (horizontal or vertical) with collision-free placement (side split, straight/Z leads, condensed burst groups). Spacing modes equal/log/proportional; fit expands the time axis until stacks fit the cross axis. Tooltip only when it adds info. Fully controlled data: pass the pre-filtered array; the component does no filtering/grouping. Items with an unset end render live (dashed/pulsing) and grow on an internal ticker until an update supplies end.",
2724
+ "props": {
2725
+ "events": {
2726
+ "type": "HistoryTimelineEvent[]",
2727
+ "required": true,
2728
+ "notes": "HistoryTimelineEvent = { id, title, start, detail?, tag?, subject?, end?: number|null, ongoing? }. end===start/omitted = instant; end null (or ongoing true) = ongoing."
2729
+ },
2730
+ "subjectName": {
2731
+ "type": "ReactNode"
2732
+ },
2733
+ "orientation": {
2734
+ "type": "enum",
2735
+ "values": [
2736
+ "horizontal",
2737
+ "vertical"
2738
+ ],
2739
+ "notes": "Controlled; defaultOrientation for uncontrolled (auto-vertical under 700px). onOrientationChange fires from the built-in toggle."
2740
+ },
2741
+ "spacing": {
2742
+ "type": "enum",
2743
+ "values": [
2744
+ "equal",
2745
+ "log",
2746
+ "proportional"
2747
+ ],
2748
+ "notes": "Controlled; defaultSpacing (default 'equal') for uncontrolled. onSpacingChange fires from the toggle."
2749
+ },
2750
+ "highlight": {
2751
+ "type": "string"
2752
+ },
2753
+ "tagColors": {
2754
+ "type": "Record<string, string>",
2755
+ "notes": "Tag→color overrides; unknown tags cycle the palette."
2756
+ },
2757
+ "showControls": {
2758
+ "type": "boolean",
2759
+ "default": true
2760
+ },
2761
+ "showLegend": {
2762
+ "type": "boolean",
2763
+ "default": true
2764
+ },
2765
+ "showSearch": {
2766
+ "type": "boolean",
2767
+ "default": true,
2768
+ "notes": "Built-in Highlight-keyword box in the toolbar. highlight prop = controlled value (pair with onHighlightChange); defaultHighlight = uncontrolled initial; renderSearch({ value, setValue }) injects a custom element instead."
2769
+ },
2770
+ "showSummary": {
2771
+ "type": "boolean",
2772
+ "default": false,
2773
+ "notes": "Dense one-line-per-item summary panel: items numbered from 01, highlight band over the currently visible viewport (auto-follows panning, scrolls independently), click smooth-scrolls (~1s ease-out) to center the item."
2774
+ },
2775
+ "summaryPlacement": {
2776
+ "type": "enum",
2777
+ "values": [
2778
+ "left",
2779
+ "right",
2780
+ "top",
2781
+ "bottom",
2782
+ "floating"
2783
+ ],
2784
+ "default": "left",
2785
+ "notes": "Dock beside the timeline, render full-width above/below (rows flow into responsive columns), or float as a draggable palette grabbed by its header. summaryDefaultPosition?: { x, y } sets the floating start offset."
2786
+ },
2787
+ "maxHeight": {
2788
+ "type": "number | string",
2789
+ "notes": "Defaults 84vh horizontal / 78vh vertical."
2790
+ },
2791
+ "selectedEventId": {
2792
+ "type": "string | null",
2793
+ "notes": "Controlled; defaultSelectedEventId for uncontrolled."
2794
+ },
2795
+ "onEventSelect": {
2796
+ "type": "(event: HistoryTimelineEvent | null) => void"
2797
+ },
2798
+ "renderCard": {
2799
+ "type": "(event: HistoryTimelineEvent, ctx: HistoryTimelineItemContext) => ReactNode",
2800
+ "notes": "Replace the card inner content; card box size still computed from default content. ctx = { index, number, color, ongoing, condensed, durationMs }."
2801
+ },
2802
+ "renderTooltip": {
2803
+ "type": "(event: HistoryTimelineEvent, ctx: HistoryTimelineItemContext) => ReactNode",
2804
+ "notes": "When set the tooltip shows for every hover; return null to suppress."
2805
+ },
2806
+ "renderDetails": {
2807
+ "type": "(event: HistoryTimelineEvent, api: { close: () => void; ongoing: boolean }) => ReactNode",
2808
+ "notes": "Replace the detail side-panel content; the panel shell is kept."
2809
+ },
2810
+ "classes": {
2811
+ "type": "Partial<HistoryTimelineClasses>",
2812
+ "shape": [
2813
+ "root",
2814
+ "toolbar",
2815
+ "legend",
2816
+ "card",
2817
+ "scroller",
2818
+ "eventCard",
2819
+ "dot",
2820
+ "summary",
2821
+ "search",
2822
+ "drawer",
2823
+ "tooltip",
2824
+ "footnote"
2825
+ ]
2826
+ }
2827
+ }
2828
+ },
2829
+ "GanttTimeline": {
2830
+ "import": "import { GanttTimeline } from '@overdoser/react-toolkit'",
2831
+ "element": "div",
2832
+ "forwardsRef": true,
2833
+ "behavior": "Gantt-style task rows sorted by start time: sticky label column and time axis, pill bars proportional to duration, running bars dashed/pulsing with a teal now line. Wheel-zoom, drag-pan, Fit, keyword highlight, detail side panel. Fully controlled data: pass the pre-filtered array; the component does no filtering/grouping. Items with an unset end render live (dashed/pulsing) and grow on an internal ticker until an update supplies end.",
2834
+ "props": {
2835
+ "tasks": {
2836
+ "type": "GanttTimelineTask[]",
2837
+ "required": true,
2838
+ "notes": "GanttTimelineTask = { id, name, start, detail?, owner?, end?: number|null }. end unset = running."
2839
+ },
2840
+ "title": {
2841
+ "type": "ReactNode"
2842
+ },
2843
+ "meta": {
2844
+ "type": "ReactNode",
2845
+ "notes": "Defaults to 'N tasks · span · K running'."
2846
+ },
2847
+ "highlight": {
2848
+ "type": "string"
2849
+ },
2850
+ "compactRows": {
2851
+ "type": "boolean",
2852
+ "default": false,
2853
+ "notes": "42px rows instead of 54px."
2854
+ },
2855
+ "showGridlines": {
2856
+ "type": "boolean",
2857
+ "default": true
2858
+ },
2859
+ "showControls": {
2860
+ "type": "boolean",
2861
+ "default": true
2862
+ },
2863
+ "showSearch": {
2864
+ "type": "boolean",
2865
+ "default": true,
2866
+ "notes": "Built-in Highlight-keyword box in the toolbar. highlight prop = controlled value (pair with onHighlightChange); defaultHighlight = uncontrolled initial; renderSearch({ value, setValue }) injects a custom element instead."
2867
+ },
2868
+ "showSummary": {
2869
+ "type": "boolean",
2870
+ "default": false,
2871
+ "notes": "Dense one-line-per-item summary panel: items numbered from 01, highlight band over the currently visible viewport (auto-follows panning, scrolls independently), click smooth-scrolls (~1s ease-out) to center the item."
2872
+ },
2873
+ "summaryPlacement": {
2874
+ "type": "enum",
2875
+ "values": [
2876
+ "left",
2877
+ "right",
2878
+ "top",
2879
+ "bottom",
2880
+ "floating"
2881
+ ],
2882
+ "default": "left",
2883
+ "notes": "Dock beside the timeline, render full-width above/below (rows flow into responsive columns), or float as a draggable palette grabbed by its header. summaryDefaultPosition?: { x, y } sets the floating start offset."
2884
+ },
2885
+ "maxHeight": {
2886
+ "type": "number | string",
2887
+ "default": "74vh"
2888
+ },
2889
+ "selectedTaskId": {
2890
+ "type": "string | null",
2891
+ "notes": "Controlled; defaultSelectedTaskId for uncontrolled."
2892
+ },
2893
+ "onTaskSelect": {
2894
+ "type": "(task: GanttTimelineTask | null) => void"
2895
+ },
2896
+ "renderRowLabel": {
2897
+ "type": "(task: GanttTimelineTask, ctx: GanttTimelineItemContext) => ReactNode",
2898
+ "notes": "Replace the sticky label-column content. ctx = { index, color, running, durationMs }."
2899
+ },
2900
+ "renderBar": {
2901
+ "type": "(task: GanttTimelineTask, ctx: GanttTimelineItemContext) => ReactNode",
2902
+ "notes": "Replace the bar pill inner content; also suppresses the outside duration text."
2903
+ },
2904
+ "renderTooltip": {
2905
+ "type": "(task: GanttTimelineTask, ctx: GanttTimelineItemContext) => ReactNode",
2906
+ "notes": "Replace tooltip content; return null to suppress."
2907
+ },
2908
+ "renderDetails": {
2909
+ "type": "(task: GanttTimelineTask, api: { close: () => void; running: boolean }) => ReactNode",
2910
+ "notes": "Replace the detail side-panel content; the panel shell is kept."
2911
+ },
2912
+ "classes": {
2913
+ "type": "Partial<GanttTimelineClasses>",
2914
+ "shape": [
2915
+ "root",
2916
+ "toolbar",
2917
+ "card",
2918
+ "scroller",
2919
+ "axis",
2920
+ "row",
2921
+ "rowLabel",
2922
+ "bar",
2923
+ "summary",
2924
+ "search",
2925
+ "drawer",
2926
+ "tooltip",
2927
+ "footnote"
2928
+ ]
2929
+ }
2930
+ }
2608
2931
  }
2609
2932
  },
2610
2933
  "hooks": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overdoser/react-toolkit",
3
- "version": "0.8.3",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",
@@ -0,0 +1,147 @@
1
+ import { useCallback, useEffect, useRef, useState } from 'react';
2
+ import {
3
+ GanttTimeline,
4
+ HistoryTimeline,
5
+ TraceTimeline,
6
+ type GanttTimelineTask,
7
+ type HistoryTimelineEvent,
8
+ type TraceTimelineEvent,
9
+ } from '@overdoser/react-toolkit';
10
+
11
+ /**
12
+ * Live event feed into the timeline components (TraceTimeline shown fully;
13
+ * the same pattern applies to HistoryTimeline and GanttTimeline).
14
+ *
15
+ * The timelines are fully controlled: they render exactly the array you pass
16
+ * and re-render items with `end` unset as "live" (dashed/pulsing, growing).
17
+ * A live feed is therefore just state management on the consumer side:
18
+ *
19
+ * - a "start" message appends an event with `end: null`;
20
+ * - a "complete" message merges response fields into the existing event and
21
+ * sets its `end` — the component picks the change up on the next render,
22
+ * including inside an open detail panel.
23
+ *
24
+ * This mirrors the push shape from the design handoff:
25
+ * push({ id, service, op, source, method, url, reqHeaders, reqBody })
26
+ * push({ id, _complete: true, status, resHeaders, resBody })
27
+ *
28
+ * Filtering (e.g. which manifest's events to show) stays on your side —
29
+ * keep ALL received events in state and pass the filtered slice down.
30
+ */
31
+
32
+ type PushMessage = Record<string, unknown> & { id: string; _complete?: boolean };
33
+
34
+ export function useTraceFeed(wsUrl?: string) {
35
+ const [events, setEvents] = useState<TraceTimelineEvent[]>([]);
36
+
37
+ const push = useCallback((msg: PushMessage) => {
38
+ setEvents((list) => {
39
+ const next = list.slice();
40
+ const i = next.findIndex((e) => e.id === msg.id);
41
+ if (msg._complete) {
42
+ // completion: merge response fields, stamp the end time
43
+ if (i >= 0) {
44
+ const { _complete, ...fields } = msg;
45
+ next[i] = {
46
+ ...next[i],
47
+ ...fields,
48
+ end: typeof msg.end === 'number' ? msg.end : Date.now(),
49
+ } as TraceTimelineEvent;
50
+ }
51
+ return next;
52
+ }
53
+ // start: append as in-flight (end: null); default start to now
54
+ next.push({
55
+ service: 'unknown',
56
+ ...msg,
57
+ start: typeof msg.start === 'number' ? msg.start : Date.now(),
58
+ end: null,
59
+ } as TraceTimelineEvent);
60
+ return next;
61
+ });
62
+ }, []);
63
+
64
+ // Optional WebSocket source — every JSON message goes through `push`.
65
+ useEffect(() => {
66
+ if (!wsUrl) return;
67
+ const ws = new WebSocket(wsUrl);
68
+ ws.onmessage = (e) => {
69
+ try {
70
+ push(JSON.parse(e.data));
71
+ } catch {
72
+ /* ignore malformed frames */
73
+ }
74
+ };
75
+ return () => ws.close();
76
+ }, [wsUrl, push]);
77
+
78
+ return { events, push };
79
+ }
80
+
81
+ export function LiveTrace({ manifestId, wsUrl }: { manifestId: string; wsUrl?: string }) {
82
+ const { events } = useTraceFeed(wsUrl);
83
+ // consumer-side correlation: the component imposes no grouping rule
84
+ const filtered = events.filter((e) => e.manifestId === manifestId);
85
+ return <TraceTimeline title={manifestId} events={filtered} />;
86
+ }
87
+
88
+ /** Same pattern for HistoryTimeline: `ongoing: true` starts an open event. */
89
+ export function useHistoryFeed() {
90
+ const [events, setEvents] = useState<HistoryTimelineEvent[]>([]);
91
+ const push = useCallback((msg: PushMessage) => {
92
+ setEvents((list) => {
93
+ const next = list.slice();
94
+ const i = next.findIndex((e) => e.id === msg.id);
95
+ if (msg._complete) {
96
+ if (i >= 0) next[i] = { ...next[i], end: Date.now() };
97
+ return next;
98
+ }
99
+ const start = typeof msg.start === 'number' ? msg.start : Date.now();
100
+ next.push({
101
+ title: msg.id,
102
+ ...msg,
103
+ start,
104
+ end: msg.ongoing ? null : start,
105
+ } as HistoryTimelineEvent);
106
+ return next;
107
+ });
108
+ }, []);
109
+ return { events, push };
110
+ }
111
+
112
+ /** Same pattern for GanttTimeline: tasks upsert; `_complete` ends the bar. */
113
+ export function useTaskFeed(initial: GanttTimelineTask[] = []) {
114
+ const [tasks, setTasks] = useState<GanttTimelineTask[]>(initial);
115
+ const push = useCallback((msg: PushMessage) => {
116
+ setTasks((list) => {
117
+ const next = list.slice();
118
+ const i = next.findIndex((t) => t.id === msg.id);
119
+ if (msg._complete) {
120
+ if (i >= 0) next[i] = { ...next[i], end: typeof msg.end === 'number' ? msg.end : Date.now() };
121
+ return next;
122
+ }
123
+ const merged = {
124
+ name: msg.id,
125
+ ...(i >= 0 ? next[i] : {}),
126
+ ...msg,
127
+ start: typeof msg.start === 'number' ? msg.start : i >= 0 ? next[i].start : Date.now(),
128
+ } as GanttTimelineTask;
129
+ if (merged.end === undefined) merged.end = i >= 0 ? next[i].end : null;
130
+ if (i >= 0) next[i] = merged;
131
+ else next.push(merged);
132
+ return next;
133
+ });
134
+ }, []);
135
+ return { tasks, push };
136
+ }
137
+
138
+ export function LiveProject() {
139
+ const { tasks } = useTaskFeed();
140
+ const ref = useRef<HTMLDivElement>(null);
141
+ return <GanttTimeline ref={ref} title="Live project" tasks={tasks} />;
142
+ }
143
+
144
+ export function LiveSubject({ subjectName }: { subjectName: string }) {
145
+ const { events } = useHistoryFeed();
146
+ return <HistoryTimeline subjectName={subjectName} events={events} />;
147
+ }