@overdoser/react-toolkit 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/AGENTS.md +6 -0
  2. package/CHANGELOG.md +84 -0
  3. package/components/Drawer/Drawer.js +88 -83
  4. package/components/Timeline/GanttTimeline.d.ts +144 -0
  5. package/components/Timeline/GanttTimeline.js +305 -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 +511 -0
  15. package/components/Timeline/TraceTimeline.module.scss.js +105 -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 +90 -0
  21. package/components/Timeline/timelineCore.js +135 -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/components/inputs/Select/Select.js +158 -154
  27. package/index.css +1 -1
  28. package/index.d.ts +2 -0
  29. package/index.js +93 -87
  30. package/index.layered.css +1 -1
  31. package/llms.txt +113 -0
  32. package/manifest.json +323 -0
  33. package/package.json +1 -1
  34. package/recipes/live-timeline-feed.tsx +147 -0
@@ -0,0 +1,82 @@
1
+ /**
2
+ * HistoryTimeline layout, ported near-verbatim from the design handoff
3
+ * (`Subject History.dc.html` logic block). Pure and unit-tested for the
4
+ * collision-avoidance guarantees. The algorithm, in order:
5
+ *
6
+ * 1. **Side split** — events too close to share a side (cluster threshold
7
+ * 120px horizontal / 110px vertical) alternate around the axis; isolated
8
+ * events alternate globally. Narrow vertical mode forces all to one side.
9
+ * 2. **Circles** sit ON the axis; they step outward in 20px levels only when
10
+ * their level within 46px is occupied on their side (protects Z stubs), or
11
+ * when a close event exists on the opposite side.
12
+ * 3. **Per-side reconciliation, newest first.** Rows extend away from the
13
+ * axis, each sized by its tallest/widest chip + 12px gap. A chip prefers a
14
+ * straight centered stem (may slide sideways past occupied extents as long
15
+ * as the stem still lands inside it); same-side bursts are placed as
16
+ * groups on consecutive rows with parallel Z-leads; non-group conflicts
17
+ * fall back to Z-leads with bounded slides, and as a last resort an extra
18
+ * row (never identical coordinates).
19
+ */
20
+ export interface HistoryLayoutEventInput {
21
+ id: string;
22
+ title: string;
23
+ detail: string;
24
+ start: number;
25
+ /** `null` = ongoing. */
26
+ end: number | null;
27
+ }
28
+ export interface HistoryLayoutConfig {
29
+ orientation: 'horizontal' | 'vertical';
30
+ spacing: 'equal' | 'log' | 'proportional';
31
+ /** Scroll container client width. */
32
+ containerWidth: number;
33
+ /** Viewport height (drives fit targets). */
34
+ viewportHeight: number;
35
+ /** Current time (sizes ongoing events). */
36
+ now: number;
37
+ /** Explicit zoom factor, or `'fit'` to fit-with-cross-axis-iteration. */
38
+ k: number | 'fit';
39
+ }
40
+ export interface HistorySeg {
41
+ l: number;
42
+ t: number;
43
+ w: number;
44
+ h: number;
45
+ }
46
+ export interface HistoryLayoutItem {
47
+ id: string;
48
+ /** Axis-position of the event. */
49
+ pos: number;
50
+ dotX: number;
51
+ dotY: number;
52
+ cardLeft: number;
53
+ cardTop: number;
54
+ cardW: number;
55
+ cardH: number;
56
+ /** Burst-condensed member (detail omitted). */
57
+ condensed: boolean;
58
+ /** Lead-line segments (axis-colored, drawn under dots and cards). */
59
+ segs: HistorySeg[];
60
+ /** 0 = above/right of the axis, 1 = below/left. */
61
+ side: number;
62
+ row: number;
63
+ mode: 's' | 'z';
64
+ }
65
+ export interface HistoryLayoutResult {
66
+ items: HistoryLayoutItem[];
67
+ axisY: number;
68
+ axisX: number;
69
+ innerW: number;
70
+ innerH: number;
71
+ /** Effective zoom factor after fit iteration. */
72
+ kEff: number;
73
+ /** Fit zoom factor (100% reference). */
74
+ kFit: number;
75
+ /** Axis-positions per event (tick placement for equal/log spacing). */
76
+ posArr: number[];
77
+ /** Time→position map (proportional spacing only). */
78
+ mapT: ((t: number) => number) | null;
79
+ /** Pixel length of the time span (proportional tick generation). */
80
+ innerSpan: number;
81
+ }
82
+ export declare function computeHistoryLayout(events: HistoryLayoutEventInput[], cfg: HistoryLayoutConfig): HistoryLayoutResult;
@@ -0,0 +1,264 @@
1
+ function Ut(jt, S) {
2
+ const C = jt.slice().sort((g, L) => g.start - L.start), X = C.length, $ = S.now, d = S.orientation === "horizontal", F = S.spacing, j = S.containerWidth, G = j < 640, tt = !d && G ? Math.max(190, j - 110) : 230, Lt = 144, st = d ? 150 : 80, Ot = d ? 150 : 140, it = X ? C[0].start : $, Pt = X ? Math.max(it + 1, ...C.map((g) => g.end == null ? $ : Math.max(g.end, g.start))) : $ + 1, At = Math.max(1, Pt - it);
3
+ let ot;
4
+ d ? ot = F === "equal" ? 300 + Math.max(0, X - 1) * 264 : Math.max(j, X * (F === "proportional" ? 200 : 170)) : ot = F === "equal" ? 200 + Math.max(0, X - 1) * 190 : Math.max(460, X * (F === "proportional" ? 150 : 130) + 180);
5
+ const Xt = (d ? j : Math.max(420, Math.round(S.viewportHeight * 0.66))) / ot, bt = (g) => {
6
+ const L = Math.max(320, Math.round(ot * g)), x = L - st - Ot;
7
+ let M = [], k = null;
8
+ if (F === "proportional")
9
+ k = (t) => st + (t - it) / At * x, M = C.map((t) => k(t.start));
10
+ else if (F === "log") {
11
+ const t = At / Math.max(8, X * 2), s = [];
12
+ let e = 0;
13
+ C.forEach((p, E) => {
14
+ E > 0 && (e += Math.log1p((p.start - C[E - 1].start) / t)), s.push(e);
15
+ });
16
+ const o = e || 1;
17
+ M = s.map((p) => st + p / o * x);
18
+ } else
19
+ M = C.map((t, s) => st + (X > 1 ? s * x / (X - 1) : 0));
20
+ let P = d ? Math.max(j, L) : 900;
21
+ const r = d ? 600 : L, b = d ? 120 : 110, v = [];
22
+ let Y = X ? [0] : [];
23
+ for (let t = 1; t < X; t++)
24
+ M[t] - M[t - 1] < b ? Y.push(t) : (v.push(Y), Y = [t]);
25
+ Y.length && v.push(Y);
26
+ const O = !d && G, h = C.map(() => ({ side: 0, row: 0, mode: "s", dlv: 0, rx: 0, lx: 0 }));
27
+ let H = 0;
28
+ for (let t = v.length - 1; t >= 0; t--) {
29
+ const s = v[t];
30
+ for (let e = s.length - 1; e >= 0; e--) {
31
+ const o = s.length - 1 - e;
32
+ h[s[e]].side = O ? 0 : s.length === 1 ? H++ % 2 : o % 2;
33
+ }
34
+ }
35
+ const Ft = M.map(
36
+ (t, s) => M.some((e, o) => o !== s && h[o].side !== h[s].side && Math.abs(e - t) < 18)
37
+ ), It = d ? tt * 0.55 : 110, U = new Array(X).fill(-1), nt = [];
38
+ [0, 1].forEach((t) => {
39
+ const s = [];
40
+ for (let o = 0; o < X; o++) h[o].side === t && s.push(o);
41
+ let e = null;
42
+ for (let o = 1; o < s.length; o++)
43
+ M[s[o]] - M[s[o - 1]] < It ? (e || (e = [s[o - 1]], nt.push(e), U[s[o - 1]] = nt.length - 1), e.push(s[o]), U[s[o]] = nt.length - 1) : e = null;
44
+ });
45
+ const Gt = {}, B = [], W = [];
46
+ for (let t = 0; t < X; t++) {
47
+ const s = C[t], e = U[t] >= 0, o = String(s.title || ""), p = String(s.detail || ""), E = s.end == null, at = (E ? $ : s.end) - s.start, wt = E || at > 0, gt = Math.min(2, Math.max(1, Math.ceil(o.length / 26))), N = e || !p ? 0 : Math.min(2, Math.ceil(p.length / 34));
48
+ B.push(Math.round(7 + gt * 17 + 3 + 15 + (N ? 3 + N * 16 : 0) + (wt ? 24 : 0) + 8)), W.push(
49
+ !d && G ? tt : e ? Math.max(160, Math.min(230, o.length * 7 + 64)) : 230
50
+ );
51
+ }
52
+ const Tt = [
53
+ { chips: [], stems: [] },
54
+ { chips: [], stems: [] }
55
+ ], _t = d ? 46 : 80, _ = [[], []];
56
+ for (let t = X - 1; t >= 0; t--) {
57
+ const s = _[h[t].side], e = M[t];
58
+ let o = Ft[t] ? 1 : 0;
59
+ for (; s.some((p) => p.lv === o && Math.abs(p.p - e) < _t); ) o++;
60
+ h[t].dlv = o, s.push({ p: e, lv: o, i: t });
61
+ }
62
+ const ft = 10, Rt = (t, s) => _[h[t].side].some(
63
+ (e) => e.i !== t && e.lv > h[t].dlv && Math.abs(e.p - s) < ft
64
+ ), Nt = (t, s, e) => _[h[t].side].some(
65
+ (o) => o.i !== t && (o.lv === h[t].dlv && o.p > s && o.p < e + ft || o.lv > h[t].dlv && Math.abs(o.p - e) < ft)
66
+ );
67
+ for (let t = X - 1; t >= 0; t--) {
68
+ const s = h[t], e = Tt[s.side], o = M[t], p = W[t], E = B[t], at = d ? o - p / 2 : o - 44, wt = (c, l, i) => !e.chips.some((m) => m.row === c && l < m.x2 + 10 && i > m.x1 - 10), gt = (c, l, i) => e.stems.some((m) => m.row > c && m.x > l - 6 && m.x < i + 6), N = (c, l) => e.chips.some((i) => i.row < c && l > i.x1 - 6 && l < i.x2 + 6), V = d ? p : E, Vt = Math.round(V / 2) - 20, y = (c, l) => {
69
+ let i = l, m = 0, f = !0;
70
+ for (; f && m++ < 60; ) {
71
+ f = !1;
72
+ for (const n of e.chips)
73
+ n.row === c && i < n.x2 + 10 && i + V > n.x1 - 10 && (i = n.x2 + 10, f = !0);
74
+ for (const n of e.stems)
75
+ n.row > c && n.x > i - 6 && n.x < i + V + 6 && (i = n.x + 7, f = !0);
76
+ }
77
+ return i;
78
+ }, St = (c, l) => {
79
+ const i = M[c], m = _[h[c].side];
80
+ let f = 1 / 0;
81
+ for (const a of m)
82
+ a.i !== c && a.lv === h[c].dlv && a.p > i && (f = Math.min(f, a.p - 8));
83
+ const n = (a) => !m.some((A) => A.i !== c && A.lv > h[c].dlv && Math.abs(A.p - a) < 8) && !e.stems.some((A) => Math.abs(A.x - a) < 4), u = Math.min(Math.max(l, i + 8), f);
84
+ for (let a = u; a <= f && a <= u + 80; a++) if (n(a)) return a;
85
+ for (let a = u - 1; a >= i + 8; a--) if (n(a)) return a;
86
+ return u;
87
+ }, Jt = (c, l) => {
88
+ const i = M[c];
89
+ return _[h[c].side].some(
90
+ (m) => m.i !== c && (m.lv > h[c].dlv && Math.abs(m.p - l) < 8 || m.lv === h[c].dlv && m.p > i && m.p < l + 8)
91
+ );
92
+ }, vt = (c, l, i) => {
93
+ const m = M[c], f = _[h[c].side];
94
+ let n = 1 / 0;
95
+ for (const w of f)
96
+ w.i !== c && w.lv === h[c].dlv && w.p > m && (n = Math.min(n, w.p - 28));
97
+ const u = (w) => !f.some((J) => J.i !== c && J.lv > h[c].dlv && Math.abs(J.p - (w + 20)) < 8);
98
+ let a = y(l, i), A = 0;
99
+ for (; !u(a) && a < n && A++ < 40; ) a = y(l, a + 4);
100
+ if (a > n || !u(a)) {
101
+ for (let w = Math.min(a, n); w >= i; w -= 2)
102
+ if (u(w) && y(l, w) === w) return w;
103
+ }
104
+ return a;
105
+ }, ct = U[t];
106
+ if (ct >= 0) {
107
+ if (!Gt[ct]) {
108
+ Gt[ct] = !0;
109
+ const c = nt[ct].slice().reverse(), l = c.length, i = c.map((f, n) => {
110
+ const u = l - 1 - n, a = M[f], A = Math.round(d ? a + 8 + (u + 1) * 10 : a + 10), w = Math.round(d ? Math.max(A + 12, a + 24 + u * 16) : a + 20);
111
+ return { j: f, jj: n, rx: A, lx: w, x1: w, x2: w + (d ? W[f] : B[f]) };
112
+ });
113
+ let m = 0;
114
+ for (; m <= 5; m++) {
115
+ let f = !0;
116
+ for (const n of i) {
117
+ const u = m + n.jj;
118
+ if (!wt(u, n.x1, n.x2) || gt(u, n.x1, n.x2)) {
119
+ f = !1;
120
+ break;
121
+ }
122
+ }
123
+ if (f) break;
124
+ }
125
+ for (let f = i.length - 1; f >= 0; f--) {
126
+ const n = i[f], u = h[n.j], a = m + n.jj, A = M[n.j], w = d ? W[n.j] : B[n.j], J = d ? A - W[n.j] / 2 : A - 44, lt = y(a, J), Kt = e.stems.some((z) => z.row > a && Math.abs(z.x - A) < 8);
127
+ if (lt - J <= Math.round(w / 2) - 20 && !Kt && !N(a, A) && !Rt(n.j, A))
128
+ u.row = a, u.mode = "s", u.sx1 = Math.round(lt), e.chips.push({ row: a, x1: lt, x2: lt + w, h: B[n.j], w: W[n.j] }), e.stems.push({ x: A, row: a });
129
+ else {
130
+ let z, Z;
131
+ d ? (z = Math.round(St(n.j, n.rx)), Z = Math.round(y(a, Math.max(n.lx, z + 12)))) : (z = n.rx, Z = Math.round(vt(n.j, a, n.lx))), u.row = a, u.mode = "z", u.rx = z, u.lx = Z, e.chips.push({ row: a, x1: Z, x2: Z + w, h: B[n.j], w: W[n.j] }), e.stems.push({ x: z, row: a });
132
+ }
133
+ }
134
+ }
135
+ continue;
136
+ }
137
+ let D = !1;
138
+ for (let c = 0; c <= 5 && !D; c++) {
139
+ const l = y(c, at);
140
+ l - at <= Vt && !N(c, o) && !Rt(t, o) && (s.row = c, s.mode = "s", s.sx1 = Math.round(l), e.chips.push({ row: c, x1: l, x2: l + V, h: E, w: p }), e.stems.push({ x: o, row: c }), D = !0);
141
+ }
142
+ if (!D)
143
+ for (const c of [64, 340]) {
144
+ for (let l = 0; l <= 5 && !D; l++) {
145
+ const i = o + 10 + l * 7, m = d ? i + 14 : o + 20, f = d ? y(l, m) : vt(t, l, m), n = d ? !Nt(t, o, i) : !Jt(t, f + 20);
146
+ f - m <= c && !N(l, d ? i : f + 20) && n && (s.row = l, s.mode = "z", s.rx = Math.round(i), s.lx = Math.round(f), e.chips.push({ row: l, x1: f, x2: f + V, h: E, w: p }), e.stems.push({ x: i, row: l }), D = !0);
147
+ }
148
+ if (D) break;
149
+ }
150
+ if (!D) {
151
+ let l, i;
152
+ d ? (l = Math.round(St(t, o + 10)), i = y(6, Math.max(o + 24, l + 12))) : (l = o + 10, i = vt(t, 6, o + 20)), s.row = 6, s.mode = "z", s.rx = Math.round(l), s.lx = Math.round(i), e.chips.push({ row: 6, x1: i, x2: i + V, h: E, w: p }), e.stems.push({ x: l, row: 6 });
153
+ }
154
+ }
155
+ const Et = Tt.map((t) => {
156
+ const s = [];
157
+ t.chips.forEach((p) => {
158
+ s[p.row] = Math.max(s[p.row] || 0, (d ? p.h : p.w) || (d ? Lt : tt));
159
+ });
160
+ const e = [];
161
+ let o = 44;
162
+ for (let p = 0; p < s.length; p++)
163
+ e[p] = o, o += (s[p] || 90) + 12;
164
+ return e.total = o, e;
165
+ }), mt = Et[0], pt = Et[1];
166
+ let ut = 0, rt = 0, Mt = 0;
167
+ if (d)
168
+ ut = 46 + Math.max(mt.total, 190), Mt = ut + Math.max(pt.total, 130) + 24;
169
+ else {
170
+ rt = G ? 26 : Math.round(j / 2), Mt = r;
171
+ const t = Math.max(0, 78 - (rt - pt.total - 16));
172
+ P = Math.max(j - 2, rt + mt.total + 16 + t + 24);
173
+ }
174
+ return { posArr: M, mapT: k, innerW: P, innerLen: r, innerSpan: x, meta: h, groupOf: U, chArr: B, cwArr: W, offA: mt, offB: pt, axisY: ut, axisX: rt, innerH: Mt };
175
+ };
176
+ let K = S.k === "fit" ? Xt : S.k, q = bt(K);
177
+ if (S.k === "fit") {
178
+ const g = d ? Math.max(380, Math.round(S.viewportHeight * 0.8)) : j + 4;
179
+ let L = 0;
180
+ for (; L++ < 6 && (d ? q.innerH > g : q.innerW > g); )
181
+ K = K * 1.3, q = bt(K);
182
+ }
183
+ const { posArr: kt, mapT: Wt, innerSpan: yt, meta: zt, groupOf: qt, chArr: Bt, cwArr: Dt, offA: Ht, offB: Yt, axisY: Q } = q;
184
+ let T = q.axisX, et = q.innerW, ht = q.innerH, I = 0, dt = 0, xt = 1e9;
185
+ const R = 1.5, Ct = C.map((g, L) => {
186
+ const x = zt[L], M = Math.round(kt[L]), k = Dt[L], P = Bt[L], r = {
187
+ id: g.id,
188
+ pos: M,
189
+ dotX: 0,
190
+ dotY: 0,
191
+ cardLeft: 0,
192
+ cardTop: 0,
193
+ cardW: k,
194
+ cardH: P,
195
+ condensed: qt[L] >= 0,
196
+ segs: [],
197
+ side: x.side,
198
+ row: x.row,
199
+ mode: x.mode
200
+ };
201
+ if (d) {
202
+ const b = M;
203
+ r.dotX = b;
204
+ const v = x.side === 0;
205
+ r.dotY = v ? Q - x.dlv * 20 : Q + x.dlv * 20;
206
+ const Y = v ? Ht : Yt, O = Y[x.row] != null ? Y[x.row] : 44 + x.row * (Lt + 12);
207
+ if (r.cardTop = v ? Q - O - P : Q + O, x.mode === "s") {
208
+ r.cardLeft = x.sx1 != null ? x.sx1 : b - Math.round(k / 2);
209
+ const h = v ? r.cardTop + P : r.dotY + 8, H = v ? r.dotY - 8 : r.cardTop;
210
+ r.segs.push({ l: b - 1, t: h, w: R, h: Math.max(2, H - h) });
211
+ } else {
212
+ const h = x.rx;
213
+ r.cardLeft = x.lx;
214
+ const H = r.cardTop + Math.round(P / 2);
215
+ r.segs.push({ l: b + 7, t: r.dotY - 1, w: Math.max(2, h - b - 7 + R), h: R }), r.segs.push({ l: h - 1, t: Math.min(r.dotY, H), w: R, h: Math.abs(H - r.dotY) + R }), r.segs.push({ l: h - 1, t: H - 1, w: Math.max(2, r.cardLeft - h + 1), h: R });
216
+ }
217
+ I = Math.max(I, r.cardLeft + k);
218
+ } else {
219
+ const b = M;
220
+ r.dotY = b;
221
+ const v = x.side === 0;
222
+ r.dotX = v || G ? T + x.dlv * 20 : T - x.dlv * 20;
223
+ const Y = v ? Ht : Yt, O = Y[x.row] != null ? Y[x.row] : 44 + x.row * (tt + 14);
224
+ if (x.mode === "s") {
225
+ r.cardTop = x.sx1 != null ? x.sx1 : b - 44, r.cardLeft = G ? T + 34 : v ? T + O : T - O - k;
226
+ const h = v || G ? r.dotX + 8 : r.cardLeft + k, H = v || G ? r.cardLeft : r.dotX - 8;
227
+ r.segs.push({ l: h, t: b - 1, w: Math.max(2, H - h), h: R });
228
+ } else {
229
+ r.cardTop = x.lx, r.cardLeft = G ? T + 34 : v ? T + O + 16 : T - O - 16 - k;
230
+ const h = r.cardTop + 20;
231
+ r.segs.push({ l: r.dotX - 1, t: b + 7, w: R, h: Math.max(2, h - b - 7 + R) });
232
+ const H = v || G ? r.cardLeft : r.cardLeft + k;
233
+ r.segs.push({ l: Math.min(r.dotX, H), t: h - 1, w: Math.max(2, Math.abs(H - r.dotX)), h: R });
234
+ }
235
+ dt = Math.max(dt, r.cardTop + P), I = Math.max(I, r.cardLeft + k), xt = Math.min(xt, r.cardLeft);
236
+ }
237
+ return r;
238
+ });
239
+ if (d) et = Math.max(et, I + 40);
240
+ else {
241
+ ht = Math.max(ht, dt + 40);
242
+ const g = Math.max(0, 78 - xt);
243
+ g && (T += g, Ct.forEach((L) => {
244
+ L.dotX += g, L.cardLeft += g, L.segs.forEach((x) => {
245
+ x.l += g;
246
+ });
247
+ })), et = Math.max(j - 2, I + g + 24);
248
+ }
249
+ return {
250
+ items: Ct,
251
+ axisY: Q,
252
+ axisX: T,
253
+ innerW: Math.ceil(et),
254
+ innerH: Math.ceil(ht),
255
+ kEff: K,
256
+ kFit: Xt,
257
+ posArr: kt,
258
+ mapT: Wt,
259
+ innerSpan: yt
260
+ };
261
+ }
262
+ export {
263
+ Ut as computeHistoryLayout
264
+ };
@@ -0,0 +1,7 @@
1
+ export type { TimelineSummaryPlacement } from './TimelineShared';
2
+ export { TraceTimeline } from './TraceTimeline';
3
+ export type { TraceTimelineProps, TraceTimelineEvent, TraceTimelineClasses, TraceTimelineItemContext, } from './TraceTimeline';
4
+ export { HistoryTimeline } from './HistoryTimeline';
5
+ export type { HistoryTimelineProps, HistoryTimelineEvent, HistoryTimelineClasses, HistoryTimelineOrientation, HistoryTimelineSpacing, HistoryTimelineItemContext, } from './HistoryTimeline';
6
+ export { GanttTimeline } from './GanttTimeline';
7
+ export type { GanttTimelineProps, GanttTimelineTask, GanttTimelineClasses, GanttTimelineItemContext, } from './GanttTimeline';
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Shared internals for the Timeline family (TraceTimeline, HistoryTimeline,
3
+ * GanttTimeline). Ported from the design-handoff `timeline-core.js` — the
4
+ * formatting rules, tick step table, and matching/highlighting semantics are
5
+ * part of the visual spec and must stay behaviorally identical.
6
+ */
7
+ export declare const SECOND = 1000;
8
+ export declare const MINUTE: number;
9
+ export declare const HOUR: number;
10
+ export declare const DAY: number;
11
+ /** `HH:MM:SS` in local time, optionally with milliseconds. */
12
+ export declare function fmtClock(t: number, ms?: boolean): string;
13
+ /** `Jul 27` in local time. */
14
+ export declare function fmtDate(t: number): string;
15
+ /**
16
+ * `Jul 27 · 14:03:22`; the year is included when not the current year, and the
17
+ * clock is dropped entirely for events older than two years.
18
+ */
19
+ export declare function fmtDateTime(t: number): string;
20
+ /** `HH:MM:SS` in UTC, optionally with milliseconds. */
21
+ export declare function fmtClockUTC(t: number, ms?: boolean): string;
22
+ /** `YYYY-MM-DD` in UTC. */
23
+ export declare function fmtDateISO(t: number): string;
24
+ /** Full ISO timestamp with explicit `Z`: `YYYY-MM-DDTHH:MM:SS[.mmm]Z`. */
25
+ export declare function fmtISO(t: number, ms?: boolean): string;
26
+ /** Adaptive duration: `412ms`, `3.1s`, `4m 12s`, `3h 20m`, `2.5d`, `1.2y`. */
27
+ export declare function fmtDur(ms: number | null | undefined): string;
28
+ /** Tick step table spanning 1 second → 500 years. */
29
+ export declare const TICK_STEPS: number[];
30
+ export interface Tick {
31
+ t: number;
32
+ label: string;
33
+ }
34
+ export interface TickResult {
35
+ step: number;
36
+ list: Tick[];
37
+ }
38
+ /**
39
+ * Pick a step from the table so ticks are at least `minPx` apart across
40
+ * `widthPx`, and enumerate them. Labels use the local clock below day
41
+ * granularity and `Jul 27`-style dates above it.
42
+ */
43
+ export declare function ticks(t0: number, t1: number, widthPx: number, minPx?: number): TickResult;
44
+ export interface HighlightPart {
45
+ t: string;
46
+ hit: boolean;
47
+ }
48
+ /**
49
+ * Split `text` into matched/unmatched parts against a case-insensitive query
50
+ * so matched substrings can be wrapped in `<mark>`-style spans.
51
+ */
52
+ export declare function highlightParts(text: unknown, q: string | undefined): HighlightPart[];
53
+ /**
54
+ * Keyword match: case-insensitive AND over whitespace-separated tokens against
55
+ * the JSON serialization of the event.
56
+ */
57
+ export declare function eventMatches(ev: unknown, q: string | undefined): boolean;
58
+ /**
59
+ * Fuzzy score for pickers: each token scores by substring position (best) or
60
+ * character subsequence (weak); a token that matches neither zeroes the score.
61
+ */
62
+ export declare function fuzzyScore(hay: unknown, q: string): number;
63
+ /** Category palette cycled across services / tags / rows. */
64
+ export declare const TIMELINE_PALETTE_VARS: string[];
65
+ /** Mix a palette color with white, e.g. tinted chip/badge backgrounds. */
66
+ export declare function tint(color: string, pct: number): string;
67
+ /**
68
+ * Theme tokens referenced from inline styles (dynamic, per-event colors are
69
+ * computed in JS; static chrome colors live in the SCSS modules).
70
+ */
71
+ export declare const TL_COLORS: {
72
+ readonly ink: "var(--crk-timeline-ink, #23201c)";
73
+ readonly body: "var(--crk-timeline-body, #3b352f)";
74
+ readonly secondary: "var(--crk-timeline-secondary, #57504a)";
75
+ readonly muted: "var(--crk-timeline-muted, #857d73)";
76
+ readonly faint: "var(--crk-timeline-faint, #b0a79b)";
77
+ readonly hairline: "var(--crk-timeline-hairline, #e8e2d9)";
78
+ readonly stem: "var(--crk-timeline-stem, #c9c1b5)";
79
+ readonly stemHot: "var(--crk-timeline-stem-hot, #8a8175)";
80
+ readonly accent: "var(--crk-timeline-accent, #0e7568)";
81
+ readonly accentDark: "var(--crk-timeline-accent-dark, #0b5a50)";
82
+ readonly accentTint: "var(--crk-timeline-accent-tint, #e4f1ee)";
83
+ readonly hlWash: "var(--crk-timeline-hl-wash, #fff3d1)";
84
+ readonly hlWashSoft: "var(--crk-timeline-hl-wash-soft, #fff9e8)";
85
+ readonly hlMark: "var(--crk-timeline-hl-mark, #ffdf7e)";
86
+ readonly hlRing: "var(--crk-timeline-hl-ring, #f3d98b)";
87
+ readonly hlBorder: "var(--crk-timeline-hl-border, #e8b931)";
88
+ readonly hlBarBg: "var(--crk-timeline-hl-bar, #ffe9ae)";
89
+ readonly selectedRing: "var(--crk-timeline-selected-ring, #b8ddd6)";
90
+ };
@@ -0,0 +1,135 @@
1
+ const O = 1e3, S = 6e4, U = 36e5, C = 864e5, c = (t) => String(t).padStart(2, "0"), h = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2
+ function f(t, e) {
3
+ const n = new Date(t);
4
+ return c(n.getHours()) + ":" + c(n.getMinutes()) + ":" + c(n.getSeconds());
5
+ }
6
+ function u(t) {
7
+ const e = new Date(t);
8
+ return h[e.getMonth()] + " " + e.getDate();
9
+ }
10
+ function E(t) {
11
+ const e = new Date(t).getFullYear(), n = e !== (/* @__PURE__ */ new Date()).getFullYear();
12
+ return n && Date.now() - t > 2 * 365 * 864e5 ? u(t) + " " + e : u(t) + (n ? " " + e : "") + " · " + f(t);
13
+ }
14
+ function g(t, e) {
15
+ const n = new Date(t);
16
+ return c(n.getUTCHours()) + ":" + c(n.getUTCMinutes()) + ":" + c(n.getUTCSeconds()) + (e ? "." + String(n.getUTCMilliseconds()).padStart(3, "0") : "");
17
+ }
18
+ function d(t) {
19
+ const e = new Date(t);
20
+ return e.getUTCFullYear() + "-" + c(e.getUTCMonth() + 1) + "-" + c(e.getUTCDate());
21
+ }
22
+ function M(t, e) {
23
+ return d(t) + "T" + g(t, e) + "Z";
24
+ }
25
+ function T(t) {
26
+ return t == null ? "" : t < 1e3 ? Math.round(t) + "ms" : t < 6e4 ? (t / 1e3).toFixed(t < 10 * 1e3 ? 1 : 0) + "s" : t < 36e5 ? Math.floor(t / 6e4) + "m " + Math.round(t % 6e4 / 1e3) + "s" : t < 2 * 864e5 ? Math.floor(t / 36e5) + "h " + Math.round(t % 36e5 / 6e4) + "m" : t < 365 * 864e5 ? (t / 864e5).toFixed(1) + "d" : (t / (365.25 * 864e5)).toFixed(t < 3650 * 864e5 ? 1 : 0) + "y";
27
+ }
28
+ const s = [
29
+ 1e3,
30
+ 2 * 1e3,
31
+ 5 * 1e3,
32
+ 10 * 1e3,
33
+ 15 * 1e3,
34
+ 30 * 1e3,
35
+ 6e4,
36
+ 2 * 6e4,
37
+ 5 * 6e4,
38
+ 10 * 6e4,
39
+ 15 * 6e4,
40
+ 30 * 6e4,
41
+ 36e5,
42
+ 2 * 36e5,
43
+ 3 * 36e5,
44
+ 6 * 36e5,
45
+ 12 * 36e5,
46
+ 864e5,
47
+ 2 * 864e5,
48
+ 7 * 864e5,
49
+ 14 * 864e5,
50
+ 30 * 864e5,
51
+ 90 * 864e5,
52
+ 180 * 864e5,
53
+ 365 * 864e5,
54
+ 730 * 864e5,
55
+ 1825 * 864e5,
56
+ 3650 * 864e5,
57
+ 9131 * 864e5,
58
+ 18262 * 864e5,
59
+ 36525 * 864e5,
60
+ 91311 * 864e5,
61
+ 182625 * 864e5
62
+ ];
63
+ function A(t, e, n, a) {
64
+ a = a || 88;
65
+ const l = Math.max(1, e - t), i = s.find((D) => D / l * n >= a) || s[s.length - 1], o = [];
66
+ let r = Math.ceil(t / i) * i;
67
+ for (; r <= e; r += i) o.push({ t: r, label: i >= 864e5 ? u(r) : f(r) });
68
+ return { step: i, list: o };
69
+ }
70
+ function N(t, e) {
71
+ const n = String(t ?? "");
72
+ if (e = (e || "").trim(), !e) return [{ t: n, hit: !1 }];
73
+ const a = e.toLowerCase(), l = n.toLowerCase(), i = [];
74
+ let o = 0;
75
+ for (; ; ) {
76
+ const r = l.indexOf(a, o);
77
+ if (r < 0) {
78
+ o < n.length && i.push({ t: n.slice(o), hit: !1 });
79
+ break;
80
+ }
81
+ r > o && i.push({ t: n.slice(o, r), hit: !1 }), i.push({ t: n.slice(r, r + e.length), hit: !0 }), o = r + e.length;
82
+ }
83
+ return i.length ? i : [{ t: n, hit: !1 }];
84
+ }
85
+ function Y(t, e) {
86
+ if (e = (e || "").trim(), !e) return !0;
87
+ let n;
88
+ try {
89
+ n = JSON.stringify(t).toLowerCase();
90
+ } catch {
91
+ n = String(t).toLowerCase();
92
+ }
93
+ return e.toLowerCase().split(/\s+/).filter(Boolean).every((a) => n.includes(a));
94
+ }
95
+ const k = [
96
+ "var(--crk-timeline-1, #0e7568)",
97
+ "var(--crk-timeline-2, #4c5bd4)",
98
+ "var(--crk-timeline-3, #c05f2c)",
99
+ "var(--crk-timeline-4, #96488a)",
100
+ "var(--crk-timeline-5, #3e6b8f)",
101
+ "var(--crk-timeline-6, #b03a48)"
102
+ ];
103
+ function m(t, e) {
104
+ return `color-mix(in srgb, ${t} ${e}%, white)`;
105
+ }
106
+ const I = {
107
+ body: "var(--crk-timeline-body, #3b352f)",
108
+ stem: "var(--crk-timeline-stem, #c9c1b5)",
109
+ stemHot: "var(--crk-timeline-stem-hot, #8a8175)",
110
+ hlWashSoft: "var(--crk-timeline-hl-wash-soft, #fff9e8)",
111
+ hlRing: "var(--crk-timeline-hl-ring, #f3d98b)",
112
+ hlBorder: "var(--crk-timeline-hl-border, #e8b931)",
113
+ hlBarBg: "var(--crk-timeline-hl-bar, #ffe9ae)",
114
+ selectedRing: "var(--crk-timeline-selected-ring, #b8ddd6)"
115
+ };
116
+ export {
117
+ C as DAY,
118
+ U as HOUR,
119
+ S as MINUTE,
120
+ O as SECOND,
121
+ s as TICK_STEPS,
122
+ k as TIMELINE_PALETTE_VARS,
123
+ I as TL_COLORS,
124
+ Y as eventMatches,
125
+ f as fmtClock,
126
+ g as fmtClockUTC,
127
+ u as fmtDate,
128
+ d as fmtDateISO,
129
+ E as fmtDateTime,
130
+ T as fmtDur,
131
+ M as fmtISO,
132
+ N as highlightParts,
133
+ A as ticks,
134
+ m as tint
135
+ };
@@ -0,0 +1,72 @@
1
+ /**
2
+ * TraceTimeline band layout, ported near-verbatim from the design handoff
3
+ * (`Manifest Trace.dc.html` logic block). Pure so it can be unit-tested for
4
+ * the no-overlap guarantees:
5
+ *
6
+ * - overlapping/simultaneous bars pack into vertical sub-rows (first-fit by
7
+ * x-extent);
8
+ * - description chips get up to 4 label rows above + 4 below the band,
9
+ * processed newest-first so recent events keep the short stems. A chip
10
+ * placement conflicts when (a) its extent overlaps a placed chip on that
11
+ * row, (b) its vertical stem would pass through a nearer placed chip, or
12
+ * (c) an already-placed farther stem would cross it. Pass 1 places clean;
13
+ * pass 2 slides left up to 140px with an elbow line back to the bar; pass 3
14
+ * accepts a stem crossing rather than hiding the chip.
15
+ */
16
+ export interface TraceLayoutInput {
17
+ /** Stable id (kept on the output). */
18
+ id: string;
19
+ /** Bar left edge, px (inner canvas coordinates). */
20
+ left: number;
21
+ /** Bar width, px. */
22
+ width: number;
23
+ /** Chip width, px. */
24
+ labelW: number;
25
+ }
26
+ export interface TraceLayoutItem extends TraceLayoutInput {
27
+ /** Vertical sub-row of the bar within the band (0-based). */
28
+ sub: number;
29
+ /** Chip row: 0-3 above the band (near→far), 4-7 below; -1 = hidden. */
30
+ row: number;
31
+ /** Chip left edge after nudging, px. */
32
+ labelX: number;
33
+ /** Whether the chip is shown. */
34
+ showLabel: boolean;
35
+ /** Bar top, px. */
36
+ barTop: number;
37
+ /** Chip top, px (when shown). */
38
+ labelTop: number;
39
+ /** Vertical stem segment (under the chip). */
40
+ conn: boolean;
41
+ connTop: number;
42
+ connH: number;
43
+ /** Horizontal elbow segment (when the chip slid off its bar x). */
44
+ hconn: boolean;
45
+ hconnLeft: number;
46
+ hconnTop: number;
47
+ hconnW: number;
48
+ }
49
+ export interface TraceLayoutResult {
50
+ items: TraceLayoutItem[];
51
+ /** Total band height in px (canvas height for the lane). */
52
+ h: number;
53
+ /** Y of the central axis line. */
54
+ axisY: number;
55
+ /** Number of bar sub-rows. */
56
+ subRows: number;
57
+ /** Rightmost extent (bar or chip) in px. */
58
+ maxExt: number;
59
+ }
60
+ export interface TraceLayoutOpts {
61
+ /** Bar height. @default 26 */
62
+ barH?: number;
63
+ /** Label row height. @default 66 */
64
+ rowH?: number;
65
+ /** Chip height. @default 51 */
66
+ chipH?: number;
67
+ /** Minimum canvas height. @default 420 */
68
+ minH?: number;
69
+ }
70
+ export declare function layoutTraceBand(inputs: TraceLayoutInput[], opts?: TraceLayoutOpts): TraceLayoutResult;
71
+ /** Chip width estimate from its three text rows (mono 10px ≈ 6px/char + padding). */
72
+ export declare function traceChipWidth(source: string, target: string, rid: string): number;