@overdoser/react-toolkit 0.8.3 → 0.10.1

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 (33) hide show
  1. package/AGENTS.md +6 -0
  2. package/CHANGELOG.md +88 -0
  3. package/README.md +2 -0
  4. package/components/Timeline/GanttTimeline.d.ts +144 -0
  5. package/components/Timeline/GanttTimeline.js +312 -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 +536 -0
  15. package/components/Timeline/TraceTimeline.module.scss.js +111 -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 +100 -0
  21. package/components/Timeline/timelineCore.js +193 -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/index.css +1 -1
  27. package/index.d.ts +2 -0
  28. package/index.js +93 -87
  29. package/index.layered.css +1 -1
  30. package/llms.txt +115 -1
  31. package/manifest.json +323 -0
  32. package/package.json +2 -1
  33. package/recipes/live-timeline-feed.tsx +147 -0
package/AGENTS.md CHANGED
@@ -101,6 +101,11 @@ For exhaustive component reference (every prop, every variant, every signature),
101
101
  - Tiny inline trend (table cell, KPI tile) → `<Sparkline>`.
102
102
  - Axis-based charts share a `config` object: `{ [dataKey]: { label, color } }`. `PieChart` uses `nameKey` + `valueKey` (+ optional `colorKey`) instead. Colors via `var(--crk-chart-1)` … `var(--crk-chart-5)`.
103
103
 
104
+ - **Need a timeline of events?** Three views, all fully controlled (you pass the pre-filtered event array; items without an `end` render live and keep growing until an update completes them), all with wheel-zoom / drag-pan / Fit, keyword highlighting (built-in toolbar search box by default — `showSearch={false}` to hide, `renderSearch` to inject your own element, or controlled `highlight` + `onHighlightChange` for an external box), tooltips, a click-to-open detail side panel, and an optional `showSummary` panel (dense numbered event list with a live viewport band and click-to-navigate smooth scrolling; `summaryPlacement` docks it left/right/top/bottom or floats it as a draggable palette). Customize via `--crk-timeline-*` tokens, `classes`, or render-prop slots (`renderChip`/`renderCard`/`renderBar`+`renderRowLabel`, `renderTooltip`, `renderDetails`) that inject custom components while the layout algorithms keep owning geometry:
105
+ - Request/response flow across services (one correlated "manifest"/saga/order) on a proportional UTC band → `<TraceTimeline events title services highlight />`.
106
+ - One subject's life story (order, incident, candidate, deploy) as cards alternating around an axis, horizontal or vertical, equal/log/proportional spacing → `<HistoryTimeline events subjectName defaultSpacing />`.
107
+ - Tasks stacked by start time with duration bars (Gantt) → `<GanttTimeline tasks title onTaskSelect />`.
108
+
104
109
  - **Multi-step / wizard form?** Use one `useForm()` per step OR a single `<Form>` wrapping all steps with conditional rendering. The toolkit doesn't ship a stepper.
105
110
 
106
111
  ## Common shapes (copy-paste)
@@ -172,6 +177,7 @@ Full copy-paste-able files live alongside this doc. Each is one self-contained f
172
177
  - [recipes/interactive-pie-chart.tsx](./recipes/interactive-pie-chart.tsx) — Metric/period filter for `PieChart`: all slices stay visible, the selector picks which metric drives the pie. Three exports: `InteractivePieChartTiles`, `InteractivePieChartNavigator`, `InteractivePieChartDropdown`.
173
178
  - [recipes/trading-chart.tsx](./recipes/trading-chart.tsx) — Full-stack `TradingChart` with a resolution selector, in-memory datafeed adapter, and the SMA/EMA/Bollinger/RSI/Volume indicator stack. Swap `createMemoryDatafeed` for your own REST/WebSocket adapter; everything else carries over.
174
179
  - [recipes/tag-input.tsx](./recipes/tag-input.tsx) — Tag-input pattern via `<Select multiple allowCreate>`: pick from existing tags or type a new one + Enter to create. `onCreate` persists the new tag back into the options list. Wired through `<FormField>` for react-hook-form integration.
180
+ - [recipes/live-timeline-feed.tsx](./recipes/live-timeline-feed.tsx) — Live event feeds into `TraceTimeline` / `HistoryTimeline` / `GanttTimeline`: consumer-side push/complete merge hooks (start appends with `end: null`, complete merges response fields + stamps `end`), optional WebSocket source, and consumer-side correlation filtering.
175
181
  - [recipes/multi-select-in-modal.tsx](./recipes/multi-select-in-modal.tsx) — `<Select multiple>` inside `<Modal size="sm">`. Default `portal={true}` lets the menu escape the modal's `overflow: hidden` and sit above the modal via `--crk-z-floating`, so the modal does NOT need to be sized to contain the menu. Pair with `closeOnBackdrop={false}` so a backdrop click closes the open menu only, not the modal.
176
182
 
177
183
  ## Anti-patterns to refuse
package/CHANGELOG.md CHANGED
@@ -4,6 +4,94 @@ All notable changes to `@overdoser/react-toolkit` are documented here.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/), and this
5
5
  project adheres to [Semantic Versioning](https://semver.org/).
6
6
 
7
+ ## [0.10.1]
8
+
9
+ Metadata-only release. No code changes.
10
+
11
+ ### Added
12
+
13
+ - `homepage` in package.json and a live-demo link in the readme — the
14
+ Storybook demo at <https://react-toolkit.overdoser.org> now appears on
15
+ the npm package page.
16
+
17
+ ## [0.10.0]
18
+
19
+ Timeline axis overhaul (sub-second zoom, tiered rails, deep-zoom
20
+ performance) plus a Modal focus-ring fix. No breaking API changes.
21
+
22
+ ### Added
23
+
24
+ - **Sub-second axis ticks.** The tick table now reaches down to 1ms (was
25
+ 1s), so a short event — e.g. a single 1.1s trace — gets a real axis with
26
+ millisecond labels instead of one gridline. Applies to all three Timeline
27
+ views.
28
+ - **Tiered axis rails in `TraceTimeline`**, coarse to fine: UTC badge,
29
+ date, time, and a milliseconds rail that appears at sub-second zooms.
30
+ Date and second labels render only at true day/second boundaries; sticky
31
+ date and (at sub-second zoom) sticky time boxes at the left edge always
32
+ name the current position, even when no boundary is in view.
33
+ - **Ruler-pattern minor ticks.** Minors sit on the step's natural units via
34
+ a per-step subdivision table: 5-unit steps read big/4-small/big, 10-unit
35
+ steps get a medium mark at the halfway unit, and clock/calendar steps
36
+ subdivide on their own units (quarter-hours, days into weeks, quarters
37
+ into years…).
38
+ - `--crk-modal-ring-guard` token (default `4px`) — see the Modal fix below.
39
+
40
+ ### Changed
41
+
42
+ - **Axis ticks span the whole scrollable canvas**, not just the interval
43
+ covered by events/tasks (TraceTimeline, GanttTimeline, and
44
+ HistoryTimeline's proportional mode).
45
+
46
+ ### Fixed
47
+
48
+ - **Deep zoom no longer freezes the page.** TraceTimeline and
49
+ GanttTimeline virtualize the axis: only ticks inside the scroll window
50
+ are materialized. Extreme zoom used to build tens of thousands of tick
51
+ nodes and re-render them on every mousemove, pegging the CPU.
52
+ - **`Modal.Body` no longer clips the top of focus rings.** The body scrolls
53
+ and had zero top padding, so the outward 3px focus ring of a form field
54
+ flush at the top lost its upper edge. The body now reserves
55
+ `--crk-modal-ring-guard` of top padding, and `Modal.Header` cedes the
56
+ same amount from its bottom padding — the header→body gap is
57
+ pixel-identical for existing consumers. Raise the token if you theme
58
+ `--crk-shadow-ring` thicker than 3px.
59
+
60
+ ## [0.9.0]
61
+
62
+ Introduces the Timeline family: three timeline views built from the
63
+ timeline-views design handoff, sharing one theming/customization surface.
64
+ Components render whatever event arrays they are given — filtering,
65
+ correlation, and live-feed sourcing stay in consumer code.
66
+
67
+ ### Added
68
+
69
+ - **`TraceTimeline`** — horizontal trace view for correlated
70
+ request/response (or custom) events, e.g. tracking one manifest across
71
+ services. Sub-row bar packing plus chip nudging keeps labels
72
+ overlap-free; events without an `end` render as live/growing; clicking
73
+ an event opens a details drawer (`renderDetails` to replace it).
74
+ - **`HistoryTimeline`** — subject history view with event circles and
75
+ description chips, horizontal or vertical, with `equal`/`proportional`/
76
+ `log` spacing. Connector segments are routed around circles and other
77
+ segments; chip heights are content-computed so chips never overlap.
78
+ - **`GanttTimeline`** — project-planning view with task bars, progress,
79
+ and row labels.
80
+ - Shared across the family: built-in hideable controls (zoom, orientation
81
+ and spacing where relevant) with controlled/uncontrolled props; a
82
+ built-in keyword-highlight search box (`showSearch`, `highlight` /
83
+ `defaultHighlight` / `onHighlightChange`, or inject your own element via
84
+ `renderSearch`); an optional summary panel (`showSummary`) listing every
85
+ event as a numbered dense row with a viewport band tracking what's
86
+ visible and ~1s smooth scroll-to-event on click, placeable
87
+ `left`/`right`/`top`/`bottom` or `floating` (draggable);
88
+ render-prop slots (`renderChip`/`renderCard`/`renderBar`/
89
+ `renderRowLabel`/`renderTooltip`/`renderDetails`); `classes` overrides;
90
+ and `--crk-timeline-*` theme tokens defaulting to the handoff palette.
91
+ - New recipe `recipes/live-timeline-feed.tsx` — push/complete merge hooks
92
+ for feeding live events into any of the three views (WebSocket example
93
+ included).
94
+
7
95
  ## [0.8.3]
8
96
 
9
97
  One more callback-ref fix, found by auditing for the 0.8.1/0.8.2
package/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  A modern, themeable React component library with SCSS modules.
4
4
 
5
+ **Live demo (Storybook):** <https://react-toolkit.overdoser.org>
6
+
5
7
  ## Installation
6
8
 
7
9
  ```bash
@@ -0,0 +1,144 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ import { TimelineSummaryPlacement } from './TimelineShared';
3
+ import { DraggablePosition } from '../Draggable';
4
+ /** One task row. A task with no `end` is running and keeps growing. */
5
+ export interface GanttTimelineTask {
6
+ /** Stable identifier (selection, completion). */
7
+ id: string;
8
+ /** Task name shown in the sticky label column. */
9
+ name: string;
10
+ /** Longer description shown in the tooltip and detail panel. */
11
+ detail?: string;
12
+ /** Owner shown in the tooltip and detail panel. */
13
+ owner?: string;
14
+ /** Start time, epoch ms. */
15
+ start: number;
16
+ /** End time, epoch ms. `null`/`undefined` while the task is still running. */
17
+ end?: number | null;
18
+ /** Extra fields are allowed and participate in keyword matching. */
19
+ [extra: string]: unknown;
20
+ }
21
+ export interface GanttTimelineClasses {
22
+ root: string;
23
+ toolbar: string;
24
+ card: string;
25
+ scroller: string;
26
+ axis: string;
27
+ row: string;
28
+ rowLabel: string;
29
+ bar: string;
30
+ summary: string;
31
+ search: string;
32
+ drawer: string;
33
+ tooltip: string;
34
+ footnote: string;
35
+ }
36
+ /** Context handed to the GanttTimeline render-prop slots. */
37
+ export interface GanttTimelineItemContext {
38
+ /** Row index after sorting by start time. */
39
+ index: number;
40
+ /** Resolved row color. */
41
+ color: string;
42
+ /** True while the task has no `end`. */
43
+ running: boolean;
44
+ /** Duration so far, ms. */
45
+ durationMs: number;
46
+ }
47
+ export interface GanttTimelineProps {
48
+ /**
49
+ * Tasks to render, one row each, sorted by start time. Provide the already
50
+ * filtered/pre-processed list — the component applies no filtering. Push
51
+ * updated arrays to animate a live feed; a task whose `end` is unset renders
52
+ * as running (dashed, pulsing) and grows until an update supplies its `end`.
53
+ */
54
+ tasks: GanttTimelineTask[];
55
+ /** Title shown in the toolbar above the chart. */
56
+ title?: ReactNode;
57
+ /** Meta text next to the title. Defaults to `N tasks · span · K running`. */
58
+ meta?: ReactNode;
59
+ /**
60
+ * Controlled keyword highlight: case-insensitive AND over
61
+ * whitespace-separated tokens, matched against each task's JSON. Matching
62
+ * rows get highlighted bars and marked substrings; non-matching rows dim.
63
+ * When set, the built-in search box reflects it — pair with
64
+ * `onHighlightChange` (or use `defaultHighlight` for uncontrolled).
65
+ */
66
+ highlight?: string;
67
+ /** Initial keyword for the built-in search box (uncontrolled). */
68
+ defaultHighlight?: string;
69
+ /** Fired when the keyword changes via the built-in box or `renderSearch`. */
70
+ onHighlightChange?: (value: string) => void;
71
+ /** Built-in "Highlight keyword…" box in the toolbar. @default true */
72
+ showSearch?: boolean;
73
+ /** Replace the built-in search box with a custom element in the toolbar. */
74
+ renderSearch?: (api: {
75
+ value: string;
76
+ setValue: (value: string) => void;
77
+ }) => ReactNode;
78
+ /** Tighter 42px rows instead of 54px. @default false */
79
+ compactRows?: boolean;
80
+ /** Vertical gridlines under each axis tick. @default true */
81
+ showGridlines?: boolean;
82
+ /** Toolbar row with the zoom −/%/+/Fit controls. @default true */
83
+ showControls?: boolean;
84
+ /**
85
+ * Dense one-line-per-task summary panel beside the chart: all tasks
86
+ * numbered chronologically from `01`, a highlight band over the tasks
87
+ * currently visible in the viewport (auto-follows drag-panning), and
88
+ * click-to-navigate — the chart smooth-scrolls (~1s, decelerating) to
89
+ * center the picked task. The panel scrolls independently.
90
+ * @default false
91
+ */
92
+ showSummary?: boolean;
93
+ /**
94
+ * Where the summary panel sits: docked `'left'`/`'right'` of the chart,
95
+ * full-width `'top'`/`'bottom'`, or `'floating'` — a draggable palette over
96
+ * the chart, grabbed by its header. @default 'left'
97
+ */
98
+ summaryPlacement?: TimelineSummaryPlacement;
99
+ /** Floating summary: initial offset from the component's top-left corner. */
100
+ summaryDefaultPosition?: DraggablePosition;
101
+ /** Max height of the scrollable chart area. @default '74vh' */
102
+ maxHeight?: number | string;
103
+ /** Controlled id of the task open in the detail panel (`null` = closed). */
104
+ selectedTaskId?: string | null;
105
+ /** Initially open task (uncontrolled). */
106
+ defaultSelectedTaskId?: string | null;
107
+ /** Fired when a task is opened (task) or closed (`null`). */
108
+ onTaskSelect?: (task: GanttTimelineTask | null) => void;
109
+ /** Replace the sticky label-column content (default: name + date range). */
110
+ renderRowLabel?: (task: GanttTimelineTask, ctx: GanttTimelineItemContext) => ReactNode;
111
+ /** Replace the content inside the bar pill (default: pulse dot + duration text; also suppresses the outside duration text). Geometry stays component-owned. */
112
+ renderBar?: (task: GanttTimelineTask, ctx: GanttTimelineItemContext) => ReactNode;
113
+ /** Replace the tooltip content. Return `null` to suppress the tooltip for that task. */
114
+ renderTooltip?: (task: GanttTimelineTask, ctx: GanttTimelineItemContext) => ReactNode;
115
+ /** Replace the detail side panel content; the sticky panel shell is kept. */
116
+ renderDetails?: (task: GanttTimelineTask, api: {
117
+ close: () => void;
118
+ running: boolean;
119
+ }) => ReactNode;
120
+ /** Override class names on internal elements. */
121
+ classes?: Partial<GanttTimelineClasses>;
122
+ className?: string;
123
+ style?: CSSProperties;
124
+ }
125
+ /**
126
+ * Gantt-style task timeline: rows stacked by start time, horizontal bars
127
+ * proportional to duration, a sticky label column and time axis. Running
128
+ * tasks (no `end`) grow live with a pulsing dashed bar and a "now" line.
129
+ * Wheel-zoom (cursor-anchored), drag-to-pan, fit-to-width, keyword
130
+ * highlighting, hover tooltips, and a click-to-open detail side panel.
131
+ *
132
+ * @example
133
+ * ```tsx
134
+ * <GanttTimeline
135
+ * title="Platform Relaunch — Q3"
136
+ * tasks={[
137
+ * { id: 't1', name: 'Kickoff', owner: 'P. Marsh', start: t0, end: t0 + 2 * DAY },
138
+ * { id: 't2', name: 'Pilot rollout', owner: 'QA', start: t0 + 5 * DAY }, // running
139
+ * ]}
140
+ * highlight={keyword}
141
+ * />
142
+ * ```
143
+ */
144
+ export declare const GanttTimeline: import('react').ForwardRefExoticComponent<GanttTimelineProps & import('react').RefAttributes<HTMLDivElement>>;
@@ -0,0 +1,312 @@
1
+ import { jsx as t, jsxs as f, Fragment as oe } from "react/jsx-runtime";
2
+ import { forwardRef as nn, useRef as y, useState as S, useCallback as V, useEffect as tn, useMemo as ln, useLayoutEffect as an } from "react";
3
+ import d from "clsx";
4
+ import r from "./Timeline.module.scss.js";
5
+ import a from "./GanttTimeline.module.scss.js";
6
+ import { ticks as rn, TIMELINE_PALETTE_VARS as b, fmtDate as ce, fmtDur as F, eventMatches as sn, fmtDateTime as Z, tint as on } from "./timelineCore.js";
7
+ import { TimelineSummary as cn, TimelineZoomControls as dn, HighlightText as un, TimelineTooltip as mn } from "./TimelineShared.js";
8
+ import { useNowTicker as hn, useContainerWidth as fn, useTimelinePan as wn, useWheelZoom as pn, animateScrollTo as gn } from "./useTimeline.js";
9
+ const w = 230, Pe = 24, R = 400, Nn = 26, Pn = nn(
10
+ function(We, De) {
11
+ const {
12
+ tasks: z,
13
+ title: B,
14
+ meta: K,
15
+ highlight: U,
16
+ defaultHighlight: He,
17
+ onHighlightChange: Ce,
18
+ showSearch: Ie = !0,
19
+ renderSearch: de,
20
+ compactRows: Ee = !1,
21
+ showGridlines: Ae = !0,
22
+ showControls: ue = !0,
23
+ showSummary: C = !1,
24
+ summaryPlacement: k = "left",
25
+ summaryDefaultPosition: Oe,
26
+ maxHeight: Ve = "74vh",
27
+ selectedTaskId: _,
28
+ defaultSelectedTaskId: Fe = null,
29
+ onTaskSelect: Ze,
30
+ renderRowLabel: me,
31
+ renderBar: $,
32
+ renderTooltip: G,
33
+ renderDetails: X,
34
+ classes: u,
35
+ className: ze,
36
+ style: Be
37
+ } = We, p = y(null), [he, fe] = S(null), [we, pe] = S(!0), [g, Y] = S(null), [Ke, Ue] = S(Fe), P = _ !== void 0 ? _ : Ke, [x, _e] = S({ l: 0, t: 0, w: 0, h: 0 }), ge = y(C);
38
+ ge.current = C;
39
+ const j = y(null), q = V(() => {
40
+ const e = p.current;
41
+ e && _e(
42
+ (n) => n.l === e.scrollLeft && n.t === e.scrollTop && n.w === e.clientWidth && n.h === e.clientHeight ? n : { l: e.scrollLeft, t: e.scrollTop, w: e.clientWidth, h: e.clientHeight }
43
+ );
44
+ }, []), [W, $e] = S({ l: 0, w: 2e3 }), J = y(W);
45
+ J.current = W;
46
+ const Q = V(() => {
47
+ const e = p.current;
48
+ if (!e) return;
49
+ const n = Math.floor(e.scrollLeft / R) * R, l = (Math.ceil((e.clientWidth || 1600) / R) + 1) * R;
50
+ (n !== J.current.l || l !== J.current.w) && $e({ l: n, w: l });
51
+ }, []), Ge = V(() => {
52
+ j.current == null && (j.current = requestAnimationFrame(() => {
53
+ j.current = null, Q(), ge.current && q();
54
+ }));
55
+ }, [q, Q]);
56
+ tn(() => {
57
+ C && q();
58
+ });
59
+ const Ne = z.some((e) => e.end == null), N = hn(Ne, 400), ee = fn(p), D = wn(p), [Xe, Ye] = S(He ?? ""), ne = U !== void 0 ? U : Xe, I = ne.trim(), ve = (e) => {
60
+ U === void 0 && Ye(e), Ce?.(e);
61
+ }, xe = de ? de({ value: ne, setValue: ve }) : Ie ? /* @__PURE__ */ t(
62
+ "input",
63
+ {
64
+ className: d(r.searchInput, u?.search),
65
+ placeholder: "Highlight keyword in tasks…",
66
+ "aria-label": "Highlight keyword",
67
+ value: ne,
68
+ onChange: (e) => ve(e.target.value)
69
+ }
70
+ ) : null, i = ln(() => z.slice().sort((e, n) => e.start - n.start), [z]);
71
+ let m = i.length ? Math.min(...i.map((e) => e.start)) : N - 1, te = i.length ? Math.max(m + 1, ...i.map((e) => e.end == null ? N : e.end)) : N;
72
+ const le = (te - m) * 0.03;
73
+ m -= le, te += le;
74
+ const ae = te - m, E = Math.max(240, ee - w - Pe) / ae, o = we || !he ? E : he, re = y(E), Me = y(o);
75
+ re.current = E, Me.current = o;
76
+ const A = y(null);
77
+ an(() => {
78
+ A.current != null && p.current && (p.current.scrollLeft = A.current, A.current = null), Q();
79
+ });
80
+ const se = V((e, n) => {
81
+ const l = p.current;
82
+ if (!l) return;
83
+ const c = Me.current || 1e-4, h = Math.max(re.current ? re.current * 0.2 : 1e-9, Math.min(1, c * e)), v = (l.scrollLeft + n - w) / c;
84
+ A.current = v * h + w - n, pe(!1), fe(h);
85
+ }, []);
86
+ pn(p, (e) => {
87
+ e.preventDefault();
88
+ const n = p.current;
89
+ n && se(Math.exp(-e.deltaY * 18e-4), e.clientX - n.getBoundingClientRect().left);
90
+ });
91
+ const ie = (e) => {
92
+ _ === void 0 && Ue(e ? e.id : null), Ze?.(e);
93
+ }, je = (e) => {
94
+ const n = window.innerWidth || 1200, l = window.innerHeight || 800, c = e.clientX < n * 0.55 ? Math.max(12, n - 340) : 16, h = Math.max(130, Math.min(e.clientY, l - 130));
95
+ return { x: c, y: h };
96
+ }, L = Ee ? 42 : 54, s = P != null && i.find((e) => e.id === P) || null, be = Math.ceil(w + ae * o + Pe + 90), qe = m + (be - w) / o, Te = Math.max(m, m + (W.l - R - w) / o), ye = Math.min(qe, m + (W.l + W.w + R - w) / o), Se = rn(Te, ye, Math.max(1, (ye - Te) * o)).list.map((e) => ({
97
+ left: Math.round(w + (e.t - m) * o),
98
+ label: e.label
99
+ })), Je = i.filter((e) => e.end == null).length, O = C ? /* @__PURE__ */ t(
100
+ cn,
101
+ {
102
+ heading: "Tasks",
103
+ className: u?.summary,
104
+ placement: k,
105
+ floatingDefaultPosition: Oe,
106
+ items: i.map((e, n) => {
107
+ const l = e.end == null ? N : e.end, c = Math.round(w + (e.start - m) * o), h = Math.max(14, Math.round(Math.max(0, l - e.start) * o)), v = 34 + n * L, M = !x.w || c < x.l + x.w && c + h > x.l, T = !x.h || v < x.t + x.h && v + L > x.t;
108
+ return {
109
+ id: e.id,
110
+ number: String(n + 1).padStart(2, "0"),
111
+ label: e.name,
112
+ color: b[n % b.length],
113
+ time: ce(e.start),
114
+ inView: M && T,
115
+ selected: P === e.id
116
+ };
117
+ }),
118
+ onPick: (e) => {
119
+ const n = i.findIndex((H) => H.id === e), l = p.current;
120
+ if (n < 0 || !l) return;
121
+ const c = i[n], h = c.end == null ? N : c.end, v = Math.round(w + (c.start - m) * o), M = Math.max(14, Math.round(Math.max(0, h - c.start) * o)), T = {
122
+ left: Math.max(0, v + M / 2 - l.clientWidth / 2)
123
+ };
124
+ l.clientHeight && (T.top = Math.max(0, 34 + n * L + L / 2 - l.clientHeight / 2)), gn(l, T);
125
+ }
126
+ }
127
+ ) : null;
128
+ return /* @__PURE__ */ f(
129
+ "div",
130
+ {
131
+ ref: De,
132
+ className: d(r.root, u?.root, ze),
133
+ style: Be,
134
+ children: [
135
+ (ue || xe || B != null || K != null) && /* @__PURE__ */ f("div", { className: d(r.toolbar, u?.toolbar), children: [
136
+ /* @__PURE__ */ f("div", { className: r.toolbarText, children: [
137
+ B != null && /* @__PURE__ */ t("span", { className: r.toolbarTitle, children: B }),
138
+ /* @__PURE__ */ t("span", { className: r.toolbarMeta, children: K ?? (i.length ? `${i.length} tasks · ${F(ae - 2 * le)} · ${Je} running` : "No tasks") })
139
+ ] }),
140
+ xe,
141
+ ue && /* @__PURE__ */ t(
142
+ dn,
143
+ {
144
+ zoomPct: `${Math.round(o / E * 100)}%`,
145
+ fitActive: we,
146
+ onZoomIn: () => se(1.5, ee / 2),
147
+ onZoomOut: () => se(1 / 1.5, ee / 2),
148
+ onFit: () => {
149
+ pe(!0), fe(null);
150
+ },
151
+ hint: "scroll zooms · drag pans"
152
+ }
153
+ )
154
+ ] }),
155
+ k === "top" && O,
156
+ /* @__PURE__ */ f("div", { className: r.layout, children: [
157
+ k === "left" && O,
158
+ /* @__PURE__ */ f("div", { className: r.main, children: [
159
+ /* @__PURE__ */ t("div", { className: d(r.card, u?.card), children: /* @__PURE__ */ t(
160
+ "div",
161
+ {
162
+ ref: p,
163
+ className: d(r.scroller, a.scroller, u?.scroller),
164
+ style: { maxHeight: Ve },
165
+ onPointerDown: D.onPointerDown,
166
+ onPointerMove: D.onPointerMove,
167
+ onPointerUp: D.onPointerUp,
168
+ onPointerLeave: D.onPointerUp,
169
+ onScroll: Ge,
170
+ children: /* @__PURE__ */ f("div", { className: a.inner, style: { width: be }, children: [
171
+ Ae && Se.map((e, n) => /* @__PURE__ */ t("div", { className: a.gridline, style: { left: e.left } }, n)),
172
+ Ne && /* @__PURE__ */ t(
173
+ "div",
174
+ {
175
+ className: a.nowLine,
176
+ style: { left: Math.round(w + (N - m) * o) }
177
+ }
178
+ ),
179
+ /* @__PURE__ */ t("div", { className: d(a.axis, u?.axis), children: Se.map((e, n) => /* @__PURE__ */ t("div", { className: a.axisLabel, style: { left: e.left }, children: e.label }, n)) }),
180
+ i.map((e, n) => {
181
+ const l = e.end == null, c = l ? N : e.end, h = Math.max(0, c - e.start), v = sn(e, I), M = b[n % b.length], T = Math.round(w + (e.start - m) * o), H = Math.max(14, Math.round(h * o)), ke = F(h) + (l ? " · running" : ""), Le = H > 130, Re = { index: n, color: M, running: l, durationMs: h };
182
+ return /* @__PURE__ */ f(
183
+ "div",
184
+ {
185
+ className: d(a.row, u?.row),
186
+ style: { height: L, opacity: I && !v ? 0.3 : 1 },
187
+ children: [
188
+ /* @__PURE__ */ t("div", { className: d(a.rowLabel, u?.rowLabel), children: me ? me(e, Re) : /* @__PURE__ */ f(oe, { children: [
189
+ /* @__PURE__ */ t("span", { className: a.rowName, children: /* @__PURE__ */ t(un, { text: e.name, query: I }) }),
190
+ /* @__PURE__ */ t("span", { className: a.rowDates, children: ce(e.start) + (l ? " → now" : " → " + ce(c)) })
191
+ ] }) }),
192
+ /* @__PURE__ */ t(
193
+ "div",
194
+ {
195
+ className: d(a.bar, l && a.barRunning, u?.bar),
196
+ style: {
197
+ left: T,
198
+ top: Math.round((L - Nn) / 2),
199
+ width: H,
200
+ borderColor: M,
201
+ background: l ? on(M, 72) : M,
202
+ boxShadow: I && v ? "0 0 0 3px var(--crk-timeline-hl-ring, #f3d98b)" : "none"
203
+ },
204
+ onClick: () => {
205
+ D.wasDragSuppressed() || (Y(null), ie(P === e.id ? null : e));
206
+ },
207
+ onMouseEnter: (Qe) => {
208
+ if (P === e.id) return;
209
+ const en = je(Qe);
210
+ Y({
211
+ ...en,
212
+ id: e.id,
213
+ title: e.name,
214
+ time: Z(e.start) + (l ? "" : " → " + Z(c)),
215
+ durLine: (l ? "running · " : "took ") + F(h) + (e.owner ? " · " + e.owner : ""),
216
+ detail: e.detail || ""
217
+ });
218
+ },
219
+ onMouseLeave: () => Y(null),
220
+ children: $ ? $(e, Re) : /* @__PURE__ */ f(oe, { children: [
221
+ l && /* @__PURE__ */ t("span", { className: d(r.pulseDot, a.barDot) }),
222
+ Le && /* @__PURE__ */ t("span", { className: a.barTextInside, children: ke })
223
+ ] })
224
+ }
225
+ ),
226
+ !$ && !Le && /* @__PURE__ */ t("div", { className: a.barTextOutside, style: { left: T + H + 10 }, children: ke })
227
+ ]
228
+ },
229
+ e.id
230
+ );
231
+ })
232
+ ] })
233
+ }
234
+ ) }),
235
+ /* @__PURE__ */ t("div", { className: d(r.footnote, u?.footnote), children: "Click a bar to open details in the side panel · dashed bars are still running and keep growing" })
236
+ ] }),
237
+ s && X && /* @__PURE__ */ t("aside", { className: d(r.aside, a.drawer, u?.drawer), children: X(s, {
238
+ close: () => ie(null),
239
+ running: s.end == null
240
+ }) }),
241
+ s && !X && /* @__PURE__ */ f("aside", { className: d(r.aside, a.drawer, u?.drawer), children: [
242
+ /* @__PURE__ */ f("div", { className: a.drawerHead, children: [
243
+ /* @__PURE__ */ t(
244
+ "span",
245
+ {
246
+ className: a.drawerSwatch,
247
+ style: {
248
+ background: b[i.indexOf(s) % b.length]
249
+ }
250
+ }
251
+ ),
252
+ /* @__PURE__ */ t("span", { className: a.drawerOwner, children: s.owner || "—" }),
253
+ /* @__PURE__ */ t(
254
+ "span",
255
+ {
256
+ className: d(
257
+ a.drawerState,
258
+ s.end == null && a.drawerStateRunning
259
+ ),
260
+ children: s.end == null ? "running" : "done"
261
+ }
262
+ ),
263
+ /* @__PURE__ */ t("div", { className: a.drawerSpacer }),
264
+ /* @__PURE__ */ t(
265
+ "button",
266
+ {
267
+ type: "button",
268
+ className: r.asideClose,
269
+ "aria-label": "Close details",
270
+ onClick: () => ie(null),
271
+ children: "✕"
272
+ }
273
+ )
274
+ ] }),
275
+ /* @__PURE__ */ t("div", { className: a.drawerName, children: s.name }),
276
+ /* @__PURE__ */ t("div", { className: a.drawerTiming, children: Z(s.start) + " → " + (s.end == null ? "now" : Z(s.end)) + " · " + F((s.end == null ? N : s.end) - s.start) }),
277
+ /* @__PURE__ */ t("div", { className: a.drawerDetail, children: s.detail || "—" }),
278
+ /* @__PURE__ */ t("div", { className: r.asideSection, children: "Raw event" }),
279
+ /* @__PURE__ */ t("pre", { className: r.asideRaw, children: JSON.stringify(s, null, 2) })
280
+ ] }),
281
+ (k === "right" || k === "floating") && O
282
+ ] }),
283
+ k === "bottom" && O,
284
+ g && (() => {
285
+ const e = i.find((l) => l.id === g.id), n = e && G ? G(e, {
286
+ index: i.indexOf(e),
287
+ color: b[i.indexOf(e) % b.length],
288
+ running: e.end == null,
289
+ durationMs: (e.end == null ? N : e.end) - e.start
290
+ }) : void 0;
291
+ return G && n == null ? null : /* @__PURE__ */ t(mn, { x: g.x, y: g.y, className: u?.tooltip, children: n !== void 0 ? n : /* @__PURE__ */ f(oe, { children: [
292
+ /* @__PURE__ */ t("div", { className: r.tooltipTitle, children: g.title }),
293
+ /* @__PURE__ */ t(
294
+ "div",
295
+ {
296
+ className: d(r.tooltipLine, r.tooltipMono),
297
+ style: { marginTop: 4 },
298
+ children: g.time
299
+ }
300
+ ),
301
+ /* @__PURE__ */ t("div", { className: r.tooltipLine, children: g.durLine }),
302
+ g.detail && /* @__PURE__ */ t("div", { className: r.tooltipDim, style: { marginTop: 5 }, children: g.detail })
303
+ ] }) });
304
+ })()
305
+ ]
306
+ }
307
+ );
308
+ }
309
+ );
310
+ export {
311
+ Pn as GanttTimeline
312
+ };
@@ -0,0 +1,55 @@
1
+ const r = "crk-scroller-y2AA7", e = "crk-inner--tSR-", a = "crk-gridline-a9CAe", n = "crk-nowLine-AtaNz", t = "crk-axis-r1FXP", c = "crk-axisLabel-yACMU", w = "crk-row-g4FCC", o = "crk-rowLabel-qOMvT", s = "crk-rowName-g7WMP", d = "crk-rowDates-tEtH6", i = "crk-bar-MKoAK", k = "crk-barRunning-2eR5o", b = "crk-barDot-kqgBw", l = "crk-barTextInside-j0xJc", g = "crk-barTextOutside-cOAGq", x = "crk-drawer-7II9B", S = "crk-drawerHead-VZyLW", T = "crk-drawerSwatch-YTo8T", L = "crk-drawerOwner-jUXtE", u = "crk-drawerState-PIrtX", m = "crk-drawerStateRunning-JYeCs", D = "crk-drawerSpacer-NxNLE", N = "crk-drawerName-VWwMl", R = "crk-drawerTiming-wPByH", O = "crk-drawerDetail-R0Gr2", A = {
2
+ scroller: r,
3
+ inner: e,
4
+ gridline: a,
5
+ nowLine: n,
6
+ axis: t,
7
+ axisLabel: c,
8
+ row: w,
9
+ rowLabel: o,
10
+ rowName: s,
11
+ rowDates: d,
12
+ bar: i,
13
+ barRunning: k,
14
+ barDot: b,
15
+ barTextInside: l,
16
+ barTextOutside: g,
17
+ drawer: x,
18
+ drawerHead: S,
19
+ drawerSwatch: T,
20
+ drawerOwner: L,
21
+ drawerState: u,
22
+ drawerStateRunning: m,
23
+ drawerSpacer: D,
24
+ drawerName: N,
25
+ drawerTiming: R,
26
+ drawerDetail: O
27
+ };
28
+ export {
29
+ t as axis,
30
+ c as axisLabel,
31
+ i as bar,
32
+ b as barDot,
33
+ k as barRunning,
34
+ l as barTextInside,
35
+ g as barTextOutside,
36
+ A as default,
37
+ x as drawer,
38
+ O as drawerDetail,
39
+ S as drawerHead,
40
+ N as drawerName,
41
+ L as drawerOwner,
42
+ D as drawerSpacer,
43
+ u as drawerState,
44
+ m as drawerStateRunning,
45
+ T as drawerSwatch,
46
+ R as drawerTiming,
47
+ a as gridline,
48
+ e as inner,
49
+ n as nowLine,
50
+ w as row,
51
+ d as rowDates,
52
+ o as rowLabel,
53
+ s as rowName,
54
+ r as scroller
55
+ };