@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.
- package/AGENTS.md +6 -0
- package/CHANGELOG.md +35 -0
- package/components/Timeline/GanttTimeline.d.ts +144 -0
- package/components/Timeline/GanttTimeline.js +305 -0
- package/components/Timeline/GanttTimeline.module.scss.js +55 -0
- package/components/Timeline/HistoryTimeline.d.ts +184 -0
- package/components/Timeline/HistoryTimeline.js +445 -0
- package/components/Timeline/HistoryTimeline.module.scss.js +59 -0
- package/components/Timeline/Timeline.module.scss.js +111 -0
- package/components/Timeline/TimelineShared.d.ts +79 -0
- package/components/Timeline/TimelineShared.js +173 -0
- package/components/Timeline/TraceTimeline.d.ts +180 -0
- package/components/Timeline/TraceTimeline.js +511 -0
- package/components/Timeline/TraceTimeline.module.scss.js +105 -0
- package/components/Timeline/demoData.d.ts +42 -0
- package/components/Timeline/historyLayout.d.ts +82 -0
- package/components/Timeline/historyLayout.js +264 -0
- package/components/Timeline/index.d.ts +7 -0
- package/components/Timeline/timelineCore.d.ts +90 -0
- package/components/Timeline/timelineCore.js +135 -0
- package/components/Timeline/traceLayout.d.ts +72 -0
- package/components/Timeline/traceLayout.js +92 -0
- package/components/Timeline/useTimeline.d.ts +39 -0
- package/components/Timeline/useTimeline.js +81 -0
- package/index.css +1 -1
- package/index.d.ts +2 -0
- package/index.js +93 -87
- package/index.layered.css +1 -1
- package/llms.txt +113 -0
- package/manifest.json +323 -0
- package/package.json +1 -1
- package/recipes/live-timeline-feed.tsx +147 -0
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { CSSProperties, ReactNode } from 'react';
|
|
2
|
+
import { TimelineSummaryPlacement } from './TimelineShared';
|
|
3
|
+
import { DraggablePosition } from '../Draggable';
|
|
4
|
+
export type HistoryTimelineOrientation = 'horizontal' | 'vertical';
|
|
5
|
+
export type HistoryTimelineSpacing = 'equal' | 'log' | 'proportional';
|
|
6
|
+
/**
|
|
7
|
+
* One event in a subject's history. Instant events have `end === start` (or
|
|
8
|
+
* omit `end`); ongoing events set `end: null` (or `ongoing: true`) until a
|
|
9
|
+
* later update supplies the end time.
|
|
10
|
+
*/
|
|
11
|
+
export interface HistoryTimelineEvent {
|
|
12
|
+
/** Stable identifier. */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Card title (bold, keyword-highlightable). */
|
|
15
|
+
title: string;
|
|
16
|
+
/** Description, ≤2 lines on the card, full text in tooltip/panel. */
|
|
17
|
+
detail?: string;
|
|
18
|
+
/** Category tag — colors the dot/lead and appears in the legend. */
|
|
19
|
+
tag?: string;
|
|
20
|
+
/** Owning subject id (informational; shown in the detail panel). */
|
|
21
|
+
subject?: string;
|
|
22
|
+
/** Start time, epoch ms. */
|
|
23
|
+
start: number;
|
|
24
|
+
/** End time. Equal to `start` (or omitted) = instant; `null` = ongoing. */
|
|
25
|
+
end?: number | null;
|
|
26
|
+
/** Alternative way to mark an event ongoing when `end` is omitted. */
|
|
27
|
+
ongoing?: boolean;
|
|
28
|
+
[extra: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface HistoryTimelineClasses {
|
|
31
|
+
root: string;
|
|
32
|
+
toolbar: string;
|
|
33
|
+
legend: string;
|
|
34
|
+
card: string;
|
|
35
|
+
scroller: string;
|
|
36
|
+
eventCard: string;
|
|
37
|
+
dot: string;
|
|
38
|
+
summary: string;
|
|
39
|
+
search: string;
|
|
40
|
+
drawer: string;
|
|
41
|
+
tooltip: string;
|
|
42
|
+
footnote: string;
|
|
43
|
+
}
|
|
44
|
+
/** Context handed to the HistoryTimeline render-prop slots. */
|
|
45
|
+
export interface HistoryTimelineItemContext {
|
|
46
|
+
/** Chronological index (0-based). */
|
|
47
|
+
index: number;
|
|
48
|
+
/** Zero-padded card number (`'01'`…). */
|
|
49
|
+
number: string;
|
|
50
|
+
/** Resolved tag color. */
|
|
51
|
+
color: string;
|
|
52
|
+
/** True while the event has no end. */
|
|
53
|
+
ongoing: boolean;
|
|
54
|
+
/** True for burst-group members (rendered condensed by default). */
|
|
55
|
+
condensed: boolean;
|
|
56
|
+
/** Duration so far, ms. */
|
|
57
|
+
durationMs: number;
|
|
58
|
+
}
|
|
59
|
+
export interface HistoryTimelineProps {
|
|
60
|
+
/**
|
|
61
|
+
* Events of one subject (an order, an incident, a candidate…). Provide the
|
|
62
|
+
* already filtered list — the component applies no subject filtering. Push
|
|
63
|
+
* updated arrays for live feeds; ongoing events (`end: null`) pulse and
|
|
64
|
+
* grow until completed.
|
|
65
|
+
*/
|
|
66
|
+
events: HistoryTimelineEvent[];
|
|
67
|
+
/** Subject display name for the detail panel (e.g. `Order ORD-58291`). */
|
|
68
|
+
subjectName?: ReactNode;
|
|
69
|
+
/** Controlled orientation. */
|
|
70
|
+
orientation?: HistoryTimelineOrientation;
|
|
71
|
+
/**
|
|
72
|
+
* Initial orientation (uncontrolled). Defaults to `'horizontal'`, falling
|
|
73
|
+
* back to `'vertical'` on narrow (<700px) viewports.
|
|
74
|
+
*/
|
|
75
|
+
defaultOrientation?: HistoryTimelineOrientation;
|
|
76
|
+
/** Fired when the built-in toggle switches orientation. */
|
|
77
|
+
onOrientationChange?: (o: HistoryTimelineOrientation) => void;
|
|
78
|
+
/** Controlled spacing mode. */
|
|
79
|
+
spacing?: HistoryTimelineSpacing;
|
|
80
|
+
/**
|
|
81
|
+
* Initial spacing (uncontrolled): `'equal'` index-based, `'log'`
|
|
82
|
+
* gap-compressed (dense bursts stay readable next to huge gaps),
|
|
83
|
+
* `'proportional'` linear time. @default 'equal'
|
|
84
|
+
*/
|
|
85
|
+
defaultSpacing?: HistoryTimelineSpacing;
|
|
86
|
+
/** Fired when the built-in toggle switches spacing. */
|
|
87
|
+
onSpacingChange?: (s: HistoryTimelineSpacing) => void;
|
|
88
|
+
/**
|
|
89
|
+
* Controlled keyword highlight: case-insensitive AND over
|
|
90
|
+
* whitespace-separated tokens against each event's JSON. Matches get an
|
|
91
|
+
* amber wash; non-matches dim. When set, the built-in search box reflects
|
|
92
|
+
* it — pair with `onHighlightChange` (or use `defaultHighlight` for
|
|
93
|
+
* uncontrolled).
|
|
94
|
+
*/
|
|
95
|
+
highlight?: string;
|
|
96
|
+
/** Initial keyword for the built-in search box (uncontrolled). */
|
|
97
|
+
defaultHighlight?: string;
|
|
98
|
+
/** Fired when the keyword changes via the built-in box or `renderSearch`. */
|
|
99
|
+
onHighlightChange?: (value: string) => void;
|
|
100
|
+
/** Built-in "Highlight keyword…" box in the toolbar. @default true */
|
|
101
|
+
showSearch?: boolean;
|
|
102
|
+
/** Replace the built-in search box with a custom element in the toolbar. */
|
|
103
|
+
renderSearch?: (api: {
|
|
104
|
+
value: string;
|
|
105
|
+
setValue: (value: string) => void;
|
|
106
|
+
}) => ReactNode;
|
|
107
|
+
/** Tag→color overrides (any CSS color). Unknown tags cycle the palette. */
|
|
108
|
+
tagColors?: Record<string, string>;
|
|
109
|
+
/** Toolbar with orientation/spacing toggles + zoom controls. @default true */
|
|
110
|
+
showControls?: boolean;
|
|
111
|
+
/** Colored bullet + tag name legend. @default true */
|
|
112
|
+
showLegend?: boolean;
|
|
113
|
+
/**
|
|
114
|
+
* Dense one-line-per-event summary panel beside the timeline: all events
|
|
115
|
+
* numbered chronologically from `01` (matching the card numbers), a
|
|
116
|
+
* highlight band over the events currently visible in the viewport
|
|
117
|
+
* (auto-follows drag-panning), and click-to-navigate — the timeline
|
|
118
|
+
* smooth-scrolls (~1s, decelerating) to center the picked event. The panel
|
|
119
|
+
* scrolls independently.
|
|
120
|
+
* @default false
|
|
121
|
+
*/
|
|
122
|
+
showSummary?: boolean;
|
|
123
|
+
/**
|
|
124
|
+
* Where the summary panel sits: docked `'left'`/`'right'` of the timeline,
|
|
125
|
+
* full-width `'top'`/`'bottom'`, or `'floating'` — a draggable palette over
|
|
126
|
+
* the timeline, grabbed by its header. @default 'left'
|
|
127
|
+
*/
|
|
128
|
+
summaryPlacement?: TimelineSummaryPlacement;
|
|
129
|
+
/** Floating summary: initial offset from the component's top-left corner. */
|
|
130
|
+
summaryDefaultPosition?: DraggablePosition;
|
|
131
|
+
/** Max height of the scrollable canvas. Defaults to 84vh (h) / 78vh (v). */
|
|
132
|
+
maxHeight?: number | string;
|
|
133
|
+
/** Controlled id of the event open in the detail panel (`null` = closed). */
|
|
134
|
+
selectedEventId?: string | null;
|
|
135
|
+
/** Initially open event (uncontrolled). */
|
|
136
|
+
defaultSelectedEventId?: string | null;
|
|
137
|
+
/** Fired when an event is opened (event) or closed (`null`). */
|
|
138
|
+
onEventSelect?: (event: HistoryTimelineEvent | null) => void;
|
|
139
|
+
/**
|
|
140
|
+
* Replace the card's inner content (default: number + tag dot + title,
|
|
141
|
+
* time, detail, duration badge). The card box geometry is still computed
|
|
142
|
+
* from the default content (title/detail lengths), so keep custom content
|
|
143
|
+
* roughly equivalent in size.
|
|
144
|
+
*/
|
|
145
|
+
renderCard?: (event: HistoryTimelineEvent, ctx: HistoryTimelineItemContext) => ReactNode;
|
|
146
|
+
/**
|
|
147
|
+
* Replace the tooltip content. When set, the tooltip shows for every
|
|
148
|
+
* hovered card (not only when it adds information); return `null` to
|
|
149
|
+
* suppress it for that event.
|
|
150
|
+
*/
|
|
151
|
+
renderTooltip?: (event: HistoryTimelineEvent, ctx: HistoryTimelineItemContext) => ReactNode;
|
|
152
|
+
/** Replace the detail side panel content; the sticky panel shell is kept. */
|
|
153
|
+
renderDetails?: (event: HistoryTimelineEvent, api: {
|
|
154
|
+
close: () => void;
|
|
155
|
+
ongoing: boolean;
|
|
156
|
+
}) => ReactNode;
|
|
157
|
+
/** Override class names on internal elements. */
|
|
158
|
+
classes?: Partial<HistoryTimelineClasses>;
|
|
159
|
+
className?: string;
|
|
160
|
+
style?: CSSProperties;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Subject history timeline: the life of one entity as numbered event cards
|
|
164
|
+
* alternating around a central axis (above/below horizontally, left/right
|
|
165
|
+
* vertically), with the handoff's collision-free reconciliation — clustered
|
|
166
|
+
* side split, outward-stepping circles, straight or Z-shaped leads, and
|
|
167
|
+
* burst groups whose members condense and stack on consecutive rows. Three
|
|
168
|
+
* spacing modes (equal / log-compressed / proportional), wheel-zoom with
|
|
169
|
+
* cross-axis fit, drag-pan, keyword highlighting, tooltips only when they
|
|
170
|
+
* add information, and a click-to-open detail side panel.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```tsx
|
|
174
|
+
* <HistoryTimeline
|
|
175
|
+
* subjectName="Order ORD-58291"
|
|
176
|
+
* events={[
|
|
177
|
+
* { id: '1', title: 'Order created', tag: 'created', start: t1 },
|
|
178
|
+
* { id: '2', title: 'Fraud review', tag: 'review', start: t2, end: t2 + 2 * HOUR },
|
|
179
|
+
* { id: '3', title: 'In transit', tag: 'shipping', start: t3, end: null }, // ongoing
|
|
180
|
+
* ]}
|
|
181
|
+
* />
|
|
182
|
+
* ```
|
|
183
|
+
*/
|
|
184
|
+
export declare const HistoryTimeline: import('react').ForwardRefExoticComponent<HistoryTimelineProps & import('react').RefAttributes<HTMLDivElement>>;
|
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
import { jsx as l, jsxs as d, Fragment as ne } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as rt, useRef as L, useState as S, useCallback as Y, useEffect as st, useMemo as ke, useLayoutEffect as ct } from "react";
|
|
3
|
+
import p from "clsx";
|
|
4
|
+
import r from "./Timeline.module.scss.js";
|
|
5
|
+
import o from "./HistoryTimeline.module.scss.js";
|
|
6
|
+
import { TIMELINE_PALETTE_VARS as u, fmtDateTime as R, eventMatches as dt, fmtDur as D, tint as ut, fmtDate as mt, fmtClock as ht, ticks as pt, DAY as E } from "./timelineCore.js";
|
|
7
|
+
import { computeHistoryLayout as ft } from "./historyLayout.js";
|
|
8
|
+
import { TimelineSummary as gt, TimelineSegmented as He, TimelineZoomControls as vt, TimelineLegend as wt, HighlightText as Me, TimelineTooltip as yt } from "./TimelineShared.js";
|
|
9
|
+
import { useNowTicker as Nt, useContainerWidth as St, useTimelinePan as bt, useWheelZoom as Tt, animateScrollTo as xt } from "./useTimeline.js";
|
|
10
|
+
const kt = {
|
|
11
|
+
created: u[0],
|
|
12
|
+
done: u[0],
|
|
13
|
+
live: u[0],
|
|
14
|
+
payment: u[1],
|
|
15
|
+
people: u[1],
|
|
16
|
+
review: u[2],
|
|
17
|
+
action: u[2],
|
|
18
|
+
offer: u[2],
|
|
19
|
+
fulfilment: u[3],
|
|
20
|
+
analysis: u[3],
|
|
21
|
+
shipping: u[4],
|
|
22
|
+
interview: u[4],
|
|
23
|
+
exception: "var(--crk-timeline-danger, #b3372f)",
|
|
24
|
+
alert: "var(--crk-timeline-danger, #b3372f)"
|
|
25
|
+
}, Ft = rt(
|
|
26
|
+
function(Ce, Le) {
|
|
27
|
+
const {
|
|
28
|
+
events: le,
|
|
29
|
+
subjectName: oe,
|
|
30
|
+
orientation: ie,
|
|
31
|
+
defaultOrientation: De,
|
|
32
|
+
onOrientationChange: Ee,
|
|
33
|
+
spacing: ae,
|
|
34
|
+
defaultSpacing: Pe = "equal",
|
|
35
|
+
onSpacingChange: Oe,
|
|
36
|
+
highlight: j,
|
|
37
|
+
defaultHighlight: Re,
|
|
38
|
+
onHighlightChange: We,
|
|
39
|
+
showSearch: Fe = !0,
|
|
40
|
+
renderSearch: re,
|
|
41
|
+
tagColors: se,
|
|
42
|
+
showControls: ce = !0,
|
|
43
|
+
showLegend: Ae = !0,
|
|
44
|
+
showSummary: W = !1,
|
|
45
|
+
summaryPlacement: H = "left",
|
|
46
|
+
summaryDefaultPosition: Ve,
|
|
47
|
+
maxHeight: de,
|
|
48
|
+
selectedEventId: q,
|
|
49
|
+
defaultSelectedEventId: ze = null,
|
|
50
|
+
onEventSelect: Ie,
|
|
51
|
+
renderCard: ue,
|
|
52
|
+
renderTooltip: F,
|
|
53
|
+
renderDetails: X,
|
|
54
|
+
classes: m,
|
|
55
|
+
className: Ye,
|
|
56
|
+
style: je
|
|
57
|
+
} = Ce, g = L(null), [qe, Xe] = S(
|
|
58
|
+
() => De ?? (typeof window < "u" && window.innerWidth < 700 ? "vertical" : "horizontal")
|
|
59
|
+
), A = ie ?? qe, w = A === "horizontal", [Ze, Ke] = S(Pe), Z = ae ?? Ze, [Ue, me] = S(1), [he, pe] = S(!0), [y, K] = S(null), [_e, Ge] = S(ze), P = q !== void 0 ? q : _e, [v, Be] = S({ l: 0, t: 0, w: 0, h: 0 }), fe = L(W);
|
|
60
|
+
fe.current = W;
|
|
61
|
+
const U = L(null), _ = Y(() => {
|
|
62
|
+
const e = g.current;
|
|
63
|
+
e && Be(
|
|
64
|
+
(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 }
|
|
65
|
+
);
|
|
66
|
+
}, []), Je = Y(() => {
|
|
67
|
+
!fe.current || U.current != null || (U.current = requestAnimationFrame(() => {
|
|
68
|
+
U.current = null, _();
|
|
69
|
+
}));
|
|
70
|
+
}, [_]);
|
|
71
|
+
st(() => {
|
|
72
|
+
W && _();
|
|
73
|
+
});
|
|
74
|
+
const [$e, Qe] = S(Re ?? ""), G = j !== void 0 ? j : $e, b = G.trim(), ge = (e) => {
|
|
75
|
+
j === void 0 && Qe(e), We?.(e);
|
|
76
|
+
}, ve = re ? re({ value: G, setValue: ge }) : Fe ? /* @__PURE__ */ l(
|
|
77
|
+
"input",
|
|
78
|
+
{
|
|
79
|
+
className: p(r.searchInput, m?.search),
|
|
80
|
+
placeholder: "Highlight keyword in events…",
|
|
81
|
+
"aria-label": "Highlight keyword",
|
|
82
|
+
value: G,
|
|
83
|
+
onChange: (e) => ge(e.target.value)
|
|
84
|
+
}
|
|
85
|
+
) : null, c = ke(
|
|
86
|
+
() => le.map((e) => ({
|
|
87
|
+
...e,
|
|
88
|
+
end: e.end !== void 0 ? e.end : e.ongoing ? null : e.start
|
|
89
|
+
})).sort((e, n) => e.start - n.start),
|
|
90
|
+
[le]
|
|
91
|
+
), et = c.some((e) => e.end == null), T = Nt(et, 500), tt = St(g), O = bt(g), M = Y(
|
|
92
|
+
(e) => {
|
|
93
|
+
const n = e || "event", t = { ...kt, ...se };
|
|
94
|
+
if (t[n]) return t[n];
|
|
95
|
+
const i = String(n).charCodeAt(0) || 0;
|
|
96
|
+
return u[(String(n).length + i) % u.length];
|
|
97
|
+
},
|
|
98
|
+
[se]
|
|
99
|
+
), s = ft(
|
|
100
|
+
c.map((e) => ({
|
|
101
|
+
id: e.id,
|
|
102
|
+
title: String(e.title || ""),
|
|
103
|
+
detail: String(e.detail || ""),
|
|
104
|
+
start: e.start,
|
|
105
|
+
end: e.end ?? null
|
|
106
|
+
})),
|
|
107
|
+
{
|
|
108
|
+
orientation: A,
|
|
109
|
+
spacing: Z,
|
|
110
|
+
containerWidth: tt,
|
|
111
|
+
viewportHeight: typeof window < "u" && window.innerHeight || 800,
|
|
112
|
+
now: T,
|
|
113
|
+
k: he ? "fit" : Ue
|
|
114
|
+
}
|
|
115
|
+
), V = new Map(s.items.map((e) => [e.id, e])), we = L(s.kFit), ye = L(s.kEff);
|
|
116
|
+
we.current = s.kFit, ye.current = s.kEff;
|
|
117
|
+
const x = L(null);
|
|
118
|
+
ct(() => {
|
|
119
|
+
const e = g.current;
|
|
120
|
+
x.current && e && (x.current.left != null && (e.scrollLeft = x.current.left), x.current.top != null && (e.scrollTop = x.current.top), x.current = null);
|
|
121
|
+
});
|
|
122
|
+
const B = Y(
|
|
123
|
+
(e, n) => {
|
|
124
|
+
const t = g.current;
|
|
125
|
+
if (!t) return;
|
|
126
|
+
const i = we.current || 1, k = ye.current || 1, h = Math.max(i * 0.3, Math.min(Math.max(i, 1) * 40, k * e)), N = w ? t.scrollLeft : t.scrollTop, f = h / k;
|
|
127
|
+
x.current = w ? { left: (N + n) * f - n } : { top: (N + n) * f - n }, pe(!1), me(h);
|
|
128
|
+
},
|
|
129
|
+
[w]
|
|
130
|
+
);
|
|
131
|
+
Tt(
|
|
132
|
+
g,
|
|
133
|
+
(e) => {
|
|
134
|
+
e.preventDefault();
|
|
135
|
+
const n = g.current;
|
|
136
|
+
if (!n) return;
|
|
137
|
+
const t = n.getBoundingClientRect(), i = w ? e.clientX - t.left : e.clientY - t.top;
|
|
138
|
+
B(Math.exp(-(e.deltaY || e.deltaX) * 22e-4), i);
|
|
139
|
+
},
|
|
140
|
+
A
|
|
141
|
+
);
|
|
142
|
+
const Ne = () => {
|
|
143
|
+
const e = g.current;
|
|
144
|
+
return e ? w ? e.clientWidth / 2 : e.clientHeight / 2 : 300;
|
|
145
|
+
}, J = (e) => {
|
|
146
|
+
q === void 0 && Ge(e ? e.id : null), Ie?.(e);
|
|
147
|
+
}, nt = (e) => {
|
|
148
|
+
ie === void 0 && Xe(e), Ee?.(e);
|
|
149
|
+
}, lt = (e) => {
|
|
150
|
+
ae === void 0 && Ke(e), Oe?.(e);
|
|
151
|
+
}, ot = (e) => {
|
|
152
|
+
const n = window.innerWidth || 1200, t = window.innerHeight || 800, i = e.clientX < n * 0.55 ? Math.max(12, n - 340) : 16, k = Math.max(130, Math.min(e.clientY, t - 130));
|
|
153
|
+
return { x: i, y: k };
|
|
154
|
+
}, $ = c.length ? c[0].start : T, Se = c.length ? Math.max($ + 1, ...c.map((e) => e.end == null ? T : Math.max(e.end, e.start))) : T + 1, Q = Math.max(1, Se - $), be = (e, n) => {
|
|
155
|
+
const t = new Date(e);
|
|
156
|
+
return n === "y" ? String(t.getFullYear()) : n === "my" ? t.toLocaleString("en", { month: "short" }) + " " + t.getFullYear() : n === "d" ? mt(e) : ht(e);
|
|
157
|
+
};
|
|
158
|
+
let ee = [];
|
|
159
|
+
if (Z === "proportional" && s.mapT) {
|
|
160
|
+
const e = pt($, Se, Math.max(200, s.innerSpan), 90), n = e.step >= 360 * E ? "y" : e.step >= 28 * E ? "my" : e.step >= E ? "d" : "c";
|
|
161
|
+
ee = e.list.map((t) => ({
|
|
162
|
+
pos: Math.round(s.mapT(t.t)),
|
|
163
|
+
label: be(t.t, n)
|
|
164
|
+
}));
|
|
165
|
+
} else {
|
|
166
|
+
const e = Q > 550 * E ? "y" : Q > 60 * E ? "my" : Q > 2 * E ? "d" : "c", n = w ? 72 : 18;
|
|
167
|
+
let t = null, i = -1e9;
|
|
168
|
+
c.forEach((k, h) => {
|
|
169
|
+
const N = be(k.start, e), f = Math.round(s.posArr[h]);
|
|
170
|
+
N !== t && f - i >= n && (ee.push({ pos: f, label: N }), t = N, i = f);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
const it = ke(() => {
|
|
174
|
+
const e = [];
|
|
175
|
+
return c.forEach((n) => {
|
|
176
|
+
const t = n.tag || "event";
|
|
177
|
+
e.includes(t) || e.push(t);
|
|
178
|
+
}), e;
|
|
179
|
+
}, [c]), a = P != null && c.find((e) => e.id === P) || null, Te = a ? a.end == null : !1, z = W ? /* @__PURE__ */ l(
|
|
180
|
+
gt,
|
|
181
|
+
{
|
|
182
|
+
className: m?.summary,
|
|
183
|
+
placement: H,
|
|
184
|
+
floatingDefaultPosition: Ve,
|
|
185
|
+
items: c.map((e, n) => {
|
|
186
|
+
const t = V.get(e.id), i = !t || !v.w && !v.h ? !0 : (!v.w || t.cardLeft < v.l + v.w && t.cardLeft + t.cardW > v.l) && (!v.h || t.cardTop < v.t + v.h && t.cardTop + t.cardH > v.t);
|
|
187
|
+
return {
|
|
188
|
+
id: e.id,
|
|
189
|
+
number: String(n + 1).padStart(2, "0"),
|
|
190
|
+
label: e.title,
|
|
191
|
+
color: M(e.tag),
|
|
192
|
+
time: R(e.start),
|
|
193
|
+
inView: i,
|
|
194
|
+
selected: P === e.id
|
|
195
|
+
};
|
|
196
|
+
}),
|
|
197
|
+
onPick: (e) => {
|
|
198
|
+
const n = V.get(e), t = g.current;
|
|
199
|
+
if (!n || !t) return;
|
|
200
|
+
const i = {};
|
|
201
|
+
(t.clientWidth || !t.clientHeight) && (i.left = Math.max(0, n.dotX - t.clientWidth / 2)), t.clientHeight && (i.top = Math.max(0, n.dotY - t.clientHeight / 2)), xt(t, i);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
) : null;
|
|
205
|
+
return /* @__PURE__ */ d("div", { ref: Le, className: p(r.root, m?.root, Ye), style: je, children: [
|
|
206
|
+
(ce || ve) && /* @__PURE__ */ d("div", { className: p(r.toolbar, m?.toolbar), children: [
|
|
207
|
+
/* @__PURE__ */ l("div", { className: r.toolbarText }),
|
|
208
|
+
ve,
|
|
209
|
+
ce && /* @__PURE__ */ d(ne, { children: [
|
|
210
|
+
/* @__PURE__ */ l(
|
|
211
|
+
He,
|
|
212
|
+
{
|
|
213
|
+
value: A,
|
|
214
|
+
options: [
|
|
215
|
+
{ value: "horizontal", label: "Horizontal" },
|
|
216
|
+
{ value: "vertical", label: "Vertical" }
|
|
217
|
+
],
|
|
218
|
+
onChange: nt
|
|
219
|
+
}
|
|
220
|
+
),
|
|
221
|
+
/* @__PURE__ */ l(
|
|
222
|
+
He,
|
|
223
|
+
{
|
|
224
|
+
value: Z,
|
|
225
|
+
options: [
|
|
226
|
+
{ value: "equal", label: "Equal" },
|
|
227
|
+
{
|
|
228
|
+
value: "log",
|
|
229
|
+
label: "Log",
|
|
230
|
+
title: "Logarithmic gaps — long waits compressed"
|
|
231
|
+
},
|
|
232
|
+
{ value: "proportional", label: "Proportional" }
|
|
233
|
+
],
|
|
234
|
+
onChange: lt
|
|
235
|
+
}
|
|
236
|
+
),
|
|
237
|
+
/* @__PURE__ */ l(
|
|
238
|
+
vt,
|
|
239
|
+
{
|
|
240
|
+
zoomPct: `${Math.round(s.kEff / s.kFit * 100)}%`,
|
|
241
|
+
fitActive: he,
|
|
242
|
+
onZoomIn: () => B(1.5, Ne()),
|
|
243
|
+
onZoomOut: () => B(1 / 1.5, Ne()),
|
|
244
|
+
onFit: () => {
|
|
245
|
+
pe(!0), me(1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
)
|
|
249
|
+
] })
|
|
250
|
+
] }),
|
|
251
|
+
Ae && /* @__PURE__ */ l(
|
|
252
|
+
wt,
|
|
253
|
+
{
|
|
254
|
+
className: m?.legend,
|
|
255
|
+
items: it.map((e) => ({ name: e, color: M(e) }))
|
|
256
|
+
}
|
|
257
|
+
),
|
|
258
|
+
H === "top" && z,
|
|
259
|
+
/* @__PURE__ */ d("div", { className: r.layout, children: [
|
|
260
|
+
H === "left" && z,
|
|
261
|
+
/* @__PURE__ */ d("div", { className: r.main, children: [
|
|
262
|
+
/* @__PURE__ */ l("div", { className: p(r.card, m?.card), children: /* @__PURE__ */ l(
|
|
263
|
+
"div",
|
|
264
|
+
{
|
|
265
|
+
ref: g,
|
|
266
|
+
className: p(
|
|
267
|
+
r.scroller,
|
|
268
|
+
w ? o.scrollerH : o.scrollerV,
|
|
269
|
+
m?.scroller
|
|
270
|
+
),
|
|
271
|
+
style: de != null ? { maxHeight: de } : void 0,
|
|
272
|
+
onPointerDown: O.onPointerDown,
|
|
273
|
+
onPointerMove: O.onPointerMove,
|
|
274
|
+
onPointerUp: O.onPointerUp,
|
|
275
|
+
onPointerLeave: O.onPointerUp,
|
|
276
|
+
onScroll: Je,
|
|
277
|
+
children: /* @__PURE__ */ d(
|
|
278
|
+
"div",
|
|
279
|
+
{
|
|
280
|
+
className: o.inner,
|
|
281
|
+
style: { width: s.innerW, height: s.innerH },
|
|
282
|
+
children: [
|
|
283
|
+
ee.map(
|
|
284
|
+
(e, n) => w ? /* @__PURE__ */ d("span", { children: [
|
|
285
|
+
/* @__PURE__ */ l("span", { className: o.gridlineH, style: { left: e.pos } }),
|
|
286
|
+
/* @__PURE__ */ l("span", { className: o.tickLabelH, style: { left: e.pos }, children: e.label })
|
|
287
|
+
] }, n) : /* @__PURE__ */ d("span", { children: [
|
|
288
|
+
/* @__PURE__ */ l("span", { className: o.gridlineV, style: { top: e.pos } }),
|
|
289
|
+
/* @__PURE__ */ l("span", { className: o.tickLabelV, style: { top: e.pos }, children: e.label })
|
|
290
|
+
] }, n)
|
|
291
|
+
),
|
|
292
|
+
w ? /* @__PURE__ */ l("div", { className: o.axisH, style: { top: s.axisY } }) : /* @__PURE__ */ l("div", { className: o.axisV, style: { left: s.axisX } }),
|
|
293
|
+
c.map((e, n) => {
|
|
294
|
+
const t = V.get(e.id);
|
|
295
|
+
if (!t) return null;
|
|
296
|
+
const i = e.end == null, h = (i ? T : e.end) - e.start, N = i || h > 0, f = dt(e, b), I = M(e.tag), xe = {
|
|
297
|
+
index: n,
|
|
298
|
+
number: String(n + 1).padStart(2, "0"),
|
|
299
|
+
color: I,
|
|
300
|
+
ongoing: i,
|
|
301
|
+
condensed: t.condensed,
|
|
302
|
+
durationMs: h
|
|
303
|
+
};
|
|
304
|
+
return /* @__PURE__ */ d("span", { children: [
|
|
305
|
+
t.segs.map((C, te) => /* @__PURE__ */ l(
|
|
306
|
+
"span",
|
|
307
|
+
{
|
|
308
|
+
className: o.seg,
|
|
309
|
+
style: {
|
|
310
|
+
left: C.l,
|
|
311
|
+
top: C.t,
|
|
312
|
+
width: C.w,
|
|
313
|
+
height: C.h,
|
|
314
|
+
background: I
|
|
315
|
+
}
|
|
316
|
+
},
|
|
317
|
+
te
|
|
318
|
+
)),
|
|
319
|
+
/* @__PURE__ */ l(
|
|
320
|
+
"span",
|
|
321
|
+
{
|
|
322
|
+
className: p(o.dot, m?.dot),
|
|
323
|
+
style: { left: t.dotX, top: t.dotY, borderColor: I }
|
|
324
|
+
}
|
|
325
|
+
),
|
|
326
|
+
/* @__PURE__ */ l(
|
|
327
|
+
"div",
|
|
328
|
+
{
|
|
329
|
+
className: p(o.eventCard, m?.eventCard),
|
|
330
|
+
style: {
|
|
331
|
+
left: t.cardLeft,
|
|
332
|
+
top: t.cardTop,
|
|
333
|
+
width: t.cardW,
|
|
334
|
+
height: t.cardH,
|
|
335
|
+
opacity: b && !f ? 0.3 : 1,
|
|
336
|
+
background: b && f ? "var(--crk-timeline-hl-wash-soft, #fff9e8)" : void 0,
|
|
337
|
+
borderColor: b && f ? "var(--crk-timeline-hl-border, #e8b931)" : void 0,
|
|
338
|
+
boxShadow: b && f ? "0 0 0 3px #f9e9b8" : "0 1px 3px rgba(35,32,28,.06)"
|
|
339
|
+
},
|
|
340
|
+
onClick: () => {
|
|
341
|
+
O.wasDragSuppressed() || (K(null), J(P === e.id ? null : e));
|
|
342
|
+
},
|
|
343
|
+
onMouseEnter: (C) => {
|
|
344
|
+
if (P === e.id) return;
|
|
345
|
+
const te = (e.detail || "").length > 80;
|
|
346
|
+
if (!F && !te && !i) return;
|
|
347
|
+
const at = ot(C);
|
|
348
|
+
K({
|
|
349
|
+
...at,
|
|
350
|
+
id: e.id,
|
|
351
|
+
title: e.title,
|
|
352
|
+
time: R(e.start),
|
|
353
|
+
durLine: i ? "ongoing · " + D(h) + " so far" : h > 0 ? "duration " + D(h) : "instant event",
|
|
354
|
+
detail: e.detail || ""
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
onMouseLeave: () => K(null),
|
|
358
|
+
children: ue ? ue(e, xe) : /* @__PURE__ */ d(ne, { children: [
|
|
359
|
+
/* @__PURE__ */ d("div", { className: o.cardTitle, children: [
|
|
360
|
+
/* @__PURE__ */ l("span", { className: o.cardNum, children: xe.number }),
|
|
361
|
+
" ",
|
|
362
|
+
/* @__PURE__ */ l("span", { className: o.cardTagDot, style: { background: I } }),
|
|
363
|
+
/* @__PURE__ */ l(Me, { text: e.title, query: b }),
|
|
364
|
+
i && /* @__PURE__ */ l("span", { className: p(r.pulseDot, o.cardOngoingDot) })
|
|
365
|
+
] }),
|
|
366
|
+
/* @__PURE__ */ l("div", { className: o.cardTime, children: R(e.start) }),
|
|
367
|
+
!t.condensed && !!e.detail && /* @__PURE__ */ l("div", { className: o.cardDetail, children: /* @__PURE__ */ l(Me, { text: e.detail, query: b }) }),
|
|
368
|
+
N && /* @__PURE__ */ l("div", { className: o.cardDur, children: i ? "ongoing · " + D(h) : "took " + D(h) })
|
|
369
|
+
] })
|
|
370
|
+
}
|
|
371
|
+
)
|
|
372
|
+
] }, e.id);
|
|
373
|
+
})
|
|
374
|
+
]
|
|
375
|
+
}
|
|
376
|
+
)
|
|
377
|
+
}
|
|
378
|
+
) }),
|
|
379
|
+
/* @__PURE__ */ l("div", { className: p(r.footnote, m?.footnote), children: "Click a card to open details in the side panel · scroll zooms · drag pans · overlapping events stack around the axis with Z-shaped leads" })
|
|
380
|
+
] }),
|
|
381
|
+
a && X && /* @__PURE__ */ l("aside", { className: p(r.aside, o.drawer, m?.drawer), children: X(a, { close: () => J(null), ongoing: Te }) }),
|
|
382
|
+
a && !X && /* @__PURE__ */ d("aside", { className: p(r.aside, o.drawer, m?.drawer), children: [
|
|
383
|
+
/* @__PURE__ */ d("div", { className: o.drawerHead, children: [
|
|
384
|
+
/* @__PURE__ */ l(
|
|
385
|
+
"span",
|
|
386
|
+
{
|
|
387
|
+
className: o.drawerTag,
|
|
388
|
+
style: {
|
|
389
|
+
background: ut(M(a.tag), 12),
|
|
390
|
+
color: M(a.tag)
|
|
391
|
+
},
|
|
392
|
+
children: a.tag || "event"
|
|
393
|
+
}
|
|
394
|
+
),
|
|
395
|
+
(oe ?? a.subject) != null && /* @__PURE__ */ l("span", { className: o.drawerSubject, children: oe ?? a.subject }),
|
|
396
|
+
/* @__PURE__ */ l("div", { className: o.drawerSpacer }),
|
|
397
|
+
/* @__PURE__ */ l(
|
|
398
|
+
"button",
|
|
399
|
+
{
|
|
400
|
+
type: "button",
|
|
401
|
+
className: r.asideClose,
|
|
402
|
+
"aria-label": "Close details",
|
|
403
|
+
onClick: () => J(null),
|
|
404
|
+
children: "✕"
|
|
405
|
+
}
|
|
406
|
+
)
|
|
407
|
+
] }),
|
|
408
|
+
/* @__PURE__ */ l("div", { className: o.drawerTitle, children: a.title }),
|
|
409
|
+
/* @__PURE__ */ l("div", { className: o.drawerTiming, children: R(a.start) + (Te ? " · ongoing, " + D(T - a.start) + " so far" : a.end > a.start ? " → " + R(a.end) + " · " + D(a.end - a.start) : "") }),
|
|
410
|
+
/* @__PURE__ */ l("div", { className: o.drawerDetail, children: a.detail || "—" }),
|
|
411
|
+
/* @__PURE__ */ l("div", { className: r.asideSection, children: "Raw event" }),
|
|
412
|
+
/* @__PURE__ */ l("pre", { className: r.asideRaw, children: JSON.stringify(a, null, 2) })
|
|
413
|
+
] }),
|
|
414
|
+
(H === "right" || H === "floating") && z
|
|
415
|
+
] }),
|
|
416
|
+
H === "bottom" && z,
|
|
417
|
+
y && (() => {
|
|
418
|
+
const e = c.find((i) => i.id === y.id), n = e ? c.indexOf(e) : -1, t = e && F ? F(e, {
|
|
419
|
+
index: n,
|
|
420
|
+
number: String(n + 1).padStart(2, "0"),
|
|
421
|
+
color: M(e.tag),
|
|
422
|
+
ongoing: e.end == null,
|
|
423
|
+
condensed: V.get(e.id)?.condensed ?? !1,
|
|
424
|
+
durationMs: (e.end == null ? T : e.end) - e.start
|
|
425
|
+
}) : void 0;
|
|
426
|
+
return F && t == null ? null : /* @__PURE__ */ l(yt, { x: y.x, y: y.y, className: m?.tooltip, children: t !== void 0 ? t : /* @__PURE__ */ d(ne, { children: [
|
|
427
|
+
/* @__PURE__ */ l("div", { className: r.tooltipTitle, children: y.title }),
|
|
428
|
+
/* @__PURE__ */ l(
|
|
429
|
+
"div",
|
|
430
|
+
{
|
|
431
|
+
className: p(r.tooltipLine, r.tooltipMono),
|
|
432
|
+
style: { marginTop: 4 },
|
|
433
|
+
children: y.time
|
|
434
|
+
}
|
|
435
|
+
),
|
|
436
|
+
/* @__PURE__ */ l("div", { className: r.tooltipLine, children: y.durLine }),
|
|
437
|
+
y.detail && /* @__PURE__ */ l("div", { className: r.tooltipDim, style: { marginTop: 5 }, children: y.detail })
|
|
438
|
+
] }) });
|
|
439
|
+
})()
|
|
440
|
+
] });
|
|
441
|
+
}
|
|
442
|
+
);
|
|
443
|
+
export {
|
|
444
|
+
Ft as HistoryTimeline
|
|
445
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const r = "crk-scrollerH-LFjBZ", c = "crk-scrollerV-bq4-N", a = "crk-inner-UOGZr", e = "crk-gridlineH-vNcMq", t = "crk-tickLabelH-9D3Vy", d = "crk-gridlineV-3Hh4e", n = "crk-tickLabelV-J1uG2", i = "crk-axisH-glZQm", o = "crk-axisV-cnYLL", s = "crk-seg-Jy0m7", l = "crk-dot-y6jZ-", k = "crk-eventCard-bgrfd", g = "crk-cardTitle-AXpEz", w = "crk-cardNum-RwPgr", T = "crk-cardTagDot-nHFoA", H = "crk-cardOngoingDot-U7vkl", D = "crk-cardTime-YR4zJ", V = "crk-cardDetail-xXigO", b = "crk-cardDur-zvm0a", m = "crk-drawer-PNT-u", u = "crk-drawerHead-YQ7XA", L = "crk-drawerTag-nM-Vq", x = "crk-drawerSubject-AIsj3", j = "crk-drawerSpacer-7yhCb", p = "crk-drawerTitle-y-rwh", v = "crk-drawerTiming-55UzB", y = "crk-drawerDetail-pagRq", N = {
|
|
2
|
+
scrollerH: r,
|
|
3
|
+
scrollerV: c,
|
|
4
|
+
inner: a,
|
|
5
|
+
gridlineH: e,
|
|
6
|
+
tickLabelH: t,
|
|
7
|
+
gridlineV: d,
|
|
8
|
+
tickLabelV: n,
|
|
9
|
+
axisH: i,
|
|
10
|
+
axisV: o,
|
|
11
|
+
seg: s,
|
|
12
|
+
dot: l,
|
|
13
|
+
eventCard: k,
|
|
14
|
+
cardTitle: g,
|
|
15
|
+
cardNum: w,
|
|
16
|
+
cardTagDot: T,
|
|
17
|
+
cardOngoingDot: H,
|
|
18
|
+
cardTime: D,
|
|
19
|
+
cardDetail: V,
|
|
20
|
+
cardDur: b,
|
|
21
|
+
drawer: m,
|
|
22
|
+
drawerHead: u,
|
|
23
|
+
drawerTag: L,
|
|
24
|
+
drawerSubject: x,
|
|
25
|
+
drawerSpacer: j,
|
|
26
|
+
drawerTitle: p,
|
|
27
|
+
drawerTiming: v,
|
|
28
|
+
drawerDetail: y
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
i as axisH,
|
|
32
|
+
o as axisV,
|
|
33
|
+
V as cardDetail,
|
|
34
|
+
b as cardDur,
|
|
35
|
+
w as cardNum,
|
|
36
|
+
H as cardOngoingDot,
|
|
37
|
+
T as cardTagDot,
|
|
38
|
+
D as cardTime,
|
|
39
|
+
g as cardTitle,
|
|
40
|
+
N as default,
|
|
41
|
+
l as dot,
|
|
42
|
+
m as drawer,
|
|
43
|
+
y as drawerDetail,
|
|
44
|
+
u as drawerHead,
|
|
45
|
+
j as drawerSpacer,
|
|
46
|
+
x as drawerSubject,
|
|
47
|
+
L as drawerTag,
|
|
48
|
+
v as drawerTiming,
|
|
49
|
+
p as drawerTitle,
|
|
50
|
+
k as eventCard,
|
|
51
|
+
e as gridlineH,
|
|
52
|
+
d as gridlineV,
|
|
53
|
+
a as inner,
|
|
54
|
+
r as scrollerH,
|
|
55
|
+
c as scrollerV,
|
|
56
|
+
s as seg,
|
|
57
|
+
t as tickLabelH,
|
|
58
|
+
n as tickLabelV
|
|
59
|
+
};
|