@cyca/react-timeline-editor 0.2.5-alpha.1 → 0.2.5-alpha.2
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.
|
@@ -777,7 +777,11 @@ const EditAction = ({ editorData, row, rowRenderHeight, action, effects, scale,
|
|
|
777
777
|
time
|
|
778
778
|
});
|
|
779
779
|
}
|
|
780
|
-
if (
|
|
780
|
+
if (isDragWhenClick.current) {
|
|
781
|
+
e.stopPropagation();
|
|
782
|
+
return;
|
|
783
|
+
}
|
|
784
|
+
if (onClickActionOnly) {
|
|
781
785
|
if (time === void 0) time = handleTime(e);
|
|
782
786
|
onClickActionOnly(e, {
|
|
783
787
|
row,
|
|
@@ -827,7 +831,7 @@ const EditAction = ({ editorData, row, rowRenderHeight, action, effects, scale,
|
|
|
827
831
|
//#endregion
|
|
828
832
|
//#region src/components/edit_area/edit-row.tsx
|
|
829
833
|
const EditRow = (props) => {
|
|
830
|
-
const { rowData, rowRenderHeight, isCollapsed = false, style = {}, onClickRow, onDoubleClickRow, onContextMenuRow, scrollContainerRef, startLeft, scale, scaleWidth, unstable_rowActionsOverscan, getEmptyRowRender, getCollapsedRowLabelRender } = props;
|
|
834
|
+
const { rowData, rowRenderHeight, isCollapsed = false, style = {}, onClickRow, onPointerMoveRow, onDoubleClickRow, onContextMenuRow, scrollContainerRef, startLeft, scale, scaleWidth, unstable_rowActionsOverscan, getEmptyRowRender, getCollapsedRowLabelRender, getActionPreviewRender, actionPreview } = props;
|
|
831
835
|
const classNames = ["edit-row"];
|
|
832
836
|
if (rowData?.selected) classNames.push("edit-row-selected");
|
|
833
837
|
const safeScale = scale ?? 1;
|
|
@@ -842,8 +846,36 @@ const EditRow = (props) => {
|
|
|
842
846
|
scaleWidth: safeScaleWidth
|
|
843
847
|
});
|
|
844
848
|
};
|
|
849
|
+
const handleTimelineCursorPreviewPointerMove = (e) => {
|
|
850
|
+
if (!rowData) return;
|
|
851
|
+
const position = e.clientX - e.currentTarget.getBoundingClientRect().x;
|
|
852
|
+
const maxCount = props.maxScaleCount ?? Infinity;
|
|
853
|
+
const maxLeft = Number.isFinite(maxCount) ? maxCount * safeScaleWidth + safeStartLeft : e.currentTarget.offsetWidth;
|
|
854
|
+
if (position < safeStartLeft || position > maxLeft) {
|
|
855
|
+
props.onTimelineCursorPreviewPointerLeave?.();
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
props.onTimelineCursorPreviewPointerMove?.({
|
|
859
|
+
surface: "edit-row",
|
|
860
|
+
row: rowData,
|
|
861
|
+
time: require_deal_data.parserPixelToTime(position, {
|
|
862
|
+
startLeft: safeStartLeft,
|
|
863
|
+
scale: safeScale,
|
|
864
|
+
scaleWidth: safeScaleWidth
|
|
865
|
+
})
|
|
866
|
+
});
|
|
867
|
+
};
|
|
845
868
|
const actions = (0, react.useMemo)(() => (rowData?.actions ? [...rowData.actions] : []).sort((a, b) => a.start - b.start), [rowData]);
|
|
846
869
|
const getItemKey = (0, react.useCallback)((index) => actions[index]?.id ?? index, [actions]);
|
|
870
|
+
const previewAction = rowData && actionPreview?.rowId === rowData.id ? actionPreview.action : null;
|
|
871
|
+
const previewTransform = previewAction ? require_deal_data.parserTimeToTransform({
|
|
872
|
+
start: previewAction.start,
|
|
873
|
+
end: previewAction.end
|
|
874
|
+
}, {
|
|
875
|
+
startLeft: safeStartLeft,
|
|
876
|
+
scale: safeScale,
|
|
877
|
+
scaleWidth: safeScaleWidth
|
|
878
|
+
}) : null;
|
|
847
879
|
const virtualizer = (0, _tanstack_react_virtual.useVirtualizer)({
|
|
848
880
|
horizontal: true,
|
|
849
881
|
count: actions.length,
|
|
@@ -877,6 +909,13 @@ const EditRow = (props) => {
|
|
|
877
909
|
style,
|
|
878
910
|
onPointerEnter: props.onPointerEnter,
|
|
879
911
|
onPointerLeave: props.onPointerLeave,
|
|
912
|
+
onPointerMove: (e) => {
|
|
913
|
+
handleTimelineCursorPreviewPointerMove(e);
|
|
914
|
+
if (rowData && onPointerMoveRow) onPointerMoveRow(e, {
|
|
915
|
+
row: rowData,
|
|
916
|
+
time: handleTime(e)
|
|
917
|
+
});
|
|
918
|
+
},
|
|
880
919
|
onClick: (e) => {
|
|
881
920
|
if (rowData && onClickRow) onClickRow(e, {
|
|
882
921
|
row: rowData,
|
|
@@ -911,6 +950,20 @@ const EditRow = (props) => {
|
|
|
911
950
|
height: rowRenderHeight
|
|
912
951
|
})
|
|
913
952
|
}),
|
|
953
|
+
rowData && previewAction && previewTransform && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
954
|
+
className: prefix("action-preview"),
|
|
955
|
+
style: {
|
|
956
|
+
height: rowRenderHeight,
|
|
957
|
+
transform: `translateX(${previewTransform.left}px)`,
|
|
958
|
+
width: previewTransform.width
|
|
959
|
+
},
|
|
960
|
+
"aria-hidden": "true",
|
|
961
|
+
children: getActionPreviewRender?.({
|
|
962
|
+
action: previewAction,
|
|
963
|
+
row: rowData,
|
|
964
|
+
height: rowRenderHeight
|
|
965
|
+
})
|
|
966
|
+
}),
|
|
914
967
|
rowData && virtualizer.getVirtualItems().map((virtualEntry) => {
|
|
915
968
|
const action = actions[virtualEntry.index];
|
|
916
969
|
if (!action) throw new Error("Action not found");
|
|
@@ -1103,7 +1156,10 @@ const EditArea = ({ ref, ...props }) => {
|
|
|
1103
1156
|
},
|
|
1104
1157
|
onPointerLeave: () => {
|
|
1105
1158
|
props.clearHoveredRowId(row.id);
|
|
1159
|
+
props.onTimelineCursorPreviewPointerLeave?.();
|
|
1106
1160
|
},
|
|
1161
|
+
onTimelineCursorPreviewPointerMove: props.onTimelineCursorPreviewPointerMove,
|
|
1162
|
+
onTimelineCursorPreviewPointerLeave: props.onTimelineCursorPreviewPointerLeave,
|
|
1107
1163
|
onActionMoveStart: (data) => {
|
|
1108
1164
|
if (row.collapsed) props.setLockedRowId(row.id);
|
|
1109
1165
|
handleInitSnap(data);
|
|
@@ -1150,7 +1206,7 @@ const EditArea = ({ ref, ...props }) => {
|
|
|
1150
1206
|
};
|
|
1151
1207
|
//#endregion
|
|
1152
1208
|
//#region src/components/time_area/time-area.tsx
|
|
1153
|
-
function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScaleCount, scale, scrollElementRef, onClickTimeArea, setCursor, getScaleRender }) {
|
|
1209
|
+
function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScaleCount, scale, scrollElementRef, onClickTimeArea, setCursor, getScaleRender, onTimelineCursorPreviewPointerMove, onTimelineCursorPreviewPointerLeave }) {
|
|
1154
1210
|
const splitCount = scaleSplitCount ?? 1;
|
|
1155
1211
|
const width = scaleWidth ?? 160;
|
|
1156
1212
|
const left = startLeft ?? 20;
|
|
@@ -1158,6 +1214,20 @@ function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScale
|
|
|
1158
1214
|
const showUnit = (scaleSplitCount ?? 0) > 0;
|
|
1159
1215
|
const columnCount = showUnit ? scaleCount * (scaleSplitCount ?? 1) + 1 : scaleCount;
|
|
1160
1216
|
const totalWidth = (showUnit ? width / splitCount : width) * (columnCount - 1) + left;
|
|
1217
|
+
const getTimeFromPointerX = (currentTarget, clientX) => {
|
|
1218
|
+
const leftStart = startLeft ?? 20;
|
|
1219
|
+
const widthValue = scaleWidth ?? 160;
|
|
1220
|
+
const scaleValue = scale ?? 1;
|
|
1221
|
+
const maxCount = maxScaleCount ?? Infinity;
|
|
1222
|
+
const position = clientX - currentTarget.getBoundingClientRect().x;
|
|
1223
|
+
const maxLeft = Number.isFinite(maxCount) ? maxCount * widthValue + leftStart : totalWidth;
|
|
1224
|
+
if (position < leftStart || position > maxLeft) return null;
|
|
1225
|
+
return require_deal_data.parserPixelToTime(position, {
|
|
1226
|
+
startLeft: leftStart,
|
|
1227
|
+
scale: scaleValue,
|
|
1228
|
+
scaleWidth: widthValue
|
|
1229
|
+
});
|
|
1230
|
+
};
|
|
1161
1231
|
const getColumnWidth = (index) => {
|
|
1162
1232
|
switch (index) {
|
|
1163
1233
|
case 0: return left;
|
|
@@ -1180,6 +1250,20 @@ function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScale
|
|
|
1180
1250
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1181
1251
|
style: { width: `${totalWidth}px` },
|
|
1182
1252
|
className: prefix("time-area"),
|
|
1253
|
+
onPointerMove: (e) => {
|
|
1254
|
+
const time = getTimeFromPointerX(e.currentTarget, e.clientX);
|
|
1255
|
+
if (time === null) {
|
|
1256
|
+
onTimelineCursorPreviewPointerLeave?.();
|
|
1257
|
+
return;
|
|
1258
|
+
}
|
|
1259
|
+
onTimelineCursorPreviewPointerMove?.({
|
|
1260
|
+
surface: "time-area",
|
|
1261
|
+
time
|
|
1262
|
+
});
|
|
1263
|
+
},
|
|
1264
|
+
onPointerLeave: () => {
|
|
1265
|
+
onTimelineCursorPreviewPointerLeave?.();
|
|
1266
|
+
},
|
|
1183
1267
|
onClick: (e) => {
|
|
1184
1268
|
const leftStart = startLeft ?? 20;
|
|
1185
1269
|
const widthValue = scaleWidth ?? 160;
|
|
@@ -1345,6 +1429,46 @@ const Cursor = ({ disableDrag, height, cursorTime, setCursor, startLeft, scaleWi
|
|
|
1345
1429
|
});
|
|
1346
1430
|
};
|
|
1347
1431
|
//#endregion
|
|
1432
|
+
//#region src/components/cursor/timeline-cursor-preview.tsx
|
|
1433
|
+
const HIDDEN_DISTANCE = 2;
|
|
1434
|
+
const VISIBLE_DISTANCE = 16;
|
|
1435
|
+
const MAX_OPACITY = 1;
|
|
1436
|
+
const TimelineCursorPreview = ({ cursorTime, height, preview, startLeft, scaleWidth, scale, getTimelineCursorPreviewHeadRender }) => {
|
|
1437
|
+
const transformOptions = {
|
|
1438
|
+
startLeft: startLeft ?? 20,
|
|
1439
|
+
scaleWidth: scaleWidth ?? 160,
|
|
1440
|
+
scale: scale ?? 1
|
|
1441
|
+
};
|
|
1442
|
+
const previewLeft = require_deal_data.parserTimeToPixel(preview.time, transformOptions);
|
|
1443
|
+
const cursorLeft = require_deal_data.parserTimeToPixel(cursorTime, transformOptions);
|
|
1444
|
+
const distance = Math.abs(previewLeft - cursorLeft);
|
|
1445
|
+
const opacity = distance <= HIDDEN_DISTANCE ? 0 : Math.min(MAX_OPACITY, (distance - HIDDEN_DISTANCE) / (VISIBLE_DISTANCE - HIDDEN_DISTANCE) * MAX_OPACITY);
|
|
1446
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1447
|
+
className: prefix("cursor-preview"),
|
|
1448
|
+
style: {
|
|
1449
|
+
height,
|
|
1450
|
+
opacity,
|
|
1451
|
+
transform: `translateX(${previewLeft}px) scaleX(0.5)`
|
|
1452
|
+
},
|
|
1453
|
+
"aria-hidden": "true",
|
|
1454
|
+
children: [getTimelineCursorPreviewHeadRender ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1455
|
+
className: prefix("cursor-preview-head"),
|
|
1456
|
+
children: getTimelineCursorPreviewHeadRender(preview)
|
|
1457
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("svg", {
|
|
1458
|
+
className: prefix("cursor-top"),
|
|
1459
|
+
width: "8",
|
|
1460
|
+
height: "12",
|
|
1461
|
+
viewBox: "0 0 8 12",
|
|
1462
|
+
fill: "none",
|
|
1463
|
+
"aria-hidden": "true",
|
|
1464
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("path", {
|
|
1465
|
+
d: "M0 1C0 0.447715 0.447715 0 1 0H7C7.55228 0 8 0.447715 8 1V9.38197C8 9.76074 7.786 10.107 7.44721 10.2764L4.44721 11.7764C4.16569 11.9172 3.83431 11.9172 3.55279 11.7764L0.552786 10.2764C0.214002 10.107 0 9.76074 0 9.38197V1Z",
|
|
1466
|
+
fill: "currentColor"
|
|
1467
|
+
})
|
|
1468
|
+
}) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: prefix("cursor-area") })]
|
|
1469
|
+
});
|
|
1470
|
+
};
|
|
1471
|
+
//#endregion
|
|
1348
1472
|
//#region src/components/scroll-area.tsx
|
|
1349
1473
|
function ScrollBar({ className, orientation = "vertical", ...props }) {
|
|
1350
1474
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(radix_ui.ScrollArea.ScrollAreaScrollbar, {
|
|
@@ -1396,9 +1520,12 @@ function Timeline({ ref, ...props }) {
|
|
|
1396
1520
|
const timelineProps = withDefaults(props);
|
|
1397
1521
|
const domRef = (0, react.useRef)(null);
|
|
1398
1522
|
const warnedDefaultRowsRef = (0, react.useRef)("");
|
|
1523
|
+
const warnedMissingActionPreviewRowRef = (0, react.useRef)("");
|
|
1399
1524
|
const { width, height } = useMeasure({ elementRef: domRef });
|
|
1400
1525
|
const [hoveredRowId, setHoveredRowId] = (0, react.useState)(null);
|
|
1401
1526
|
const [lockedRowId, setLockedRowId] = (0, react.useState)(null);
|
|
1527
|
+
const [timelineCursorPreview, setTimelineCursorPreview] = (0, react.useState)(null);
|
|
1528
|
+
const [isCursorDragging, setIsCursorDragging] = (0, react.useState)(false);
|
|
1402
1529
|
const editorAreaKey = props.unstable_forceRemountEditorArea ?? 0;
|
|
1403
1530
|
const minScaleCount = timelineProps.minScaleCount ?? Math.max(require_deal_data.getScaleCountByRows(timelineProps.editorData, {
|
|
1404
1531
|
scale: timelineProps.scale,
|
|
@@ -1427,6 +1554,10 @@ function Timeline({ ref, ...props }) {
|
|
|
1427
1554
|
warnedDefaultRowsRef.current = duplicateDefaultRowsKey;
|
|
1428
1555
|
console.warn("Warning: multiple collapsible rows set expandedByDefault. The first row in editorData wins.");
|
|
1429
1556
|
}
|
|
1557
|
+
if (timelineProps.actionPreview && !timelineProps.editorData.some((row) => row.id === timelineProps.actionPreview?.rowId) && warnedMissingActionPreviewRowRef.current !== timelineProps.actionPreview.rowId) {
|
|
1558
|
+
warnedMissingActionPreviewRowRef.current = timelineProps.actionPreview.rowId;
|
|
1559
|
+
console.warn(`Warning: actionPreview rowId "${timelineProps.actionPreview.rowId}" does not match any timeline row.`);
|
|
1560
|
+
}
|
|
1430
1561
|
/** Dynamically set scale count - overrides the derived value */
|
|
1431
1562
|
const handleSetScaleCount = (value) => {
|
|
1432
1563
|
setOverrideScaleCount(Math.min(timelineProps.maxScaleCount, value));
|
|
@@ -1462,6 +1593,14 @@ function Timeline({ ref, ...props }) {
|
|
|
1462
1593
|
}
|
|
1463
1594
|
return false;
|
|
1464
1595
|
};
|
|
1596
|
+
const handleTimelineCursorPreviewPointerMove = (0, react.useCallback)((preview) => {
|
|
1597
|
+
setTimelineCursorPreview(preview);
|
|
1598
|
+
}, []);
|
|
1599
|
+
const handleTimelineCursorPreviewPointerLeave = (0, react.useCallback)(() => {
|
|
1600
|
+
setTimelineCursorPreview(null);
|
|
1601
|
+
}, []);
|
|
1602
|
+
const timelineCursorHeight = Math.max(height, rowPresentation.totalHeight + 42);
|
|
1603
|
+
const showTimelineCursorPreview = timelineProps.showTimelineCursorPreview !== false && (timelineProps.showTimelineCursorPreview === true || Boolean(timelineProps.getTimelineCursorPreviewHeadRender));
|
|
1465
1604
|
const handleScrollToTime = (time, options = {}) => {
|
|
1466
1605
|
const element = domRef.current;
|
|
1467
1606
|
if (!element) return;
|
|
@@ -1551,7 +1690,9 @@ function Timeline({ ref, ...props }) {
|
|
|
1551
1690
|
...timelineProps,
|
|
1552
1691
|
setCursor: handleSetCursor,
|
|
1553
1692
|
scaleCount,
|
|
1554
|
-
scrollElementRef: domRef
|
|
1693
|
+
scrollElementRef: domRef,
|
|
1694
|
+
onTimelineCursorPreviewPointerMove: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerMove : void 0,
|
|
1695
|
+
onTimelineCursorPreviewPointerLeave: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerLeave : void 0
|
|
1555
1696
|
}),
|
|
1556
1697
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditArea, {
|
|
1557
1698
|
...timelineProps,
|
|
@@ -1571,19 +1712,38 @@ function Timeline({ ref, ...props }) {
|
|
|
1571
1712
|
clearHoveredRowId: (rowId) => {
|
|
1572
1713
|
setHoveredRowId((currentRowId) => currentRowId === rowId ? null : currentRowId);
|
|
1573
1714
|
},
|
|
1574
|
-
setLockedRowId
|
|
1715
|
+
setLockedRowId,
|
|
1716
|
+
onTimelineCursorPreviewPointerMove: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerMove : void 0,
|
|
1717
|
+
onTimelineCursorPreviewPointerLeave: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerLeave : void 0
|
|
1575
1718
|
}, `__editor_area_${editorAreaKey}__`),
|
|
1719
|
+
showTimelineCursorPreview && timelineCursorPreview && !isCursorDragging && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TimelineCursorPreview, {
|
|
1720
|
+
cursorTime,
|
|
1721
|
+
height: timelineCursorHeight,
|
|
1722
|
+
preview: timelineCursorPreview,
|
|
1723
|
+
startLeft: timelineProps.startLeft,
|
|
1724
|
+
scaleWidth: timelineProps.scaleWidth,
|
|
1725
|
+
scale: timelineProps.scale,
|
|
1726
|
+
getTimelineCursorPreviewHeadRender: timelineProps.getTimelineCursorPreviewHeadRender
|
|
1727
|
+
}),
|
|
1576
1728
|
!timelineProps.hideCursor && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Cursor, {
|
|
1577
1729
|
...timelineProps,
|
|
1578
1730
|
timelineWidth: width,
|
|
1579
|
-
height:
|
|
1731
|
+
height: timelineCursorHeight,
|
|
1580
1732
|
scaleCount,
|
|
1581
1733
|
setScaleCount: handleSetScaleCount,
|
|
1582
1734
|
setCursor: handleSetCursor,
|
|
1583
1735
|
cursorTime,
|
|
1584
1736
|
editorData: timelineProps.editorData,
|
|
1585
1737
|
scrollElementRef: domRef,
|
|
1586
|
-
snapPositions
|
|
1738
|
+
snapPositions,
|
|
1739
|
+
onCursorDragStart: (time) => {
|
|
1740
|
+
setIsCursorDragging(true);
|
|
1741
|
+
timelineProps.onCursorDragStart?.(time);
|
|
1742
|
+
},
|
|
1743
|
+
onCursorDragEnd: (time) => {
|
|
1744
|
+
setIsCursorDragging(false);
|
|
1745
|
+
timelineProps.onCursorDragEnd?.(time);
|
|
1746
|
+
}
|
|
1587
1747
|
})
|
|
1588
1748
|
]
|
|
1589
1749
|
}),
|
|
@@ -11,6 +11,14 @@ interface TimelineEffect {
|
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/interface/timeline.d.ts
|
|
14
|
+
type TimelineCursorPreviewRenderParams = {
|
|
15
|
+
surface: "time-area";
|
|
16
|
+
time: number;
|
|
17
|
+
} | {
|
|
18
|
+
surface: "edit-row";
|
|
19
|
+
time: number;
|
|
20
|
+
row: TimelineRow;
|
|
21
|
+
};
|
|
14
22
|
interface EditData {
|
|
15
23
|
/**
|
|
16
24
|
* @description Timeline editing data
|
|
@@ -80,6 +88,11 @@ interface EditData {
|
|
|
80
88
|
* @default false
|
|
81
89
|
*/
|
|
82
90
|
hideCursor?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* @description Whether to show the timeline cursor preview while hovering the timeline surface
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
showTimelineCursorPreview?: boolean;
|
|
83
96
|
/**
|
|
84
97
|
* @description Disable dragging in all action areas
|
|
85
98
|
* @default false
|
|
@@ -89,6 +102,25 @@ interface EditData {
|
|
|
89
102
|
* @description Custom action area rendering
|
|
90
103
|
*/
|
|
91
104
|
getActionRender?: (action: TimelineAction, row: TimelineRow) => React$1.ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* @description Client-controlled action preview to render before insertion
|
|
107
|
+
*/
|
|
108
|
+
actionPreview?: {
|
|
109
|
+
rowId: string;
|
|
110
|
+
action: TimelineAction;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* @description Render custom content for an action preview
|
|
114
|
+
*/
|
|
115
|
+
getActionPreviewRender?: (params: {
|
|
116
|
+
action: TimelineAction;
|
|
117
|
+
row: TimelineRow;
|
|
118
|
+
height: number;
|
|
119
|
+
}) => React$1.ReactNode;
|
|
120
|
+
/**
|
|
121
|
+
* @description Render custom content inside the timeline cursor preview head
|
|
122
|
+
*/
|
|
123
|
+
getTimelineCursorPreviewHeadRender?: (params: TimelineCursorPreviewRenderParams) => React$1.ReactNode;
|
|
92
124
|
/**
|
|
93
125
|
* @description Render custom content inside rows with no actions
|
|
94
126
|
*/
|
|
@@ -167,6 +199,13 @@ interface EditData {
|
|
|
167
199
|
row: TimelineRow;
|
|
168
200
|
time: number;
|
|
169
201
|
}) => void;
|
|
202
|
+
/**
|
|
203
|
+
* @description Pointer move row callback
|
|
204
|
+
*/
|
|
205
|
+
onPointerMoveRow?: (e: React$1.PointerEvent<HTMLElement>, param: {
|
|
206
|
+
row: TimelineRow;
|
|
207
|
+
time: number;
|
|
208
|
+
}) => void;
|
|
170
209
|
/**
|
|
171
210
|
* @description Click action callback
|
|
172
211
|
*/
|
|
@@ -310,4 +349,4 @@ declare function Timeline({
|
|
|
310
349
|
unstable_forceRemountEditorArea?: number;
|
|
311
350
|
}): React.JSX.Element;
|
|
312
351
|
//#endregion
|
|
313
|
-
export { type EditData, Timeline, type TimelineAction, type TimelineEditor, type TimelineEffect, type TimelineRow, type TimelineState };
|
|
352
|
+
export { type EditData, Timeline, type TimelineAction, type TimelineCursorPreviewRenderParams, type TimelineEditor, type TimelineEffect, type TimelineRow, type TimelineState };
|
|
@@ -11,6 +11,14 @@ interface TimelineEffect {
|
|
|
11
11
|
}
|
|
12
12
|
//#endregion
|
|
13
13
|
//#region src/interface/timeline.d.ts
|
|
14
|
+
type TimelineCursorPreviewRenderParams = {
|
|
15
|
+
surface: "time-area";
|
|
16
|
+
time: number;
|
|
17
|
+
} | {
|
|
18
|
+
surface: "edit-row";
|
|
19
|
+
time: number;
|
|
20
|
+
row: TimelineRow;
|
|
21
|
+
};
|
|
14
22
|
interface EditData {
|
|
15
23
|
/**
|
|
16
24
|
* @description Timeline editing data
|
|
@@ -80,6 +88,11 @@ interface EditData {
|
|
|
80
88
|
* @default false
|
|
81
89
|
*/
|
|
82
90
|
hideCursor?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* @description Whether to show the timeline cursor preview while hovering the timeline surface
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
showTimelineCursorPreview?: boolean;
|
|
83
96
|
/**
|
|
84
97
|
* @description Disable dragging in all action areas
|
|
85
98
|
* @default false
|
|
@@ -89,6 +102,25 @@ interface EditData {
|
|
|
89
102
|
* @description Custom action area rendering
|
|
90
103
|
*/
|
|
91
104
|
getActionRender?: (action: TimelineAction, row: TimelineRow) => React$1.ReactNode;
|
|
105
|
+
/**
|
|
106
|
+
* @description Client-controlled action preview to render before insertion
|
|
107
|
+
*/
|
|
108
|
+
actionPreview?: {
|
|
109
|
+
rowId: string;
|
|
110
|
+
action: TimelineAction;
|
|
111
|
+
};
|
|
112
|
+
/**
|
|
113
|
+
* @description Render custom content for an action preview
|
|
114
|
+
*/
|
|
115
|
+
getActionPreviewRender?: (params: {
|
|
116
|
+
action: TimelineAction;
|
|
117
|
+
row: TimelineRow;
|
|
118
|
+
height: number;
|
|
119
|
+
}) => React$1.ReactNode;
|
|
120
|
+
/**
|
|
121
|
+
* @description Render custom content inside the timeline cursor preview head
|
|
122
|
+
*/
|
|
123
|
+
getTimelineCursorPreviewHeadRender?: (params: TimelineCursorPreviewRenderParams) => React$1.ReactNode;
|
|
92
124
|
/**
|
|
93
125
|
* @description Render custom content inside rows with no actions
|
|
94
126
|
*/
|
|
@@ -167,6 +199,13 @@ interface EditData {
|
|
|
167
199
|
row: TimelineRow;
|
|
168
200
|
time: number;
|
|
169
201
|
}) => void;
|
|
202
|
+
/**
|
|
203
|
+
* @description Pointer move row callback
|
|
204
|
+
*/
|
|
205
|
+
onPointerMoveRow?: (e: React$1.PointerEvent<HTMLElement>, param: {
|
|
206
|
+
row: TimelineRow;
|
|
207
|
+
time: number;
|
|
208
|
+
}) => void;
|
|
170
209
|
/**
|
|
171
210
|
* @description Click action callback
|
|
172
211
|
*/
|
|
@@ -310,4 +349,4 @@ declare function Timeline({
|
|
|
310
349
|
unstable_forceRemountEditorArea?: number;
|
|
311
350
|
}): React.JSX.Element;
|
|
312
351
|
//#endregion
|
|
313
|
-
export { type EditData, Timeline, type TimelineAction, type TimelineEditor, type TimelineEffect, type TimelineRow, type TimelineState };
|
|
352
|
+
export { type EditData, Timeline, type TimelineAction, type TimelineCursorPreviewRenderParams, type TimelineEditor, type TimelineEffect, type TimelineRow, type TimelineState };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as parserTimeToPixel, c as PREFIX, i as parserPixelToTime, n as getScaleCountByRows, o as parserTimeToTransform, r as parserActionsToPositions, s as parserTransformToTime, t as getScaleCountByPixel } from "./deal-data-DH3Lh6kA.mjs";
|
|
2
2
|
import { createElement, useCallback, useEffect, useEffectEvent, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { prefixNames } from "framework-utils";
|
|
4
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useDrag } from "@use-gesture/react";
|
|
6
6
|
import { ScrollArea, Slot } from "radix-ui";
|
|
7
7
|
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
@@ -752,7 +752,11 @@ const EditAction = ({ editorData, row, rowRenderHeight, action, effects, scale,
|
|
|
752
752
|
time
|
|
753
753
|
});
|
|
754
754
|
}
|
|
755
|
-
if (
|
|
755
|
+
if (isDragWhenClick.current) {
|
|
756
|
+
e.stopPropagation();
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
759
|
+
if (onClickActionOnly) {
|
|
756
760
|
if (time === void 0) time = handleTime(e);
|
|
757
761
|
onClickActionOnly(e, {
|
|
758
762
|
row,
|
|
@@ -802,7 +806,7 @@ const EditAction = ({ editorData, row, rowRenderHeight, action, effects, scale,
|
|
|
802
806
|
//#endregion
|
|
803
807
|
//#region src/components/edit_area/edit-row.tsx
|
|
804
808
|
const EditRow = (props) => {
|
|
805
|
-
const { rowData, rowRenderHeight, isCollapsed = false, style = {}, onClickRow, onDoubleClickRow, onContextMenuRow, scrollContainerRef, startLeft, scale, scaleWidth, unstable_rowActionsOverscan, getEmptyRowRender, getCollapsedRowLabelRender } = props;
|
|
809
|
+
const { rowData, rowRenderHeight, isCollapsed = false, style = {}, onClickRow, onPointerMoveRow, onDoubleClickRow, onContextMenuRow, scrollContainerRef, startLeft, scale, scaleWidth, unstable_rowActionsOverscan, getEmptyRowRender, getCollapsedRowLabelRender, getActionPreviewRender, actionPreview } = props;
|
|
806
810
|
const classNames = ["edit-row"];
|
|
807
811
|
if (rowData?.selected) classNames.push("edit-row-selected");
|
|
808
812
|
const safeScale = scale ?? 1;
|
|
@@ -817,8 +821,36 @@ const EditRow = (props) => {
|
|
|
817
821
|
scaleWidth: safeScaleWidth
|
|
818
822
|
});
|
|
819
823
|
};
|
|
824
|
+
const handleTimelineCursorPreviewPointerMove = (e) => {
|
|
825
|
+
if (!rowData) return;
|
|
826
|
+
const position = e.clientX - e.currentTarget.getBoundingClientRect().x;
|
|
827
|
+
const maxCount = props.maxScaleCount ?? Infinity;
|
|
828
|
+
const maxLeft = Number.isFinite(maxCount) ? maxCount * safeScaleWidth + safeStartLeft : e.currentTarget.offsetWidth;
|
|
829
|
+
if (position < safeStartLeft || position > maxLeft) {
|
|
830
|
+
props.onTimelineCursorPreviewPointerLeave?.();
|
|
831
|
+
return;
|
|
832
|
+
}
|
|
833
|
+
props.onTimelineCursorPreviewPointerMove?.({
|
|
834
|
+
surface: "edit-row",
|
|
835
|
+
row: rowData,
|
|
836
|
+
time: parserPixelToTime(position, {
|
|
837
|
+
startLeft: safeStartLeft,
|
|
838
|
+
scale: safeScale,
|
|
839
|
+
scaleWidth: safeScaleWidth
|
|
840
|
+
})
|
|
841
|
+
});
|
|
842
|
+
};
|
|
820
843
|
const actions = useMemo(() => (rowData?.actions ? [...rowData.actions] : []).sort((a, b) => a.start - b.start), [rowData]);
|
|
821
844
|
const getItemKey = useCallback((index) => actions[index]?.id ?? index, [actions]);
|
|
845
|
+
const previewAction = rowData && actionPreview?.rowId === rowData.id ? actionPreview.action : null;
|
|
846
|
+
const previewTransform = previewAction ? parserTimeToTransform({
|
|
847
|
+
start: previewAction.start,
|
|
848
|
+
end: previewAction.end
|
|
849
|
+
}, {
|
|
850
|
+
startLeft: safeStartLeft,
|
|
851
|
+
scale: safeScale,
|
|
852
|
+
scaleWidth: safeScaleWidth
|
|
853
|
+
}) : null;
|
|
822
854
|
const virtualizer = useVirtualizer({
|
|
823
855
|
horizontal: true,
|
|
824
856
|
count: actions.length,
|
|
@@ -852,6 +884,13 @@ const EditRow = (props) => {
|
|
|
852
884
|
style,
|
|
853
885
|
onPointerEnter: props.onPointerEnter,
|
|
854
886
|
onPointerLeave: props.onPointerLeave,
|
|
887
|
+
onPointerMove: (e) => {
|
|
888
|
+
handleTimelineCursorPreviewPointerMove(e);
|
|
889
|
+
if (rowData && onPointerMoveRow) onPointerMoveRow(e, {
|
|
890
|
+
row: rowData,
|
|
891
|
+
time: handleTime(e)
|
|
892
|
+
});
|
|
893
|
+
},
|
|
855
894
|
onClick: (e) => {
|
|
856
895
|
if (rowData && onClickRow) onClickRow(e, {
|
|
857
896
|
row: rowData,
|
|
@@ -886,6 +925,20 @@ const EditRow = (props) => {
|
|
|
886
925
|
height: rowRenderHeight
|
|
887
926
|
})
|
|
888
927
|
}),
|
|
928
|
+
rowData && previewAction && previewTransform && /* @__PURE__ */ jsx("div", {
|
|
929
|
+
className: prefix("action-preview"),
|
|
930
|
+
style: {
|
|
931
|
+
height: rowRenderHeight,
|
|
932
|
+
transform: `translateX(${previewTransform.left}px)`,
|
|
933
|
+
width: previewTransform.width
|
|
934
|
+
},
|
|
935
|
+
"aria-hidden": "true",
|
|
936
|
+
children: getActionPreviewRender?.({
|
|
937
|
+
action: previewAction,
|
|
938
|
+
row: rowData,
|
|
939
|
+
height: rowRenderHeight
|
|
940
|
+
})
|
|
941
|
+
}),
|
|
889
942
|
rowData && virtualizer.getVirtualItems().map((virtualEntry) => {
|
|
890
943
|
const action = actions[virtualEntry.index];
|
|
891
944
|
if (!action) throw new Error("Action not found");
|
|
@@ -1078,7 +1131,10 @@ const EditArea = ({ ref, ...props }) => {
|
|
|
1078
1131
|
},
|
|
1079
1132
|
onPointerLeave: () => {
|
|
1080
1133
|
props.clearHoveredRowId(row.id);
|
|
1134
|
+
props.onTimelineCursorPreviewPointerLeave?.();
|
|
1081
1135
|
},
|
|
1136
|
+
onTimelineCursorPreviewPointerMove: props.onTimelineCursorPreviewPointerMove,
|
|
1137
|
+
onTimelineCursorPreviewPointerLeave: props.onTimelineCursorPreviewPointerLeave,
|
|
1082
1138
|
onActionMoveStart: (data) => {
|
|
1083
1139
|
if (row.collapsed) props.setLockedRowId(row.id);
|
|
1084
1140
|
handleInitSnap(data);
|
|
@@ -1125,7 +1181,7 @@ const EditArea = ({ ref, ...props }) => {
|
|
|
1125
1181
|
};
|
|
1126
1182
|
//#endregion
|
|
1127
1183
|
//#region src/components/time_area/time-area.tsx
|
|
1128
|
-
function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScaleCount, scale, scrollElementRef, onClickTimeArea, setCursor, getScaleRender }) {
|
|
1184
|
+
function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScaleCount, scale, scrollElementRef, onClickTimeArea, setCursor, getScaleRender, onTimelineCursorPreviewPointerMove, onTimelineCursorPreviewPointerLeave }) {
|
|
1129
1185
|
const splitCount = scaleSplitCount ?? 1;
|
|
1130
1186
|
const width = scaleWidth ?? 160;
|
|
1131
1187
|
const left = startLeft ?? 20;
|
|
@@ -1133,6 +1189,20 @@ function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScale
|
|
|
1133
1189
|
const showUnit = (scaleSplitCount ?? 0) > 0;
|
|
1134
1190
|
const columnCount = showUnit ? scaleCount * (scaleSplitCount ?? 1) + 1 : scaleCount;
|
|
1135
1191
|
const totalWidth = (showUnit ? width / splitCount : width) * (columnCount - 1) + left;
|
|
1192
|
+
const getTimeFromPointerX = (currentTarget, clientX) => {
|
|
1193
|
+
const leftStart = startLeft ?? 20;
|
|
1194
|
+
const widthValue = scaleWidth ?? 160;
|
|
1195
|
+
const scaleValue = scale ?? 1;
|
|
1196
|
+
const maxCount = maxScaleCount ?? Infinity;
|
|
1197
|
+
const position = clientX - currentTarget.getBoundingClientRect().x;
|
|
1198
|
+
const maxLeft = Number.isFinite(maxCount) ? maxCount * widthValue + leftStart : totalWidth;
|
|
1199
|
+
if (position < leftStart || position > maxLeft) return null;
|
|
1200
|
+
return parserPixelToTime(position, {
|
|
1201
|
+
startLeft: leftStart,
|
|
1202
|
+
scale: scaleValue,
|
|
1203
|
+
scaleWidth: widthValue
|
|
1204
|
+
});
|
|
1205
|
+
};
|
|
1136
1206
|
const getColumnWidth = (index) => {
|
|
1137
1207
|
switch (index) {
|
|
1138
1208
|
case 0: return left;
|
|
@@ -1155,6 +1225,20 @@ function TimeArea({ scaleSplitCount, scaleWidth, startLeft, scaleCount, maxScale
|
|
|
1155
1225
|
return /* @__PURE__ */ jsx("div", {
|
|
1156
1226
|
style: { width: `${totalWidth}px` },
|
|
1157
1227
|
className: prefix("time-area"),
|
|
1228
|
+
onPointerMove: (e) => {
|
|
1229
|
+
const time = getTimeFromPointerX(e.currentTarget, e.clientX);
|
|
1230
|
+
if (time === null) {
|
|
1231
|
+
onTimelineCursorPreviewPointerLeave?.();
|
|
1232
|
+
return;
|
|
1233
|
+
}
|
|
1234
|
+
onTimelineCursorPreviewPointerMove?.({
|
|
1235
|
+
surface: "time-area",
|
|
1236
|
+
time
|
|
1237
|
+
});
|
|
1238
|
+
},
|
|
1239
|
+
onPointerLeave: () => {
|
|
1240
|
+
onTimelineCursorPreviewPointerLeave?.();
|
|
1241
|
+
},
|
|
1158
1242
|
onClick: (e) => {
|
|
1159
1243
|
const leftStart = startLeft ?? 20;
|
|
1160
1244
|
const widthValue = scaleWidth ?? 160;
|
|
@@ -1320,6 +1404,46 @@ const Cursor = ({ disableDrag, height, cursorTime, setCursor, startLeft, scaleWi
|
|
|
1320
1404
|
});
|
|
1321
1405
|
};
|
|
1322
1406
|
//#endregion
|
|
1407
|
+
//#region src/components/cursor/timeline-cursor-preview.tsx
|
|
1408
|
+
const HIDDEN_DISTANCE = 2;
|
|
1409
|
+
const VISIBLE_DISTANCE = 16;
|
|
1410
|
+
const MAX_OPACITY = 1;
|
|
1411
|
+
const TimelineCursorPreview = ({ cursorTime, height, preview, startLeft, scaleWidth, scale, getTimelineCursorPreviewHeadRender }) => {
|
|
1412
|
+
const transformOptions = {
|
|
1413
|
+
startLeft: startLeft ?? 20,
|
|
1414
|
+
scaleWidth: scaleWidth ?? 160,
|
|
1415
|
+
scale: scale ?? 1
|
|
1416
|
+
};
|
|
1417
|
+
const previewLeft = parserTimeToPixel(preview.time, transformOptions);
|
|
1418
|
+
const cursorLeft = parserTimeToPixel(cursorTime, transformOptions);
|
|
1419
|
+
const distance = Math.abs(previewLeft - cursorLeft);
|
|
1420
|
+
const opacity = distance <= HIDDEN_DISTANCE ? 0 : Math.min(MAX_OPACITY, (distance - HIDDEN_DISTANCE) / (VISIBLE_DISTANCE - HIDDEN_DISTANCE) * MAX_OPACITY);
|
|
1421
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
1422
|
+
className: prefix("cursor-preview"),
|
|
1423
|
+
style: {
|
|
1424
|
+
height,
|
|
1425
|
+
opacity,
|
|
1426
|
+
transform: `translateX(${previewLeft}px) scaleX(0.5)`
|
|
1427
|
+
},
|
|
1428
|
+
"aria-hidden": "true",
|
|
1429
|
+
children: [getTimelineCursorPreviewHeadRender ? /* @__PURE__ */ jsx("div", {
|
|
1430
|
+
className: prefix("cursor-preview-head"),
|
|
1431
|
+
children: getTimelineCursorPreviewHeadRender(preview)
|
|
1432
|
+
}) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("svg", {
|
|
1433
|
+
className: prefix("cursor-top"),
|
|
1434
|
+
width: "8",
|
|
1435
|
+
height: "12",
|
|
1436
|
+
viewBox: "0 0 8 12",
|
|
1437
|
+
fill: "none",
|
|
1438
|
+
"aria-hidden": "true",
|
|
1439
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
1440
|
+
d: "M0 1C0 0.447715 0.447715 0 1 0H7C7.55228 0 8 0.447715 8 1V9.38197C8 9.76074 7.786 10.107 7.44721 10.2764L4.44721 11.7764C4.16569 11.9172 3.83431 11.9172 3.55279 11.7764L0.552786 10.2764C0.214002 10.107 0 9.76074 0 9.38197V1Z",
|
|
1441
|
+
fill: "currentColor"
|
|
1442
|
+
})
|
|
1443
|
+
}) }), /* @__PURE__ */ jsx("div", { className: prefix("cursor-area") })]
|
|
1444
|
+
});
|
|
1445
|
+
};
|
|
1446
|
+
//#endregion
|
|
1323
1447
|
//#region src/components/scroll-area.tsx
|
|
1324
1448
|
function ScrollBar({ className, orientation = "vertical", ...props }) {
|
|
1325
1449
|
return /* @__PURE__ */ jsx(ScrollArea.ScrollAreaScrollbar, {
|
|
@@ -1371,9 +1495,12 @@ function Timeline({ ref, ...props }) {
|
|
|
1371
1495
|
const timelineProps = withDefaults(props);
|
|
1372
1496
|
const domRef = useRef(null);
|
|
1373
1497
|
const warnedDefaultRowsRef = useRef("");
|
|
1498
|
+
const warnedMissingActionPreviewRowRef = useRef("");
|
|
1374
1499
|
const { width, height } = useMeasure({ elementRef: domRef });
|
|
1375
1500
|
const [hoveredRowId, setHoveredRowId] = useState(null);
|
|
1376
1501
|
const [lockedRowId, setLockedRowId] = useState(null);
|
|
1502
|
+
const [timelineCursorPreview, setTimelineCursorPreview] = useState(null);
|
|
1503
|
+
const [isCursorDragging, setIsCursorDragging] = useState(false);
|
|
1377
1504
|
const editorAreaKey = props.unstable_forceRemountEditorArea ?? 0;
|
|
1378
1505
|
const minScaleCount = timelineProps.minScaleCount ?? Math.max(getScaleCountByRows(timelineProps.editorData, {
|
|
1379
1506
|
scale: timelineProps.scale,
|
|
@@ -1402,6 +1529,10 @@ function Timeline({ ref, ...props }) {
|
|
|
1402
1529
|
warnedDefaultRowsRef.current = duplicateDefaultRowsKey;
|
|
1403
1530
|
console.warn("Warning: multiple collapsible rows set expandedByDefault. The first row in editorData wins.");
|
|
1404
1531
|
}
|
|
1532
|
+
if (timelineProps.actionPreview && !timelineProps.editorData.some((row) => row.id === timelineProps.actionPreview?.rowId) && warnedMissingActionPreviewRowRef.current !== timelineProps.actionPreview.rowId) {
|
|
1533
|
+
warnedMissingActionPreviewRowRef.current = timelineProps.actionPreview.rowId;
|
|
1534
|
+
console.warn(`Warning: actionPreview rowId "${timelineProps.actionPreview.rowId}" does not match any timeline row.`);
|
|
1535
|
+
}
|
|
1405
1536
|
/** Dynamically set scale count - overrides the derived value */
|
|
1406
1537
|
const handleSetScaleCount = (value) => {
|
|
1407
1538
|
setOverrideScaleCount(Math.min(timelineProps.maxScaleCount, value));
|
|
@@ -1437,6 +1568,14 @@ function Timeline({ ref, ...props }) {
|
|
|
1437
1568
|
}
|
|
1438
1569
|
return false;
|
|
1439
1570
|
};
|
|
1571
|
+
const handleTimelineCursorPreviewPointerMove = useCallback((preview) => {
|
|
1572
|
+
setTimelineCursorPreview(preview);
|
|
1573
|
+
}, []);
|
|
1574
|
+
const handleTimelineCursorPreviewPointerLeave = useCallback(() => {
|
|
1575
|
+
setTimelineCursorPreview(null);
|
|
1576
|
+
}, []);
|
|
1577
|
+
const timelineCursorHeight = Math.max(height, rowPresentation.totalHeight + 42);
|
|
1578
|
+
const showTimelineCursorPreview = timelineProps.showTimelineCursorPreview !== false && (timelineProps.showTimelineCursorPreview === true || Boolean(timelineProps.getTimelineCursorPreviewHeadRender));
|
|
1440
1579
|
const handleScrollToTime = (time, options = {}) => {
|
|
1441
1580
|
const element = domRef.current;
|
|
1442
1581
|
if (!element) return;
|
|
@@ -1526,7 +1665,9 @@ function Timeline({ ref, ...props }) {
|
|
|
1526
1665
|
...timelineProps,
|
|
1527
1666
|
setCursor: handleSetCursor,
|
|
1528
1667
|
scaleCount,
|
|
1529
|
-
scrollElementRef: domRef
|
|
1668
|
+
scrollElementRef: domRef,
|
|
1669
|
+
onTimelineCursorPreviewPointerMove: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerMove : void 0,
|
|
1670
|
+
onTimelineCursorPreviewPointerLeave: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerLeave : void 0
|
|
1530
1671
|
}),
|
|
1531
1672
|
/* @__PURE__ */ jsx(EditArea, {
|
|
1532
1673
|
...timelineProps,
|
|
@@ -1546,19 +1687,38 @@ function Timeline({ ref, ...props }) {
|
|
|
1546
1687
|
clearHoveredRowId: (rowId) => {
|
|
1547
1688
|
setHoveredRowId((currentRowId) => currentRowId === rowId ? null : currentRowId);
|
|
1548
1689
|
},
|
|
1549
|
-
setLockedRowId
|
|
1690
|
+
setLockedRowId,
|
|
1691
|
+
onTimelineCursorPreviewPointerMove: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerMove : void 0,
|
|
1692
|
+
onTimelineCursorPreviewPointerLeave: showTimelineCursorPreview ? handleTimelineCursorPreviewPointerLeave : void 0
|
|
1550
1693
|
}, `__editor_area_${editorAreaKey}__`),
|
|
1694
|
+
showTimelineCursorPreview && timelineCursorPreview && !isCursorDragging && /* @__PURE__ */ jsx(TimelineCursorPreview, {
|
|
1695
|
+
cursorTime,
|
|
1696
|
+
height: timelineCursorHeight,
|
|
1697
|
+
preview: timelineCursorPreview,
|
|
1698
|
+
startLeft: timelineProps.startLeft,
|
|
1699
|
+
scaleWidth: timelineProps.scaleWidth,
|
|
1700
|
+
scale: timelineProps.scale,
|
|
1701
|
+
getTimelineCursorPreviewHeadRender: timelineProps.getTimelineCursorPreviewHeadRender
|
|
1702
|
+
}),
|
|
1551
1703
|
!timelineProps.hideCursor && /* @__PURE__ */ jsx(Cursor, {
|
|
1552
1704
|
...timelineProps,
|
|
1553
1705
|
timelineWidth: width,
|
|
1554
|
-
height:
|
|
1706
|
+
height: timelineCursorHeight,
|
|
1555
1707
|
scaleCount,
|
|
1556
1708
|
setScaleCount: handleSetScaleCount,
|
|
1557
1709
|
setCursor: handleSetCursor,
|
|
1558
1710
|
cursorTime,
|
|
1559
1711
|
editorData: timelineProps.editorData,
|
|
1560
1712
|
scrollElementRef: domRef,
|
|
1561
|
-
snapPositions
|
|
1713
|
+
snapPositions,
|
|
1714
|
+
onCursorDragStart: (time) => {
|
|
1715
|
+
setIsCursorDragging(true);
|
|
1716
|
+
timelineProps.onCursorDragStart?.(time);
|
|
1717
|
+
},
|
|
1718
|
+
onCursorDragEnd: (time) => {
|
|
1719
|
+
setIsCursorDragging(false);
|
|
1720
|
+
timelineProps.onCursorDragEnd?.(time);
|
|
1721
|
+
}
|
|
1562
1722
|
})
|
|
1563
1723
|
]
|
|
1564
1724
|
}),
|
package/dist/styles.css
CHANGED
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
.timeline-editor-collapsed-row-label {
|
|
105
|
-
z-index:
|
|
105
|
+
z-index: 3;
|
|
106
106
|
pointer-events: none;
|
|
107
107
|
align-self: stretch;
|
|
108
108
|
align-items: center;
|
|
@@ -123,12 +123,21 @@
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
.timeline-editor-action {
|
|
126
|
+
z-index: 2;
|
|
126
127
|
background-color: oklch(35.3% 0 0);
|
|
127
128
|
position: absolute;
|
|
128
129
|
top: 0;
|
|
129
130
|
left: 0;
|
|
130
131
|
}
|
|
131
132
|
|
|
133
|
+
.timeline-editor-action-preview {
|
|
134
|
+
pointer-events: none;
|
|
135
|
+
z-index: 1;
|
|
136
|
+
position: absolute;
|
|
137
|
+
top: 0;
|
|
138
|
+
left: 0;
|
|
139
|
+
}
|
|
140
|
+
|
|
132
141
|
.timeline-editor-action-left-stretch, .timeline-editor-action-right-stretch {
|
|
133
142
|
cursor: ew-resize;
|
|
134
143
|
width: .625rem;
|
|
@@ -224,13 +233,43 @@
|
|
|
224
233
|
--scale-x: .5;
|
|
225
234
|
cursor: ew-resize;
|
|
226
235
|
box-sizing: border-box;
|
|
227
|
-
z-index:
|
|
236
|
+
z-index: 4;
|
|
228
237
|
min-height: calc(100% - 32px);
|
|
229
238
|
position: absolute;
|
|
230
239
|
top: 2rem;
|
|
231
240
|
left: -4px;
|
|
232
241
|
}
|
|
233
242
|
|
|
243
|
+
.timeline-editor-cursor-preview {
|
|
244
|
+
box-sizing: border-box;
|
|
245
|
+
z-index: 5;
|
|
246
|
+
pointer-events: none;
|
|
247
|
+
color: oklch(78% 0 0);
|
|
248
|
+
transform-origin: 0 0;
|
|
249
|
+
min-height: calc(100% - 32px);
|
|
250
|
+
transition: opacity 80ms ease-out;
|
|
251
|
+
position: absolute;
|
|
252
|
+
top: 2rem;
|
|
253
|
+
left: -4px;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.timeline-editor-cursor-preview-head {
|
|
257
|
+
color: inherit;
|
|
258
|
+
transform-origin: 0 0;
|
|
259
|
+
position: sticky;
|
|
260
|
+
top: 2rem;
|
|
261
|
+
transform: scaleX(2);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.timeline-editor-cursor-preview .timeline-editor-cursor-top {
|
|
265
|
+
color: oklch(78% 0 0);
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
.timeline-editor-cursor-preview .timeline-editor-cursor-area {
|
|
269
|
+
border-left-color: oklch(78% 0 0);
|
|
270
|
+
border-right-color: oklch(78% 0 0);
|
|
271
|
+
}
|
|
272
|
+
|
|
234
273
|
.timeline-editor-cursor-top {
|
|
235
274
|
color: oklch(65.1% .197 250.3);
|
|
236
275
|
position: sticky;
|