awesome-timeline-react 0.13.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/README.md +26 -0
- package/dist/_tsup-dts-rollup.d.mts +93 -2
- package/dist/_tsup-dts-rollup.d.ts +93 -2
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +259 -70
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +259 -70
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -520,7 +520,10 @@ var DEFAULT_THEME = {
|
|
|
520
520
|
groupChildBackground: "rgba(0,0,0,0.05)",
|
|
521
521
|
groupShadowColor: "rgba(0,0,0,0.22)",
|
|
522
522
|
pointerLineColor: "rgba(15,23,42,0.7)",
|
|
523
|
-
pointerLabelColor: "#ffffff"
|
|
523
|
+
pointerLabelColor: "#ffffff",
|
|
524
|
+
linkColor: "#2563eb",
|
|
525
|
+
linkWidth: 2,
|
|
526
|
+
linkMarkerTextColor: "#ffffff"
|
|
524
527
|
};
|
|
525
528
|
var resolveTheme = (theme) => __spreadValues(__spreadValues({}, DEFAULT_THEME), theme);
|
|
526
529
|
|
|
@@ -714,65 +717,8 @@ import React5, {
|
|
|
714
717
|
useSyncExternalStore
|
|
715
718
|
} from "react";
|
|
716
719
|
|
|
717
|
-
// src/
|
|
718
|
-
var
|
|
719
|
-
constructor(onFrame) {
|
|
720
|
-
this.onFrame = onFrame;
|
|
721
|
-
this.rafId = null;
|
|
722
|
-
this.dirty = { static: false, dynamic: false };
|
|
723
|
-
}
|
|
724
|
-
invalidate(layer) {
|
|
725
|
-
if (layer === "all" || layer === "static") this.dirty.static = true;
|
|
726
|
-
if (layer === "all" || layer === "dynamic") this.dirty.dynamic = true;
|
|
727
|
-
this.schedule();
|
|
728
|
-
}
|
|
729
|
-
/** Runs a pending frame immediately (tests, synchronous reads). */
|
|
730
|
-
flush() {
|
|
731
|
-
if (this.rafId !== null) {
|
|
732
|
-
cancelAnimationFrame(this.rafId);
|
|
733
|
-
this.rafId = null;
|
|
734
|
-
this.run();
|
|
735
|
-
}
|
|
736
|
-
}
|
|
737
|
-
dispose() {
|
|
738
|
-
if (this.rafId !== null) {
|
|
739
|
-
cancelAnimationFrame(this.rafId);
|
|
740
|
-
this.rafId = null;
|
|
741
|
-
}
|
|
742
|
-
this.dirty = { static: false, dynamic: false };
|
|
743
|
-
}
|
|
744
|
-
schedule() {
|
|
745
|
-
if (this.rafId !== null) return;
|
|
746
|
-
this.rafId = requestAnimationFrame(() => {
|
|
747
|
-
this.rafId = null;
|
|
748
|
-
this.run();
|
|
749
|
-
});
|
|
750
|
-
}
|
|
751
|
-
run() {
|
|
752
|
-
const dirty = this.dirty;
|
|
753
|
-
this.dirty = { static: false, dynamic: false };
|
|
754
|
-
if (dirty.static || dirty.dynamic) this.onFrame(dirty);
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
// src/core/culling.ts
|
|
759
|
-
var cullToWindow = (events, windowStart, windowEnd) => {
|
|
760
|
-
let lo = 0;
|
|
761
|
-
let hi = events.length;
|
|
762
|
-
while (lo < hi) {
|
|
763
|
-
const mid = lo + hi >> 1;
|
|
764
|
-
if (events[mid].startTime <= windowEnd) {
|
|
765
|
-
lo = mid + 1;
|
|
766
|
-
} else {
|
|
767
|
-
hi = mid;
|
|
768
|
-
}
|
|
769
|
-
}
|
|
770
|
-
const visible = [];
|
|
771
|
-
for (let i = 0; i < lo; i++) {
|
|
772
|
-
if (events[i].endTime >= windowStart) visible.push(events[i]);
|
|
773
|
-
}
|
|
774
|
-
return visible;
|
|
775
|
-
};
|
|
720
|
+
// src/core/types.ts
|
|
721
|
+
var rectContains = (rect, x, y) => x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
776
722
|
|
|
777
723
|
// src/core/coords.ts
|
|
778
724
|
var timeToX = (time, windowStart, tick) => (time - windowStart) / tick;
|
|
@@ -822,6 +768,92 @@ var assignLanes = (rowEvents) => {
|
|
|
822
768
|
return { laneOf, highestLane: Math.max(0, laneEnd.length - 1) };
|
|
823
769
|
};
|
|
824
770
|
|
|
771
|
+
// src/core/links.ts
|
|
772
|
+
var MARKER_HEIGHT = 20;
|
|
773
|
+
var MARKER_PAD = 8;
|
|
774
|
+
var MARKER_INSET = 4;
|
|
775
|
+
var MARKER_GAP = 4;
|
|
776
|
+
var LABEL_MAX = 28;
|
|
777
|
+
var eventRect = (scene, offsetOf, eventId, view) => {
|
|
778
|
+
var _a;
|
|
779
|
+
const event = scene.getEvent(eventId);
|
|
780
|
+
if (!event) return null;
|
|
781
|
+
const top = offsetOf.get(event.rowId);
|
|
782
|
+
if (top === void 0) return null;
|
|
783
|
+
const g = scene.getGeometry();
|
|
784
|
+
const lane = (_a = scene.getLanes(event.rowId).laneOf.get(eventId)) != null ? _a : 0;
|
|
785
|
+
return {
|
|
786
|
+
x: timeToX(event.startTime, view.windowStart, view.tick),
|
|
787
|
+
y: top - view.scrollTop + scene.getLaneInset(event.rowId) + laneTop(lane, g),
|
|
788
|
+
width: timeToWidth(event.startTime, event.endTime, view.tick),
|
|
789
|
+
height: g.barHeight
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
var linkRoute = (from, to, stub = 8) => {
|
|
793
|
+
const ax = from.x + from.width, ay = from.y + from.height / 2;
|
|
794
|
+
const bx = to.x, by = to.y + to.height / 2;
|
|
795
|
+
if (bx - ax >= 2 * stub) return [[ax, ay], [ax + stub, ay], [ax + stub, by], [bx, by]];
|
|
796
|
+
const midY = Math.abs(ay - by) < 1 ? from.y + from.height + stub / 2 : (ay + by) / 2;
|
|
797
|
+
return [[ax, ay], [ax + stub, ay], [ax + stub, midY], [bx - stub, midY], [bx - stub, by], [bx, by]];
|
|
798
|
+
};
|
|
799
|
+
var truncate = (text) => text.length > LABEL_MAX ? `${text.slice(0, LABEL_MAX - 1)}\u2026` : text;
|
|
800
|
+
var linkMarkers = (scene, links, rectOf, view, measure) => {
|
|
801
|
+
const shown = (r) => r.y + r.height > 0 && r.y < view.height;
|
|
802
|
+
const wanted = /* @__PURE__ */ new Map();
|
|
803
|
+
for (const link of links) {
|
|
804
|
+
const a = rectOf(link.fromEventId), b = rectOf(link.toEventId);
|
|
805
|
+
if (!a || !b) continue;
|
|
806
|
+
for (const [hidden, id, other] of [[b, link.toEventId, a], [a, link.fromEventId, b]]) {
|
|
807
|
+
if (shown(hidden) || !shown(other) || wanted.has(id)) continue;
|
|
808
|
+
wanted.set(id, { up: hidden.y + hidden.height <= 0, x: hidden.x });
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
const out = [];
|
|
812
|
+
for (const up of [true, false]) {
|
|
813
|
+
const y = up ? MARKER_INSET : view.height - MARKER_HEIGHT - MARKER_INSET;
|
|
814
|
+
const edge = [...wanted].filter(([, w]) => w.up === up).sort((p, q) => p[1].x - q[1].x).map(([eventId, w]) => {
|
|
815
|
+
var _a, _b, _c;
|
|
816
|
+
const label = truncate(`${up ? "\u25B2" : "\u25BC"} ${(_c = (_b = (_a = scene.getEvent(eventId)) == null ? void 0 : _a.props) == null ? void 0 : _b.label) != null ? _c : eventId}`);
|
|
817
|
+
return { eventId, up, label, rect: { x: w.x, y, width: measure(label) + 2 * MARKER_PAD, height: MARKER_HEIGHT } };
|
|
818
|
+
});
|
|
819
|
+
let right = MARKER_INSET - MARKER_GAP;
|
|
820
|
+
for (const m of edge) {
|
|
821
|
+
m.rect.x = Math.max(m.rect.x, right + MARKER_GAP);
|
|
822
|
+
right = m.rect.x + m.rect.width;
|
|
823
|
+
}
|
|
824
|
+
let left = view.width - MARKER_INSET + MARKER_GAP;
|
|
825
|
+
for (const m of [...edge].reverse()) {
|
|
826
|
+
m.rect.x = Math.max(MARKER_INSET, Math.min(m.rect.x, left - MARKER_GAP - m.rect.width));
|
|
827
|
+
left = m.rect.x;
|
|
828
|
+
}
|
|
829
|
+
out.push(...edge);
|
|
830
|
+
}
|
|
831
|
+
return out;
|
|
832
|
+
};
|
|
833
|
+
var markerAt = (markers, x, y) => {
|
|
834
|
+
var _a;
|
|
835
|
+
return (_a = markers.find((m) => rectContains(m.rect, x, y))) != null ? _a : null;
|
|
836
|
+
};
|
|
837
|
+
|
|
838
|
+
// src/core/culling.ts
|
|
839
|
+
var cullToWindow = (events, windowStart, windowEnd) => {
|
|
840
|
+
let lo = 0;
|
|
841
|
+
let hi = events.length;
|
|
842
|
+
while (lo < hi) {
|
|
843
|
+
const mid = lo + hi >> 1;
|
|
844
|
+
if (events[mid].startTime <= windowEnd) {
|
|
845
|
+
lo = mid + 1;
|
|
846
|
+
} else {
|
|
847
|
+
hi = mid;
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
const visible = [];
|
|
851
|
+
for (let i = 0; i < lo; i++) {
|
|
852
|
+
if (events[i].endTime >= windowStart) visible.push(events[i]);
|
|
853
|
+
}
|
|
854
|
+
return visible;
|
|
855
|
+
};
|
|
856
|
+
|
|
825
857
|
// src/core/interactions.ts
|
|
826
858
|
var computeDropTimes = ({
|
|
827
859
|
pointerX,
|
|
@@ -1079,7 +1111,7 @@ var paintOverlapStripes = (ctx, event, rect, rowStatics, windowStart, tick, colo
|
|
|
1079
1111
|
ctx.restore();
|
|
1080
1112
|
}
|
|
1081
1113
|
};
|
|
1082
|
-
var drawEvents = (ctx, view, scene, font, animator) => {
|
|
1114
|
+
var drawEvents = (ctx, view, scene, font, animator, beforeSelected) => {
|
|
1083
1115
|
var _a, _b, _c, _d;
|
|
1084
1116
|
if (view.tick === null) return;
|
|
1085
1117
|
const [windowStart, windowEnd] = view.windowTime;
|
|
@@ -1109,6 +1141,7 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
1109
1141
|
defaultDrawEvent(ctx, event, rect, view, font, geometry.barRadius);
|
|
1110
1142
|
}
|
|
1111
1143
|
if (view.stripeOverlap && rowStatics.length > 0) {
|
|
1144
|
+
ctx.shadowColor = "transparent";
|
|
1112
1145
|
paintOverlapStripes(
|
|
1113
1146
|
ctx,
|
|
1114
1147
|
event,
|
|
@@ -1208,9 +1241,104 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
1208
1241
|
}
|
|
1209
1242
|
}
|
|
1210
1243
|
}
|
|
1244
|
+
beforeSelected == null ? void 0 : beforeSelected();
|
|
1211
1245
|
for (const paint of deferred) paint();
|
|
1212
1246
|
};
|
|
1213
1247
|
|
|
1248
|
+
// src/canvas/draw-links.ts
|
|
1249
|
+
var ARROW = 6;
|
|
1250
|
+
var drawLinks = (ctx, view, scene, font) => {
|
|
1251
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
1252
|
+
if (view.tick === null || !view.links.length) return [];
|
|
1253
|
+
const { offsetOf } = scene.getRowOffsets();
|
|
1254
|
+
const at = { windowStart: view.windowTime[0], tick: view.tick, scrollTop: view.scrollTop };
|
|
1255
|
+
const rects = /* @__PURE__ */ new Map();
|
|
1256
|
+
const rectOf = (id) => {
|
|
1257
|
+
var _a2;
|
|
1258
|
+
if (!rects.has(id)) rects.set(id, eventRect(scene, offsetOf, id, at));
|
|
1259
|
+
return (_a2 = rects.get(id)) != null ? _a2 : null;
|
|
1260
|
+
};
|
|
1261
|
+
const { theme } = view;
|
|
1262
|
+
ctx.save();
|
|
1263
|
+
ctx.lineJoin = "round";
|
|
1264
|
+
for (const link of view.links) {
|
|
1265
|
+
const a = rectOf(link.fromEventId), b = rectOf(link.toEventId);
|
|
1266
|
+
if (!a || !b) continue;
|
|
1267
|
+
const color = (_b = (_a = link.style) == null ? void 0 : _a.stroke) != null ? _b : theme.linkColor;
|
|
1268
|
+
const points = linkRoute(a, b);
|
|
1269
|
+
ctx.strokeStyle = color;
|
|
1270
|
+
ctx.lineWidth = (_d = (_c = link.style) == null ? void 0 : _c.strokeWidth) != null ? _d : theme.linkWidth;
|
|
1271
|
+
ctx.setLineDash((_f = (_e = link.style) == null ? void 0 : _e.dash) != null ? _f : []);
|
|
1272
|
+
ctx.beginPath();
|
|
1273
|
+
points.forEach(([x, y], i) => i ? ctx.lineTo(x, y) : ctx.moveTo(x, y));
|
|
1274
|
+
ctx.stroke();
|
|
1275
|
+
const [bx, by] = points[points.length - 1];
|
|
1276
|
+
ctx.setLineDash([]);
|
|
1277
|
+
ctx.fillStyle = color;
|
|
1278
|
+
ctx.beginPath();
|
|
1279
|
+
ctx.moveTo(bx, by);
|
|
1280
|
+
ctx.lineTo(bx - ARROW, by - ARROW / 1.4);
|
|
1281
|
+
ctx.lineTo(bx - ARROW, by + ARROW / 1.4);
|
|
1282
|
+
ctx.closePath();
|
|
1283
|
+
ctx.fill();
|
|
1284
|
+
}
|
|
1285
|
+
ctx.font = (_g = theme.font) != null ? _g : font;
|
|
1286
|
+
ctx.textBaseline = "middle";
|
|
1287
|
+
ctx.textAlign = "left";
|
|
1288
|
+
const markers = linkMarkers(scene, view.links, rectOf, view, (text) => ctx.measureText(text).width);
|
|
1289
|
+
for (const m of markers) {
|
|
1290
|
+
const { x, y, width, height } = m.rect;
|
|
1291
|
+
ctx.fillStyle = theme.linkColor;
|
|
1292
|
+
roundedRect(ctx, x, y, width, height, height / 2);
|
|
1293
|
+
ctx.fill();
|
|
1294
|
+
ctx.fillStyle = theme.linkMarkerTextColor;
|
|
1295
|
+
ctx.fillText(m.label, x + 8, y + height / 2);
|
|
1296
|
+
}
|
|
1297
|
+
ctx.restore();
|
|
1298
|
+
return markers;
|
|
1299
|
+
};
|
|
1300
|
+
|
|
1301
|
+
// src/canvas/frame-scheduler.ts
|
|
1302
|
+
var FrameScheduler = class {
|
|
1303
|
+
constructor(onFrame) {
|
|
1304
|
+
this.onFrame = onFrame;
|
|
1305
|
+
this.rafId = null;
|
|
1306
|
+
this.dirty = { static: false, dynamic: false };
|
|
1307
|
+
}
|
|
1308
|
+
invalidate(layer) {
|
|
1309
|
+
if (layer === "all" || layer === "static") this.dirty.static = true;
|
|
1310
|
+
if (layer === "all" || layer === "dynamic") this.dirty.dynamic = true;
|
|
1311
|
+
this.schedule();
|
|
1312
|
+
}
|
|
1313
|
+
/** Runs a pending frame immediately (tests, synchronous reads). */
|
|
1314
|
+
flush() {
|
|
1315
|
+
if (this.rafId !== null) {
|
|
1316
|
+
cancelAnimationFrame(this.rafId);
|
|
1317
|
+
this.rafId = null;
|
|
1318
|
+
this.run();
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
dispose() {
|
|
1322
|
+
if (this.rafId !== null) {
|
|
1323
|
+
cancelAnimationFrame(this.rafId);
|
|
1324
|
+
this.rafId = null;
|
|
1325
|
+
}
|
|
1326
|
+
this.dirty = { static: false, dynamic: false };
|
|
1327
|
+
}
|
|
1328
|
+
schedule() {
|
|
1329
|
+
if (this.rafId !== null) return;
|
|
1330
|
+
this.rafId = requestAnimationFrame(() => {
|
|
1331
|
+
this.rafId = null;
|
|
1332
|
+
this.run();
|
|
1333
|
+
});
|
|
1334
|
+
}
|
|
1335
|
+
run() {
|
|
1336
|
+
const dirty = this.dirty;
|
|
1337
|
+
this.dirty = { static: false, dynamic: false };
|
|
1338
|
+
if (dirty.static || dirty.dynamic) this.onFrame(dirty);
|
|
1339
|
+
}
|
|
1340
|
+
};
|
|
1341
|
+
|
|
1214
1342
|
// src/canvas/renderer.ts
|
|
1215
1343
|
var TimelineRenderer = class {
|
|
1216
1344
|
constructor(staticCanvas, dynamicCanvas, scene) {
|
|
@@ -1231,8 +1359,10 @@ var TimelineRenderer = class {
|
|
|
1231
1359
|
hoveredEventId: null,
|
|
1232
1360
|
draggedEventId: null,
|
|
1233
1361
|
resizePreview: null,
|
|
1234
|
-
selectedEventIds: /* @__PURE__ */ new Set()
|
|
1362
|
+
selectedEventIds: /* @__PURE__ */ new Set(),
|
|
1363
|
+
links: []
|
|
1235
1364
|
};
|
|
1365
|
+
this.linkMarkers = [];
|
|
1236
1366
|
this.animator = new LayoutAnimator();
|
|
1237
1367
|
this.dpr = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
1238
1368
|
this.font = "16px sans-serif";
|
|
@@ -1248,6 +1378,10 @@ var TimelineRenderer = class {
|
|
|
1248
1378
|
getView() {
|
|
1249
1379
|
return this.view;
|
|
1250
1380
|
}
|
|
1381
|
+
/** the link edge markers as last drawn, in viewport px */
|
|
1382
|
+
getLinkMarkers() {
|
|
1383
|
+
return this.linkMarkers;
|
|
1384
|
+
}
|
|
1251
1385
|
setView(partial) {
|
|
1252
1386
|
const sizeChanged = partial.width !== void 0 && partial.width !== this.view.width || partial.height !== void 0 && partial.height !== this.view.height;
|
|
1253
1387
|
this.view = __spreadValues(__spreadValues({}, this.view), partial);
|
|
@@ -1316,7 +1450,9 @@ var TimelineRenderer = class {
|
|
|
1316
1450
|
const ctx = this.dynamicCanvas.getContext("2d");
|
|
1317
1451
|
if (ctx) {
|
|
1318
1452
|
ctx.clearRect(0, 0, this.view.width, this.view.height);
|
|
1319
|
-
drawEvents(ctx, this.view, this.scene, this.font, this.animator)
|
|
1453
|
+
drawEvents(ctx, this.view, this.scene, this.font, this.animator, () => {
|
|
1454
|
+
this.linkMarkers = drawLinks(ctx, this.view, this.scene, this.font);
|
|
1455
|
+
});
|
|
1320
1456
|
}
|
|
1321
1457
|
}
|
|
1322
1458
|
if (this.animator.isAnimating()) {
|
|
@@ -1328,9 +1464,6 @@ var TimelineRenderer = class {
|
|
|
1328
1464
|
// src/hooks/use-canvas-interactions.ts
|
|
1329
1465
|
import { useCallback, useEffect as useEffect4, useMemo, useRef as useRef4 } from "react";
|
|
1330
1466
|
|
|
1331
|
-
// src/core/types.ts
|
|
1332
|
-
var rectContains = (rect, x, y) => x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
1333
|
-
|
|
1334
1467
|
// src/core/hit-test.ts
|
|
1335
1468
|
var hitTest = (scene, view, x, y) => {
|
|
1336
1469
|
const { windowStart, windowEnd, tick, scrollTop } = view;
|
|
@@ -1415,6 +1548,7 @@ var useCanvasInteractions = ({
|
|
|
1415
1548
|
onResize,
|
|
1416
1549
|
onEventClick,
|
|
1417
1550
|
onEventHover,
|
|
1551
|
+
onLinkReveal,
|
|
1418
1552
|
eventsResize,
|
|
1419
1553
|
panZoom,
|
|
1420
1554
|
selectable,
|
|
@@ -1544,6 +1678,32 @@ var useCanvasInteractions = ({
|
|
|
1544
1678
|
},
|
|
1545
1679
|
[dynamicCanvasRef, eventsResize]
|
|
1546
1680
|
);
|
|
1681
|
+
const markerUnder = useCallback(
|
|
1682
|
+
(clientX, clientY) => {
|
|
1683
|
+
const canvas = dynamicCanvasRef.current;
|
|
1684
|
+
const renderer = rendererRef.current;
|
|
1685
|
+
if (!canvas || !renderer) return null;
|
|
1686
|
+
const rect = canvas.getBoundingClientRect();
|
|
1687
|
+
return markerAt(renderer.getLinkMarkers(), clientX - rect.left, clientY - rect.top);
|
|
1688
|
+
},
|
|
1689
|
+
[dynamicCanvasRef, rendererRef]
|
|
1690
|
+
);
|
|
1691
|
+
const reveal = useCallback(
|
|
1692
|
+
(eventId) => {
|
|
1693
|
+
const event = scene.getEvent(eventId);
|
|
1694
|
+
if (!event) return;
|
|
1695
|
+
const body = bodyRef.current;
|
|
1696
|
+
const top = scene.getRowOffsets().offsetOf.get(event.rowId);
|
|
1697
|
+
if (top !== void 0 && body) body.scrollTop = Math.max(0, top - body.clientHeight / 3);
|
|
1698
|
+
setWindowTime((prev) => {
|
|
1699
|
+
if (event.startTime >= prev[0] && event.startTime <= prev[1]) return prev;
|
|
1700
|
+
const span = prev[1] - prev[0];
|
|
1701
|
+
return [event.startTime - span / 5, event.startTime - span / 5 + span];
|
|
1702
|
+
});
|
|
1703
|
+
onLinkReveal == null ? void 0 : onLinkReveal(eventId);
|
|
1704
|
+
},
|
|
1705
|
+
[scene, bodyRef, setWindowTime, onLinkReveal]
|
|
1706
|
+
);
|
|
1547
1707
|
const schedulePan = useCallback(() => {
|
|
1548
1708
|
if (panFrameRef.current !== null) return;
|
|
1549
1709
|
panFrameRef.current = requestAnimationFrame(() => {
|
|
@@ -1633,6 +1793,17 @@ var useCanvasInteractions = ({
|
|
|
1633
1793
|
return;
|
|
1634
1794
|
}
|
|
1635
1795
|
if (pointerEvent.button !== 0) return;
|
|
1796
|
+
const marker = markerUnder(pointerEvent.clientX, pointerEvent.clientY);
|
|
1797
|
+
if (marker) {
|
|
1798
|
+
stateRef.current = {
|
|
1799
|
+
mode: "marker",
|
|
1800
|
+
eventId: marker.eventId,
|
|
1801
|
+
startClientX: pointerEvent.clientX,
|
|
1802
|
+
startClientY: pointerEvent.clientY
|
|
1803
|
+
};
|
|
1804
|
+
canvas.setPointerCapture(pointerEvent.pointerId);
|
|
1805
|
+
return;
|
|
1806
|
+
}
|
|
1636
1807
|
const hit = currentHit(pointerEvent.clientX, pointerEvent.clientY);
|
|
1637
1808
|
if ((hit == null ? void 0 : hit.kind) === "event" && !((_b = hit.event.props) == null ? void 0 : _b.isLocked)) {
|
|
1638
1809
|
const direction = resizeDirectionAt(hit, pointerEvent.clientX);
|
|
@@ -1701,7 +1872,8 @@ var useCanvasInteractions = ({
|
|
|
1701
1872
|
ghostRef,
|
|
1702
1873
|
rendererRef,
|
|
1703
1874
|
styleGhost,
|
|
1704
|
-
selectable
|
|
1875
|
+
selectable,
|
|
1876
|
+
markerUnder
|
|
1705
1877
|
]
|
|
1706
1878
|
);
|
|
1707
1879
|
const handleHover = useCallback(
|
|
@@ -1723,6 +1895,7 @@ var useCanvasInteractions = ({
|
|
|
1723
1895
|
} else {
|
|
1724
1896
|
canvas.style.cursor = "grab";
|
|
1725
1897
|
}
|
|
1898
|
+
if (markerUnder(pointerEvent.clientX, pointerEvent.clientY)) canvas.style.cursor = "pointer";
|
|
1726
1899
|
const hoveredId = (hit == null ? void 0 : hit.kind) === "event" ? hit.event.id : null;
|
|
1727
1900
|
const prevId = (prevHovered == null ? void 0 : prevHovered.kind) === "event" ? prevHovered.event.id : null;
|
|
1728
1901
|
if (hoveredId !== prevId) {
|
|
@@ -1756,7 +1929,8 @@ var useCanvasInteractions = ({
|
|
|
1756
1929
|
dynamicCanvasRef,
|
|
1757
1930
|
eventPromptRef,
|
|
1758
1931
|
rendererRef,
|
|
1759
|
-
onEventHover
|
|
1932
|
+
onEventHover,
|
|
1933
|
+
markerUnder
|
|
1760
1934
|
]
|
|
1761
1935
|
);
|
|
1762
1936
|
const resolveRowAtClientY = useCallback(
|
|
@@ -1840,6 +2014,7 @@ var useCanvasInteractions = ({
|
|
|
1840
2014
|
}
|
|
1841
2015
|
return;
|
|
1842
2016
|
}
|
|
2017
|
+
if (state.mode === "marker") return;
|
|
1843
2018
|
state.deltaPx = pointerEvent.clientX - state.startClientX;
|
|
1844
2019
|
(_d = rendererRef.current) == null ? void 0 : _d.setView({
|
|
1845
2020
|
resizePreview: {
|
|
@@ -1978,6 +2153,9 @@ var useCanvasInteractions = ({
|
|
|
1978
2153
|
}
|
|
1979
2154
|
} else if (state.mode === "resize") {
|
|
1980
2155
|
commitResize(state);
|
|
2156
|
+
} else if (state.mode === "marker") {
|
|
2157
|
+
const moved = Math.abs(pointerEvent.clientX - state.startClientX) + Math.abs(pointerEvent.clientY - state.startClientY) > DRAG_THRESHOLD_PX;
|
|
2158
|
+
if (!moved) reveal(state.eventId);
|
|
1981
2159
|
}
|
|
1982
2160
|
},
|
|
1983
2161
|
[
|
|
@@ -1990,7 +2168,8 @@ var useCanvasInteractions = ({
|
|
|
1990
2168
|
selectable,
|
|
1991
2169
|
applySelection,
|
|
1992
2170
|
getSelection,
|
|
1993
|
-
scene
|
|
2171
|
+
scene,
|
|
2172
|
+
reveal
|
|
1994
2173
|
]
|
|
1995
2174
|
);
|
|
1996
2175
|
const handlePointerCancel = useCallback(
|
|
@@ -2117,6 +2296,8 @@ var CanvasBoard = forwardRef2(
|
|
|
2117
2296
|
onEventHover,
|
|
2118
2297
|
eventsResize,
|
|
2119
2298
|
stripeOverlap,
|
|
2299
|
+
links,
|
|
2300
|
+
onLinkReveal,
|
|
2120
2301
|
timeBar,
|
|
2121
2302
|
panZoom,
|
|
2122
2303
|
animations,
|
|
@@ -2160,6 +2341,7 @@ var CanvasBoard = forwardRef2(
|
|
|
2160
2341
|
drawEvent,
|
|
2161
2342
|
eventsResize,
|
|
2162
2343
|
stripeOverlap,
|
|
2344
|
+
links,
|
|
2163
2345
|
timeBar
|
|
2164
2346
|
});
|
|
2165
2347
|
}, [
|
|
@@ -2170,6 +2352,7 @@ var CanvasBoard = forwardRef2(
|
|
|
2170
2352
|
drawEvent,
|
|
2171
2353
|
eventsResize,
|
|
2172
2354
|
stripeOverlap,
|
|
2355
|
+
links,
|
|
2173
2356
|
timeBar,
|
|
2174
2357
|
animations,
|
|
2175
2358
|
rendererRef
|
|
@@ -2298,6 +2481,7 @@ var CanvasBoard = forwardRef2(
|
|
|
2298
2481
|
onResize,
|
|
2299
2482
|
onEventClick,
|
|
2300
2483
|
onEventHover,
|
|
2484
|
+
onLinkReveal,
|
|
2301
2485
|
eventsResize,
|
|
2302
2486
|
panZoom,
|
|
2303
2487
|
selectable,
|
|
@@ -2965,6 +3149,7 @@ var SceneStore = class {
|
|
|
2965
3149
|
|
|
2966
3150
|
// src/timeline.tsx
|
|
2967
3151
|
var defaultPointerFormat = (time) => new Date(time * 1e3).toLocaleString();
|
|
3152
|
+
var NO_LINKS = [];
|
|
2968
3153
|
var Timeline = forwardRef4(
|
|
2969
3154
|
({
|
|
2970
3155
|
rows,
|
|
@@ -2996,7 +3181,9 @@ var Timeline = forwardRef4(
|
|
|
2996
3181
|
showPointerLine = false,
|
|
2997
3182
|
formatPointerTime,
|
|
2998
3183
|
onPointerTime,
|
|
2999
|
-
animations = true
|
|
3184
|
+
animations = true,
|
|
3185
|
+
links = NO_LINKS,
|
|
3186
|
+
onLinkReveal
|
|
3000
3187
|
}, handleRef) => {
|
|
3001
3188
|
const [windowTime, setWindowTime] = useState4([
|
|
3002
3189
|
new Date(
|
|
@@ -3317,6 +3504,8 @@ var Timeline = forwardRef4(
|
|
|
3317
3504
|
onEventHover: handleEventHover,
|
|
3318
3505
|
eventsResize,
|
|
3319
3506
|
stripeOverlap,
|
|
3507
|
+
links,
|
|
3508
|
+
onLinkReveal,
|
|
3320
3509
|
timeBar,
|
|
3321
3510
|
panZoom,
|
|
3322
3511
|
animations: resolvedAnimations,
|