@overdoser/react-toolkit 0.12.0 → 0.14.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/llms.txt CHANGED
@@ -151,6 +151,8 @@ Example:
151
151
  <CopyButton value={shareUrl} iconOnly aria-label="Copy link" /> // icon only
152
152
  ```
153
153
 
154
+ Floating over content (e.g. pinned to a code snippet's corner): `secondary`/`ghost` are transparent at rest, so wrap the button in a div with a solid `background: var(--crk-color-bg)` and the button's border radius — every state then composites over that surface instead of the content underneath. Prefer `variant="secondary"` there (visible outline at rest; ghost has none). Full copy-paste version: `recipes/floating-copy-button.tsx`.
155
+
154
156
  ### Link
155
157
  Import: `import { Link } from '@overdoser/react-toolkit'`
156
158
  Element: `<a>` (forwards ref, accepts all native anchor props).
@@ -1293,9 +1295,11 @@ Theming: `--crk-timeline-1..6` category palette (cycled over services/tags/rows)
1293
1295
  #### TraceTimeline
1294
1296
  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.
1295
1297
 
1296
- **Dock rail + drawers (default on):** a sticky 44px icon rail on the far right toggles one docked drawer at a time — *Event details* (the request/response panel, now with its own uppercase header, an empty state until an event is picked, and Copy buttons beside the Request/Response payloads) or *Full log* (420px default: every event vertically — number, method/status chips, `source → service`, clock, op, path, then REQUEST/RESPONSE payloads stacked full-width, each with a Copy button that doesn't select the row). Drawers dock into the card row itself, flush against the timeline (full card height, square touching corners — no gap, so the canvas keeps every other pixel); the divider strip between card and drawer is a drag handle to resize drawer vs timeline (arrow keys work when it's focused). Nothing is docked initially; clicking an event opens the details drawer. Timeline↔log stay in sync both ways: clicking a timeline event (or summary row) scrolls an open log to that entry and flashes it; clicking a log entry selects the event and centers the timeline on it (centering waits for the drawer-induced resize to settle). `showDock={false}` removes the rail and full log — the details panel then simply opens/closes with the selection as before. The events-summary bubble (see the summary panel section) is also on by default.
1298
+ **Dock rail + drawers (default on):** a sticky 44px icon rail on the far right toggles one docked drawer at a time — *Event details* (its own uppercase header, an empty state until an event is picked, labeled fields throughout and Copy buttons beside every payload — sections adapt to the event, see below) or *Full log* (420px default: every event vertically — number, method/status (or level) chips, `source → service`, clock, op, path, message, `details` fields, then the payloads it has — PAYLOAD for plain events, REQUEST/RESPONSE for requests — stacked full-width, each with a Copy button that doesn't select the row). Drawers dock into the card row itself, flush against the timeline (full card height, square touching corners — no gap, so the canvas keeps every other pixel); the divider strip between card and drawer is a drag handle to resize drawer vs timeline (arrow keys work when it's focused). Nothing is docked initially; clicking an event opens the details drawer. Timeline↔log stay in sync both ways: clicking a timeline event (or summary row) scrolls an open log to that entry and flashes it; clicking a log entry selects the event and centers the timeline on it (centering waits for the drawer-induced resize to settle). `showDock={false}` removes the rail and full log — the details panel then simply opens/closes with the selection as before. The events-summary bubble (see the summary panel section) is also on by default.
1299
+
1300
+ `TraceTimelineEvent`: `{ id: string; service: string; source?; op?; kind?: 'request' | 'event'; level?: 'debug' | 'info' | 'success' | 'warning' | 'error'; message?: string; payload?: unknown; details?: TraceTimelineField[]; 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).
1297
1301
 
1298
- `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).
1302
+ **Not every event is a request.** `kind` is inferred when omitted — `'request'` as soon as any of `method`/`url`/`status`/`query`/`reqHeaders`/`reqBody`/`resHeaders`/`resBody` is set, `'event'` otherwise — and the details drawer + full log render only the sections an event actually has, never an empty Request/Response scaffold. Plain events use: `message` (one-line description), `payload` (the generic body — the counterpart of `reqBody`/`resBody`, pretty-printed JSON, strings verbatim, with a copy button; an event may carry nothing else), `details?: TraceTimelineField[]` (`{ label, value, mono?, copy? }` — arbitrary labeled values in order: strings/numbers/booleans/React elements inline, objects/arrays as copyable JSON blocks) and `level` (badge in place of the status code: `error`/`warning` tinted, `success` accent, `info`/`debug` muted). `end: null` reads as *ongoing* (not "in flight"), `source` is not defaulted to `client` for plain events (the chip shows the service alone), and unknown keys are listed under an *Other fields* section (`showExtraFields={false}` to hide). Every value in the panel — identity, URL, request id, **Started / Ended / Duration** — is rendered as a labeled field with its label above it, stacked one per row (start and end are never put side by side).
1299
1303
 
1300
1304
  Props:
1301
1305
  - `events: TraceTimelineEvent[]` — one correlated set; correlation key is your concern.
@@ -1313,12 +1317,14 @@ Props:
1313
1317
  - `summaryPlacement?: 'bubble' | 'left' | 'right' | 'top' | 'bottom' | 'floating'` — default `'bubble'`; `summaryDefaultPosition?: { x, y }` for floating.
1314
1318
  - `showDock?: boolean` — default `true`. Dock rail + drawers (see above).
1315
1319
  - `defaultDock?: 'details' | 'log' | null` (`TraceTimelineDock`) — drawer docked open initially; default `null`.
1320
+ - `showExtraFields?: boolean` — default `true`. Lists event keys the panel doesn't render itself under *Other fields*.
1321
+ - `hiddenFields?: string[]` — extra event keys to hide from the drawer's *Other fields* and exclude from keyword matching. For plumbing values that ride along on every event (tenant ids, ingestion timestamps, shared correlation ids) and would otherwise clutter the drawer or light up the whole trace when searched.
1316
1322
  - `maxHeight?: number | string` — default `'80vh'` (caps the scrollable canvas).
1317
1323
  - `minHeight?: number` — default `420`. Minimum event-band height, px (the sticky axis adds its 68px on top): sparse traces stretch to it with the bar band vertically centered; dense traces still grow past it.
1318
1324
  - `selectedEventId?: string | null`, `defaultSelectedEventId?`, `onEventSelect?: (ev | null) => void`
1319
1325
  - `renderChip?: (ev, ctx: TraceTimelineItemContext) => ReactNode` — replace the chip's inner content (chip box width is still estimated from the default text).
1320
1326
  - `renderTooltip?: (ev, ctx) => ReactNode` — replace tooltip content; return `null` to suppress.
1321
- - `renderDetails?: (ev, { close, pending }) => ReactNode` — replace the request/response panel content.
1327
+ - `renderDetails?: (ev, { close, pending }) => ReactNode` — replace the detail panel content entirely (the drawer shell is kept).
1322
1328
  - `classes?: Partial<TraceTimelineClasses>` where `TraceTimelineClasses = { root, toolbar, legend, card, scroller, axis, bar, chip, summary, search, drawer, log, rail, tooltip, footnote }`
1323
1329
 
1324
1330
  Example:
@@ -1331,6 +1337,30 @@ Example:
1331
1337
  />
1332
1338
  ```
1333
1339
 
1340
+ #### TraceEventDetails
1341
+ Import: `import { TraceEventDetails } from '@overdoser/react-toolkit'`
1342
+
1343
+ The event inspector behind TraceTimeline's *Event details* drawer, exported standalone so the same panel can live in your own drawer, modal or split view. Same adaptive rules as the drawer: every value is rendered under its own label (identity, URL, request id and Started / Ended / Duration, each stacked on its own row), and only the sections the event has appear — Request/Response (query parameters, headers, bodies, "Awaiting response…" while in flight) for request-like events, Message/Payload/Details for plain ones, *Other fields* for unrecognized keys. It ships no shell of its own (no surface, border or scrolling) — wrap it in your own panel.
1344
+
1345
+ Props:
1346
+ - `event: TraceTimelineEvent` — the event to describe (required).
1347
+ - `now?: number` — "now" for an unfinished event's running duration, epoch ms; pass a ticking value to keep it live. Default `Date.now()`.
1348
+ - `highlight?: string` — keyword marked inside field values.
1349
+ - `showExtraFields?: boolean` — default `true`; `false` drops the *Other fields* section.
1350
+ - `hiddenFields?: string[]` — individual extra keys to leave out of *Other fields* (finer-grained than `showExtraFields`).
1351
+ - `onClose?: () => void` — adds a ✕ to the header row (omitted when absent).
1352
+ - `classes?: Partial<TraceEventDetailsClasses>` where `TraceEventDetailsClasses = { root, head, body, section, field }`; plus `className`, `style`. Forwards its ref to the root `div`.
1353
+
1354
+ ```tsx
1355
+ <TraceEventDetails
1356
+ event={{ id: 'evt-1', service: 'Payments', op: 'payment.authorized', level: 'success',
1357
+ message: 'Authorized on the first attempt.', payload: { authCode: '88112' },
1358
+ start: t0, end: t1 }}
1359
+ />
1360
+ ```
1361
+
1362
+ The inference helpers behind the panel are exported too, so an app can make the same decisions (an error count in a header, a custom chip) without re-implementing them: `isRequestEvent(ev)` — the request/event decision described above; `badgeOf(ev, pending)` — the status/level badge as `{ text, tone } | null` with `tone: TraceBadgeTone = 'ok' | 'pending' | 'warn' | 'error'`; `extraFieldsOf(ev, hidden?)` — the unknown keys as `TraceTimelineField[]`, minus any `hidden` names.
1363
+
1334
1364
  #### HistoryTimeline
1335
1365
  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).
1336
1366
 
package/manifest.json CHANGED
@@ -248,7 +248,7 @@
248
248
  "element": "button",
249
249
  "extendsNativeProps": "button (except children)",
250
250
  "forwardsRef": true,
251
- "notes": "Preconfigured ActionButton for copy-to-clipboard: clipboard icon morphs into a check, label swaps Copy \u2192 Copied, success tint, auto-reset. All ActionButton props apply. Falls back to execCommand('copy') without the Clipboard API.",
251
+ "notes": "Preconfigured ActionButton for copy-to-clipboard: clipboard icon morphs into a check, label swaps Copy \u2192 Copied, success tint, auto-reset. All ActionButton props apply. Falls back to execCommand('copy') without the Clipboard API. Floating over content (e.g. a code snippet): secondary/ghost are transparent at rest, so give a wrapper a solid --crk-color-bg fill + the button's radius \u2014 see recipes/floating-copy-button.tsx.",
252
252
  "props": {
253
253
  "value": {
254
254
  "type": "string | (() => string | Promise<string>)",
@@ -3019,12 +3019,12 @@
3019
3019
  "import": "import { TraceTimeline } from '@overdoser/react-toolkit'",
3020
3020
  "element": "div",
3021
3021
  "forwardsRef": true,
3022
- "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). Ctrl/Cmd-wheel zoom (wheelZoom prop: 'ctrl' default | 'free' | 'none'), drag-pan, Fit, keyword highlight, hover tooltip. A right-side icon rail (default on) docks one drawer at a time: Event details (request/response panel with copy buttons, opened by clicking an event, empty state until then) or Full log (every event vertically with stacked payloads + copy buttons; kept in sync with timeline clicks both ways \u2014 timeline click scrolls/flashes the log entry, log click selects and centers the timeline). Drawers dock into the card row flush against the timeline (full card height, no gap); the divider strip between card and drawer drags to resize drawer vs timeline. An events-summary bubble (default on) sits bottom-left and expands into a draggable panel, dockable from its header as a full-height column flush beside the card (the timeline shrinks to make room) with the same resizable divider. 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.",
3022
+ "behavior": "Trace of one correlated flow on a single proportional UTC time band \u2014 HTTP calls, plain domain events, or both. Overlapping bars pack into sub-rows; description chips are placed collision-free (3-pass nudging). Ctrl/Cmd-wheel zoom (wheelZoom prop: 'ctrl' default | 'free' | 'none'), drag-pan, Fit, keyword highlight, hover tooltip. A right-side icon rail (default on) docks one drawer at a time: Event details (opened by clicking an event, empty state until then; every value rendered under its own label \u2014 Started/Ended/Duration stacked one per row \u2014 and only the sections the event actually has: Message/Payload/Details for plain events, Request/Response for requests, unknown keys under Other fields) or Full log (every event vertically with message, details fields and the payloads it has + copy buttons; kept in sync with timeline clicks both ways \u2014 timeline click scrolls/flashes the log entry, log click selects and centers the timeline). Drawers dock into the card row flush against the timeline (full card height, no gap); the divider strip between card and drawer drags to resize drawer vs timeline. An events-summary bubble (default on) sits bottom-left and expands into a draggable panel, dockable from its header as a full-height column flush beside the card (the timeline shrinks to make room) with the same resizable divider. 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.",
3023
3023
  "props": {
3024
3024
  "events": {
3025
3025
  "type": "TraceTimelineEvent[]",
3026
3026
  "required": true,
3027
- "notes": "TraceTimelineEvent = { id, service, start, source?, op?, requestId?, method?, url?, label?, query?, reqHeaders?, reqBody?, status?, resHeaders?, resBody?, end?: number|null }. end unset = in flight."
3027
+ "notes": "TraceTimelineEvent = { id, service, start, end?: number|null, source?, op?, kind?: 'request'|'event', level?: 'debug'|'info'|'success'|'warning'|'error', message?, payload?, details?: { label, value, mono?, copy? }[], requestId?, method?, url?, label?, query?, reqHeaders?, reqBody?, status?, resHeaders?, resBody? }. end unset = in flight (requests) / ongoing (plain events). kind is inferred when omitted: 'request' as soon as any of method/url/status/query/reqHeaders/reqBody/resHeaders/resBody is set, else 'event' \u2014 which drives which detail sections render. payload is the generic body for non-request events (counterpart of reqBody/resBody; an event may carry nothing but payload). details adds arbitrary labeled values (objects render as copyable JSON blocks). Extra keys are allowed, are searched by highlight and are listed under Other fields."
3028
3028
  },
3029
3029
  "title": {
3030
3030
  "type": "ReactNode"
@@ -3103,6 +3103,15 @@
3103
3103
  "default": null,
3104
3104
  "notes": "Drawer docked open initially (uncontrolled). Type TraceTimelineDock."
3105
3105
  },
3106
+ "showExtraFields": {
3107
+ "type": "boolean",
3108
+ "default": true,
3109
+ "notes": "Lists event keys the panel does not render itself under an Other fields section in the details drawer."
3110
+ },
3111
+ "hiddenFields": {
3112
+ "type": "string[]",
3113
+ "notes": "Extra event keys to hide from the drawer's Other fields section and exclude from keyword matching. For plumbing values that ride along on every event (tenant ids, ingestion timestamps, shared correlation ids) and would otherwise clutter the drawer or match every event when searched."
3114
+ },
3106
3115
  "maxHeight": {
3107
3116
  "type": "number | string",
3108
3117
  "default": "80vh",
@@ -3154,6 +3163,45 @@
3154
3163
  }
3155
3164
  }
3156
3165
  },
3166
+ "TraceEventDetails": {
3167
+ "import": "import { TraceEventDetails } from '@overdoser/react-toolkit'",
3168
+ "element": "div",
3169
+ "forwardsRef": true,
3170
+ "behavior": "Standalone event inspector \u2014 the panel behind TraceTimeline's Event details drawer, usable in any drawer/modal/split view. Adapts to the event instead of assuming an HTTP call: every value is rendered under its own label (identity, URL, request id and Started / Ended / Duration, each stacked on its own row) and only the sections the event has are shown \u2014 Request/Response (query parameters, headers, bodies, 'Awaiting response\u2026' while in flight) for request-like events, Message/Payload/Details for plain events, Other fields for unrecognized keys. Ships no shell (no surface/border/scrolling) \u2014 wrap it in your own panel. The inference helpers behind it are exported too: isRequestEvent(ev) (the request/event decision), badgeOf(ev, pending) (the status/level badge as { text, tone: TraceBadgeTone } | null), extraFieldsOf(ev, hidden?) (unknown keys as TraceTimelineField[], minus hidden names).",
3171
+ "props": {
3172
+ "event": {
3173
+ "type": "TraceTimelineEvent",
3174
+ "required": true,
3175
+ "notes": "Same model as TraceTimeline events; see the TraceTimeline entry."
3176
+ },
3177
+ "now": {
3178
+ "type": "number",
3179
+ "default": "Date.now()",
3180
+ "notes": "'Now' for an unfinished event's running duration, epoch ms. Pass a ticking value to keep it live."
3181
+ },
3182
+ "highlight": {
3183
+ "type": "string",
3184
+ "notes": "Keyword marked inside field values."
3185
+ },
3186
+ "showExtraFields": {
3187
+ "type": "boolean",
3188
+ "default": true,
3189
+ "notes": "Lists keys the panel does not render itself under an Other fields section."
3190
+ },
3191
+ "hiddenFields": {
3192
+ "type": "string[]",
3193
+ "notes": "Individual extra keys to leave out of Other fields; finer-grained than showExtraFields."
3194
+ },
3195
+ "onClose": {
3196
+ "type": "() => void",
3197
+ "notes": "Adds a close button to the header row; omitted when absent."
3198
+ },
3199
+ "classes": {
3200
+ "type": "Partial<TraceEventDetailsClasses>",
3201
+ "notes": "{ root, head, body, section, field }"
3202
+ }
3203
+ }
3204
+ },
3157
3205
  "HistoryTimeline": {
3158
3206
  "import": "import { HistoryTimeline } from '@overdoser/react-toolkit'",
3159
3207
  "element": "div",
@@ -3451,6 +3499,9 @@
3451
3499
  "recipes/interactive-pie-chart.tsx",
3452
3500
  "recipes/trading-chart.tsx",
3453
3501
  "recipes/tag-input.tsx",
3454
- "recipes/multi-select-in-modal.tsx"
3502
+ "recipes/multi-select-in-modal.tsx",
3503
+ "recipes/comparison-table.tsx",
3504
+ "recipes/live-timeline-feed.tsx",
3505
+ "recipes/floating-copy-button.tsx"
3455
3506
  ]
3456
3507
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@overdoser/react-toolkit",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "homepage": "https://react-toolkit.overdoser.org",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -0,0 +1,68 @@
1
+ import { CopyButton } from '@overdoser/react-toolkit';
2
+
3
+ /**
4
+ * Copy button floating over a code snippet (docs-site pattern).
5
+ *
6
+ * The two things this recipe encodes:
7
+ *
8
+ * 1. **Solid wrapper surface.** The `secondary` and `ghost` variants are
9
+ * transparent at rest by design, so a button floated over content would
10
+ * let the code text run straight under the glyph. Give the *wrapper* a
11
+ * solid `--crk-color-bg` fill (with the button's border radius) — every
12
+ * button state then composites over that surface instead of the code.
13
+ * 2. **`secondary` over `ghost` for floating use.** Ghost has no border in
14
+ * its resting state; secondary's inset outline gives the floating button
15
+ * a visible affordance against the snippet background.
16
+ *
17
+ * The hover/success fills themselves are opaque (they mix the accent into
18
+ * `--crk-color-bg`), so mid-morph the code never shines through the button.
19
+ */
20
+
21
+ interface CodeSnippetProps {
22
+ code: string;
23
+ /** Language hint rendered as a class for external highlighters. @default undefined */
24
+ language?: string;
25
+ }
26
+
27
+ export function CodeSnippet({ code, language }: CodeSnippetProps) {
28
+ return (
29
+ <div style={{ position: 'relative' }}>
30
+ <pre
31
+ style={{
32
+ margin: 0,
33
+ padding: '16px 20px',
34
+ // Keep long lines scrollable; the button stays pinned to the box.
35
+ overflowX: 'auto',
36
+ background: 'var(--crk-color-bg-muted)',
37
+ border: '1px solid var(--crk-color-border-hover)',
38
+ borderRadius: 'var(--crk-border-radius-md)',
39
+ fontSize: 'var(--crk-font-size-sm)',
40
+ lineHeight: 1.6,
41
+ }}
42
+ >
43
+ <code className={language ? `language-${language}` : undefined}>{code}</code>
44
+ </pre>
45
+ {/* Solid layer under the (transparent-at-rest) button — see note above. */}
46
+ <div
47
+ style={{
48
+ position: 'absolute',
49
+ top: 8,
50
+ right: 8,
51
+ background: 'var(--crk-color-bg)',
52
+ borderRadius: 'var(--crk-border-radius-md)',
53
+ }}
54
+ >
55
+ <CopyButton value={code} variant="secondary" iconOnly aria-label="Copy code" />
56
+ </div>
57
+ </div>
58
+ );
59
+ }
60
+
61
+ export function Example() {
62
+ return (
63
+ <CodeSnippet
64
+ language="bash"
65
+ code={'npm install @overdoser/react-toolkit\n# then import the theme once:\n# import "@overdoser/react-toolkit/theme.css"'}
66
+ />
67
+ );
68
+ }