awesome-timeline-react 0.3.0 → 0.4.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 +131 -1
- package/dist/_tsup-dts-rollup.d.mts +230 -10
- package/dist/_tsup-dts-rollup.d.ts +230 -10
- package/dist/index.css +9 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +705 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +707 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -60,7 +60,6 @@ var DEFAULT_FADE_DURATION_MS = 120;
|
|
|
60
60
|
var ease = (t) => t * t * (3 - 2 * t);
|
|
61
61
|
var LayoutAnimator = class {
|
|
62
62
|
constructor() {
|
|
63
|
-
this.rowHeights = /* @__PURE__ */ new Map();
|
|
64
63
|
this.eventTops = /* @__PURE__ */ new Map();
|
|
65
64
|
this.handleAlphas = /* @__PURE__ */ new Map();
|
|
66
65
|
this.now = 0;
|
|
@@ -75,9 +74,6 @@ var LayoutAnimator = class {
|
|
|
75
74
|
beginFrame(now) {
|
|
76
75
|
this.now = now;
|
|
77
76
|
}
|
|
78
|
-
rowHeight(rowId, target) {
|
|
79
|
-
return this.value(this.rowHeights, rowId, target, this.layoutDuration);
|
|
80
|
-
}
|
|
81
77
|
eventTop(eventId, target) {
|
|
82
78
|
return this.value(this.eventTops, eventId, target, this.layoutDuration);
|
|
83
79
|
}
|
|
@@ -98,7 +94,6 @@ var LayoutAnimator = class {
|
|
|
98
94
|
}
|
|
99
95
|
/** Drop all state, e.g. when the scene is reset wholesale. */
|
|
100
96
|
reset() {
|
|
101
|
-
this.rowHeights.clear();
|
|
102
97
|
this.eventTops.clear();
|
|
103
98
|
this.handleAlphas.clear();
|
|
104
99
|
this.activeUntil = 0;
|
|
@@ -462,11 +457,17 @@ var DEFAULT_THEME = {
|
|
|
462
457
|
gridColor: "#e4dcdc",
|
|
463
458
|
timeBarBorder: "yellow",
|
|
464
459
|
timeBarTextColor: "white",
|
|
460
|
+
dimmedOpacity: 0.35,
|
|
461
|
+
selectionShadowColor: "rgba(0,0,0,0.35)",
|
|
462
|
+
selectionShadowBlur: 8,
|
|
463
|
+
selectionElevation: 2,
|
|
465
464
|
font: void 0,
|
|
466
465
|
barHeight: 20,
|
|
467
466
|
laneGap: 2,
|
|
468
467
|
rowPaddingY: 10,
|
|
469
|
-
barRadius: 5
|
|
468
|
+
barRadius: 5,
|
|
469
|
+
groupChildBackground: "rgba(0,0,0,0.05)",
|
|
470
|
+
groupShadowColor: "rgba(0,0,0,0.22)"
|
|
470
471
|
};
|
|
471
472
|
var resolveTheme = (theme) => __spreadValues(__spreadValues({}, DEFAULT_THEME), theme);
|
|
472
473
|
|
|
@@ -761,9 +762,10 @@ var computeResizeTimes = (event, deltaPx, tick, direction) => {
|
|
|
761
762
|
return null;
|
|
762
763
|
};
|
|
763
764
|
var canResizeEvent = (event, eventsResize) => {
|
|
764
|
-
var _a, _b, _c, _d;
|
|
765
|
-
return !((_a = event.props) == null ? void 0 : _a.isLocked) && (eventsResize && (((
|
|
765
|
+
var _a, _b, _c, _d, _e;
|
|
766
|
+
return !((_a = event.props) == null ? void 0 : _a.isLocked) && !((_b = event.props) == null ? void 0 : _b.isGroupParent) && (eventsResize && (((_c = event.props) == null ? void 0 : _c.isResizable) === true || ((_d = event.props) == null ? void 0 : _d.isResizable) === void 0) || !eventsResize && ((_e = event.props) == null ? void 0 : _e.isResizable) === true);
|
|
766
767
|
};
|
|
768
|
+
var isRowDroppable = (droppableRowIds, targetRowId) => droppableRowIds === void 0 || droppableRowIds.includes(targetRowId);
|
|
767
769
|
var stepCellWidth = (cellWidth, deltaY, tick) => {
|
|
768
770
|
const pixelsToCalculate = 900 / tick;
|
|
769
771
|
const next = deltaY > 0 ? cellWidth + pixelsToCalculate : cellWidth - pixelsToCalculate;
|
|
@@ -811,18 +813,75 @@ var roundedRect = (ctx, x, y, width, height, radius) => {
|
|
|
811
813
|
ctx.closePath();
|
|
812
814
|
}
|
|
813
815
|
};
|
|
814
|
-
var
|
|
816
|
+
var drawGroupShading = (ctx, view, scene) => {
|
|
817
|
+
var _a;
|
|
815
818
|
const [windowStart, windowEnd] = view.windowTime;
|
|
816
|
-
const
|
|
819
|
+
const visible = scene.getVisibleRowIds();
|
|
820
|
+
const regions = [];
|
|
821
|
+
let y = 0;
|
|
822
|
+
let runParent = null;
|
|
823
|
+
let runTop = 0;
|
|
824
|
+
let runBottom = 0;
|
|
825
|
+
const flush = () => {
|
|
826
|
+
if (runParent !== null) regions.push({ top: runTop, bottom: runBottom });
|
|
827
|
+
runParent = null;
|
|
828
|
+
};
|
|
829
|
+
for (const rowId of visible) {
|
|
830
|
+
const height = scene.getRowHeight(rowId, windowStart, windowEnd);
|
|
831
|
+
const parentId = (_a = scene.getRow(rowId)) == null ? void 0 : _a.parentId;
|
|
832
|
+
if (parentId !== void 0) {
|
|
833
|
+
if (runParent === parentId) {
|
|
834
|
+
runBottom = y + height;
|
|
835
|
+
} else {
|
|
836
|
+
flush();
|
|
837
|
+
runParent = parentId;
|
|
838
|
+
runTop = y;
|
|
839
|
+
runBottom = y + height;
|
|
840
|
+
}
|
|
841
|
+
} else {
|
|
842
|
+
flush();
|
|
843
|
+
}
|
|
844
|
+
y += height;
|
|
845
|
+
}
|
|
846
|
+
flush();
|
|
847
|
+
if (regions.length === 0) return;
|
|
848
|
+
ctx.save();
|
|
849
|
+
for (const { top, bottom } of regions) {
|
|
850
|
+
const sTop = top - view.scrollTop;
|
|
851
|
+
const sBottom = bottom - view.scrollTop;
|
|
852
|
+
if (sBottom < 0 || sTop > view.height) continue;
|
|
853
|
+
const regionHeight = sBottom - sTop;
|
|
854
|
+
ctx.fillStyle = view.theme.groupChildBackground;
|
|
855
|
+
ctx.fillRect(0, sTop, view.width, regionHeight);
|
|
856
|
+
const depth = Math.min(12, regionHeight / 2);
|
|
857
|
+
const topGrad = ctx.createLinearGradient(0, sTop, 0, sTop + depth);
|
|
858
|
+
topGrad.addColorStop(0, view.theme.groupShadowColor);
|
|
859
|
+
topGrad.addColorStop(1, "rgba(0,0,0,0)");
|
|
860
|
+
ctx.fillStyle = topGrad;
|
|
861
|
+
ctx.fillRect(0, sTop, view.width, depth);
|
|
862
|
+
const botGrad = ctx.createLinearGradient(0, sBottom - depth, 0, sBottom);
|
|
863
|
+
botGrad.addColorStop(0, "rgba(0,0,0,0)");
|
|
864
|
+
botGrad.addColorStop(1, view.theme.groupShadowColor);
|
|
865
|
+
ctx.fillStyle = botGrad;
|
|
866
|
+
ctx.fillRect(0, sBottom - depth, view.width, depth);
|
|
867
|
+
const leftShadow = 10;
|
|
868
|
+
const hGrad = ctx.createLinearGradient(0, 0, leftShadow, 0);
|
|
869
|
+
hGrad.addColorStop(0, view.theme.groupShadowColor);
|
|
870
|
+
hGrad.addColorStop(1, "rgba(0,0,0,0)");
|
|
871
|
+
ctx.fillStyle = hGrad;
|
|
872
|
+
ctx.fillRect(0, sTop, leftShadow, regionHeight);
|
|
873
|
+
}
|
|
874
|
+
ctx.restore();
|
|
875
|
+
};
|
|
876
|
+
var drawRowDividers = (ctx, view, scene) => {
|
|
877
|
+
const [windowStart, windowEnd] = view.windowTime;
|
|
878
|
+
const rowIds = scene.getVisibleRowIds();
|
|
817
879
|
ctx.strokeStyle = view.theme.gridColor;
|
|
818
880
|
ctx.lineWidth = 1;
|
|
819
881
|
ctx.beginPath();
|
|
820
882
|
let y = 0;
|
|
821
883
|
for (let i = 0; i < rowIds.length; i++) {
|
|
822
|
-
y +=
|
|
823
|
-
rowIds[i],
|
|
824
|
-
scene.getRowHeight(rowIds[i], windowStart, windowEnd)
|
|
825
|
-
);
|
|
884
|
+
y += scene.getRowHeight(rowIds[i], windowStart, windowEnd);
|
|
826
885
|
if (i === rowIds.length - 1) break;
|
|
827
886
|
const screenY = y - view.scrollTop;
|
|
828
887
|
if (screenY < 0) continue;
|
|
@@ -898,7 +957,7 @@ var defaultDrawEvent = (ctx, event, rect, view, font, barRadius) => {
|
|
|
898
957
|
}
|
|
899
958
|
};
|
|
900
959
|
var drawEvents = (ctx, view, scene, font, animator) => {
|
|
901
|
-
var _a
|
|
960
|
+
var _a;
|
|
902
961
|
if (view.tick === null) return;
|
|
903
962
|
const [windowStart, windowEnd] = view.windowTime;
|
|
904
963
|
const tick = view.tick;
|
|
@@ -906,12 +965,45 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
906
965
|
ctx.font = (_a = view.theme.font) != null ? _a : font;
|
|
907
966
|
ctx.textBaseline = "middle";
|
|
908
967
|
ctx.textAlign = "left";
|
|
968
|
+
const selectedIds = view.selectedEventIds;
|
|
969
|
+
const hasSelection = selectedIds.size > 0;
|
|
970
|
+
const deferred = [];
|
|
971
|
+
const paintEvent = (event, rect, state, opts) => {
|
|
972
|
+
var _a2, _b, _c, _d, _e;
|
|
973
|
+
ctx.save();
|
|
974
|
+
if (opts.elevate) {
|
|
975
|
+
ctx.translate(0, -view.theme.selectionElevation);
|
|
976
|
+
ctx.shadowColor = view.theme.selectionShadowColor;
|
|
977
|
+
ctx.shadowBlur = view.theme.selectionShadowBlur;
|
|
978
|
+
ctx.shadowOffsetY = view.theme.selectionElevation;
|
|
979
|
+
}
|
|
980
|
+
if (state.dragging) ctx.globalAlpha = 0.5;
|
|
981
|
+
else if (opts.dim) ctx.globalAlpha *= view.theme.dimmedOpacity;
|
|
982
|
+
const custom = (_b = (_a2 = event.props) == null ? void 0 : _a2.drawEvent) != null ? _b : view.drawEvent;
|
|
983
|
+
const drawn = custom !== void 0 && custom(ctx, event, rect, state, view.theme) !== false;
|
|
984
|
+
if (!drawn) {
|
|
985
|
+
defaultDrawEvent(ctx, event, rect, view, font, geometry.barRadius);
|
|
986
|
+
}
|
|
987
|
+
if (canResizeEvent(event, view.eventsResize)) {
|
|
988
|
+
const alpha = animator.handleAlpha(
|
|
989
|
+
event.id,
|
|
990
|
+
state.hovered || state.resizing ? 1 : 0
|
|
991
|
+
);
|
|
992
|
+
if (alpha > 0.01) {
|
|
993
|
+
ctx.shadowColor = "transparent";
|
|
994
|
+
drawResizeHandles(
|
|
995
|
+
ctx,
|
|
996
|
+
rect,
|
|
997
|
+
alpha,
|
|
998
|
+
(_e = (_d = (_c = event.props) == null ? void 0 : _c.style) == null ? void 0 : _d.stroke) != null ? _e : view.theme.eventStroke
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
ctx.restore();
|
|
1003
|
+
};
|
|
909
1004
|
let rowTop = 0;
|
|
910
|
-
for (const rowId of scene.
|
|
911
|
-
const rowHeight =
|
|
912
|
-
rowId,
|
|
913
|
-
scene.getRowHeight(rowId, windowStart, windowEnd)
|
|
914
|
-
);
|
|
1005
|
+
for (const rowId of scene.getVisibleRowIds()) {
|
|
1006
|
+
const rowHeight = scene.getRowHeight(rowId, windowStart, windowEnd);
|
|
915
1007
|
const rowY = rowTop - view.scrollTop;
|
|
916
1008
|
rowTop += rowHeight;
|
|
917
1009
|
if (rowY + rowHeight < 0) continue;
|
|
@@ -957,36 +1049,23 @@ var drawEvents = (ctx, view, scene, font, animator) => {
|
|
|
957
1049
|
}
|
|
958
1050
|
}
|
|
959
1051
|
const rect = { x, y, width, height: geometry.barHeight };
|
|
1052
|
+
const selected = selectedIds.has(event.id);
|
|
960
1053
|
const state = {
|
|
961
1054
|
hovered: view.hoveredEventId === event.id,
|
|
962
1055
|
dragging: view.draggedEventId === event.id,
|
|
963
1056
|
resizing,
|
|
964
|
-
selected
|
|
1057
|
+
selected
|
|
965
1058
|
};
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
const drawn = custom !== void 0 && custom(ctx, event, rect, state, view.theme) !== false;
|
|
970
|
-
if (!drawn) {
|
|
971
|
-
defaultDrawEvent(ctx, event, rect, view, font, geometry.barRadius);
|
|
972
|
-
}
|
|
973
|
-
if (canResizeEvent(event, view.eventsResize)) {
|
|
974
|
-
const alpha = animator.handleAlpha(
|
|
975
|
-
event.id,
|
|
976
|
-
state.hovered || state.resizing ? 1 : 0
|
|
1059
|
+
if (selected) {
|
|
1060
|
+
deferred.push(
|
|
1061
|
+
() => paintEvent(event, rect, state, { dim: false, elevate: true })
|
|
977
1062
|
);
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
ctx,
|
|
981
|
-
rect,
|
|
982
|
-
alpha,
|
|
983
|
-
(_f = (_e = (_d = event.props) == null ? void 0 : _d.style) == null ? void 0 : _e.stroke) != null ? _f : view.theme.eventStroke
|
|
984
|
-
);
|
|
985
|
-
}
|
|
1063
|
+
} else {
|
|
1064
|
+
paintEvent(event, rect, state, { dim: hasSelection, elevate: false });
|
|
986
1065
|
}
|
|
987
|
-
ctx.restore();
|
|
988
1066
|
}
|
|
989
1067
|
}
|
|
1068
|
+
for (const paint of deferred) paint();
|
|
990
1069
|
};
|
|
991
1070
|
|
|
992
1071
|
// src/canvas/renderer.ts
|
|
@@ -1007,7 +1086,8 @@ var TimelineRenderer = class {
|
|
|
1007
1086
|
eventsResize: true,
|
|
1008
1087
|
hoveredEventId: null,
|
|
1009
1088
|
draggedEventId: null,
|
|
1010
|
-
resizePreview: null
|
|
1089
|
+
resizePreview: null,
|
|
1090
|
+
selectedEventIds: /* @__PURE__ */ new Set()
|
|
1011
1091
|
};
|
|
1012
1092
|
this.animator = new LayoutAnimator();
|
|
1013
1093
|
this.dpr = typeof window !== "undefined" ? window.devicePixelRatio : 1;
|
|
@@ -1018,6 +1098,7 @@ var TimelineRenderer = class {
|
|
|
1018
1098
|
this.dpr = dpr;
|
|
1019
1099
|
this.resizeCanvases();
|
|
1020
1100
|
this.invalidate("all");
|
|
1101
|
+
this.scheduler.flush();
|
|
1021
1102
|
});
|
|
1022
1103
|
}
|
|
1023
1104
|
getView() {
|
|
@@ -1029,6 +1110,7 @@ var TimelineRenderer = class {
|
|
|
1029
1110
|
if (sizeChanged) {
|
|
1030
1111
|
this.resizeCanvases();
|
|
1031
1112
|
this.invalidate("all");
|
|
1113
|
+
this.scheduler.flush();
|
|
1032
1114
|
return;
|
|
1033
1115
|
}
|
|
1034
1116
|
this.invalidate("all");
|
|
@@ -1059,6 +1141,7 @@ var TimelineRenderer = class {
|
|
|
1059
1141
|
const ctx = this.staticCanvas.getContext("2d");
|
|
1060
1142
|
if (ctx) {
|
|
1061
1143
|
ctx.clearRect(0, 0, this.view.width, this.view.height);
|
|
1144
|
+
drawGroupShading(ctx, this.view, this.scene);
|
|
1062
1145
|
drawGridLines(ctx, {
|
|
1063
1146
|
width: this.view.width,
|
|
1064
1147
|
height: this.view.height,
|
|
@@ -1067,7 +1150,7 @@ var TimelineRenderer = class {
|
|
|
1067
1150
|
tick: this.view.tick,
|
|
1068
1151
|
color: this.view.theme.gridColor
|
|
1069
1152
|
});
|
|
1070
|
-
drawRowDividers(ctx, this.view, this.scene
|
|
1153
|
+
drawRowDividers(ctx, this.view, this.scene);
|
|
1071
1154
|
}
|
|
1072
1155
|
}
|
|
1073
1156
|
if (dirty.dynamic) {
|
|
@@ -1096,7 +1179,7 @@ var hitTest = (scene, view, x, y) => {
|
|
|
1096
1179
|
const yContent = y + scrollTop;
|
|
1097
1180
|
let rowTop = 0;
|
|
1098
1181
|
let rowId = null;
|
|
1099
|
-
for (const id of scene.
|
|
1182
|
+
for (const id of scene.getVisibleRowIds()) {
|
|
1100
1183
|
const height = scene.getRowHeight(id, windowStart, windowEnd);
|
|
1101
1184
|
if (yContent >= rowTop && yContent < rowTop + height) {
|
|
1102
1185
|
rowId = id;
|
|
@@ -1173,7 +1256,10 @@ var useCanvasInteractions = ({
|
|
|
1173
1256
|
onEventClick,
|
|
1174
1257
|
onEventHover,
|
|
1175
1258
|
eventsResize,
|
|
1176
|
-
panZoom
|
|
1259
|
+
panZoom,
|
|
1260
|
+
selectable,
|
|
1261
|
+
applySelection,
|
|
1262
|
+
getSelection
|
|
1177
1263
|
}) => {
|
|
1178
1264
|
const stateRef = (0, import_react5.useRef)({ mode: "idle" });
|
|
1179
1265
|
const changeGridRef = (0, import_react5.useRef)(false);
|
|
@@ -1317,14 +1403,22 @@ var useCanvasInteractions = ({
|
|
|
1317
1403
|
}, [rendererRef, setWindowTime]);
|
|
1318
1404
|
const updateGhost = (0, import_react5.useCallback)(
|
|
1319
1405
|
(state, clientX, clientY) => {
|
|
1406
|
+
var _a;
|
|
1320
1407
|
const ghost = ghostRef.current;
|
|
1321
1408
|
if (!ghost) return;
|
|
1409
|
+
const rawLeft = state.hit.rect.x + (clientX - state.startClientX);
|
|
1410
|
+
const rawTop = state.hit.rect.y + (clientY - state.startClientY);
|
|
1411
|
+
const view = (_a = rendererRef.current) == null ? void 0 : _a.getView();
|
|
1412
|
+
const ghostWidth = state.hit.rect.width;
|
|
1413
|
+
const ghostHeight = state.hit.rect.height;
|
|
1414
|
+
const left = view ? Math.max(0, Math.min(rawLeft, Math.max(0, view.width - ghostWidth))) : rawLeft;
|
|
1415
|
+
const top = view ? Math.max(0, Math.min(rawTop, Math.max(0, view.height - ghostHeight))) : rawTop;
|
|
1322
1416
|
ghost.style.display = "flex";
|
|
1323
|
-
ghost.style.left = `${
|
|
1324
|
-
ghost.style.top = `${
|
|
1325
|
-
ghost.style.width = `${
|
|
1417
|
+
ghost.style.left = `${left}px`;
|
|
1418
|
+
ghost.style.top = `${top}px`;
|
|
1419
|
+
ghost.style.width = `${ghostWidth}px`;
|
|
1326
1420
|
},
|
|
1327
|
-
[ghostRef]
|
|
1421
|
+
[ghostRef, rendererRef]
|
|
1328
1422
|
);
|
|
1329
1423
|
const styleGhost = (0, import_react5.useCallback)(
|
|
1330
1424
|
(event) => {
|
|
@@ -1417,9 +1511,20 @@ var useCanvasInteractions = ({
|
|
|
1417
1511
|
mode: "pan",
|
|
1418
1512
|
lastClientX: pointerEvent.clientX,
|
|
1419
1513
|
lastClientY: pointerEvent.clientY,
|
|
1514
|
+
startClientX: pointerEvent.clientX,
|
|
1515
|
+
startClientY: pointerEvent.clientY,
|
|
1420
1516
|
touch: isTouch
|
|
1421
1517
|
};
|
|
1422
1518
|
canvas.style.cursor = "grabbing";
|
|
1519
|
+
} else if (selectable && !hit) {
|
|
1520
|
+
stateRef.current = {
|
|
1521
|
+
mode: "pan",
|
|
1522
|
+
lastClientX: pointerEvent.clientX,
|
|
1523
|
+
lastClientY: pointerEvent.clientY,
|
|
1524
|
+
startClientX: pointerEvent.clientX,
|
|
1525
|
+
startClientY: pointerEvent.clientY,
|
|
1526
|
+
touch: isTouch
|
|
1527
|
+
};
|
|
1423
1528
|
} else {
|
|
1424
1529
|
return;
|
|
1425
1530
|
}
|
|
@@ -1435,7 +1540,8 @@ var useCanvasInteractions = ({
|
|
|
1435
1540
|
snapshotView,
|
|
1436
1541
|
ghostRef,
|
|
1437
1542
|
rendererRef,
|
|
1438
|
-
styleGhost
|
|
1543
|
+
styleGhost,
|
|
1544
|
+
selectable
|
|
1439
1545
|
]
|
|
1440
1546
|
);
|
|
1441
1547
|
const handleHover = (0, import_react5.useCallback)(
|
|
@@ -1493,9 +1599,31 @@ var useCanvasInteractions = ({
|
|
|
1493
1599
|
onEventHover
|
|
1494
1600
|
]
|
|
1495
1601
|
);
|
|
1602
|
+
const resolveRowAtClientY = (0, import_react5.useCallback)(
|
|
1603
|
+
(clientY) => {
|
|
1604
|
+
const canvas = dynamicCanvasRef.current;
|
|
1605
|
+
const renderer = rendererRef.current;
|
|
1606
|
+
if (!canvas || !renderer) return null;
|
|
1607
|
+
const view = renderer.getView();
|
|
1608
|
+
if (view.tick === null) return null;
|
|
1609
|
+
const yContent = clientY - canvas.getBoundingClientRect().top + view.scrollTop;
|
|
1610
|
+
let rowTop = 0;
|
|
1611
|
+
for (const id of scene.getVisibleRowIds()) {
|
|
1612
|
+
const height = scene.getRowHeight(
|
|
1613
|
+
id,
|
|
1614
|
+
view.windowTime[0],
|
|
1615
|
+
view.windowTime[1]
|
|
1616
|
+
);
|
|
1617
|
+
if (yContent >= rowTop && yContent < rowTop + height) return id;
|
|
1618
|
+
rowTop += height;
|
|
1619
|
+
}
|
|
1620
|
+
return null;
|
|
1621
|
+
},
|
|
1622
|
+
[dynamicCanvasRef, rendererRef, scene]
|
|
1623
|
+
);
|
|
1496
1624
|
const handlePointerMove = (0, import_react5.useCallback)(
|
|
1497
1625
|
(pointerEvent) => {
|
|
1498
|
-
var _a, _b;
|
|
1626
|
+
var _a, _b, _c, _d;
|
|
1499
1627
|
const tracked = pointersRef.current.get(pointerEvent.pointerId);
|
|
1500
1628
|
if (tracked) {
|
|
1501
1629
|
tracked.x = pointerEvent.clientX;
|
|
@@ -1539,17 +1667,25 @@ var useCanvasInteractions = ({
|
|
|
1539
1667
|
return;
|
|
1540
1668
|
}
|
|
1541
1669
|
if (state.mode === "drag") {
|
|
1670
|
+
if ((_a = state.hit.event.props) == null ? void 0 : _a.isGroupParent) return;
|
|
1542
1671
|
if (!state.active && Math.abs(pointerEvent.clientX - state.startClientX) + Math.abs(pointerEvent.clientY - state.startClientY) > DRAG_THRESHOLD_PX) {
|
|
1543
1672
|
state.active = true;
|
|
1544
|
-
(
|
|
1673
|
+
(_b = rendererRef.current) == null ? void 0 : _b.setView({ draggedEventId: state.hit.event.id });
|
|
1545
1674
|
}
|
|
1546
1675
|
if (state.active) {
|
|
1547
1676
|
updateGhost(state, pointerEvent.clientX, pointerEvent.clientY);
|
|
1677
|
+
const allowed = (_c = state.hit.event.props) == null ? void 0 : _c.droppableRowIds;
|
|
1678
|
+
if (allowed) {
|
|
1679
|
+
const row = resolveRowAtClientY(pointerEvent.clientY);
|
|
1680
|
+
const ok = row !== null && isRowDroppable(allowed, row);
|
|
1681
|
+
const canvas = dynamicCanvasRef.current;
|
|
1682
|
+
if (canvas) canvas.style.cursor = ok ? "grabbing" : "not-allowed";
|
|
1683
|
+
}
|
|
1548
1684
|
}
|
|
1549
1685
|
return;
|
|
1550
1686
|
}
|
|
1551
1687
|
state.deltaPx = pointerEvent.clientX - state.startClientX;
|
|
1552
|
-
(
|
|
1688
|
+
(_d = rendererRef.current) == null ? void 0 : _d.setView({
|
|
1553
1689
|
resizePreview: {
|
|
1554
1690
|
eventId: state.event.id,
|
|
1555
1691
|
deltaPx: state.deltaPx,
|
|
@@ -1563,35 +1699,28 @@ var useCanvasInteractions = ({
|
|
|
1563
1699
|
updateGhost,
|
|
1564
1700
|
rendererRef,
|
|
1565
1701
|
scheduleContinuousZoom,
|
|
1566
|
-
bodyRef
|
|
1702
|
+
bodyRef,
|
|
1703
|
+
resolveRowAtClientY,
|
|
1704
|
+
dynamicCanvasRef
|
|
1567
1705
|
]
|
|
1568
1706
|
);
|
|
1569
1707
|
const commitDrop = (0, import_react5.useCallback)(
|
|
1570
1708
|
(state, clientX, clientY) => {
|
|
1709
|
+
var _a;
|
|
1571
1710
|
const canvas = dynamicCanvasRef.current;
|
|
1572
1711
|
const renderer = rendererRef.current;
|
|
1573
1712
|
if (!canvas || !renderer) return;
|
|
1574
1713
|
const view = renderer.getView();
|
|
1575
1714
|
if (view.tick === null || view.cellWidth <= 0) return;
|
|
1576
1715
|
const canvasRect = canvas.getBoundingClientRect();
|
|
1577
|
-
const
|
|
1578
|
-
let rowTop = 0;
|
|
1579
|
-
let targetRowId = null;
|
|
1580
|
-
for (const id of scene.getRowIds()) {
|
|
1581
|
-
const height = scene.getRowHeight(
|
|
1582
|
-
id,
|
|
1583
|
-
view.windowTime[0],
|
|
1584
|
-
view.windowTime[1]
|
|
1585
|
-
);
|
|
1586
|
-
if (yContent >= rowTop && yContent < rowTop + height) {
|
|
1587
|
-
targetRowId = id;
|
|
1588
|
-
break;
|
|
1589
|
-
}
|
|
1590
|
-
rowTop += height;
|
|
1591
|
-
}
|
|
1716
|
+
const targetRowId = resolveRowAtClientY(clientY);
|
|
1592
1717
|
if (targetRowId === null) return;
|
|
1593
1718
|
const liveEvent = scene.getEvent(state.hit.event.id);
|
|
1594
1719
|
if (!liveEvent) return;
|
|
1720
|
+
if (!isRowDroppable((_a = liveEvent.props) == null ? void 0 : _a.droppableRowIds, targetRowId)) {
|
|
1721
|
+
renderer.animator.snapEventTop(liveEvent.id);
|
|
1722
|
+
return;
|
|
1723
|
+
}
|
|
1595
1724
|
const { startTime, endTime } = computeDropTimes({
|
|
1596
1725
|
pointerX: clientX - canvasRect.left,
|
|
1597
1726
|
cellWidth: view.cellWidth,
|
|
@@ -1617,7 +1746,7 @@ var useCanvasInteractions = ({
|
|
|
1617
1746
|
}
|
|
1618
1747
|
]);
|
|
1619
1748
|
},
|
|
1620
|
-
[scene, dynamicCanvasRef, rendererRef, onDrop]
|
|
1749
|
+
[scene, dynamicCanvasRef, rendererRef, onDrop, resolveRowAtClientY]
|
|
1621
1750
|
);
|
|
1622
1751
|
const commitResize = (0, import_react5.useCallback)(
|
|
1623
1752
|
(state) => {
|
|
@@ -1678,6 +1807,19 @@ var useCanvasInteractions = ({
|
|
|
1678
1807
|
}
|
|
1679
1808
|
});
|
|
1680
1809
|
}
|
|
1810
|
+
if (selectable) {
|
|
1811
|
+
const id = state.hit.event.id;
|
|
1812
|
+
if (scene.isEventSelectable(id)) {
|
|
1813
|
+
applySelection(
|
|
1814
|
+
pointerEvent.ctrlKey || pointerEvent.metaKey ? scene.getConnectedEventIds(id) : [id]
|
|
1815
|
+
);
|
|
1816
|
+
}
|
|
1817
|
+
}
|
|
1818
|
+
} else if (state.mode === "pan") {
|
|
1819
|
+
const moved = Math.abs(pointerEvent.clientX - state.startClientX) + Math.abs(pointerEvent.clientY - state.startClientY) > DRAG_THRESHOLD_PX;
|
|
1820
|
+
if (selectable && !moved && getSelection().length > 0) {
|
|
1821
|
+
applySelection([]);
|
|
1822
|
+
}
|
|
1681
1823
|
} else if (state.mode === "resize") {
|
|
1682
1824
|
commitResize(state);
|
|
1683
1825
|
}
|
|
@@ -1688,7 +1830,11 @@ var useCanvasInteractions = ({
|
|
|
1688
1830
|
rendererRef,
|
|
1689
1831
|
commitDrop,
|
|
1690
1832
|
commitResize,
|
|
1691
|
-
onEventClick
|
|
1833
|
+
onEventClick,
|
|
1834
|
+
selectable,
|
|
1835
|
+
applySelection,
|
|
1836
|
+
getSelection,
|
|
1837
|
+
scene
|
|
1692
1838
|
]
|
|
1693
1839
|
);
|
|
1694
1840
|
const handlePointerCancel = (0, import_react5.useCallback)(
|
|
@@ -1770,6 +1916,16 @@ var useCanvasInteractions = ({
|
|
|
1770
1916
|
return () => canvas.removeEventListener("wheel", handleWheel);
|
|
1771
1917
|
}, [dynamicCanvasRef, rendererRef, setCellWidth, applyZoom, config]);
|
|
1772
1918
|
(0, import_react5.useEffect)(() => unlockCursor, []);
|
|
1919
|
+
(0, import_react5.useEffect)(() => {
|
|
1920
|
+
if (!selectable) return;
|
|
1921
|
+
const handleKeyDown = (keyEvent) => {
|
|
1922
|
+
if (keyEvent.key === "Escape" && getSelection().length > 0) {
|
|
1923
|
+
applySelection([]);
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
1927
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
1928
|
+
}, [selectable, getSelection, applySelection]);
|
|
1773
1929
|
return {
|
|
1774
1930
|
handlePointerDown,
|
|
1775
1931
|
handlePointerMove,
|
|
@@ -1804,11 +1960,16 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
1804
1960
|
onEventHover,
|
|
1805
1961
|
eventsResize,
|
|
1806
1962
|
panZoom,
|
|
1807
|
-
animations
|
|
1963
|
+
animations,
|
|
1964
|
+
selectable,
|
|
1965
|
+
applySelection,
|
|
1966
|
+
getSelection
|
|
1808
1967
|
}, contentRef) => {
|
|
1809
1968
|
const staticCanvasRef = (0, import_react6.useRef)(null);
|
|
1810
1969
|
const dynamicCanvasRef = (0, import_react6.useRef)(null);
|
|
1811
1970
|
const ghostRef = (0, import_react6.useRef)(null);
|
|
1971
|
+
const headerWrapperRef = (0, import_react6.useRef)(null);
|
|
1972
|
+
const totalHeightRef = (0, import_react6.useRef)(0);
|
|
1812
1973
|
const [scrollTop, setScrollTop] = (0, import_react6.useState)(0);
|
|
1813
1974
|
const [viewportHeight, setViewportHeight] = (0, import_react6.useState)(0);
|
|
1814
1975
|
(0, import_react6.useEffect)(() => {
|
|
@@ -1848,25 +2009,29 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
1848
2009
|
animations,
|
|
1849
2010
|
rendererRef
|
|
1850
2011
|
]);
|
|
2012
|
+
const measureViewport = (0, import_react6.useCallback)(() => {
|
|
2013
|
+
var _a;
|
|
2014
|
+
const column = contentRef && "current" in contentRef ? contentRef.current : null;
|
|
2015
|
+
const body = bodyRef.current;
|
|
2016
|
+
if (!column || !body) return;
|
|
2017
|
+
const cap = totalHeightRef.current > 0 ? totalHeightRef.current : Infinity;
|
|
2018
|
+
const height = Math.min(body.clientHeight, cap, window.innerHeight);
|
|
2019
|
+
setViewportHeight(height);
|
|
2020
|
+
(_a = rendererRef.current) == null ? void 0 : _a.setView({
|
|
2021
|
+
width: column.getBoundingClientRect().width,
|
|
2022
|
+
height
|
|
2023
|
+
});
|
|
2024
|
+
}, [bodyRef, contentRef, rendererRef]);
|
|
1851
2025
|
(0, import_react6.useEffect)(() => {
|
|
1852
2026
|
const column = contentRef && "current" in contentRef ? contentRef.current : null;
|
|
1853
2027
|
const body = bodyRef.current;
|
|
1854
2028
|
if (!column || !body) return;
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
const height = Math.min(body.clientHeight, window.innerHeight);
|
|
1858
|
-
setViewportHeight(height);
|
|
1859
|
-
(_a = rendererRef.current) == null ? void 0 : _a.setView({
|
|
1860
|
-
width: column.getBoundingClientRect().width,
|
|
1861
|
-
height
|
|
1862
|
-
});
|
|
1863
|
-
};
|
|
1864
|
-
measure();
|
|
1865
|
-
const observer = new ResizeObserver(measure);
|
|
2029
|
+
measureViewport();
|
|
2030
|
+
const observer = new ResizeObserver(measureViewport);
|
|
1866
2031
|
observer.observe(column);
|
|
1867
2032
|
observer.observe(body);
|
|
1868
2033
|
return () => observer.disconnect();
|
|
1869
|
-
}, [bodyRef, contentRef,
|
|
2034
|
+
}, [bodyRef, contentRef, measureViewport]);
|
|
1870
2035
|
(0, import_react6.useEffect)(() => {
|
|
1871
2036
|
const body = bodyRef.current;
|
|
1872
2037
|
if (!body) return;
|
|
@@ -1882,6 +2047,43 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
1882
2047
|
(0, import_react6.useCallback)((listener) => scene.subscribe(listener), [scene]),
|
|
1883
2048
|
() => scene.version
|
|
1884
2049
|
);
|
|
2050
|
+
(0, import_react6.useLayoutEffect)(() => {
|
|
2051
|
+
const wrapper = headerWrapperRef.current;
|
|
2052
|
+
if (!wrapper) return;
|
|
2053
|
+
const measurer = document.createElement("div");
|
|
2054
|
+
measurer.className = "row-header-label";
|
|
2055
|
+
measurer.setAttribute("aria-hidden", "true");
|
|
2056
|
+
measurer.style.position = "absolute";
|
|
2057
|
+
measurer.style.left = "-9999px";
|
|
2058
|
+
measurer.style.top = "0";
|
|
2059
|
+
measurer.style.visibility = "hidden";
|
|
2060
|
+
measurer.style.height = "auto";
|
|
2061
|
+
wrapper.appendChild(measurer);
|
|
2062
|
+
let lastWidth = -1;
|
|
2063
|
+
const measure = () => {
|
|
2064
|
+
var _a;
|
|
2065
|
+
const width = wrapper.clientWidth;
|
|
2066
|
+
if (width === 0 || width === lastWidth) return;
|
|
2067
|
+
lastWidth = width;
|
|
2068
|
+
measurer.style.width = `${width}px`;
|
|
2069
|
+
const heights = /* @__PURE__ */ new Map();
|
|
2070
|
+
for (const row of rows) {
|
|
2071
|
+
measurer.textContent = (_a = row.name) != null ? _a : "";
|
|
2072
|
+
heights.set(
|
|
2073
|
+
row.id,
|
|
2074
|
+
Math.ceil(measurer.offsetHeight) + 2 * theme.rowPaddingY
|
|
2075
|
+
);
|
|
2076
|
+
}
|
|
2077
|
+
scene.setLabelMinHeights(heights);
|
|
2078
|
+
};
|
|
2079
|
+
measure();
|
|
2080
|
+
const observer = new ResizeObserver(measure);
|
|
2081
|
+
observer.observe(wrapper);
|
|
2082
|
+
return () => {
|
|
2083
|
+
observer.disconnect();
|
|
2084
|
+
wrapper.removeChild(measurer);
|
|
2085
|
+
};
|
|
2086
|
+
}, [rows, scene, theme.rowPaddingY, rowsHeaderClassName]);
|
|
1885
2087
|
const {
|
|
1886
2088
|
handlePointerDown,
|
|
1887
2089
|
handlePointerMove,
|
|
@@ -1904,19 +2106,46 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
1904
2106
|
onEventClick,
|
|
1905
2107
|
onEventHover,
|
|
1906
2108
|
eventsResize,
|
|
1907
|
-
panZoom
|
|
2109
|
+
panZoom,
|
|
2110
|
+
selectable,
|
|
2111
|
+
applySelection,
|
|
2112
|
+
getSelection
|
|
1908
2113
|
});
|
|
2114
|
+
(0, import_react6.useEffect)(() => {
|
|
2115
|
+
var _a;
|
|
2116
|
+
(_a = rendererRef.current) == null ? void 0 : _a.setView({
|
|
2117
|
+
selectedEventIds: new Set(getSelection())
|
|
2118
|
+
});
|
|
2119
|
+
}, [getSelection, rendererRef]);
|
|
1909
2120
|
const { offsetOf, totalHeight } = scene.getRowOffsets(
|
|
1910
2121
|
windowTime[0],
|
|
1911
2122
|
windowTime[1]
|
|
1912
2123
|
);
|
|
2124
|
+
totalHeightRef.current = totalHeight;
|
|
2125
|
+
(0, import_react6.useLayoutEffect)(() => {
|
|
2126
|
+
measureViewport();
|
|
2127
|
+
}, [totalHeight, measureViewport]);
|
|
2128
|
+
const lastChildOf = /* @__PURE__ */ new Map();
|
|
2129
|
+
for (const row of rows) {
|
|
2130
|
+
if (row.parentId !== void 0) lastChildOf.set(row.parentId, row.id);
|
|
2131
|
+
}
|
|
2132
|
+
const connectorColor = theme.gridColor;
|
|
2133
|
+
const SPINE_X = 11;
|
|
1913
2134
|
const visibleHeaders = [];
|
|
1914
2135
|
for (let i = 0; i < rows.length; i++) {
|
|
1915
2136
|
const row = rows[i];
|
|
2137
|
+
if (scene.isRowHidden(row.id)) continue;
|
|
1916
2138
|
const top = offsetOf.get(row.id);
|
|
2139
|
+
if (top === void 0) continue;
|
|
1917
2140
|
const height = scene.getRowHeight(row.id, windowTime[0], windowTime[1]);
|
|
1918
2141
|
if (top + height < scrollTop) continue;
|
|
1919
2142
|
if (top > scrollTop + viewportHeight) break;
|
|
2143
|
+
const isParent = scene.isRowParent(row.id);
|
|
2144
|
+
const parentId = row.parentId;
|
|
2145
|
+
const isChild = parentId !== void 0;
|
|
2146
|
+
const isLastChild = parentId !== void 0 && lastChildOf.get(parentId) === row.id;
|
|
2147
|
+
const collapsed = scene.isRowCollapsed(row.id);
|
|
2148
|
+
const grouped = isParent || isChild;
|
|
1920
2149
|
visibleHeaders.push(
|
|
1921
2150
|
/* @__PURE__ */ import_react6.default.createElement(
|
|
1922
2151
|
"div",
|
|
@@ -1927,16 +2156,79 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
1927
2156
|
top,
|
|
1928
2157
|
height,
|
|
1929
2158
|
borderBottom: i === rows.length - 1 ? "none" : "1px solid yellow",
|
|
1930
|
-
//
|
|
1931
|
-
|
|
2159
|
+
// Row heights/positions apply instantly (no layout tween) so the
|
|
2160
|
+
// header snaps in lockstep with its canvas row — see draw-events.
|
|
2161
|
+
// Grouped rows left-align so the caret + tree spine line up; plain
|
|
2162
|
+
// rows keep the centered default.
|
|
2163
|
+
justifyContent: grouped ? "flex-start" : void 0,
|
|
2164
|
+
paddingLeft: isChild ? 24 : isParent ? 6 : void 0
|
|
1932
2165
|
}
|
|
1933
2166
|
},
|
|
1934
|
-
row
|
|
2167
|
+
isChild && // tree connector: a vertical spine + a horizontal tick at the row's
|
|
2168
|
+
// vertical center. The spine runs the full height for a mid child
|
|
2169
|
+
// (├─) and stops at the center for the last child (└─), so stacked
|
|
2170
|
+
// children form one continuous spine descending from the parent.
|
|
2171
|
+
/* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(
|
|
2172
|
+
"span",
|
|
2173
|
+
{
|
|
2174
|
+
"aria-hidden": true,
|
|
2175
|
+
style: {
|
|
2176
|
+
position: "absolute",
|
|
2177
|
+
left: SPINE_X,
|
|
2178
|
+
top: 0,
|
|
2179
|
+
width: 1,
|
|
2180
|
+
height: isLastChild ? "50%" : "100%",
|
|
2181
|
+
backgroundColor: connectorColor,
|
|
2182
|
+
pointerEvents: "none"
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
2186
|
+
"span",
|
|
2187
|
+
{
|
|
2188
|
+
"aria-hidden": true,
|
|
2189
|
+
style: {
|
|
2190
|
+
position: "absolute",
|
|
2191
|
+
left: SPINE_X,
|
|
2192
|
+
top: "50%",
|
|
2193
|
+
width: 9,
|
|
2194
|
+
height: 1,
|
|
2195
|
+
backgroundColor: connectorColor,
|
|
2196
|
+
pointerEvents: "none"
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
)),
|
|
2200
|
+
isParent && /* @__PURE__ */ import_react6.default.createElement(
|
|
2201
|
+
"span",
|
|
2202
|
+
{
|
|
2203
|
+
className: "row-header-caret",
|
|
2204
|
+
role: "button",
|
|
2205
|
+
"aria-label": collapsed ? "Expand group" : "Collapse group",
|
|
2206
|
+
onClick: () => scene.toggleCollapsed(row.id),
|
|
2207
|
+
style: { cursor: "pointer", marginRight: 4, userSelect: "none" }
|
|
2208
|
+
},
|
|
2209
|
+
collapsed ? "\u25B8" : "\u25BE"
|
|
2210
|
+
),
|
|
2211
|
+
/* @__PURE__ */ import_react6.default.createElement(
|
|
2212
|
+
"span",
|
|
2213
|
+
{
|
|
2214
|
+
className: "row-header-label",
|
|
2215
|
+
style: grouped ? { textAlign: "left" } : void 0
|
|
2216
|
+
},
|
|
2217
|
+
row.name
|
|
2218
|
+
)
|
|
1935
2219
|
)
|
|
1936
2220
|
);
|
|
1937
2221
|
}
|
|
1938
2222
|
const headerClassNames = rowsHeaderClassName ? `rows-header-wrapper canvas-rows-header ${rowsHeaderClassName}` : "rows-header-wrapper canvas-rows-header";
|
|
1939
|
-
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(
|
|
2223
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(
|
|
2224
|
+
"div",
|
|
2225
|
+
{
|
|
2226
|
+
ref: headerWrapperRef,
|
|
2227
|
+
className: headerClassNames,
|
|
2228
|
+
style: { height: totalHeight }
|
|
2229
|
+
},
|
|
2230
|
+
visibleHeaders
|
|
2231
|
+
), /* @__PURE__ */ import_react6.default.createElement("div", { className: "canvas-content-column", ref: contentRef }, /* @__PURE__ */ import_react6.default.createElement("div", { className: "canvas-sticky" }, /* @__PURE__ */ import_react6.default.createElement("canvas", { ref: staticCanvasRef }), /* @__PURE__ */ import_react6.default.createElement(
|
|
1940
2232
|
"canvas",
|
|
1941
2233
|
{
|
|
1942
2234
|
ref: dynamicCanvasRef,
|
|
@@ -1984,11 +2276,39 @@ var SceneStore = class {
|
|
|
1984
2276
|
this.rowIndexes = /* @__PURE__ */ new Map();
|
|
1985
2277
|
this.rowOrder = [];
|
|
1986
2278
|
this.eventRow = /* @__PURE__ */ new Map();
|
|
2279
|
+
// Group index for tag-based "connected" selection. eventGroup: eventId ->
|
|
2280
|
+
// groupId; groupMembers: groupId -> set of eventIds. Maintained alongside
|
|
2281
|
+
// eventRow so Cmd/Ctrl+click resolves the whole group in O(group size)
|
|
2282
|
+
// without scanning all rows.
|
|
2283
|
+
this.eventGroup = /* @__PURE__ */ new Map();
|
|
2284
|
+
this.groupMembers = /* @__PURE__ */ new Map();
|
|
2285
|
+
// Row hierarchy for grouped (collapsible) rows. parentOf: childRowId ->
|
|
2286
|
+
// parentRowId; childRowsOf: parentRowId -> ordered child row ids. Rebuilt in
|
|
2287
|
+
// setRows from `row.parentId`. One level of nesting only in v1.
|
|
2288
|
+
this.parentOf = /* @__PURE__ */ new Map();
|
|
2289
|
+
this.childRowsOf = /* @__PURE__ */ new Map();
|
|
2290
|
+
// Rows the user has collapsed. Lives only here so it survives every data
|
|
2291
|
+
// update (setEvents / applyPatches / events-prop reset); setRows only prunes
|
|
2292
|
+
// entries for rows that no longer exist.
|
|
2293
|
+
this.collapsedRows = /* @__PURE__ */ new Set();
|
|
2294
|
+
// Parent↔child EVENT index (distinct from the row hierarchy above).
|
|
2295
|
+
// childrenOf: parentEventId -> child event ids; parentEventOf: childEventId ->
|
|
2296
|
+
// parentEventId. Driven by props.parentEventId / props.isGroupParent. A parent
|
|
2297
|
+
// event's [startTime,endTime] is derived lazily from its children; any child
|
|
2298
|
+
// mutation marks the parent dirty and the span is recomputed on the next query
|
|
2299
|
+
// of the parent's row (flushParentSpans) — off-screen groups cost nothing.
|
|
2300
|
+
this.childrenOf = /* @__PURE__ */ new Map();
|
|
2301
|
+
this.parentEventOf = /* @__PURE__ */ new Map();
|
|
2302
|
+
this.parentSpanDirty = /* @__PURE__ */ new Set();
|
|
1987
2303
|
this.listeners = /* @__PURE__ */ new Set();
|
|
1988
2304
|
// Themeable vertical layout. Lanes are geometry-free (pure time logic), so a
|
|
1989
2305
|
// geometry change only affects heights/offsets — the cached lanes stay valid
|
|
1990
2306
|
// and we just bump to trigger a redraw.
|
|
1991
2307
|
this.geometry = DEFAULT_GEOMETRY;
|
|
2308
|
+
// Per-row minimum height demanded by the (DOM-measured) row label when it
|
|
2309
|
+
// wraps to multiple lines. Measured in the shell and fed back here so the
|
|
2310
|
+
// canvas grid/dividers, hit-testing and the DOM header all agree on height.
|
|
2311
|
+
this.labelMinHeights = /* @__PURE__ */ new Map();
|
|
1992
2312
|
this.version = 0;
|
|
1993
2313
|
}
|
|
1994
2314
|
setGeometry(geometry) {
|
|
@@ -2016,23 +2336,53 @@ var SceneStore = class {
|
|
|
2016
2336
|
);
|
|
2017
2337
|
}
|
|
2018
2338
|
for (const [id, rowId] of this.eventRow) {
|
|
2019
|
-
if (!next.has(rowId))
|
|
2339
|
+
if (!next.has(rowId)) {
|
|
2340
|
+
this.eventRow.delete(id);
|
|
2341
|
+
this.removeFromGroup(id);
|
|
2342
|
+
}
|
|
2020
2343
|
}
|
|
2021
2344
|
this.rowIndexes = next;
|
|
2022
2345
|
this.rowOrder = rows.map((row) => row.id);
|
|
2346
|
+
this.parentOf = /* @__PURE__ */ new Map();
|
|
2347
|
+
this.childRowsOf = /* @__PURE__ */ new Map();
|
|
2348
|
+
for (const row of rows) {
|
|
2349
|
+
if (row.parentId === void 0) continue;
|
|
2350
|
+
this.parentOf.set(row.id, row.parentId);
|
|
2351
|
+
let children = this.childRowsOf.get(row.parentId);
|
|
2352
|
+
if (!children) {
|
|
2353
|
+
children = [];
|
|
2354
|
+
this.childRowsOf.set(row.parentId, children);
|
|
2355
|
+
}
|
|
2356
|
+
children.push(row.id);
|
|
2357
|
+
}
|
|
2358
|
+
if (this.collapsedRows.size > 0) {
|
|
2359
|
+
const rowIds = new Set(this.rowOrder);
|
|
2360
|
+
for (const id of [...this.collapsedRows]) {
|
|
2361
|
+
if (!rowIds.has(id)) this.collapsedRows.delete(id);
|
|
2362
|
+
}
|
|
2363
|
+
}
|
|
2023
2364
|
this.bump();
|
|
2024
2365
|
}
|
|
2025
2366
|
setEvents(events) {
|
|
2367
|
+
var _a;
|
|
2026
2368
|
for (const index of this.rowIndexes.values()) {
|
|
2027
2369
|
index.events = [];
|
|
2028
2370
|
index.lanesDirty = true;
|
|
2029
2371
|
}
|
|
2030
2372
|
this.eventRow.clear();
|
|
2373
|
+
this.eventGroup.clear();
|
|
2374
|
+
this.groupMembers.clear();
|
|
2375
|
+
this.childrenOf.clear();
|
|
2376
|
+
this.parentEventOf.clear();
|
|
2377
|
+
this.parentSpanDirty.clear();
|
|
2031
2378
|
for (const event of events) {
|
|
2032
2379
|
const index = this.rowIndexes.get(event.rowId);
|
|
2033
2380
|
if (!index) continue;
|
|
2034
2381
|
index.events.push(event);
|
|
2035
2382
|
this.eventRow.set(event.id, event.rowId);
|
|
2383
|
+
this.addToGroup(event.id, (_a = event.props) == null ? void 0 : _a.groupId);
|
|
2384
|
+
this.addToParentIndex(event);
|
|
2385
|
+
this.validateDroppable(event);
|
|
2036
2386
|
}
|
|
2037
2387
|
for (const index of this.rowIndexes.values()) {
|
|
2038
2388
|
index.events.sort(sort_events_default);
|
|
@@ -2075,15 +2425,88 @@ var SceneStore = class {
|
|
|
2075
2425
|
if (rowId === void 0) return void 0;
|
|
2076
2426
|
return (_a = this.rowIndexes.get(rowId)) == null ? void 0 : _a.events.find((event) => event.id === id);
|
|
2077
2427
|
}
|
|
2428
|
+
/**
|
|
2429
|
+
* Event ids "connected" to the given event via a shared `props.groupId`.
|
|
2430
|
+
* Returns every member of the group (including the event itself), or just
|
|
2431
|
+
* `[eventId]` when the event has no group / no other members / is unknown.
|
|
2432
|
+
*/
|
|
2433
|
+
getConnectedEventIds(eventId) {
|
|
2434
|
+
const groupId = this.eventGroup.get(eventId);
|
|
2435
|
+
if (groupId === void 0) return [eventId];
|
|
2436
|
+
const members = this.groupMembers.get(groupId);
|
|
2437
|
+
if (!members || members.size === 0) return [eventId];
|
|
2438
|
+
return [...members];
|
|
2439
|
+
}
|
|
2440
|
+
/**
|
|
2441
|
+
* Whether an event may enter the selection. False only when the event is
|
|
2442
|
+
* present and explicitly opted out (`props.isSelectable === false`); unknown
|
|
2443
|
+
* ids are treated as selectable so a selection can be set before data loads
|
|
2444
|
+
* and survives streaming.
|
|
2445
|
+
*/
|
|
2446
|
+
isEventSelectable(id) {
|
|
2447
|
+
var _a;
|
|
2448
|
+
const event = this.getEvent(id);
|
|
2449
|
+
return event === void 0 || ((_a = event.props) == null ? void 0 : _a.isSelectable) !== false;
|
|
2450
|
+
}
|
|
2078
2451
|
getRowIds() {
|
|
2079
2452
|
return this.rowOrder;
|
|
2080
2453
|
}
|
|
2454
|
+
/**
|
|
2455
|
+
* Row ids in display order, minus rows hidden inside a collapsed parent.
|
|
2456
|
+
* Drives offsets, drawing and hit-testing. The header still walks
|
|
2457
|
+
* `getRowIds()` so it can draw the carets and decide which rows to skip.
|
|
2458
|
+
*/
|
|
2459
|
+
getVisibleRowIds() {
|
|
2460
|
+
if (this.collapsedRows.size === 0) return this.rowOrder;
|
|
2461
|
+
const visible = [];
|
|
2462
|
+
for (const rowId of this.rowOrder) {
|
|
2463
|
+
const parent = this.parentOf.get(rowId);
|
|
2464
|
+
if (parent !== void 0 && this.collapsedRows.has(parent)) continue;
|
|
2465
|
+
visible.push(rowId);
|
|
2466
|
+
}
|
|
2467
|
+
return visible;
|
|
2468
|
+
}
|
|
2469
|
+
/** whether a row is a parent (owns at least one child row) */
|
|
2470
|
+
isRowParent(rowId) {
|
|
2471
|
+
var _a, _b;
|
|
2472
|
+
return ((_b = (_a = this.childRowsOf.get(rowId)) == null ? void 0 : _a.length) != null ? _b : 0) > 0;
|
|
2473
|
+
}
|
|
2474
|
+
/** whether a row is hidden because its parent row is collapsed */
|
|
2475
|
+
isRowHidden(rowId) {
|
|
2476
|
+
const parent = this.parentOf.get(rowId);
|
|
2477
|
+
return parent !== void 0 && this.collapsedRows.has(parent);
|
|
2478
|
+
}
|
|
2479
|
+
isRowCollapsed(rowId) {
|
|
2480
|
+
return this.collapsedRows.has(rowId);
|
|
2481
|
+
}
|
|
2482
|
+
getCollapsedRowIds() {
|
|
2483
|
+
return [...this.collapsedRows];
|
|
2484
|
+
}
|
|
2485
|
+
setCollapsed(rowId, collapsed) {
|
|
2486
|
+
const has = this.collapsedRows.has(rowId);
|
|
2487
|
+
if (collapsed && !has) {
|
|
2488
|
+
this.collapsedRows.add(rowId);
|
|
2489
|
+
this.bump();
|
|
2490
|
+
} else if (!collapsed && has) {
|
|
2491
|
+
this.collapsedRows.delete(rowId);
|
|
2492
|
+
this.bump();
|
|
2493
|
+
}
|
|
2494
|
+
}
|
|
2495
|
+
toggleCollapsed(rowId) {
|
|
2496
|
+
this.setCollapsed(rowId, !this.collapsedRows.has(rowId));
|
|
2497
|
+
}
|
|
2498
|
+
/** child event ids of a parent (summary) event; empty if it has none */
|
|
2499
|
+
getChildEventIds(parentEventId) {
|
|
2500
|
+
const children = this.childrenOf.get(parentEventId);
|
|
2501
|
+
return children ? [...children] : [];
|
|
2502
|
+
}
|
|
2081
2503
|
getRow(rowId) {
|
|
2082
2504
|
var _a;
|
|
2083
2505
|
return (_a = this.rowIndexes.get(rowId)) == null ? void 0 : _a.row;
|
|
2084
2506
|
}
|
|
2085
2507
|
getRowEvents(rowId) {
|
|
2086
2508
|
var _a, _b;
|
|
2509
|
+
this.flushParentSpans(rowId);
|
|
2087
2510
|
return (_b = (_a = this.rowIndexes.get(rowId)) == null ? void 0 : _a.events) != null ? _b : [];
|
|
2088
2511
|
}
|
|
2089
2512
|
getRowStaticEvents(rowId) {
|
|
@@ -2091,6 +2514,7 @@ var SceneStore = class {
|
|
|
2091
2514
|
return (_b = (_a = this.rowIndexes.get(rowId)) == null ? void 0 : _a.staticEvents) != null ? _b : [];
|
|
2092
2515
|
}
|
|
2093
2516
|
getLanes(rowId, windowStart, windowEnd) {
|
|
2517
|
+
this.flushParentSpans(rowId);
|
|
2094
2518
|
const index = this.rowIndexes.get(rowId);
|
|
2095
2519
|
if (!index) return { laneOf: /* @__PURE__ */ new Map(), highestLane: 0 };
|
|
2096
2520
|
if (index.lanesDirty || index.lanes === null || index.laneWindowStart !== windowStart || index.laneWindowEnd !== windowEnd) {
|
|
@@ -2101,11 +2525,35 @@ var SceneStore = class {
|
|
|
2101
2525
|
}
|
|
2102
2526
|
return index.lanes;
|
|
2103
2527
|
}
|
|
2528
|
+
/**
|
|
2529
|
+
* Report the per-row label heights measured against the live DOM header
|
|
2530
|
+
* (key: rowId, value: the minimum row height the wrapped label needs,
|
|
2531
|
+
* already including vertical padding). Replaces the previous map wholesale
|
|
2532
|
+
* and only bumps when a value actually changed, so re-measuring identical
|
|
2533
|
+
* labels is a no-op and can't feed back into an infinite render loop.
|
|
2534
|
+
*/
|
|
2535
|
+
setLabelMinHeights(heights) {
|
|
2536
|
+
let changed = heights.size !== this.labelMinHeights.size;
|
|
2537
|
+
if (!changed) {
|
|
2538
|
+
for (const [id, h] of heights) {
|
|
2539
|
+
if (this.labelMinHeights.get(id) !== h) {
|
|
2540
|
+
changed = true;
|
|
2541
|
+
break;
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
if (!changed) return;
|
|
2546
|
+
this.labelMinHeights = heights;
|
|
2547
|
+
this.bump();
|
|
2548
|
+
}
|
|
2104
2549
|
getRowHeight(rowId, windowStart, windowEnd) {
|
|
2105
|
-
|
|
2550
|
+
var _a;
|
|
2551
|
+
const laneHeight = rowMinHeight(
|
|
2106
2552
|
this.getLanes(rowId, windowStart, windowEnd).highestLane,
|
|
2107
2553
|
this.geometry
|
|
2108
2554
|
);
|
|
2555
|
+
const labelHeight = (_a = this.labelMinHeights.get(rowId)) != null ? _a : 0;
|
|
2556
|
+
return Math.max(laneHeight, labelHeight);
|
|
2109
2557
|
}
|
|
2110
2558
|
/**
|
|
2111
2559
|
* y offset of each row's top edge (content coordinates, before scroll) plus
|
|
@@ -2114,7 +2562,7 @@ var SceneStore = class {
|
|
|
2114
2562
|
getRowOffsets(windowStart, windowEnd) {
|
|
2115
2563
|
const offsetOf = /* @__PURE__ */ new Map();
|
|
2116
2564
|
let y = 0;
|
|
2117
|
-
for (const rowId of this.
|
|
2565
|
+
for (const rowId of this.getVisibleRowIds()) {
|
|
2118
2566
|
offsetOf.set(rowId, y);
|
|
2119
2567
|
y += this.getRowHeight(rowId, windowStart, windowEnd);
|
|
2120
2568
|
}
|
|
@@ -2125,11 +2573,15 @@ var SceneStore = class {
|
|
|
2125
2573
|
return () => this.listeners.delete(listener);
|
|
2126
2574
|
}
|
|
2127
2575
|
insert(event) {
|
|
2576
|
+
var _a;
|
|
2128
2577
|
const index = this.rowIndexes.get(event.rowId);
|
|
2129
2578
|
if (!index) return;
|
|
2130
2579
|
index.events.splice(binaryInsertIndex(index.events, event), 0, event);
|
|
2131
2580
|
index.lanesDirty = true;
|
|
2132
2581
|
this.eventRow.set(event.id, event.rowId);
|
|
2582
|
+
this.addToGroup(event.id, (_a = event.props) == null ? void 0 : _a.groupId);
|
|
2583
|
+
this.addToParentIndex(event);
|
|
2584
|
+
this.validateDroppable(event);
|
|
2133
2585
|
}
|
|
2134
2586
|
remove(id) {
|
|
2135
2587
|
const rowId = this.eventRow.get(id);
|
|
@@ -2141,6 +2593,117 @@ var SceneStore = class {
|
|
|
2141
2593
|
index.lanesDirty = true;
|
|
2142
2594
|
}
|
|
2143
2595
|
this.eventRow.delete(id);
|
|
2596
|
+
this.removeFromGroup(id);
|
|
2597
|
+
this.removeFromParentIndex(id);
|
|
2598
|
+
}
|
|
2599
|
+
addToGroup(eventId, groupId) {
|
|
2600
|
+
if (groupId === void 0) return;
|
|
2601
|
+
this.eventGroup.set(eventId, groupId);
|
|
2602
|
+
let members = this.groupMembers.get(groupId);
|
|
2603
|
+
if (!members) {
|
|
2604
|
+
members = /* @__PURE__ */ new Set();
|
|
2605
|
+
this.groupMembers.set(groupId, members);
|
|
2606
|
+
}
|
|
2607
|
+
members.add(eventId);
|
|
2608
|
+
}
|
|
2609
|
+
removeFromGroup(eventId) {
|
|
2610
|
+
const groupId = this.eventGroup.get(eventId);
|
|
2611
|
+
if (groupId === void 0) return;
|
|
2612
|
+
this.eventGroup.delete(eventId);
|
|
2613
|
+
const members = this.groupMembers.get(groupId);
|
|
2614
|
+
if (members) {
|
|
2615
|
+
members.delete(eventId);
|
|
2616
|
+
if (members.size === 0) this.groupMembers.delete(groupId);
|
|
2617
|
+
}
|
|
2618
|
+
}
|
|
2619
|
+
/**
|
|
2620
|
+
* Enforce the authoring contract for `props.droppableRowIds`: if the event's
|
|
2621
|
+
* current row is not among its allowed rows, record a `droppableError` on
|
|
2622
|
+
* `props.metadata` (merged non-destructively); otherwise clear any stale one.
|
|
2623
|
+
* Cheap no-op for events without `droppableRowIds` and no prior error.
|
|
2624
|
+
*/
|
|
2625
|
+
validateDroppable(event) {
|
|
2626
|
+
var _a, _b;
|
|
2627
|
+
const allowed = (_a = event.props) == null ? void 0 : _a.droppableRowIds;
|
|
2628
|
+
const meta = (_b = event.props) == null ? void 0 : _b.metadata;
|
|
2629
|
+
const metaObj = typeof meta === "object" && meta !== null ? meta : void 0;
|
|
2630
|
+
const hadError = metaObj !== void 0 && "droppableError" in metaObj;
|
|
2631
|
+
const needsError = allowed !== void 0 && !allowed.includes(event.rowId);
|
|
2632
|
+
if (!needsError && !hadError) return;
|
|
2633
|
+
if (!event.props) return;
|
|
2634
|
+
if (needsError) {
|
|
2635
|
+
event.props.metadata = __spreadProps(__spreadValues({}, metaObj != null ? metaObj : {}), {
|
|
2636
|
+
droppableError: {
|
|
2637
|
+
rowId: event.rowId,
|
|
2638
|
+
droppableRowIds: allowed
|
|
2639
|
+
}
|
|
2640
|
+
});
|
|
2641
|
+
} else {
|
|
2642
|
+
const rest = __spreadValues({}, metaObj);
|
|
2643
|
+
delete rest.droppableError;
|
|
2644
|
+
event.props.metadata = Object.keys(rest).length > 0 ? rest : void 0;
|
|
2645
|
+
}
|
|
2646
|
+
}
|
|
2647
|
+
addToParentIndex(event) {
|
|
2648
|
+
var _a;
|
|
2649
|
+
const parentId = (_a = event.props) == null ? void 0 : _a.parentEventId;
|
|
2650
|
+
if (parentId === void 0) return;
|
|
2651
|
+
this.parentEventOf.set(event.id, parentId);
|
|
2652
|
+
let children = this.childrenOf.get(parentId);
|
|
2653
|
+
if (!children) {
|
|
2654
|
+
children = /* @__PURE__ */ new Set();
|
|
2655
|
+
this.childrenOf.set(parentId, children);
|
|
2656
|
+
}
|
|
2657
|
+
children.add(event.id);
|
|
2658
|
+
this.parentSpanDirty.add(parentId);
|
|
2659
|
+
}
|
|
2660
|
+
removeFromParentIndex(eventId) {
|
|
2661
|
+
const parentId = this.parentEventOf.get(eventId);
|
|
2662
|
+
if (parentId === void 0) return;
|
|
2663
|
+
this.parentEventOf.delete(eventId);
|
|
2664
|
+
const children = this.childrenOf.get(parentId);
|
|
2665
|
+
if (children) {
|
|
2666
|
+
children.delete(eventId);
|
|
2667
|
+
if (children.size === 0) this.childrenOf.delete(parentId);
|
|
2668
|
+
}
|
|
2669
|
+
this.parentSpanDirty.add(parentId);
|
|
2670
|
+
}
|
|
2671
|
+
/**
|
|
2672
|
+
* Recompute the derived span of any dirty parent event living on `rowId`
|
|
2673
|
+
* (earliest child start → latest child end), write it back into the parent
|
|
2674
|
+
* event, and re-sort the row so the sorted-array invariant holds. Cheap no-op
|
|
2675
|
+
* when nothing is dirty (the common no-groups case never touches this).
|
|
2676
|
+
*/
|
|
2677
|
+
flushParentSpans(rowId) {
|
|
2678
|
+
var _a;
|
|
2679
|
+
if (this.parentSpanDirty.size === 0) return;
|
|
2680
|
+
const index = this.rowIndexes.get(rowId);
|
|
2681
|
+
if (!index) return;
|
|
2682
|
+
let changed = false;
|
|
2683
|
+
for (const event of index.events) {
|
|
2684
|
+
if (!((_a = event.props) == null ? void 0 : _a.isGroupParent)) continue;
|
|
2685
|
+
if (!this.parentSpanDirty.has(event.id)) continue;
|
|
2686
|
+
this.parentSpanDirty.delete(event.id);
|
|
2687
|
+
const children = this.childrenOf.get(event.id);
|
|
2688
|
+
if (!children || children.size === 0) continue;
|
|
2689
|
+
let minStart = Infinity;
|
|
2690
|
+
let maxEnd = -Infinity;
|
|
2691
|
+
for (const childId of children) {
|
|
2692
|
+
const child = this.getEvent(childId);
|
|
2693
|
+
if (!child) continue;
|
|
2694
|
+
if (child.startTime < minStart) minStart = child.startTime;
|
|
2695
|
+
if (child.endTime > maxEnd) maxEnd = child.endTime;
|
|
2696
|
+
}
|
|
2697
|
+
if (minStart !== Infinity && (event.startTime !== minStart || event.endTime !== maxEnd)) {
|
|
2698
|
+
event.startTime = minStart;
|
|
2699
|
+
event.endTime = maxEnd;
|
|
2700
|
+
changed = true;
|
|
2701
|
+
}
|
|
2702
|
+
}
|
|
2703
|
+
if (changed) {
|
|
2704
|
+
index.events.sort(sort_events_default);
|
|
2705
|
+
index.lanesDirty = true;
|
|
2706
|
+
}
|
|
2144
2707
|
}
|
|
2145
2708
|
bump() {
|
|
2146
2709
|
this.version++;
|
|
@@ -2158,6 +2721,10 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2158
2721
|
onResize,
|
|
2159
2722
|
onEventClick,
|
|
2160
2723
|
onEventHover,
|
|
2724
|
+
selectable = false,
|
|
2725
|
+
defaultSelectedEventIds,
|
|
2726
|
+
onSelectionChange,
|
|
2727
|
+
defaultCollapsedRowIds,
|
|
2161
2728
|
startDate,
|
|
2162
2729
|
endDate,
|
|
2163
2730
|
theme,
|
|
@@ -2202,15 +2769,53 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2202
2769
|
sceneRef.current = new SceneStore();
|
|
2203
2770
|
}
|
|
2204
2771
|
const scene = sceneRef.current;
|
|
2772
|
+
const selectionRef = (0, import_react7.useRef)(
|
|
2773
|
+
new Set(defaultSelectedEventIds != null ? defaultSelectedEventIds : [])
|
|
2774
|
+
);
|
|
2775
|
+
const onSelectionChangeRef = (0, import_react7.useRef)(onSelectionChange);
|
|
2776
|
+
onSelectionChangeRef.current = onSelectionChange;
|
|
2777
|
+
const applySelection = (0, import_react7.useCallback)(
|
|
2778
|
+
(ids) => {
|
|
2779
|
+
var _a, _b;
|
|
2780
|
+
const expanded = [];
|
|
2781
|
+
for (const id of ids) {
|
|
2782
|
+
expanded.push(id);
|
|
2783
|
+
for (const childId of scene.getChildEventIds(id)) {
|
|
2784
|
+
expanded.push(childId);
|
|
2785
|
+
}
|
|
2786
|
+
}
|
|
2787
|
+
selectionRef.current = new Set(
|
|
2788
|
+
expanded.filter((id) => scene.isEventSelectable(id))
|
|
2789
|
+
);
|
|
2790
|
+
(_a = rendererRef.current) == null ? void 0 : _a.setView({
|
|
2791
|
+
selectedEventIds: selectionRef.current
|
|
2792
|
+
});
|
|
2793
|
+
(_b = onSelectionChangeRef.current) == null ? void 0 : _b.call(onSelectionChangeRef, [...selectionRef.current]);
|
|
2794
|
+
},
|
|
2795
|
+
[scene]
|
|
2796
|
+
);
|
|
2797
|
+
const getSelection = (0, import_react7.useCallback)(() => [...selectionRef.current], []);
|
|
2205
2798
|
(0, import_react7.useEffect)(() => {
|
|
2799
|
+
var _a;
|
|
2206
2800
|
scene.setRows(rows);
|
|
2801
|
+
(_a = rendererRef.current) == null ? void 0 : _a.animator.reset();
|
|
2207
2802
|
}, [scene, rows]);
|
|
2208
2803
|
(0, import_react7.useEffect)(() => {
|
|
2804
|
+
var _a;
|
|
2209
2805
|
scene.setEvents([...events].sort(sort_events_default));
|
|
2806
|
+
(_a = rendererRef.current) == null ? void 0 : _a.animator.reset();
|
|
2210
2807
|
}, [scene, events]);
|
|
2211
2808
|
(0, import_react7.useEffect)(() => {
|
|
2212
2809
|
scene.setStaticEvents(staticEvents ? [...staticEvents] : []);
|
|
2213
2810
|
}, [scene, staticEvents]);
|
|
2811
|
+
const seededCollapseRef = (0, import_react7.useRef)(false);
|
|
2812
|
+
(0, import_react7.useEffect)(() => {
|
|
2813
|
+
if (seededCollapseRef.current) return;
|
|
2814
|
+
seededCollapseRef.current = true;
|
|
2815
|
+
for (const id of defaultCollapsedRowIds != null ? defaultCollapsedRowIds : []) {
|
|
2816
|
+
scene.setCollapsed(id, true);
|
|
2817
|
+
}
|
|
2818
|
+
}, [scene, defaultCollapsedRowIds]);
|
|
2214
2819
|
const windowTimeRef = (0, import_react7.useRef)(windowTime);
|
|
2215
2820
|
windowTimeRef.current = windowTime;
|
|
2216
2821
|
(0, import_react7.useImperativeHandle)(
|
|
@@ -2234,12 +2839,16 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2234
2839
|
startTime: windowTimeRef.current[0],
|
|
2235
2840
|
endTime: windowTimeRef.current[1]
|
|
2236
2841
|
}),
|
|
2842
|
+
setSelection: (ids) => applySelection(ids),
|
|
2843
|
+
getSelection,
|
|
2844
|
+
toggleRow: (rowId) => scene.toggleCollapsed(rowId),
|
|
2845
|
+
setCollapsed: (rowId, collapsed) => scene.setCollapsed(rowId, collapsed),
|
|
2237
2846
|
redraw: () => {
|
|
2238
2847
|
var _a;
|
|
2239
2848
|
return (_a = rendererRef.current) == null ? void 0 : _a.invalidate("all");
|
|
2240
2849
|
}
|
|
2241
2850
|
}),
|
|
2242
|
-
[scene]
|
|
2851
|
+
[scene, applySelection, getSelection]
|
|
2243
2852
|
);
|
|
2244
2853
|
(0, import_react7.useEffect)(() => {
|
|
2245
2854
|
if (contentRef.current) {
|
|
@@ -2327,6 +2936,9 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2327
2936
|
eventsResize,
|
|
2328
2937
|
panZoom,
|
|
2329
2938
|
animations: resolvedAnimations,
|
|
2939
|
+
selectable,
|
|
2940
|
+
applySelection,
|
|
2941
|
+
getSelection,
|
|
2330
2942
|
ref: contentRef
|
|
2331
2943
|
}
|
|
2332
2944
|
), showEventPrompt && eventPrompt));
|