@overdoser/react-toolkit 0.11.0 → 0.12.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 CHANGED
@@ -101,8 +101,8 @@ 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, floats it as a draggable palette, or — `'bubble'`, the TraceTimeline default — collapses it into a pill bottom-left of the timeline that expands in place). 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 />`. Ships a right-side dock rail by default (`showDock={false}` to remove): one docked drawer at a time — *Event details* (request/response panel with payload copy buttons) or *Full log* (all events vertically with payloads + copy buttons, scroll-synced with timeline clicks both ways).
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 (Ctrl/Cmd-gated by default; `wheelZoom`: `'ctrl' | 'free' | 'none'`) / 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, floats it as a draggable palette, or — `'bubble'`, the TraceTimeline default — collapses it into a pill bottom-left of the timeline that expands in place and can dock from its header as a full-height resizable column flush beside the card). 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 />`. Ships a right-side dock rail by default (`showDock={false}` to remove): one docked drawer at a time — *Event details* (request/response panel with payload copy buttons) or *Full log* (all events vertically with payloads + copy buttons, scroll-synced with timeline clicks both ways); drawers sit flush against the timeline card at full card height, with a draggable divider to resize drawer vs timeline.
106
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
107
  - Tasks stacked by start time with duration bars (Gantt) → `<GanttTimeline tasks title onTaskSelect />`.
108
108
 
package/CHANGELOG.md CHANGED
@@ -4,6 +4,59 @@ 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.12.0]
8
+
9
+ The timeline summary and drawers become dockable, flush and resizable, and
10
+ wheel zoom is now Ctrl/Cmd-gated by default — see *Changed* for the two
11
+ behavior changes and how to opt back out.
12
+
13
+ ### Added
14
+
15
+ - **Timeline summary dock mode** — the events-summary bubble panel's header
16
+ gained a dock/undock toggle (all three timelines): docked, the panel becomes
17
+ a full-height column flush left of the timeline card and the card shrinks to
18
+ make room (nothing overlays the canvas, so sticky labels stay visible).
19
+ Dockedness survives collapse/re-expand; undocking floats the panel back at
20
+ its home corner.
21
+ - **Resizable dock dividers** — the visible 7px divider strip between a docked
22
+ panel and the timeline card (summary on the left, drawers on the right) is a
23
+ drag handle: drag to trade width between panel and timeline, or nudge with
24
+ the arrow keys when focused (summary 200–520px, details 280–640px, log
25
+ 320–680px).
26
+ - **`wheelZoom` prop** on `TraceTimeline` / `HistoryTimeline` /
27
+ `GanttTimeline`: `'ctrl' | 'free' | 'none'`. `'ctrl'` zooms only while
28
+ Ctrl/Cmd is held (trackpad pinch still zooms — browsers report it as a
29
+ `ctrlKey` wheel), `'free'` zooms on any scroll, `'none'` leaves zooming to
30
+ the toolbar buttons. Exported `TimelineWheelZoom` type; the Trace/Gantt
31
+ toolbar hint follows the active mode.
32
+
33
+ ### Changed
34
+
35
+ - **Wheel zoom is Ctrl/Cmd-gated by default** (`wheelZoom` defaults to
36
+ `'ctrl'`): plain scrolling over the canvas now passes through to the page
37
+ instead of zooming. Pass `wheelZoom="free"` for the pre-0.12 behavior.
38
+ - **TraceTimeline drawers dock into the card row** — the details and full-log
39
+ drawers now sit flush against the timeline card at full card height (square
40
+ touching corners, no gap) instead of floating as sticky siblings with a 16px
41
+ gutter, and are resizable via their divider.
42
+ - The bubble summary (pill, dragged panel and docked panel) now anchors to the
43
+ card's exact box via a new card wrapper in all three timelines.
44
+
45
+ ### Fixed
46
+
47
+ - **`Draggable` re-clamps to its bounds outside drag gestures** — a
48
+ ResizeObserver on the element (and its parent for `bounds="parent"`) plus a
49
+ window resize listener re-apply clamping when sizes change. Previously a
50
+ panel dragged to an edge could grow past the viewport (e.g. the summary
51
+ bubble panel gaining rows from live events) with its drag handle stuck
52
+ off-screen. Controlled components receive the corrected offset via `onDrag`.
53
+ - Full-log copy buttons melted into the selected row's tint (the CopyButton
54
+ secondary variant has a transparent resting background) — they now sit on a
55
+ solid surface background.
56
+ - The full-log navigation flash is a keyframe animation that always decays
57
+ back to the row's resting background, instead of a steady tint that could
58
+ read as a second "selected" row.
59
+
7
60
  ## [0.11.0]
8
61
 
9
62
  TraceTimeline gets the summary bubble, dock drawers and a full-log view
@@ -17,7 +17,7 @@ export interface DraggableProps extends Omit<ComponentPropsWithoutRef<'div'>, 'o
17
17
  position?: DraggablePosition;
18
18
  /** Restrict movement to one axis. @default 'both' */
19
19
  axis?: 'both' | 'x' | 'y';
20
- /** Where the element is allowed to move. `'viewport'` and `'parent'` clamp to those bounds; `'none'` is unconstrained. @default 'viewport' */
20
+ /** Where the element is allowed to move. `'viewport'` and `'parent'` clamp to those bounds — during drags and again whenever the element or its bounds resize; `'none'` is unconstrained. @default 'viewport' */
21
21
  bounds?: 'viewport' | 'parent' | 'none';
22
22
  /** Pixel step applied when moving via arrow keys with a focused handle. @default 10 */
23
23
  keyboardStep?: number;
@@ -1,142 +1,152 @@
1
- import { jsx as Y } from "react/jsx-runtime";
2
- import { forwardRef as nt, useRef as H, useState as X, useCallback as s, useEffect as W, useContext as et, createContext as rt } from "react";
3
- import q from "clsx";
4
- import c from "./Draggable.module.scss.js";
5
- const z = rt(null), F = nt(
1
+ import { jsx as N } from "react/jsx-runtime";
2
+ import { forwardRef as et, useRef as b, useState as L, useCallback as s, useEffect as X, useContext as nt, createContext as rt } from "react";
3
+ import W from "clsx";
4
+ import g from "./Draggable.module.scss.js";
5
+ const q = rt(null), F = et(
6
6
  ({
7
- children: b,
7
+ children: R,
8
8
  defaultPosition: C,
9
- position: f,
9
+ position: p,
10
10
  axis: a = "both",
11
11
  bounds: o = "viewport",
12
- keyboardStep: g = 10,
13
- disabled: l = !1,
14
- onDragStart: E,
15
- onDrag: L,
16
- onDragEnd: m,
12
+ keyboardStep: m = 10,
13
+ disabled: c = !1,
14
+ onDragStart: Y,
15
+ onDrag: z,
16
+ onDragEnd: v,
17
17
  classes: A,
18
18
  className: J,
19
- style: M,
19
+ style: E,
20
20
  ...Q
21
- }, u) => {
22
- const h = H(null), P = f !== void 0, [T, V] = X(
21
+ }, w) => {
22
+ const h = b(null), M = p !== void 0, [T, V] = L(
23
23
  C ?? { x: 0, y: 0 }
24
- ), w = P ? f : T, d = H(w);
25
- d.current = w;
26
- const [p, B] = X(!1), R = H(null), N = H(0), [$, K] = X(!1), Z = s(() => (N.current += 1, K(!0), () => {
27
- N.current -= 1, N.current === 0 && K(!1);
24
+ ), x = M ? p : T, l = b(x);
25
+ l.current = x;
26
+ const [y, B] = L(!1), D = b(null), P = b(0), [$, K] = L(!1), Z = s(() => (P.current += 1, K(!0), () => {
27
+ P.current -= 1, P.current === 0 && K(!1);
28
28
  }), []), _ = s(
29
29
  (t) => {
30
- h.current = t, typeof u == "function" ? u(t) : u && (u.current = t);
30
+ h.current = t, typeof w == "function" ? w(t) : w && (w.current = t);
31
31
  },
32
- [u]
33
- ), x = s((t) => {
34
- const e = h.current?.getBoundingClientRect();
35
- return e ? { left: e.left - t.x, top: e.top - t.y, width: e.width, height: e.height } : { left: 0, top: 0, width: 0, height: 0 };
36
- }, []), v = s(
37
- (t, e, r) => {
38
- if (o === "none" || typeof window > "u") return { x: t, y: e };
39
- const n = o === "parent" && h.current?.parentElement ? h.current.parentElement.getBoundingClientRect() : { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight }, i = n.left - r.left, y = n.right - r.width - r.left, U = n.top - r.top, O = n.bottom - r.height - r.top;
32
+ [w]
33
+ ), u = s((t) => {
34
+ const n = h.current?.getBoundingClientRect();
35
+ return n ? { left: n.left - t.x, top: n.top - t.y, width: n.width, height: n.height } : { left: 0, top: 0, width: 0, height: 0 };
36
+ }, []), d = s(
37
+ (t, n, r) => {
38
+ if (o === "none" || typeof window > "u") return { x: t, y: n };
39
+ const e = o === "parent" && h.current?.parentElement ? h.current.parentElement.getBoundingClientRect() : { left: 0, top: 0, right: window.innerWidth, bottom: window.innerHeight }, i = e.left - r.left, H = e.right - r.width - r.left, I = e.top - r.top, U = e.bottom - r.height - r.top;
40
40
  return {
41
- x: Math.min(Math.max(t, Math.min(i, y)), Math.max(i, y)),
42
- y: Math.min(Math.max(e, Math.min(U, O)), Math.max(U, O))
41
+ x: Math.min(Math.max(t, Math.min(i, H)), Math.max(i, H)),
42
+ y: Math.min(Math.max(n, Math.min(I, U)), Math.max(I, U))
43
43
  };
44
44
  },
45
45
  [o]
46
- ), D = s(
46
+ ), f = s(
47
47
  (t) => {
48
- d.current = t, P || V(t), L?.(t);
48
+ l.current = t, M || V(t), z?.(t);
49
49
  },
50
- [P, L]
51
- ), j = s(
50
+ [M, z]
51
+ ), O = s(
52
52
  (t) => {
53
- if (l || t.button > 0) return;
53
+ if (c || t.button > 0) return;
54
54
  t.preventDefault();
55
- const e = d.current;
56
- R.current = {
55
+ const n = l.current;
56
+ D.current = {
57
57
  startX: t.clientX,
58
58
  startY: t.clientY,
59
- origin: e,
60
- base: x(e)
61
- }, B(!0), E?.(e);
59
+ origin: n,
60
+ base: u(n)
61
+ }, B(!0), Y?.(n);
62
62
  },
63
- [l, x, E]
63
+ [c, u, Y]
64
64
  );
65
- W(() => {
66
- if (!p) return;
65
+ X(() => {
66
+ if (!y) return;
67
67
  const t = (r) => {
68
- const n = R.current;
69
- if (!n) return;
70
- const i = a === "y" ? n.origin.x : n.origin.x + (r.clientX - n.startX), y = a === "x" ? n.origin.y : n.origin.y + (r.clientY - n.startY);
71
- D(v(i, y, n.base));
72
- }, e = () => {
73
- B(!1), R.current = null, m?.(d.current);
68
+ const e = D.current;
69
+ if (!e) return;
70
+ const i = a === "y" ? e.origin.x : e.origin.x + (r.clientX - e.startX), H = a === "x" ? e.origin.y : e.origin.y + (r.clientY - e.startY);
71
+ f(d(i, H, e.base));
72
+ }, n = () => {
73
+ B(!1), D.current = null, v?.(l.current);
74
74
  };
75
- return window.addEventListener("pointermove", t), window.addEventListener("pointerup", e), () => {
76
- window.removeEventListener("pointermove", t), window.removeEventListener("pointerup", e);
75
+ return window.addEventListener("pointermove", t), window.addEventListener("pointerup", n), () => {
76
+ window.removeEventListener("pointermove", t), window.removeEventListener("pointerup", n);
77
77
  };
78
- }, [p, a, v, D, m]);
78
+ }, [y, a, d, f, v]), X(() => {
79
+ if (o === "none" || typeof window > "u") return;
80
+ const t = () => {
81
+ if (D.current) return;
82
+ const e = l.current, i = d(e.x, e.y, u(e));
83
+ (i.x !== e.x || i.y !== e.y) && f(i);
84
+ }, n = h.current, r = typeof ResizeObserver > "u" ? null : new ResizeObserver(t);
85
+ return n && (r?.observe(n), o === "parent" && n.parentElement && r?.observe(n.parentElement)), window.addEventListener("resize", t), () => {
86
+ r?.disconnect(), window.removeEventListener("resize", t);
87
+ };
88
+ }, [o, d, f, u]);
79
89
  const k = s(
80
90
  (t) => {
81
- if (l) return;
91
+ if (c) return;
82
92
  const r = {
83
- ArrowLeft: [-g, 0],
84
- ArrowRight: [g, 0],
85
- ArrowUp: [0, -g],
86
- ArrowDown: [0, g]
93
+ ArrowLeft: [-m, 0],
94
+ ArrowRight: [m, 0],
95
+ ArrowUp: [0, -m],
96
+ ArrowDown: [0, m]
87
97
  }[t.key];
88
98
  if (!r || a === "x" && r[1] !== 0 || a === "y" && r[0] !== 0) return;
89
99
  t.preventDefault();
90
- const n = d.current, i = v(n.x + r[0], n.y + r[1], x(n));
91
- D(i), m?.(i);
100
+ const e = l.current, i = d(e.x + r[0], e.y + r[1], u(e));
101
+ f(i), v?.(i);
92
102
  },
93
- [a, v, D, l, x, g, m]
103
+ [a, d, f, c, u, m, v]
94
104
  ), S = {
95
- startPointerDrag: j,
105
+ startPointerDrag: O,
96
106
  onHandleKeyDown: k,
97
107
  registerHandle: Z,
98
108
  handleClassName: A?.handle,
99
- disabled: l,
100
- dragging: p
101
- }, I = `translate(${w.x}px, ${w.y}px)`, tt = {
102
- ...M,
103
- transform: M?.transform ? `${I} ${M.transform}` : I
109
+ disabled: c,
110
+ dragging: y
111
+ }, j = `translate(${x.x}px, ${x.y}px)`, tt = {
112
+ ...E,
113
+ transform: E?.transform ? `${j} ${E.transform}` : j
104
114
  };
105
- return /* @__PURE__ */ Y(z.Provider, { value: S, children: /* @__PURE__ */ Y(
115
+ return /* @__PURE__ */ N(q.Provider, { value: S, children: /* @__PURE__ */ N(
106
116
  "div",
107
117
  {
108
118
  ref: _,
109
- className: q(
110
- c.root,
111
- !$ && !l && c.surfaceDraggable,
112
- p && c.dragging,
119
+ className: W(
120
+ g.root,
121
+ !$ && !c && g.surfaceDraggable,
122
+ y && g.dragging,
113
123
  A?.root,
114
124
  J
115
125
  ),
116
126
  style: tt,
117
- onPointerDown: $ ? void 0 : j,
127
+ onPointerDown: $ ? void 0 : O,
118
128
  ...Q,
119
- children: b
129
+ children: R
120
130
  }
121
131
  ) });
122
132
  }
123
133
  );
124
134
  F.displayName = "Draggable";
125
- function G({ children: b, className: C, style: f, ...a }) {
126
- const o = et(z);
135
+ function G({ children: R, className: C, style: p, ...a }) {
136
+ const o = nt(q);
127
137
  if (!o)
128
138
  throw new Error("Draggable.Handle must be rendered inside a <Draggable>.");
129
- return W(() => o.registerHandle(), [o.registerHandle]), /* @__PURE__ */ Y(
139
+ return X(() => o.registerHandle(), [o.registerHandle]), /* @__PURE__ */ N(
130
140
  "div",
131
141
  {
132
- className: q(
133
- c.handle,
134
- o.disabled && c.handleDisabled,
135
- o.dragging && c.handleDragging,
142
+ className: W(
143
+ g.handle,
144
+ o.disabled && g.handleDisabled,
145
+ o.dragging && g.handleDragging,
136
146
  o.handleClassName,
137
147
  C
138
148
  ),
139
- style: f,
149
+ style: p,
140
150
  role: "button",
141
151
  "aria-label": "Drag handle",
142
152
  "aria-disabled": o.disabled || void 0,
@@ -144,12 +154,12 @@ function G({ children: b, className: C, style: f, ...a }) {
144
154
  onPointerDown: o.startPointerDrag,
145
155
  onKeyDown: o.onHandleKeyDown,
146
156
  ...a,
147
- children: b
157
+ children: R
148
158
  }
149
159
  );
150
160
  }
151
161
  G.displayName = "Draggable.Handle";
152
- const lt = Object.assign(F, { Handle: G });
162
+ const ct = Object.assign(F, { Handle: G });
153
163
  export {
154
- lt as Draggable
164
+ ct as Draggable
155
165
  };
@@ -1,6 +1,7 @@
1
1
  import { CSSProperties, ReactNode } from 'react';
2
2
  import { TimelineSummaryPlacement } from './TimelineShared';
3
3
  import { DraggablePosition } from '../Draggable';
4
+ import { TimelineWheelZoom } from './useTimeline';
4
5
  /** One task row. A task with no `end` is running and keeps growing. */
5
6
  export interface GanttTimelineTask {
6
7
  /** Stable identifier (selection, completion). */
@@ -81,6 +82,15 @@ export interface GanttTimelineProps {
81
82
  showGridlines?: boolean;
82
83
  /** Toolbar row with the zoom −/%/+/Fit controls. @default true */
83
84
  showControls?: boolean;
85
+ /**
86
+ * How the mouse wheel / trackpad zooms the timeline: `'ctrl'` zooms only
87
+ * while Ctrl/Cmd is held (plain scrolling passes through to the page;
88
+ * trackpad pinch still zooms), `'free'` zooms on any scroll over the
89
+ * canvas, `'none'` disables wheel zoom entirely — the toolbar buttons
90
+ * still work.
91
+ * @default 'ctrl'
92
+ */
93
+ wheelZoom?: TimelineWheelZoom;
84
94
  /**
85
95
  * Dense one-line-per-task summary panel beside the chart: all tasks
86
96
  * numbered chronologically from `01`, a highlight band over the tasks