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.js
CHANGED
|
@@ -52,7 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
module.exports = __toCommonJS(index_exports);
|
|
53
53
|
|
|
54
54
|
// src/timeline.tsx
|
|
55
|
-
var
|
|
55
|
+
var import_react8 = __toESM(require("react"));
|
|
56
56
|
|
|
57
57
|
// src/canvas/animator.ts
|
|
58
58
|
var DEFAULT_LAYOUT_DURATION_MS = 200;
|
|
@@ -129,34 +129,40 @@ var LayoutAnimator = class {
|
|
|
129
129
|
|
|
130
130
|
// src/hooks/use-resize-observer.ts
|
|
131
131
|
var import_react = require("react");
|
|
132
|
+
var createWidthObserver = (getWindow, onScale) => {
|
|
133
|
+
let prevWidth = 0;
|
|
134
|
+
return new ResizeObserver((entries) => {
|
|
135
|
+
var _a;
|
|
136
|
+
for (const entry of entries) {
|
|
137
|
+
const width = (_a = entry.borderBoxSize) == null ? void 0 : _a[0].inlineSize;
|
|
138
|
+
if (typeof width === "number" && width !== prevWidth) {
|
|
139
|
+
prevWidth = width;
|
|
140
|
+
const [start, end] = getWindow();
|
|
141
|
+
const windowDuration = end - start;
|
|
142
|
+
onScale(
|
|
143
|
+
windowDuration / entry.contentRect.width,
|
|
144
|
+
entry.contentRect.width / (windowDuration / 3600)
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
});
|
|
149
|
+
};
|
|
132
150
|
var useResizeObserver = ({
|
|
133
|
-
|
|
151
|
+
windowTimeRef,
|
|
134
152
|
setTick,
|
|
135
153
|
setCellWidth,
|
|
136
154
|
contentRef
|
|
137
155
|
}) => {
|
|
138
|
-
const prevWidthRef = (0, import_react.useRef)(0);
|
|
139
|
-
const resizeObserver = (0, import_react.useMemo)(() => {
|
|
140
|
-
return new ResizeObserver((entries) => {
|
|
141
|
-
var _a;
|
|
142
|
-
for (const entry of entries) {
|
|
143
|
-
const width = (_a = entry.borderBoxSize) == null ? void 0 : _a[0].inlineSize;
|
|
144
|
-
if (typeof width === "number" && width !== prevWidthRef.current) {
|
|
145
|
-
prevWidthRef.current = width;
|
|
146
|
-
const windowDuration = windowTime[1] - windowTime[0];
|
|
147
|
-
const numberOfHourBlocks = windowDuration / 3600;
|
|
148
|
-
setTick(windowDuration / entry.contentRect.width);
|
|
149
|
-
setCellWidth(entry.contentRect.width / numberOfHourBlocks);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
}, [windowTime]);
|
|
154
156
|
(0, import_react.useEffect)(() => {
|
|
157
|
+
const observer = createWidthObserver(() => windowTimeRef.current, (tick, cellWidth) => {
|
|
158
|
+
setTick(tick);
|
|
159
|
+
setCellWidth(cellWidth);
|
|
160
|
+
});
|
|
155
161
|
if (contentRef.current) {
|
|
156
|
-
|
|
162
|
+
observer.observe(contentRef.current, { box: "border-box" });
|
|
157
163
|
}
|
|
158
|
-
return () =>
|
|
159
|
-
}, [
|
|
164
|
+
return () => observer.disconnect();
|
|
165
|
+
}, [windowTimeRef, setTick, setCellWidth, contentRef]);
|
|
160
166
|
};
|
|
161
167
|
var use_resize_observer_default = useResizeObserver;
|
|
162
168
|
|
|
@@ -467,8 +473,11 @@ var DEFAULT_THEME = {
|
|
|
467
473
|
laneGap: 2,
|
|
468
474
|
rowPaddingY: 10,
|
|
469
475
|
barRadius: 5,
|
|
476
|
+
minHitWidth: 0,
|
|
470
477
|
groupChildBackground: "rgba(0,0,0,0.05)",
|
|
471
|
-
groupShadowColor: "rgba(0,0,0,0.22)"
|
|
478
|
+
groupShadowColor: "rgba(0,0,0,0.22)",
|
|
479
|
+
pointerLineColor: "rgba(15,23,42,0.7)",
|
|
480
|
+
pointerLabelColor: "#ffffff"
|
|
472
481
|
};
|
|
473
482
|
var resolveTheme = (theme) => __spreadValues(__spreadValues({}, DEFAULT_THEME), theme);
|
|
474
483
|
|
|
@@ -548,7 +557,8 @@ var drawTimeBar = (ctx, {
|
|
|
548
557
|
};
|
|
549
558
|
|
|
550
559
|
// src/components/canvas-time-bar.tsx
|
|
551
|
-
var
|
|
560
|
+
var TIME_BAR_HEIGHT = 50;
|
|
561
|
+
var TIME_BAR_INNER_HEIGHT = TIME_BAR_HEIGHT - 2;
|
|
552
562
|
var CanvasTimeBar = ({
|
|
553
563
|
windowTime,
|
|
554
564
|
tick,
|
|
@@ -692,7 +702,8 @@ var DEFAULT_GEOMETRY = {
|
|
|
692
702
|
laneTopOffset: 10,
|
|
693
703
|
rowBaseHeight: 40,
|
|
694
704
|
staticEventBaseHeight: 20,
|
|
695
|
-
barRadius: 5
|
|
705
|
+
barRadius: 5,
|
|
706
|
+
minHitWidth: 0
|
|
696
707
|
};
|
|
697
708
|
var geometryFromTheme = (theme) => {
|
|
698
709
|
const barHeight = theme.barHeight;
|
|
@@ -703,7 +714,8 @@ var geometryFromTheme = (theme) => {
|
|
|
703
714
|
laneTopOffset: rowPaddingY,
|
|
704
715
|
rowBaseHeight: barHeight + 2 * rowPaddingY,
|
|
705
716
|
staticEventBaseHeight: barHeight,
|
|
706
|
-
barRadius: theme.barRadius
|
|
717
|
+
barRadius: theme.barRadius,
|
|
718
|
+
minHitWidth: theme.minHitWidth
|
|
707
719
|
};
|
|
708
720
|
};
|
|
709
721
|
|
|
@@ -1252,7 +1264,8 @@ var hitTest = (scene, view, x, y) => {
|
|
|
1252
1264
|
width: timeToWidth(event.startTime, event.endTime, tick),
|
|
1253
1265
|
height: geometry.barHeight
|
|
1254
1266
|
};
|
|
1255
|
-
|
|
1267
|
+
const hit = rect.width >= geometry.minHitWidth ? rect : __spreadProps(__spreadValues({}, rect), { x: rect.x + (rect.width - geometry.minHitWidth) / 2, width: geometry.minHitWidth });
|
|
1268
|
+
if (rectContains(hit, x, y)) {
|
|
1256
1269
|
return { kind: "event", event, rowId, rect };
|
|
1257
1270
|
}
|
|
1258
1271
|
}
|
|
@@ -2354,6 +2367,43 @@ var CanvasBoard = (0, import_react6.forwardRef)(
|
|
|
2354
2367
|
);
|
|
2355
2368
|
var canvas_board_default = CanvasBoard;
|
|
2356
2369
|
|
|
2370
|
+
// src/components/pointer-line.tsx
|
|
2371
|
+
var import_react7 = __toESM(require("react"));
|
|
2372
|
+
var PointerLine = (0, import_react7.forwardRef)(({ contentRef, mainRef, top, color, labelColor, font }, ref) => {
|
|
2373
|
+
const lineRef = (0, import_react7.useRef)(null);
|
|
2374
|
+
const labelRef = (0, import_react7.useRef)(null);
|
|
2375
|
+
(0, import_react7.useImperativeHandle)(ref, () => ({
|
|
2376
|
+
show: (x, label) => {
|
|
2377
|
+
var _a, _b;
|
|
2378
|
+
const line = lineRef.current, tag = labelRef.current;
|
|
2379
|
+
const content = contentRef.current, main = mainRef.current;
|
|
2380
|
+
if (!line || !tag || !content || !main) return;
|
|
2381
|
+
const box = content.getBoundingClientRect();
|
|
2382
|
+
const frame = main.getBoundingClientRect();
|
|
2383
|
+
const left = box.left - frame.left;
|
|
2384
|
+
const bottom = Math.min(box.bottom, (_b = (_a = content.parentElement) == null ? void 0 : _a.getBoundingClientRect().bottom) != null ? _b : box.bottom);
|
|
2385
|
+
line.style.height = `${Math.max(bottom - frame.top - top, 0)}px`;
|
|
2386
|
+
line.style.display = "block";
|
|
2387
|
+
line.style.transform = `translateX(${Math.round(left + x)}px)`;
|
|
2388
|
+
if (label === null) {
|
|
2389
|
+
tag.style.display = "none";
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
tag.textContent = label;
|
|
2393
|
+
tag.style.display = "block";
|
|
2394
|
+
const w = tag.offsetWidth;
|
|
2395
|
+
const at = Math.min(Math.max(x - w / 2, 0), Math.max(box.width - w, 0));
|
|
2396
|
+
tag.style.transform = `translateX(${Math.round(left + at)}px)`;
|
|
2397
|
+
},
|
|
2398
|
+
hide: () => {
|
|
2399
|
+
if (lineRef.current) lineRef.current.style.display = "none";
|
|
2400
|
+
if (labelRef.current) labelRef.current.style.display = "none";
|
|
2401
|
+
}
|
|
2402
|
+
}), [contentRef, mainRef, top]);
|
|
2403
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.default.Fragment, null, /* @__PURE__ */ import_react7.default.createElement("div", { ref: lineRef, className: "pointer-line", style: { top, borderLeftColor: color } }), /* @__PURE__ */ import_react7.default.createElement("div", { ref: labelRef, className: "pointer-label", style: { background: color, color: labelColor, font } }));
|
|
2404
|
+
});
|
|
2405
|
+
var pointer_line_default = PointerLine;
|
|
2406
|
+
|
|
2357
2407
|
// src/core/scene.ts
|
|
2358
2408
|
var binaryInsertIndex = (events, event) => {
|
|
2359
2409
|
let lo = 0;
|
|
@@ -2813,7 +2863,8 @@ var SceneStore = class {
|
|
|
2813
2863
|
};
|
|
2814
2864
|
|
|
2815
2865
|
// src/timeline.tsx
|
|
2816
|
-
var
|
|
2866
|
+
var defaultPointerFormat = (time) => new Date(time * 1e3).toLocaleString();
|
|
2867
|
+
var Timeline = (0, import_react8.forwardRef)(
|
|
2817
2868
|
({
|
|
2818
2869
|
rows,
|
|
2819
2870
|
events,
|
|
@@ -2841,9 +2892,12 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2841
2892
|
panZoom,
|
|
2842
2893
|
timeBar,
|
|
2843
2894
|
showTimeBar = true,
|
|
2895
|
+
showPointerLine = false,
|
|
2896
|
+
formatPointerTime,
|
|
2897
|
+
onPointerTime,
|
|
2844
2898
|
animations = true
|
|
2845
2899
|
}, handleRef) => {
|
|
2846
|
-
const [windowTime, setWindowTime] = (0,
|
|
2900
|
+
const [windowTime, setWindowTime] = (0, import_react8.useState)([
|
|
2847
2901
|
new Date(
|
|
2848
2902
|
startDate.getFullYear(),
|
|
2849
2903
|
startDate.getMonth(),
|
|
@@ -2861,25 +2915,25 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2861
2915
|
0
|
|
2862
2916
|
).getTime() / 1e3
|
|
2863
2917
|
]);
|
|
2864
|
-
const [cellWidth, setCellWidth] = (0,
|
|
2865
|
-
const contentRef = (0,
|
|
2866
|
-
const mainRef = (0,
|
|
2867
|
-
const bodyRef = (0,
|
|
2868
|
-
const [tick, setTick] = (0,
|
|
2869
|
-
const [scrollWidth, setScrollWidth] = (0,
|
|
2870
|
-
const eventPromptRef = (0,
|
|
2871
|
-
const rendererRef = (0,
|
|
2872
|
-
const sceneRef = (0,
|
|
2918
|
+
const [cellWidth, setCellWidth] = (0, import_react8.useState)(0);
|
|
2919
|
+
const contentRef = (0, import_react8.useRef)(null);
|
|
2920
|
+
const mainRef = (0, import_react8.useRef)(null);
|
|
2921
|
+
const bodyRef = (0, import_react8.useRef)(null);
|
|
2922
|
+
const [tick, setTick] = (0, import_react8.useState)(null);
|
|
2923
|
+
const [scrollWidth, setScrollWidth] = (0, import_react8.useState)(0);
|
|
2924
|
+
const eventPromptRef = (0, import_react8.useRef)(null);
|
|
2925
|
+
const rendererRef = (0, import_react8.useRef)(null);
|
|
2926
|
+
const sceneRef = (0, import_react8.useRef)(null);
|
|
2873
2927
|
if (sceneRef.current === null) {
|
|
2874
2928
|
sceneRef.current = new SceneStore();
|
|
2875
2929
|
}
|
|
2876
2930
|
const scene = sceneRef.current;
|
|
2877
|
-
const selectionRef = (0,
|
|
2931
|
+
const selectionRef = (0, import_react8.useRef)(
|
|
2878
2932
|
new Set(defaultSelectedEventIds != null ? defaultSelectedEventIds : [])
|
|
2879
2933
|
);
|
|
2880
|
-
const onSelectionChangeRef = (0,
|
|
2934
|
+
const onSelectionChangeRef = (0, import_react8.useRef)(onSelectionChange);
|
|
2881
2935
|
onSelectionChangeRef.current = onSelectionChange;
|
|
2882
|
-
const applySelection = (0,
|
|
2936
|
+
const applySelection = (0, import_react8.useCallback)(
|
|
2883
2937
|
(ids) => {
|
|
2884
2938
|
var _a, _b;
|
|
2885
2939
|
const expanded = [];
|
|
@@ -2899,13 +2953,13 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2899
2953
|
},
|
|
2900
2954
|
[scene]
|
|
2901
2955
|
);
|
|
2902
|
-
const getSelection = (0,
|
|
2903
|
-
(0,
|
|
2956
|
+
const getSelection = (0, import_react8.useCallback)(() => [...selectionRef.current], []);
|
|
2957
|
+
(0, import_react8.useEffect)(() => {
|
|
2904
2958
|
var _a;
|
|
2905
2959
|
scene.setRows(rows);
|
|
2906
2960
|
(_a = rendererRef.current) == null ? void 0 : _a.animator.reset();
|
|
2907
2961
|
}, [scene, rows]);
|
|
2908
|
-
(0,
|
|
2962
|
+
(0, import_react8.useEffect)(() => {
|
|
2909
2963
|
var _a, _b, _c;
|
|
2910
2964
|
scene.setEvents([...events].sort(sort_events_default));
|
|
2911
2965
|
(_a = rendererRef.current) == null ? void 0 : _a.animator.reset();
|
|
@@ -2918,26 +2972,81 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2918
2972
|
(_c = onSelectionChangeRef.current) == null ? void 0 : _c.call(onSelectionChangeRef, survivors);
|
|
2919
2973
|
}
|
|
2920
2974
|
}, [scene, events]);
|
|
2921
|
-
(0,
|
|
2975
|
+
(0, import_react8.useEffect)(() => {
|
|
2922
2976
|
scene.setStaticEvents(staticEvents ? [...staticEvents] : []);
|
|
2923
2977
|
}, [scene, staticEvents]);
|
|
2924
|
-
const seededCollapseRef = (0,
|
|
2925
|
-
(0,
|
|
2978
|
+
const seededCollapseRef = (0, import_react8.useRef)(false);
|
|
2979
|
+
(0, import_react8.useEffect)(() => {
|
|
2926
2980
|
if (seededCollapseRef.current) return;
|
|
2927
2981
|
seededCollapseRef.current = true;
|
|
2928
2982
|
for (const id of defaultCollapsedRowIds != null ? defaultCollapsedRowIds : []) {
|
|
2929
2983
|
scene.setCollapsed(id, true);
|
|
2930
2984
|
}
|
|
2931
2985
|
}, [scene, defaultCollapsedRowIds]);
|
|
2932
|
-
const windowTimeRef = (0,
|
|
2986
|
+
const windowTimeRef = (0, import_react8.useRef)(windowTime);
|
|
2933
2987
|
windowTimeRef.current = windowTime;
|
|
2934
|
-
const onWindowChangeRef = (0,
|
|
2988
|
+
const onWindowChangeRef = (0, import_react8.useRef)(onWindowChange);
|
|
2935
2989
|
onWindowChangeRef.current = onWindowChange;
|
|
2936
|
-
(0,
|
|
2990
|
+
(0, import_react8.useEffect)(() => {
|
|
2937
2991
|
var _a;
|
|
2938
2992
|
(_a = onWindowChangeRef.current) == null ? void 0 : _a.call(onWindowChangeRef, { startTime: windowTime[0], endTime: windowTime[1] });
|
|
2939
2993
|
}, [windowTime[0], windowTime[1]]);
|
|
2940
|
-
(0,
|
|
2994
|
+
const tickRef = (0, import_react8.useRef)(tick);
|
|
2995
|
+
tickRef.current = tick;
|
|
2996
|
+
const pointerLineRef = (0, import_react8.useRef)(null);
|
|
2997
|
+
const pointerRef = (0, import_react8.useRef)(null);
|
|
2998
|
+
const pointerOpts = (0, import_react8.useRef)({ showPointerLine, showTimeBar, formatPointerTime, onPointerTime });
|
|
2999
|
+
pointerOpts.current = { showPointerLine, showTimeBar, formatPointerTime, onPointerTime };
|
|
3000
|
+
const drawPointer = (0, import_react8.useCallback)(() => {
|
|
3001
|
+
var _a, _b;
|
|
3002
|
+
const line = pointerLineRef.current;
|
|
3003
|
+
const p = pointerRef.current;
|
|
3004
|
+
const t = tickRef.current;
|
|
3005
|
+
if (!line) return;
|
|
3006
|
+
if (!p || !t) return line.hide();
|
|
3007
|
+
const start = windowTimeRef.current[0];
|
|
3008
|
+
const time = "x" in p ? start + p.x * t : p.time;
|
|
3009
|
+
const x = "x" in p ? p.x : (p.time - start) / t;
|
|
3010
|
+
const width = (_b = (_a = contentRef.current) == null ? void 0 : _a.getBoundingClientRect().width) != null ? _b : 0;
|
|
3011
|
+
if (x < 0 || x > width) return line.hide();
|
|
3012
|
+
const { showTimeBar: labelled, formatPointerTime: format } = pointerOpts.current;
|
|
3013
|
+
line.show(x, labelled ? (format != null ? format : defaultPointerFormat)(time) : null);
|
|
3014
|
+
}, []);
|
|
3015
|
+
(0, import_react8.useEffect)(() => {
|
|
3016
|
+
const column = contentRef.current;
|
|
3017
|
+
if (!column) return;
|
|
3018
|
+
const move = (e) => {
|
|
3019
|
+
var _a, _b;
|
|
3020
|
+
const t = tickRef.current;
|
|
3021
|
+
if (!t) return;
|
|
3022
|
+
const x = e.clientX - column.getBoundingClientRect().left;
|
|
3023
|
+
(_b = (_a = pointerOpts.current).onPointerTime) == null ? void 0 : _b.call(_a, windowTimeRef.current[0] + x * t);
|
|
3024
|
+
if (!pointerOpts.current.showPointerLine) return;
|
|
3025
|
+
pointerRef.current = { x };
|
|
3026
|
+
drawPointer();
|
|
3027
|
+
};
|
|
3028
|
+
const leave = () => {
|
|
3029
|
+
var _a, _b;
|
|
3030
|
+
(_b = (_a = pointerOpts.current).onPointerTime) == null ? void 0 : _b.call(_a, null);
|
|
3031
|
+
if (pointerRef.current && "x" in pointerRef.current) {
|
|
3032
|
+
pointerRef.current = null;
|
|
3033
|
+
drawPointer();
|
|
3034
|
+
}
|
|
3035
|
+
};
|
|
3036
|
+
column.addEventListener("pointermove", move);
|
|
3037
|
+
column.addEventListener("pointerleave", leave);
|
|
3038
|
+
return () => {
|
|
3039
|
+
column.removeEventListener("pointermove", move);
|
|
3040
|
+
column.removeEventListener("pointerleave", leave);
|
|
3041
|
+
};
|
|
3042
|
+
}, [drawPointer]);
|
|
3043
|
+
(0, import_react8.useEffect)(() => {
|
|
3044
|
+
var _a, _b;
|
|
3045
|
+
const p = pointerRef.current;
|
|
3046
|
+
if (p && "x" in p && tick) (_b = (_a = pointerOpts.current).onPointerTime) == null ? void 0 : _b.call(_a, windowTime[0] + p.x * tick);
|
|
3047
|
+
drawPointer();
|
|
3048
|
+
}, [windowTime[0], windowTime[1], tick, drawPointer]);
|
|
3049
|
+
(0, import_react8.useImperativeHandle)(
|
|
2941
3050
|
handleRef,
|
|
2942
3051
|
() => ({
|
|
2943
3052
|
setEvents: (next) => scene.setEvents([...next].sort(sort_events_default)),
|
|
@@ -2955,6 +3064,7 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2955
3064
|
// the scale follows the window, or a zoom applied from outside draws and pans at the old one
|
|
2956
3065
|
setWindow: (startTime, endTime) => {
|
|
2957
3066
|
var _a;
|
|
3067
|
+
windowTimeRef.current = [startTime, endTime];
|
|
2958
3068
|
setWindowTime([startTime, endTime]);
|
|
2959
3069
|
const width = (_a = contentRef.current) == null ? void 0 : _a.getBoundingClientRect().width;
|
|
2960
3070
|
if (width && endTime > startTime) {
|
|
@@ -2966,6 +3076,10 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2966
3076
|
startTime: windowTimeRef.current[0],
|
|
2967
3077
|
endTime: windowTimeRef.current[1]
|
|
2968
3078
|
}),
|
|
3079
|
+
setPointerTime: (time) => {
|
|
3080
|
+
pointerRef.current = time === null ? null : { time };
|
|
3081
|
+
drawPointer();
|
|
3082
|
+
},
|
|
2969
3083
|
setSelection: (ids) => applySelection(ids),
|
|
2970
3084
|
getSelection,
|
|
2971
3085
|
toggleRow: (rowId) => scene.toggleCollapsed(rowId),
|
|
@@ -2975,9 +3089,9 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
2975
3089
|
return (_a = rendererRef.current) == null ? void 0 : _a.invalidate("all");
|
|
2976
3090
|
}
|
|
2977
3091
|
}),
|
|
2978
|
-
[scene, applySelection, getSelection]
|
|
3092
|
+
[scene, applySelection, getSelection, drawPointer]
|
|
2979
3093
|
);
|
|
2980
|
-
(0,
|
|
3094
|
+
(0, import_react8.useEffect)(() => {
|
|
2981
3095
|
if (contentRef.current) {
|
|
2982
3096
|
const windowDuration = windowTime[1] - windowTime[0];
|
|
2983
3097
|
const numberOfHourBlocks = windowDuration / 3600;
|
|
@@ -3005,8 +3119,8 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
3005
3119
|
0,
|
|
3006
3120
|
0
|
|
3007
3121
|
).getTime() / 1e3;
|
|
3008
|
-
const lastFitRef = (0,
|
|
3009
|
-
(0,
|
|
3122
|
+
const lastFitRef = (0, import_react8.useRef)([fitStart, fitEnd]);
|
|
3123
|
+
(0, import_react8.useEffect)(() => {
|
|
3010
3124
|
var _a;
|
|
3011
3125
|
if (lastFitRef.current[0] === fitStart && lastFitRef.current[1] === fitEnd) {
|
|
3012
3126
|
return;
|
|
@@ -3020,23 +3134,23 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
3020
3134
|
setCellWidth(width / (windowDuration / 3600));
|
|
3021
3135
|
}
|
|
3022
3136
|
}, [fitStart, fitEnd]);
|
|
3023
|
-
(0,
|
|
3137
|
+
(0, import_react8.useEffect)(() => {
|
|
3024
3138
|
if (bodyRef.current) {
|
|
3025
3139
|
setScrollWidth(
|
|
3026
3140
|
bodyRef.current.getBoundingClientRect().width - bodyRef.current.scrollWidth
|
|
3027
3141
|
);
|
|
3028
3142
|
}
|
|
3029
3143
|
}, []);
|
|
3030
|
-
use_resize_observer_default({ contentRef, setCellWidth, setTick,
|
|
3031
|
-
const resolvedTheme = (0,
|
|
3032
|
-
const geometry = (0,
|
|
3144
|
+
use_resize_observer_default({ contentRef, setCellWidth, setTick, windowTimeRef });
|
|
3145
|
+
const resolvedTheme = (0, import_react8.useMemo)(() => resolveTheme(theme), [theme]);
|
|
3146
|
+
const geometry = (0, import_react8.useMemo)(
|
|
3033
3147
|
() => geometryFromTheme(resolvedTheme),
|
|
3034
3148
|
[resolvedTheme]
|
|
3035
3149
|
);
|
|
3036
|
-
(0,
|
|
3150
|
+
(0, import_react8.useEffect)(() => {
|
|
3037
3151
|
scene.setGeometry(geometry);
|
|
3038
3152
|
}, [scene, geometry]);
|
|
3039
|
-
const resolvedAnimations = (0,
|
|
3153
|
+
const resolvedAnimations = (0, import_react8.useMemo)(() => {
|
|
3040
3154
|
var _a, _b;
|
|
3041
3155
|
if (animations === false) return { layoutMs: 0, fadeMs: 0 };
|
|
3042
3156
|
if (animations === true) {
|
|
@@ -3050,8 +3164,8 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
3050
3164
|
fadeMs: (_b = animations.fadeMs) != null ? _b : DEFAULT_FADE_DURATION_MS
|
|
3051
3165
|
};
|
|
3052
3166
|
}, [animations]);
|
|
3053
|
-
const eventPrompt = (0,
|
|
3054
|
-
() => /* @__PURE__ */
|
|
3167
|
+
const eventPrompt = (0, import_react8.useMemo)(
|
|
3168
|
+
() => /* @__PURE__ */ import_react8.default.createElement(
|
|
3055
3169
|
event_prompt_default,
|
|
3056
3170
|
{
|
|
3057
3171
|
ref: eventPromptRef,
|
|
@@ -3060,7 +3174,7 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
3060
3174
|
),
|
|
3061
3175
|
[eventPromptTemplate]
|
|
3062
3176
|
);
|
|
3063
|
-
return /* @__PURE__ */
|
|
3177
|
+
return /* @__PURE__ */ import_react8.default.createElement("div", { className: "main-wrapper", ref: mainRef }, showRTIndicator && /* @__PURE__ */ import_react8.default.createElement(rt_indicator_default, { tick, windowTime }), showTimeBar && /* @__PURE__ */ import_react8.default.createElement(
|
|
3064
3178
|
canvas_time_bar_default,
|
|
3065
3179
|
{
|
|
3066
3180
|
windowTime,
|
|
@@ -3070,7 +3184,7 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
3070
3184
|
theme: resolvedTheme,
|
|
3071
3185
|
timeBar
|
|
3072
3186
|
}
|
|
3073
|
-
), /* @__PURE__ */
|
|
3187
|
+
), /* @__PURE__ */ import_react8.default.createElement("div", { className: "body-wrapper", ref: bodyRef, style: { borderColor: resolvedTheme.borderColor } }, /* @__PURE__ */ import_react8.default.createElement(
|
|
3074
3188
|
canvas_board_default,
|
|
3075
3189
|
{
|
|
3076
3190
|
scene,
|
|
@@ -3101,7 +3215,18 @@ var Timeline = (0, import_react7.forwardRef)(
|
|
|
3101
3215
|
getSelection,
|
|
3102
3216
|
ref: contentRef
|
|
3103
3217
|
}
|
|
3104
|
-
), showEventPrompt && eventPrompt)
|
|
3218
|
+
), showEventPrompt && eventPrompt), /* @__PURE__ */ import_react8.default.createElement(
|
|
3219
|
+
pointer_line_default,
|
|
3220
|
+
{
|
|
3221
|
+
ref: pointerLineRef,
|
|
3222
|
+
contentRef,
|
|
3223
|
+
mainRef,
|
|
3224
|
+
top: showTimeBar ? TIME_BAR_HEIGHT : 0,
|
|
3225
|
+
color: resolvedTheme.pointerLineColor,
|
|
3226
|
+
labelColor: resolvedTheme.pointerLabelColor,
|
|
3227
|
+
font: resolvedTheme.font
|
|
3228
|
+
}
|
|
3229
|
+
));
|
|
3105
3230
|
}
|
|
3106
3231
|
);
|
|
3107
3232
|
// Annotate the CommonJS export names for ESM import in node:
|