@cyca/react-timeline-editor 0.2.4-alpha.6 → 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.
@@ -0,0 +1,352 @@
1
+ import { n as TimelineRow, t as TimelineAction } from "./action-C-MnAPdg.cjs";
2
+ import * as React$1 from "react";
3
+ import React from "react";
4
+
5
+ //#region src/interface/effect.d.ts
6
+ interface TimelineEffect {
7
+ /** Effect id */
8
+ id: string;
9
+ /** Effect name */
10
+ name?: string;
11
+ }
12
+ //#endregion
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
+ };
22
+ interface EditData {
23
+ /**
24
+ * @description Timeline editing data
25
+ */
26
+ editorData: TimelineRow[];
27
+ /**
28
+ * @description Timeline action effects map
29
+ */
30
+ effects: Record<string, TimelineEffect>;
31
+ /**
32
+ * @description Single scale mark range (>0)
33
+ * @default 1
34
+ */
35
+ scale?: number;
36
+ /**
37
+ * @description Minimum number of scales (>=1)
38
+ * @default 20
39
+ */
40
+ minScaleCount?: number;
41
+ /**
42
+ * @description Maximum number of scales (>=minScaleCount)
43
+ * @default Infinity
44
+ */
45
+ maxScaleCount?: number;
46
+ /**
47
+ * @description Number of subdivision units per scale (>0 integer)
48
+ * @default 10
49
+ */
50
+ scaleSplitCount?: number;
51
+ /**
52
+ * @description Display width of a single scale (>0, unit: px)
53
+ * @default 160
54
+ */
55
+ scaleWidth?: number;
56
+ /**
57
+ * @description Distance from the left where the scale starts (>=0, unit: px)
58
+ * @default 20
59
+ */
60
+ startLeft?: number;
61
+ /**
62
+ * @description Default height of each editing row (>0, unit: px)
63
+ * @default 32
64
+ */
65
+ rowHeight?: number;
66
+ /**
67
+ * @description Default collapsed height for collapsible rows (>0, unit: px)
68
+ * @default rowHeight
69
+ */
70
+ collapsedRowHeight?: number;
71
+ /**
72
+ * @description Whether to enable grid snap
73
+ * @default false
74
+ */
75
+ gridSnap?: boolean;
76
+ /**
77
+ * @description Enable snap
78
+ * @default false
79
+ */
80
+ snap?: boolean;
81
+ /**
82
+ * @description Enable cursor snap to action endpoints when dragging
83
+ * @default false
84
+ */
85
+ cursorSnap?: boolean;
86
+ /**
87
+ * @description Whether to hide cursor
88
+ * @default false
89
+ */
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;
96
+ /**
97
+ * @description Disable dragging in all action areas
98
+ * @default false
99
+ */
100
+ disableDrag?: boolean;
101
+ /**
102
+ * @description Custom action area rendering
103
+ */
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;
124
+ /**
125
+ * @description Render custom content inside rows with no actions
126
+ */
127
+ getEmptyRowRender?: (params: {
128
+ row: TimelineRow;
129
+ height: number;
130
+ }) => React$1.ReactNode;
131
+ /**
132
+ * @description Render decorative content over a collapsible row only while it is collapsed
133
+ */
134
+ getCollapsedRowLabelRender?: (params: {
135
+ row: TimelineRow;
136
+ height: number;
137
+ }) => React$1.ReactNode;
138
+ /**
139
+ * @description Custom scale rendering
140
+ */
141
+ getScaleRender?: (scale: number) => React$1.ReactNode;
142
+ /**
143
+ * @description Start move callback
144
+ */
145
+ onActionMoveStart?: (params: {
146
+ action: TimelineAction;
147
+ row: TimelineRow;
148
+ }) => void;
149
+ /**
150
+ * @description Move callback (return false to prevent movement)
151
+ */
152
+ onActionMoving?: (params: {
153
+ action: TimelineAction;
154
+ row: TimelineRow;
155
+ start: number;
156
+ end: number;
157
+ }) => void | boolean;
158
+ /**
159
+ * @description Move end callback (return false to prevent onChange trigger)
160
+ */
161
+ onActionMoveEnd?: (params: {
162
+ action: TimelineAction;
163
+ row: TimelineRow;
164
+ start: number;
165
+ end: number;
166
+ }) => void;
167
+ /**
168
+ * @description Start resize callback
169
+ */
170
+ onActionResizeStart?: (params: {
171
+ action: TimelineAction;
172
+ row: TimelineRow;
173
+ dir: "right" | "left";
174
+ }) => void;
175
+ /**
176
+ * @description Resize callback (return false to prevent resize)
177
+ */
178
+ onActionResizing?: (params: {
179
+ action: TimelineAction;
180
+ row: TimelineRow;
181
+ start: number;
182
+ end: number;
183
+ dir: "right" | "left";
184
+ }) => void | boolean;
185
+ /**
186
+ * @description Resize end callback (return false to prevent onChange trigger)
187
+ */
188
+ onActionResizeEnd?: (params: {
189
+ action: TimelineAction;
190
+ row: TimelineRow;
191
+ start: number;
192
+ end: number;
193
+ dir: "right" | "left";
194
+ }) => void;
195
+ /**
196
+ * @description Click row callback
197
+ */
198
+ onClickRow?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
199
+ row: TimelineRow;
200
+ time: number;
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;
209
+ /**
210
+ * @description Click action callback
211
+ */
212
+ onClickAction?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
213
+ action: TimelineAction;
214
+ row: TimelineRow;
215
+ time: number;
216
+ }) => void;
217
+ /**
218
+ * @description Click action callback (not executed when drag is triggered)
219
+ */
220
+ onClickActionOnly?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
221
+ action: TimelineAction;
222
+ row: TimelineRow;
223
+ time: number;
224
+ }) => void;
225
+ /**
226
+ * @description Double click row callback
227
+ */
228
+ onDoubleClickRow?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
229
+ row: TimelineRow;
230
+ time: number;
231
+ }) => void;
232
+ /**
233
+ * @description Double click action callback
234
+ */
235
+ onDoubleClickAction?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
236
+ action: TimelineAction;
237
+ row: TimelineRow;
238
+ time: number;
239
+ }) => void;
240
+ /**
241
+ * @description Right click row callback
242
+ */
243
+ onContextMenuRow?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
244
+ row: TimelineRow;
245
+ time: number;
246
+ }) => void;
247
+ /**
248
+ * @description Right click action callback
249
+ */
250
+ onContextMenuAction?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
251
+ action: TimelineAction;
252
+ row: TimelineRow;
253
+ time: number;
254
+ }) => void;
255
+ /**
256
+ * @description Get the list of action ids to show assist drag lines, calculated at move/resize start, defaults to all actions except the currently moving action
257
+ */
258
+ getAssistDragLineActionIds?: (params: {
259
+ action: TimelineAction;
260
+ editorData: TimelineRow[];
261
+ row: TimelineRow;
262
+ }) => string[];
263
+ /**
264
+ * @description Cursor drag start event
265
+ */
266
+ onCursorDragStart?: (time: number) => void;
267
+ /**
268
+ * @description Cursor drag end event
269
+ */
270
+ onCursorDragEnd?: (time: number) => void;
271
+ /**
272
+ * @description Cursor drag event
273
+ */
274
+ onCursorDrag?: (time: number) => void;
275
+ /**
276
+ * @description Click time area event, return false to prevent setting time
277
+ */
278
+ onClickTimeArea?: (time: number, e: React$1.MouseEvent<HTMLDivElement, MouseEvent>) => boolean | undefined;
279
+ /**
280
+ * @description Virtualization overscan count (unstable API, may change or be removed)
281
+ * @default 5
282
+ */
283
+ unstable_rowActionsOverscan?: number;
284
+ }
285
+ type ScrollToTimeBlock = "start" | "center" | "end";
286
+ interface ScrollToTimeOptions {
287
+ block?: ScrollToTimeBlock;
288
+ offset?: number;
289
+ /**
290
+ * @description Only scroll if the time is not currently visible in the viewport
291
+ * @default false
292
+ */
293
+ onlyIfNotVisible?: boolean;
294
+ behavior?: "instant" | "smooth" | "auto";
295
+ }
296
+ interface TimelineState {
297
+ readonly target: HTMLDivElement;
298
+ time: number;
299
+ getTime(): number;
300
+ setTime(time: number): void;
301
+ setScrollLeft: (val: number) => void;
302
+ setScrollTop: (val: number) => void;
303
+ scrollLeft: number;
304
+ scrollTop: number;
305
+ scrollToTime(time: number, options?: ScrollToTimeOptions): void;
306
+ getTimePixelPosition(time?: number): number;
307
+ }
308
+ /**
309
+ * Animation editor parameters
310
+ * @export
311
+ * @interface TimelineProp
312
+ */
313
+ interface TimelineEditor extends EditData {
314
+ /**
315
+ * @description Editing area scroll callback (used to control synchronization with editing row scrolling)
316
+ */
317
+ onScroll?: (params: EventTarget & HTMLDivElement) => void;
318
+ /**
319
+ * @description Whether to enable auto scroll when dragging
320
+ * @default false
321
+ */
322
+ autoScroll?: boolean;
323
+ /**
324
+ * @description Auto scroll speed (default 1)
325
+ * @default 1
326
+ */
327
+ autoScrollSpeed?: number;
328
+ /**
329
+ * @description Auto scroll max speed (default 10)
330
+ * @default 10
331
+ */
332
+ autoScrollMaxSpeed?: number;
333
+ /**
334
+ * @description Custom timeline style
335
+ */
336
+ style?: React$1.CSSProperties;
337
+ /**
338
+ * @description Data change callback, triggered after action end changes data (return false to prevent automatic engine synchronization, used to reduce performance overhead)
339
+ */
340
+ onChange?: (editorData: TimelineRow[]) => void | boolean;
341
+ }
342
+ //#endregion
343
+ //#region src/components/timeline.d.ts
344
+ declare function Timeline({
345
+ ref,
346
+ ...props
347
+ }: TimelineEditor & {
348
+ ref?: React.RefObject<TimelineState | null>;
349
+ unstable_forceRemountEditorArea?: number;
350
+ }): React.JSX.Element;
351
+ //#endregion
352
+ export { type EditData, Timeline, type TimelineAction, type TimelineCursorPreviewRenderParams, type TimelineEditor, type TimelineEffect, type TimelineRow, type TimelineState };
@@ -0,0 +1,352 @@
1
+ import { n as TimelineRow, t as TimelineAction } from "./action-C-MnAPdg.mjs";
2
+ import * as React$1 from "react";
3
+ import React from "react";
4
+
5
+ //#region src/interface/effect.d.ts
6
+ interface TimelineEffect {
7
+ /** Effect id */
8
+ id: string;
9
+ /** Effect name */
10
+ name?: string;
11
+ }
12
+ //#endregion
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
+ };
22
+ interface EditData {
23
+ /**
24
+ * @description Timeline editing data
25
+ */
26
+ editorData: TimelineRow[];
27
+ /**
28
+ * @description Timeline action effects map
29
+ */
30
+ effects: Record<string, TimelineEffect>;
31
+ /**
32
+ * @description Single scale mark range (>0)
33
+ * @default 1
34
+ */
35
+ scale?: number;
36
+ /**
37
+ * @description Minimum number of scales (>=1)
38
+ * @default 20
39
+ */
40
+ minScaleCount?: number;
41
+ /**
42
+ * @description Maximum number of scales (>=minScaleCount)
43
+ * @default Infinity
44
+ */
45
+ maxScaleCount?: number;
46
+ /**
47
+ * @description Number of subdivision units per scale (>0 integer)
48
+ * @default 10
49
+ */
50
+ scaleSplitCount?: number;
51
+ /**
52
+ * @description Display width of a single scale (>0, unit: px)
53
+ * @default 160
54
+ */
55
+ scaleWidth?: number;
56
+ /**
57
+ * @description Distance from the left where the scale starts (>=0, unit: px)
58
+ * @default 20
59
+ */
60
+ startLeft?: number;
61
+ /**
62
+ * @description Default height of each editing row (>0, unit: px)
63
+ * @default 32
64
+ */
65
+ rowHeight?: number;
66
+ /**
67
+ * @description Default collapsed height for collapsible rows (>0, unit: px)
68
+ * @default rowHeight
69
+ */
70
+ collapsedRowHeight?: number;
71
+ /**
72
+ * @description Whether to enable grid snap
73
+ * @default false
74
+ */
75
+ gridSnap?: boolean;
76
+ /**
77
+ * @description Enable snap
78
+ * @default false
79
+ */
80
+ snap?: boolean;
81
+ /**
82
+ * @description Enable cursor snap to action endpoints when dragging
83
+ * @default false
84
+ */
85
+ cursorSnap?: boolean;
86
+ /**
87
+ * @description Whether to hide cursor
88
+ * @default false
89
+ */
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;
96
+ /**
97
+ * @description Disable dragging in all action areas
98
+ * @default false
99
+ */
100
+ disableDrag?: boolean;
101
+ /**
102
+ * @description Custom action area rendering
103
+ */
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;
124
+ /**
125
+ * @description Render custom content inside rows with no actions
126
+ */
127
+ getEmptyRowRender?: (params: {
128
+ row: TimelineRow;
129
+ height: number;
130
+ }) => React$1.ReactNode;
131
+ /**
132
+ * @description Render decorative content over a collapsible row only while it is collapsed
133
+ */
134
+ getCollapsedRowLabelRender?: (params: {
135
+ row: TimelineRow;
136
+ height: number;
137
+ }) => React$1.ReactNode;
138
+ /**
139
+ * @description Custom scale rendering
140
+ */
141
+ getScaleRender?: (scale: number) => React$1.ReactNode;
142
+ /**
143
+ * @description Start move callback
144
+ */
145
+ onActionMoveStart?: (params: {
146
+ action: TimelineAction;
147
+ row: TimelineRow;
148
+ }) => void;
149
+ /**
150
+ * @description Move callback (return false to prevent movement)
151
+ */
152
+ onActionMoving?: (params: {
153
+ action: TimelineAction;
154
+ row: TimelineRow;
155
+ start: number;
156
+ end: number;
157
+ }) => void | boolean;
158
+ /**
159
+ * @description Move end callback (return false to prevent onChange trigger)
160
+ */
161
+ onActionMoveEnd?: (params: {
162
+ action: TimelineAction;
163
+ row: TimelineRow;
164
+ start: number;
165
+ end: number;
166
+ }) => void;
167
+ /**
168
+ * @description Start resize callback
169
+ */
170
+ onActionResizeStart?: (params: {
171
+ action: TimelineAction;
172
+ row: TimelineRow;
173
+ dir: "right" | "left";
174
+ }) => void;
175
+ /**
176
+ * @description Resize callback (return false to prevent resize)
177
+ */
178
+ onActionResizing?: (params: {
179
+ action: TimelineAction;
180
+ row: TimelineRow;
181
+ start: number;
182
+ end: number;
183
+ dir: "right" | "left";
184
+ }) => void | boolean;
185
+ /**
186
+ * @description Resize end callback (return false to prevent onChange trigger)
187
+ */
188
+ onActionResizeEnd?: (params: {
189
+ action: TimelineAction;
190
+ row: TimelineRow;
191
+ start: number;
192
+ end: number;
193
+ dir: "right" | "left";
194
+ }) => void;
195
+ /**
196
+ * @description Click row callback
197
+ */
198
+ onClickRow?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
199
+ row: TimelineRow;
200
+ time: number;
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;
209
+ /**
210
+ * @description Click action callback
211
+ */
212
+ onClickAction?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
213
+ action: TimelineAction;
214
+ row: TimelineRow;
215
+ time: number;
216
+ }) => void;
217
+ /**
218
+ * @description Click action callback (not executed when drag is triggered)
219
+ */
220
+ onClickActionOnly?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
221
+ action: TimelineAction;
222
+ row: TimelineRow;
223
+ time: number;
224
+ }) => void;
225
+ /**
226
+ * @description Double click row callback
227
+ */
228
+ onDoubleClickRow?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
229
+ row: TimelineRow;
230
+ time: number;
231
+ }) => void;
232
+ /**
233
+ * @description Double click action callback
234
+ */
235
+ onDoubleClickAction?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
236
+ action: TimelineAction;
237
+ row: TimelineRow;
238
+ time: number;
239
+ }) => void;
240
+ /**
241
+ * @description Right click row callback
242
+ */
243
+ onContextMenuRow?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
244
+ row: TimelineRow;
245
+ time: number;
246
+ }) => void;
247
+ /**
248
+ * @description Right click action callback
249
+ */
250
+ onContextMenuAction?: (e: React$1.MouseEvent<HTMLElement, MouseEvent>, param: {
251
+ action: TimelineAction;
252
+ row: TimelineRow;
253
+ time: number;
254
+ }) => void;
255
+ /**
256
+ * @description Get the list of action ids to show assist drag lines, calculated at move/resize start, defaults to all actions except the currently moving action
257
+ */
258
+ getAssistDragLineActionIds?: (params: {
259
+ action: TimelineAction;
260
+ editorData: TimelineRow[];
261
+ row: TimelineRow;
262
+ }) => string[];
263
+ /**
264
+ * @description Cursor drag start event
265
+ */
266
+ onCursorDragStart?: (time: number) => void;
267
+ /**
268
+ * @description Cursor drag end event
269
+ */
270
+ onCursorDragEnd?: (time: number) => void;
271
+ /**
272
+ * @description Cursor drag event
273
+ */
274
+ onCursorDrag?: (time: number) => void;
275
+ /**
276
+ * @description Click time area event, return false to prevent setting time
277
+ */
278
+ onClickTimeArea?: (time: number, e: React$1.MouseEvent<HTMLDivElement, MouseEvent>) => boolean | undefined;
279
+ /**
280
+ * @description Virtualization overscan count (unstable API, may change or be removed)
281
+ * @default 5
282
+ */
283
+ unstable_rowActionsOverscan?: number;
284
+ }
285
+ type ScrollToTimeBlock = "start" | "center" | "end";
286
+ interface ScrollToTimeOptions {
287
+ block?: ScrollToTimeBlock;
288
+ offset?: number;
289
+ /**
290
+ * @description Only scroll if the time is not currently visible in the viewport
291
+ * @default false
292
+ */
293
+ onlyIfNotVisible?: boolean;
294
+ behavior?: "instant" | "smooth" | "auto";
295
+ }
296
+ interface TimelineState {
297
+ readonly target: HTMLDivElement;
298
+ time: number;
299
+ getTime(): number;
300
+ setTime(time: number): void;
301
+ setScrollLeft: (val: number) => void;
302
+ setScrollTop: (val: number) => void;
303
+ scrollLeft: number;
304
+ scrollTop: number;
305
+ scrollToTime(time: number, options?: ScrollToTimeOptions): void;
306
+ getTimePixelPosition(time?: number): number;
307
+ }
308
+ /**
309
+ * Animation editor parameters
310
+ * @export
311
+ * @interface TimelineProp
312
+ */
313
+ interface TimelineEditor extends EditData {
314
+ /**
315
+ * @description Editing area scroll callback (used to control synchronization with editing row scrolling)
316
+ */
317
+ onScroll?: (params: EventTarget & HTMLDivElement) => void;
318
+ /**
319
+ * @description Whether to enable auto scroll when dragging
320
+ * @default false
321
+ */
322
+ autoScroll?: boolean;
323
+ /**
324
+ * @description Auto scroll speed (default 1)
325
+ * @default 1
326
+ */
327
+ autoScrollSpeed?: number;
328
+ /**
329
+ * @description Auto scroll max speed (default 10)
330
+ * @default 10
331
+ */
332
+ autoScrollMaxSpeed?: number;
333
+ /**
334
+ * @description Custom timeline style
335
+ */
336
+ style?: React$1.CSSProperties;
337
+ /**
338
+ * @description Data change callback, triggered after action end changes data (return false to prevent automatic engine synchronization, used to reduce performance overhead)
339
+ */
340
+ onChange?: (editorData: TimelineRow[]) => void | boolean;
341
+ }
342
+ //#endregion
343
+ //#region src/components/timeline.d.ts
344
+ declare function Timeline({
345
+ ref,
346
+ ...props
347
+ }: TimelineEditor & {
348
+ ref?: React.RefObject<TimelineState | null>;
349
+ unstable_forceRemountEditorArea?: number;
350
+ }): React.JSX.Element;
351
+ //#endregion
352
+ export { type EditData, Timeline, type TimelineAction, type TimelineCursorPreviewRenderParams, type TimelineEditor, type TimelineEffect, type TimelineRow, type TimelineState };