@cyca/react-timeline-editor 0.2.4-alpha.6 → 0.2.5-alpha.1

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