awesome-timeline-react 0.9.0 → 0.11.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 +7 -1
- package/dist/_tsup-dts-rollup.d.mts +63 -12
- package/dist/_tsup-dts-rollup.d.ts +63 -12
- package/dist/index.css +22 -0
- package/dist/index.css.map +1 -1
- package/dist/index.js +190 -65
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +192 -67
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -19,12 +19,12 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
21
|
// src/timeline.tsx
|
|
22
|
-
import
|
|
23
|
-
forwardRef as
|
|
22
|
+
import React7, {
|
|
23
|
+
forwardRef as forwardRef4,
|
|
24
24
|
useCallback as useCallback3,
|
|
25
25
|
useEffect as useEffect6,
|
|
26
|
-
useImperativeHandle as
|
|
27
|
-
useMemo as
|
|
26
|
+
useImperativeHandle as useImperativeHandle3,
|
|
27
|
+
useMemo as useMemo2,
|
|
28
28
|
useRef as useRef7,
|
|
29
29
|
useState as useState4
|
|
30
30
|
} from "react";
|
|
@@ -103,35 +103,41 @@ var LayoutAnimator = class {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
// src/hooks/use-resize-observer.ts
|
|
106
|
-
import { useEffect
|
|
106
|
+
import { useEffect } from "react";
|
|
107
|
+
var createWidthObserver = (getWindow, onScale) => {
|
|
108
|
+
let prevWidth = 0;
|
|
109
|
+
return new ResizeObserver((entries) => {
|
|
110
|
+
var _a;
|
|
111
|
+
for (const entry of entries) {
|
|
112
|
+
const width = (_a = entry.borderBoxSize) == null ? void 0 : _a[0].inlineSize;
|
|
113
|
+
if (typeof width === "number" && width !== prevWidth) {
|
|
114
|
+
prevWidth = width;
|
|
115
|
+
const [start, end] = getWindow();
|
|
116
|
+
const windowDuration = end - start;
|
|
117
|
+
onScale(
|
|
118
|
+
windowDuration / entry.contentRect.width,
|
|
119
|
+
entry.contentRect.width / (windowDuration / 3600)
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
};
|
|
107
125
|
var useResizeObserver = ({
|
|
108
|
-
|
|
126
|
+
windowTimeRef,
|
|
109
127
|
setTick,
|
|
110
128
|
setCellWidth,
|
|
111
129
|
contentRef
|
|
112
130
|
}) => {
|
|
113
|
-
const prevWidthRef = useRef(0);
|
|
114
|
-
const resizeObserver = useMemo(() => {
|
|
115
|
-
return new ResizeObserver((entries) => {
|
|
116
|
-
var _a;
|
|
117
|
-
for (const entry of entries) {
|
|
118
|
-
const width = (_a = entry.borderBoxSize) == null ? void 0 : _a[0].inlineSize;
|
|
119
|
-
if (typeof width === "number" && width !== prevWidthRef.current) {
|
|
120
|
-
prevWidthRef.current = width;
|
|
121
|
-
const windowDuration = windowTime[1] - windowTime[0];
|
|
122
|
-
const numberOfHourBlocks = windowDuration / 3600;
|
|
123
|
-
setTick(windowDuration / entry.contentRect.width);
|
|
124
|
-
setCellWidth(entry.contentRect.width / numberOfHourBlocks);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
});
|
|
128
|
-
}, [windowTime]);
|
|
129
131
|
useEffect(() => {
|
|
132
|
+
const observer = createWidthObserver(() => windowTimeRef.current, (tick, cellWidth) => {
|
|
133
|
+
setTick(tick);
|
|
134
|
+
setCellWidth(cellWidth);
|
|
135
|
+
});
|
|
130
136
|
if (contentRef.current) {
|
|
131
|
-
|
|
137
|
+
observer.observe(contentRef.current, { box: "border-box" });
|
|
132
138
|
}
|
|
133
|
-
return () =>
|
|
134
|
-
}, [
|
|
139
|
+
return () => observer.disconnect();
|
|
140
|
+
}, [windowTimeRef, setTick, setCellWidth, contentRef]);
|
|
135
141
|
};
|
|
136
142
|
var use_resize_observer_default = useResizeObserver;
|
|
137
143
|
|
|
@@ -151,14 +157,14 @@ var sortEvents = (eventA, eventB) => {
|
|
|
151
157
|
var sort_events_default = sortEvents;
|
|
152
158
|
|
|
153
159
|
// src/components/rt-indicator.tsx
|
|
154
|
-
import React, { useEffect as useEffect2, useRef
|
|
160
|
+
import React, { useEffect as useEffect2, useRef, useState } from "react";
|
|
155
161
|
var RTIndicator = ({
|
|
156
162
|
tick,
|
|
157
163
|
windowTime
|
|
158
164
|
}) => {
|
|
159
165
|
const [currentTime, setCurrentTime] = useState((/* @__PURE__ */ new Date()).getTime() / 1e3);
|
|
160
166
|
const [leftOffset, setLeftOffset] = useState(0);
|
|
161
|
-
const intervalIdRef =
|
|
167
|
+
const intervalIdRef = useRef(null);
|
|
162
168
|
useEffect2(() => {
|
|
163
169
|
if (tick) {
|
|
164
170
|
const leftOffsetTime = currentTime - windowTime[0];
|
|
@@ -180,15 +186,15 @@ var rt_indicator_default = RTIndicator;
|
|
|
180
186
|
import React2, {
|
|
181
187
|
forwardRef,
|
|
182
188
|
useImperativeHandle,
|
|
183
|
-
useRef as
|
|
189
|
+
useRef as useRef2,
|
|
184
190
|
useState as useState2
|
|
185
191
|
} from "react";
|
|
186
192
|
import { computePosition, flip, offset, shift } from "@floating-ui/dom";
|
|
187
193
|
var EventPrompt = forwardRef(
|
|
188
194
|
({ template }, ref) => {
|
|
189
|
-
const promptRef =
|
|
195
|
+
const promptRef = useRef2(null);
|
|
190
196
|
const [hoveredEvent, setHoveredEvent] = useState2();
|
|
191
|
-
const showSeqRef =
|
|
197
|
+
const showSeqRef = useRef2(0);
|
|
192
198
|
useImperativeHandle(ref, () => {
|
|
193
199
|
return {
|
|
194
200
|
show(event, anchorRect) {
|
|
@@ -238,7 +244,7 @@ var EventPrompt = forwardRef(
|
|
|
238
244
|
var event_prompt_default = EventPrompt;
|
|
239
245
|
|
|
240
246
|
// src/components/canvas-time-bar.tsx
|
|
241
|
-
import React3, { useEffect as useEffect3, useRef as
|
|
247
|
+
import React3, { useEffect as useEffect3, useRef as useRef3 } from "react";
|
|
242
248
|
|
|
243
249
|
// src/helpers/get-month-name.ts
|
|
244
250
|
var getMonthName = (monthIndex) => {
|
|
@@ -447,8 +453,11 @@ var DEFAULT_THEME = {
|
|
|
447
453
|
laneGap: 2,
|
|
448
454
|
rowPaddingY: 10,
|
|
449
455
|
barRadius: 5,
|
|
456
|
+
minHitWidth: 0,
|
|
450
457
|
groupChildBackground: "rgba(0,0,0,0.05)",
|
|
451
|
-
groupShadowColor: "rgba(0,0,0,0.22)"
|
|
458
|
+
groupShadowColor: "rgba(0,0,0,0.22)",
|
|
459
|
+
pointerLineColor: "rgba(15,23,42,0.7)",
|
|
460
|
+
pointerLabelColor: "#ffffff"
|
|
452
461
|
};
|
|
453
462
|
var resolveTheme = (theme) => __spreadValues(__spreadValues({}, DEFAULT_THEME), theme);
|
|
454
463
|
|
|
@@ -528,7 +537,8 @@ var drawTimeBar = (ctx, {
|
|
|
528
537
|
};
|
|
529
538
|
|
|
530
539
|
// src/components/canvas-time-bar.tsx
|
|
531
|
-
var
|
|
540
|
+
var TIME_BAR_HEIGHT = 50;
|
|
541
|
+
var TIME_BAR_INNER_HEIGHT = TIME_BAR_HEIGHT - 2;
|
|
532
542
|
var CanvasTimeBar = ({
|
|
533
543
|
windowTime,
|
|
534
544
|
tick,
|
|
@@ -538,7 +548,7 @@ var CanvasTimeBar = ({
|
|
|
538
548
|
timeBar
|
|
539
549
|
}) => {
|
|
540
550
|
var _a, _b, _c;
|
|
541
|
-
const canvasRef =
|
|
551
|
+
const canvasRef = useRef3(null);
|
|
542
552
|
const header = theme != null ? theme : DEFAULT_THEME;
|
|
543
553
|
const topRow = (_a = timeBar == null ? void 0 : timeBar.topRow) != null ? _a : { unit: "day" };
|
|
544
554
|
const bottomRow = (_b = timeBar == null ? void 0 : timeBar.bottomRow) != null ? _b : { unit: "hour" };
|
|
@@ -604,7 +614,7 @@ import React5, {
|
|
|
604
614
|
useCallback as useCallback2,
|
|
605
615
|
useEffect as useEffect5,
|
|
606
616
|
useLayoutEffect,
|
|
607
|
-
useRef as
|
|
617
|
+
useRef as useRef5,
|
|
608
618
|
useState as useState3,
|
|
609
619
|
useSyncExternalStore
|
|
610
620
|
} from "react";
|
|
@@ -680,7 +690,8 @@ var DEFAULT_GEOMETRY = {
|
|
|
680
690
|
laneTopOffset: 10,
|
|
681
691
|
rowBaseHeight: 40,
|
|
682
692
|
staticEventBaseHeight: 20,
|
|
683
|
-
barRadius: 5
|
|
693
|
+
barRadius: 5,
|
|
694
|
+
minHitWidth: 0
|
|
684
695
|
};
|
|
685
696
|
var geometryFromTheme = (theme) => {
|
|
686
697
|
const barHeight = theme.barHeight;
|
|
@@ -691,7 +702,8 @@ var geometryFromTheme = (theme) => {
|
|
|
691
702
|
laneTopOffset: rowPaddingY,
|
|
692
703
|
rowBaseHeight: barHeight + 2 * rowPaddingY,
|
|
693
704
|
staticEventBaseHeight: barHeight,
|
|
694
|
-
barRadius: theme.barRadius
|
|
705
|
+
barRadius: theme.barRadius,
|
|
706
|
+
minHitWidth: theme.minHitWidth
|
|
695
707
|
};
|
|
696
708
|
};
|
|
697
709
|
|
|
@@ -1204,7 +1216,7 @@ var TimelineRenderer = class {
|
|
|
1204
1216
|
};
|
|
1205
1217
|
|
|
1206
1218
|
// src/hooks/use-canvas-interactions.ts
|
|
1207
|
-
import { useCallback, useEffect as useEffect4, useMemo
|
|
1219
|
+
import { useCallback, useEffect as useEffect4, useMemo, useRef as useRef4 } from "react";
|
|
1208
1220
|
|
|
1209
1221
|
// src/core/types.ts
|
|
1210
1222
|
var rectContains = (rect, x, y) => x >= rect.x && x <= rect.x + rect.width && y >= rect.y && y <= rect.y + rect.height;
|
|
@@ -1240,7 +1252,8 @@ var hitTest = (scene, view, x, y) => {
|
|
|
1240
1252
|
width: timeToWidth(event.startTime, event.endTime, tick),
|
|
1241
1253
|
height: geometry.barHeight
|
|
1242
1254
|
};
|
|
1243
|
-
|
|
1255
|
+
const hit = rect.width >= geometry.minHitWidth ? rect : __spreadProps(__spreadValues({}, rect), { x: rect.x + (rect.width - geometry.minHitWidth) / 2, width: geometry.minHitWidth });
|
|
1256
|
+
if (rectContains(hit, x, y)) {
|
|
1244
1257
|
return { kind: "event", event, rowId, rect };
|
|
1245
1258
|
}
|
|
1246
1259
|
}
|
|
@@ -1298,15 +1311,15 @@ var useCanvasInteractions = ({
|
|
|
1298
1311
|
applySelection,
|
|
1299
1312
|
getSelection
|
|
1300
1313
|
}) => {
|
|
1301
|
-
const stateRef =
|
|
1302
|
-
const changeGridRef =
|
|
1303
|
-
const panFrameRef =
|
|
1304
|
-
const panPendingDxRef =
|
|
1305
|
-
const hoveredRef =
|
|
1306
|
-
const pointersRef =
|
|
1307
|
-
const zoomFrameRef =
|
|
1308
|
-
const zoomPendingRef =
|
|
1309
|
-
const config =
|
|
1314
|
+
const stateRef = useRef4({ mode: "idle" });
|
|
1315
|
+
const changeGridRef = useRef4(false);
|
|
1316
|
+
const panFrameRef = useRef4(null);
|
|
1317
|
+
const panPendingDxRef = useRef4(0);
|
|
1318
|
+
const hoveredRef = useRef4(null);
|
|
1319
|
+
const pointersRef = useRef4(/* @__PURE__ */ new Map());
|
|
1320
|
+
const zoomFrameRef = useRef4(null);
|
|
1321
|
+
const zoomPendingRef = useRef4(null);
|
|
1322
|
+
const config = useMemo(
|
|
1310
1323
|
() => {
|
|
1311
1324
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
1312
1325
|
return {
|
|
@@ -1321,7 +1334,7 @@ var useCanvasInteractions = ({
|
|
|
1321
1334
|
},
|
|
1322
1335
|
[panZoom]
|
|
1323
1336
|
);
|
|
1324
|
-
const limits =
|
|
1337
|
+
const limits = useMemo(
|
|
1325
1338
|
() => {
|
|
1326
1339
|
var _a, _b;
|
|
1327
1340
|
return {
|
|
@@ -2001,12 +2014,12 @@ var CanvasBoard = forwardRef2(
|
|
|
2001
2014
|
getSelection
|
|
2002
2015
|
}, contentRef) => {
|
|
2003
2016
|
var _a;
|
|
2004
|
-
const staticCanvasRef =
|
|
2005
|
-
const dynamicCanvasRef =
|
|
2006
|
-
const ghostRef =
|
|
2007
|
-
const headerWrapperRef =
|
|
2008
|
-
const measureLayerRef =
|
|
2009
|
-
const totalHeightRef =
|
|
2017
|
+
const staticCanvasRef = useRef5(null);
|
|
2018
|
+
const dynamicCanvasRef = useRef5(null);
|
|
2019
|
+
const ghostRef = useRef5(null);
|
|
2020
|
+
const headerWrapperRef = useRef5(null);
|
|
2021
|
+
const measureLayerRef = useRef5(null);
|
|
2022
|
+
const totalHeightRef = useRef5(0);
|
|
2010
2023
|
const [scrollTop, setScrollTop] = useState3(0);
|
|
2011
2024
|
const [viewportHeight, setViewportHeight] = useState3(0);
|
|
2012
2025
|
useEffect5(() => {
|
|
@@ -2342,6 +2355,43 @@ var CanvasBoard = forwardRef2(
|
|
|
2342
2355
|
);
|
|
2343
2356
|
var canvas_board_default = CanvasBoard;
|
|
2344
2357
|
|
|
2358
|
+
// src/components/pointer-line.tsx
|
|
2359
|
+
import React6, { forwardRef as forwardRef3, useImperativeHandle as useImperativeHandle2, useRef as useRef6 } from "react";
|
|
2360
|
+
var PointerLine = forwardRef3(({ contentRef, mainRef, top, color, labelColor, font }, ref) => {
|
|
2361
|
+
const lineRef = useRef6(null);
|
|
2362
|
+
const labelRef = useRef6(null);
|
|
2363
|
+
useImperativeHandle2(ref, () => ({
|
|
2364
|
+
show: (x, label) => {
|
|
2365
|
+
var _a, _b;
|
|
2366
|
+
const line = lineRef.current, tag = labelRef.current;
|
|
2367
|
+
const content = contentRef.current, main = mainRef.current;
|
|
2368
|
+
if (!line || !tag || !content || !main) return;
|
|
2369
|
+
const box = content.getBoundingClientRect();
|
|
2370
|
+
const frame = main.getBoundingClientRect();
|
|
2371
|
+
const left = box.left - frame.left;
|
|
2372
|
+
const bottom = Math.min(box.bottom, (_b = (_a = content.parentElement) == null ? void 0 : _a.getBoundingClientRect().bottom) != null ? _b : box.bottom);
|
|
2373
|
+
line.style.height = `${Math.max(bottom - frame.top - top, 0)}px`;
|
|
2374
|
+
line.style.display = "block";
|
|
2375
|
+
line.style.transform = `translateX(${Math.round(left + x)}px)`;
|
|
2376
|
+
if (label === null) {
|
|
2377
|
+
tag.style.display = "none";
|
|
2378
|
+
return;
|
|
2379
|
+
}
|
|
2380
|
+
tag.textContent = label;
|
|
2381
|
+
tag.style.display = "block";
|
|
2382
|
+
const w = tag.offsetWidth;
|
|
2383
|
+
const at = Math.min(Math.max(x - w / 2, 0), Math.max(box.width - w, 0));
|
|
2384
|
+
tag.style.transform = `translateX(${Math.round(left + at)}px)`;
|
|
2385
|
+
},
|
|
2386
|
+
hide: () => {
|
|
2387
|
+
if (lineRef.current) lineRef.current.style.display = "none";
|
|
2388
|
+
if (labelRef.current) labelRef.current.style.display = "none";
|
|
2389
|
+
}
|
|
2390
|
+
}), [contentRef, mainRef, top]);
|
|
2391
|
+
return /* @__PURE__ */ React6.createElement(React6.Fragment, null, /* @__PURE__ */ React6.createElement("div", { ref: lineRef, className: "pointer-line", style: { top, borderLeftColor: color } }), /* @__PURE__ */ React6.createElement("div", { ref: labelRef, className: "pointer-label", style: { background: color, color: labelColor, font } }));
|
|
2392
|
+
});
|
|
2393
|
+
var pointer_line_default = PointerLine;
|
|
2394
|
+
|
|
2345
2395
|
// src/core/scene.ts
|
|
2346
2396
|
var binaryInsertIndex = (events, event) => {
|
|
2347
2397
|
let lo = 0;
|
|
@@ -2801,7 +2851,8 @@ var SceneStore = class {
|
|
|
2801
2851
|
};
|
|
2802
2852
|
|
|
2803
2853
|
// src/timeline.tsx
|
|
2804
|
-
var
|
|
2854
|
+
var defaultPointerFormat = (time) => new Date(time * 1e3).toLocaleString();
|
|
2855
|
+
var Timeline = forwardRef4(
|
|
2805
2856
|
({
|
|
2806
2857
|
rows,
|
|
2807
2858
|
events,
|
|
@@ -2829,6 +2880,9 @@ var Timeline = forwardRef3(
|
|
|
2829
2880
|
panZoom,
|
|
2830
2881
|
timeBar,
|
|
2831
2882
|
showTimeBar = true,
|
|
2883
|
+
showPointerLine = false,
|
|
2884
|
+
formatPointerTime,
|
|
2885
|
+
onPointerTime,
|
|
2832
2886
|
animations = true
|
|
2833
2887
|
}, handleRef) => {
|
|
2834
2888
|
const [windowTime, setWindowTime] = useState4([
|
|
@@ -2925,7 +2979,62 @@ var Timeline = forwardRef3(
|
|
|
2925
2979
|
var _a;
|
|
2926
2980
|
(_a = onWindowChangeRef.current) == null ? void 0 : _a.call(onWindowChangeRef, { startTime: windowTime[0], endTime: windowTime[1] });
|
|
2927
2981
|
}, [windowTime[0], windowTime[1]]);
|
|
2928
|
-
|
|
2982
|
+
const tickRef = useRef7(tick);
|
|
2983
|
+
tickRef.current = tick;
|
|
2984
|
+
const pointerLineRef = useRef7(null);
|
|
2985
|
+
const pointerRef = useRef7(null);
|
|
2986
|
+
const pointerOpts = useRef7({ showPointerLine, showTimeBar, formatPointerTime, onPointerTime });
|
|
2987
|
+
pointerOpts.current = { showPointerLine, showTimeBar, formatPointerTime, onPointerTime };
|
|
2988
|
+
const drawPointer = useCallback3(() => {
|
|
2989
|
+
var _a, _b;
|
|
2990
|
+
const line = pointerLineRef.current;
|
|
2991
|
+
const p = pointerRef.current;
|
|
2992
|
+
const t = tickRef.current;
|
|
2993
|
+
if (!line) return;
|
|
2994
|
+
if (!p || !t) return line.hide();
|
|
2995
|
+
const start = windowTimeRef.current[0];
|
|
2996
|
+
const time = "x" in p ? start + p.x * t : p.time;
|
|
2997
|
+
const x = "x" in p ? p.x : (p.time - start) / t;
|
|
2998
|
+
const width = (_b = (_a = contentRef.current) == null ? void 0 : _a.getBoundingClientRect().width) != null ? _b : 0;
|
|
2999
|
+
if (x < 0 || x > width) return line.hide();
|
|
3000
|
+
const { showTimeBar: labelled, formatPointerTime: format } = pointerOpts.current;
|
|
3001
|
+
line.show(x, labelled ? (format != null ? format : defaultPointerFormat)(time) : null);
|
|
3002
|
+
}, []);
|
|
3003
|
+
useEffect6(() => {
|
|
3004
|
+
const column = contentRef.current;
|
|
3005
|
+
if (!column) return;
|
|
3006
|
+
const move = (e) => {
|
|
3007
|
+
var _a, _b;
|
|
3008
|
+
const t = tickRef.current;
|
|
3009
|
+
if (!t) return;
|
|
3010
|
+
const x = e.clientX - column.getBoundingClientRect().left;
|
|
3011
|
+
(_b = (_a = pointerOpts.current).onPointerTime) == null ? void 0 : _b.call(_a, windowTimeRef.current[0] + x * t);
|
|
3012
|
+
if (!pointerOpts.current.showPointerLine) return;
|
|
3013
|
+
pointerRef.current = { x };
|
|
3014
|
+
drawPointer();
|
|
3015
|
+
};
|
|
3016
|
+
const leave = () => {
|
|
3017
|
+
var _a, _b;
|
|
3018
|
+
(_b = (_a = pointerOpts.current).onPointerTime) == null ? void 0 : _b.call(_a, null);
|
|
3019
|
+
if (pointerRef.current && "x" in pointerRef.current) {
|
|
3020
|
+
pointerRef.current = null;
|
|
3021
|
+
drawPointer();
|
|
3022
|
+
}
|
|
3023
|
+
};
|
|
3024
|
+
column.addEventListener("pointermove", move);
|
|
3025
|
+
column.addEventListener("pointerleave", leave);
|
|
3026
|
+
return () => {
|
|
3027
|
+
column.removeEventListener("pointermove", move);
|
|
3028
|
+
column.removeEventListener("pointerleave", leave);
|
|
3029
|
+
};
|
|
3030
|
+
}, [drawPointer]);
|
|
3031
|
+
useEffect6(() => {
|
|
3032
|
+
var _a, _b;
|
|
3033
|
+
const p = pointerRef.current;
|
|
3034
|
+
if (p && "x" in p && tick) (_b = (_a = pointerOpts.current).onPointerTime) == null ? void 0 : _b.call(_a, windowTime[0] + p.x * tick);
|
|
3035
|
+
drawPointer();
|
|
3036
|
+
}, [windowTime[0], windowTime[1], tick, drawPointer]);
|
|
3037
|
+
useImperativeHandle3(
|
|
2929
3038
|
handleRef,
|
|
2930
3039
|
() => ({
|
|
2931
3040
|
setEvents: (next) => scene.setEvents([...next].sort(sort_events_default)),
|
|
@@ -2943,6 +3052,7 @@ var Timeline = forwardRef3(
|
|
|
2943
3052
|
// the scale follows the window, or a zoom applied from outside draws and pans at the old one
|
|
2944
3053
|
setWindow: (startTime, endTime) => {
|
|
2945
3054
|
var _a;
|
|
3055
|
+
windowTimeRef.current = [startTime, endTime];
|
|
2946
3056
|
setWindowTime([startTime, endTime]);
|
|
2947
3057
|
const width = (_a = contentRef.current) == null ? void 0 : _a.getBoundingClientRect().width;
|
|
2948
3058
|
if (width && endTime > startTime) {
|
|
@@ -2954,6 +3064,10 @@ var Timeline = forwardRef3(
|
|
|
2954
3064
|
startTime: windowTimeRef.current[0],
|
|
2955
3065
|
endTime: windowTimeRef.current[1]
|
|
2956
3066
|
}),
|
|
3067
|
+
setPointerTime: (time) => {
|
|
3068
|
+
pointerRef.current = time === null ? null : { time };
|
|
3069
|
+
drawPointer();
|
|
3070
|
+
},
|
|
2957
3071
|
setSelection: (ids) => applySelection(ids),
|
|
2958
3072
|
getSelection,
|
|
2959
3073
|
toggleRow: (rowId) => scene.toggleCollapsed(rowId),
|
|
@@ -2963,7 +3077,7 @@ var Timeline = forwardRef3(
|
|
|
2963
3077
|
return (_a = rendererRef.current) == null ? void 0 : _a.invalidate("all");
|
|
2964
3078
|
}
|
|
2965
3079
|
}),
|
|
2966
|
-
[scene, applySelection, getSelection]
|
|
3080
|
+
[scene, applySelection, getSelection, drawPointer]
|
|
2967
3081
|
);
|
|
2968
3082
|
useEffect6(() => {
|
|
2969
3083
|
if (contentRef.current) {
|
|
@@ -3015,16 +3129,16 @@ var Timeline = forwardRef3(
|
|
|
3015
3129
|
);
|
|
3016
3130
|
}
|
|
3017
3131
|
}, []);
|
|
3018
|
-
use_resize_observer_default({ contentRef, setCellWidth, setTick,
|
|
3019
|
-
const resolvedTheme =
|
|
3020
|
-
const geometry =
|
|
3132
|
+
use_resize_observer_default({ contentRef, setCellWidth, setTick, windowTimeRef });
|
|
3133
|
+
const resolvedTheme = useMemo2(() => resolveTheme(theme), [theme]);
|
|
3134
|
+
const geometry = useMemo2(
|
|
3021
3135
|
() => geometryFromTheme(resolvedTheme),
|
|
3022
3136
|
[resolvedTheme]
|
|
3023
3137
|
);
|
|
3024
3138
|
useEffect6(() => {
|
|
3025
3139
|
scene.setGeometry(geometry);
|
|
3026
3140
|
}, [scene, geometry]);
|
|
3027
|
-
const resolvedAnimations =
|
|
3141
|
+
const resolvedAnimations = useMemo2(() => {
|
|
3028
3142
|
var _a, _b;
|
|
3029
3143
|
if (animations === false) return { layoutMs: 0, fadeMs: 0 };
|
|
3030
3144
|
if (animations === true) {
|
|
@@ -3038,8 +3152,8 @@ var Timeline = forwardRef3(
|
|
|
3038
3152
|
fadeMs: (_b = animations.fadeMs) != null ? _b : DEFAULT_FADE_DURATION_MS
|
|
3039
3153
|
};
|
|
3040
3154
|
}, [animations]);
|
|
3041
|
-
const eventPrompt =
|
|
3042
|
-
() => /* @__PURE__ */
|
|
3155
|
+
const eventPrompt = useMemo2(
|
|
3156
|
+
() => /* @__PURE__ */ React7.createElement(
|
|
3043
3157
|
event_prompt_default,
|
|
3044
3158
|
{
|
|
3045
3159
|
ref: eventPromptRef,
|
|
@@ -3048,7 +3162,7 @@ var Timeline = forwardRef3(
|
|
|
3048
3162
|
),
|
|
3049
3163
|
[eventPromptTemplate]
|
|
3050
3164
|
);
|
|
3051
|
-
return /* @__PURE__ */
|
|
3165
|
+
return /* @__PURE__ */ React7.createElement("div", { className: "main-wrapper", ref: mainRef }, showRTIndicator && /* @__PURE__ */ React7.createElement(rt_indicator_default, { tick, windowTime }), showTimeBar && /* @__PURE__ */ React7.createElement(
|
|
3052
3166
|
canvas_time_bar_default,
|
|
3053
3167
|
{
|
|
3054
3168
|
windowTime,
|
|
@@ -3058,7 +3172,7 @@ var Timeline = forwardRef3(
|
|
|
3058
3172
|
theme: resolvedTheme,
|
|
3059
3173
|
timeBar
|
|
3060
3174
|
}
|
|
3061
|
-
), /* @__PURE__ */
|
|
3175
|
+
), /* @__PURE__ */ React7.createElement("div", { className: "body-wrapper", ref: bodyRef, style: { borderColor: resolvedTheme.borderColor } }, /* @__PURE__ */ React7.createElement(
|
|
3062
3176
|
canvas_board_default,
|
|
3063
3177
|
{
|
|
3064
3178
|
scene,
|
|
@@ -3089,7 +3203,18 @@ var Timeline = forwardRef3(
|
|
|
3089
3203
|
getSelection,
|
|
3090
3204
|
ref: contentRef
|
|
3091
3205
|
}
|
|
3092
|
-
), showEventPrompt && eventPrompt)
|
|
3206
|
+
), showEventPrompt && eventPrompt), /* @__PURE__ */ React7.createElement(
|
|
3207
|
+
pointer_line_default,
|
|
3208
|
+
{
|
|
3209
|
+
ref: pointerLineRef,
|
|
3210
|
+
contentRef,
|
|
3211
|
+
mainRef,
|
|
3212
|
+
top: showTimeBar ? TIME_BAR_HEIGHT : 0,
|
|
3213
|
+
color: resolvedTheme.pointerLineColor,
|
|
3214
|
+
labelColor: resolvedTheme.pointerLabelColor,
|
|
3215
|
+
font: resolvedTheme.font
|
|
3216
|
+
}
|
|
3217
|
+
));
|
|
3093
3218
|
}
|
|
3094
3219
|
);
|
|
3095
3220
|
export {
|