awesome-timeline-react 0.1.14 → 0.2.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.
@@ -1,329 +1,738 @@
1
- /// <reference types="react" />
2
-
3
- import { Context } from "react";
4
- import { CSSProperties } from "react";
5
- import { default as React_2 } from "react";
6
-
7
- declare type ContentType = {
8
- rows: RowType[];
9
- events: EventType[];
10
- staticEvents?: EventType[];
11
- setEvents: React_2.Dispatch<React_2.SetStateAction<EventType[]>>;
12
- tick: number | null;
13
- windowTime: number[];
14
- cellWidth: number;
15
- setWindowTime: React_2.Dispatch<React_2.SetStateAction<number[]>>;
16
- contentWidth: number | null;
17
- setCellWidth: React_2.Dispatch<React_2.SetStateAction<number>>;
18
- bodyRef: React_2.MutableRefObject<HTMLDivElement | null>;
19
- lineClassName?: string;
20
- };
21
-
22
- export declare const default_alias: {
23
- title: string;
24
- };
25
-
26
- export declare const default_alias_1: React_2.ForwardRefExoticComponent<
27
- ContentType & React_2.RefAttributes<HTMLDivElement>
28
- >;
29
-
30
- export declare const default_alias_10: ({
31
- id,
32
- startPosition,
33
- width,
34
- top,
35
- height,
36
- }: {
37
- id: string;
38
- startPosition: CSSProperties["left"];
39
- width: CSSProperties["width"];
40
- top: CSSProperties["top"];
41
- height: CSSProperties["height"];
42
- }) => React_2.JSX.Element;
43
-
44
- export declare const default_alias_11: ({
45
- windowTime,
46
- tick,
47
- contentWidth,
48
- scrollWidth,
49
- additionalClassNames,
50
- }: {
51
- windowTime: number[];
52
- tick: number | null;
53
- contentWidth: number | null;
54
- scrollWidth: number;
55
- additionalClassNames?: PartialRecord<keyof ModifableElements, string>;
56
- }) => React_2.JSX.Element;
57
-
58
- export declare const default_alias_12: (monthIndex: number) => string;
59
-
60
- export declare const default_alias_13: (dayIndex: number) => string;
61
-
62
- export declare const default_alias_14: (
63
- eventA: EventType,
64
- eventB: EventType
65
- ) => 1 | -1;
66
-
67
- export declare const default_alias_15: ({
68
- windowTime,
69
- tick,
70
- contentWidth,
71
- blockWidth,
72
- }: {
73
- windowTime: number[];
74
- tick: number | null;
75
- contentWidth: number | null;
76
- blockWidth: number;
77
- }) => {
78
- dayBlocks: JSX.Element[];
79
- hourBlocks: JSX.Element[];
80
- };
81
-
82
- export declare const default_alias_16: ({
83
- windowTime,
84
- contentWidth,
85
- }: {
86
- windowTime: number[];
87
- contentWidth: number | null;
88
- }) => {
89
- numberOfHourBlocks: number;
90
- blockWidth: number;
91
- };
92
-
93
- export declare const default_alias_17: ({
94
- bodyRef,
95
- rowsContentRef,
96
- }: {
97
- bodyRef: React.MutableRefObject<HTMLDivElement | null>;
98
- rowsContentRef: React.MutableRefObject<HTMLDivElement[] | null>;
99
- }) => void;
100
-
101
- export declare const default_alias_18: ({
102
- rows,
103
- windowTime,
104
- tick,
105
- events,
106
- staticEvents,
107
- cellWidth,
108
- setEvents,
109
- bodyRef,
110
- }: ProduceContentType) => React_2.JSX.Element[];
111
-
112
- export declare const default_alias_19: ({
113
- windowTime,
114
- setTick,
115
- setCellWidth,
116
- contentRef,
117
- }: {
118
- windowTime: number[];
119
- setTick: React.Dispatch<React.SetStateAction<number | null>>;
120
- setCellWidth: React.Dispatch<React.SetStateAction<number>>;
121
- contentRef: React.MutableRefObject<HTMLDivElement | null>;
122
- }) => void;
123
-
124
- export declare const default_alias_2: React_2.ForwardRefExoticComponent<
125
- EventPromptType & React_2.RefAttributes<EventPromptActionsType>
126
- >;
127
-
128
- export declare const default_alias_3: ({
129
- eventData,
130
- startPosition,
131
- width,
132
- top,
133
- setEvents,
134
- tick,
135
- }: {
136
- eventData: EventType;
137
- startPosition: number;
138
- width: number;
139
- top: CSSProperties["top"];
140
- setEvents: React_2.Dispatch<React_2.SetStateAction<EventType[]>>;
141
- tick: number | null;
142
- }) => React_2.JSX.Element;
143
-
144
- export declare const default_alias_4: ({
145
- contentWidth,
146
- cellWidth,
147
- lineClassName,
148
- }: {
149
- contentWidth: number | null;
150
- cellWidth: number;
151
- lineClassName?: string;
152
- }) => React_2.JSX.Element;
153
-
154
- export declare const default_alias_5: () => React_2.JSX.Element;
155
-
156
- export declare const default_alias_6: React_2.ForwardRefExoticComponent<
157
- RowContentProps & {
158
- children?: React_2.ReactNode;
159
- } & React_2.RefAttributes<HTMLDivElement>
160
- >;
161
-
162
- export declare const default_alias_7: ({
163
- name,
164
- id,
165
- }: {
166
- name: string;
167
- id: string;
168
- }) => React_2.JSX.Element;
169
-
170
- export declare const default_alias_8: ({
171
- rows,
172
- className,
173
- }: {
174
- rows: RowType[];
175
- className?: string;
176
- }) => React_2.JSX.Element;
177
-
178
- export declare const default_alias_9: ({
179
- tick,
180
- windowTime,
181
- }: {
182
- tick: number | null;
183
- windowTime: number[];
184
- }) => React_2.JSX.Element;
185
-
186
- export declare const DragStartedContext: Context<DragStartedContext_2>;
187
-
188
- declare type DragStartedContext_2 = {
189
- dragStarted: boolean;
190
- setDragStarted: React.Dispatch<React.SetStateAction<boolean>>;
191
- };
192
-
193
- export declare type EventPromptActionsType = {
194
- setDisplay: (value: string) => void;
195
- setRight: (value: string) => void;
196
- setBottom: (value: string) => void;
197
- setEvent: (event: EventType) => void;
198
- };
199
-
200
- declare type EventPromptType = {
201
- template?: (metadata?: any) => JSX.Element;
202
- };
203
-
204
- export declare type EventPropsType = {
205
- isLocked?: boolean;
206
- content?: JSX.Element | string;
207
- classNames?: string[];
208
- isResizable?: boolean;
209
- showPrompt?: boolean;
210
- metadata?: any;
211
- };
212
-
213
- export declare type EventType = {
214
- id: string;
215
- rowId: string;
216
- startTime: number;
217
- endTime: number;
218
- props?: EventPropsType;
219
- };
220
-
221
- export declare const ExternalPropertiesContext: Context<ExternalPropertiesType>;
222
-
223
- declare type ExternalPropertiesType = {
224
- onDrop?: (props: OnDropProps) => void;
225
- onResize?: (props: OnResizeProps) => void;
226
- eventsResize?: boolean;
227
- eventPromptRef?: React.MutableRefObject<EventPromptActionsType | null>;
228
- };
229
-
230
- export declare type ModifableElements = {
231
- timeBar: string;
232
- dayRow: string;
233
- hourRow: string;
234
- gridLine: string;
235
- rowsHeader: string;
236
- };
237
-
238
- export declare type OnDropProps = {
239
- eventId: string;
240
- oldRowId: string;
241
- newRowId: string;
242
- startTime: number;
243
- endTime: number;
244
- };
245
-
246
- export declare type OnResizeProps = {
247
- eventId: string;
248
- startTime: number;
249
- endTime: number;
250
- };
251
-
252
- export declare type PartialRecord<K extends keyof any, T> = Partial<
253
- Record<K, T>
254
- >;
255
-
256
- declare type ProduceContentType = {
257
- rows: RowType[];
258
- events: EventType[];
259
- staticEvents?: EventType[];
260
- setEvents: React_2.Dispatch<React_2.SetStateAction<EventType[]>>;
261
- tick: number | null;
262
- windowTime: number[];
263
- cellWidth: number;
264
- bodyRef: React_2.MutableRefObject<HTMLDivElement | null>;
265
- };
266
-
267
- declare type RowContentProps = {
268
- id: string;
269
- setEvents: React_2.Dispatch<React_2.SetStateAction<EventType[]>>;
270
- tick: number | null;
271
- windowTime: number[];
272
- cellWidth: number;
273
- };
274
-
275
- export declare const RowsHeightContext: Context<RowsHeightContextType | null>;
276
-
277
- declare type RowsHeightContextType = {
278
- rowsHeight: Record<string, RowsHeightType> | null;
279
- setRowsHeight: React.Dispatch<
280
- React.SetStateAction<Record<string, RowsHeightType> | null>
281
- >;
282
- allRowsHeight: number;
283
- setAllRowsHeight: React.Dispatch<React.SetStateAction<number>>;
284
- };
285
-
286
- export declare type RowsHeightType = {
287
- minHeight: number;
288
- };
289
-
290
- export declare type RowType = {
291
- id: string;
292
- name: string;
293
- };
294
-
295
- declare const Timeline: ({
296
- rows,
297
- events,
298
- staticEvents,
299
- onDrop,
300
- onResize,
301
- startDate,
302
- endDate,
303
- additionalClassNames,
304
- showRTIndicator,
305
- eventsResize,
306
- eventPromptTemplate,
307
- showEventPrompt,
308
- }: TimelineType) => React_2.JSX.Element;
309
- export { Timeline };
310
- export { Timeline as Timeline_alias_1 };
311
-
312
- export declare const TimelinePrimary: () => React_2.JSX.Element;
313
-
314
- export declare type TimelineType = {
315
- rows: RowType[];
316
- events: EventType[];
317
- staticEvents?: EventType[];
318
- onDrop?: (props: OnDropProps) => void;
319
- onResize?: (props: OnResizeProps) => void;
320
- startDate: Date;
321
- endDate: Date;
322
- additionalClassNames?: PartialRecord<keyof ModifableElements, string>;
323
- showRTIndicator?: boolean;
324
- eventsResize?: boolean;
325
- eventPromptTemplate?: (event: EventType) => JSX.Element;
326
- showEventPrompt?: boolean;
327
- };
328
-
329
- export {};
1
+ import { default as React_2 } from 'react';
2
+
3
+ /**
4
+ * Layout animation configuration. `false` disables all animations;
5
+ * an object tunes the durations (0 disables that animation).
6
+ */
7
+ export declare type AnimationConfig = boolean | {
8
+ /** event stacking / row height tween, ms (default 200) */
9
+ layoutMs?: number;
10
+ /** resize-handle fade, ms (default 120) */
11
+ fadeMs?: number;
12
+ };
13
+
14
+ /**
15
+ * Assigns a vertical lane (stacking order) to each window-visible event of a
16
+ * single row. Faithful extraction of the algorithm previously inlined in
17
+ * use-produce-content.tsx — including its quirks:
18
+ *
19
+ * - Events outside [windowStart, windowEnd] are skipped and do not influence
20
+ * lane assignment at all.
21
+ * - The occupancy scan for an event only covers lanes 0..eventOrder (the lane
22
+ * of the previously placed event), not every tracked lane.
23
+ * - Touching events (prev.endTime === next.startTime) do not overlap.
24
+ *
25
+ * `rowEvents` must already be filtered to one row and sorted with
26
+ * helpers/sort-events (startTime asc, endTime asc).
27
+ */
28
+ export declare const assignLanes: (rowEvents: EventType[], windowStart: number, windowEnd: number) => LaneResult;
29
+
30
+ /** Eligibility: same expression as the legacy Event component's render guard. */
31
+ export declare const canResizeEvent: (event: EventType, eventsResize: boolean) => boolean;
32
+
33
+ declare type CanvasBoardProps = {
34
+ scene: SceneStore;
35
+ rows: RowType[];
36
+ windowTime: number[];
37
+ tick: number | null;
38
+ cellWidth: number;
39
+ theme: ResolvedTheme;
40
+ drawEvent?: DrawEventFn;
41
+ bodyRef: React_2.MutableRefObject<HTMLDivElement | null>;
42
+ rendererRef: React_2.MutableRefObject<TimelineRenderer | null>;
43
+ eventPromptRef: React_2.MutableRefObject<EventPromptActionsType | null>;
44
+ rowsHeaderClassName?: string;
45
+ setWindowTime: React_2.Dispatch<React_2.SetStateAction<number[]>>;
46
+ setCellWidth: React_2.Dispatch<React_2.SetStateAction<number>>;
47
+ onDrop?: (props: OnDropProps) => void;
48
+ onResize?: (props: OnResizeProps) => void;
49
+ onEventClick?: (props: OnEventClickProps) => void;
50
+ onEventHover?: (props: OnEventHoverProps) => void;
51
+ eventsResize: boolean;
52
+ panZoom?: PanZoomConfig;
53
+ animations: {
54
+ layoutMs: number;
55
+ fadeMs: number;
56
+ };
57
+ };
58
+
59
+ /** Drop: same cell-snap as row-content.tsx handleOnDrop. */
60
+ export declare const computeDropTimes: ({ pointerX, cellWidth, tick, windowStart, duration, }: {
61
+ pointerX: number;
62
+ cellWidth: number;
63
+ tick: number;
64
+ windowStart: number;
65
+ duration: number;
66
+ }) => {
67
+ startTime: number;
68
+ endTime: number;
69
+ };
70
+
71
+ /**
72
+ * Resize: same rounding and duration-must-stay-positive guard as
73
+ * event.tsx handleDocumentOnMouseUp. Returns null when the resize would
74
+ * collapse or invert the event (legacy keeps the old value silently).
75
+ */
76
+ export declare const computeResizeTimes: (event: Pick<EventType, "startTime" | "endTime">, deltaPx: number, // raw pointer delta (clientX - initial), sign preserved
77
+ tick: number, direction: "left" | "right") => {
78
+ startTime: number;
79
+ endTime: number;
80
+ } | null;
81
+
82
+ /**
83
+ * Returns the window-visible slice of a startTime-sorted event array.
84
+ * Binary search cuts the tail (startTime > windowEnd) in O(log n); the head
85
+ * is filtered linearly on endTime, which cannot be binary-searched on a
86
+ * startTime ordering.
87
+ */
88
+ export declare const cullToWindow: (events: EventType[], windowStart: number, windowEnd: number) => EventType[];
89
+
90
+ export declare const default_alias: {
91
+ title: string;
92
+ };
93
+
94
+ /**
95
+ * Canvas board: two viewport-sized canvases (grid + events) kept fixed
96
+ * inside the scrolling body via position:sticky, with a tall spacer div
97
+ * providing the native scrollbar. Drawing is translated by scrollTop, so the
98
+ * canvas never exceeds browser size limits regardless of row count.
99
+ *
100
+ * The forwarded ref targets the content column — the element timeline.tsx
101
+ * measures for tick/cellWidth.
102
+ */
103
+ export declare const default_alias_1: React_2.ForwardRefExoticComponent<CanvasBoardProps & React_2.RefAttributes<HTMLDivElement>>;
104
+
105
+ export declare const default_alias_10: ({ windowTime, setTick, setCellWidth, contentRef, }: {
106
+ windowTime: number[];
107
+ setTick: React.Dispatch<React.SetStateAction<number | null>>;
108
+ setCellWidth: React.Dispatch<React.SetStateAction<number>>;
109
+ contentRef: React.MutableRefObject<HTMLDivElement | null>;
110
+ }) => void;
111
+
112
+ export declare const default_alias_2: ({ windowTime, tick, contentWidth, scrollWidth, theme, }: {
113
+ windowTime: number[];
114
+ tick: number | null;
115
+ contentWidth: number | null;
116
+ scrollWidth: number;
117
+ theme?: ResolvedTheme;
118
+ }) => React_2.JSX.Element;
119
+
120
+ /**
121
+ * Hover tooltip for events. Positioned with @floating-ui/dom against the
122
+ * hovered event's rect (viewport coordinates): preferred above the event,
123
+ * flips below when there is no room, and shifts horizontally to stay
124
+ * on-screen.
125
+ */
126
+ export declare const default_alias_3: React_2.ForwardRefExoticComponent<EventPromptType & React_2.RefAttributes<EventPromptActionsType>>;
127
+
128
+ export declare const default_alias_4: ({ tick, windowTime, }: {
129
+ tick: number | null;
130
+ windowTime: number[];
131
+ }) => React_2.JSX.Element;
132
+
133
+ export declare const default_alias_5: (monthIndex: number) => string;
134
+
135
+ export declare const default_alias_6: (dayIndex: number) => string;
136
+
137
+ export declare const default_alias_7: (eventA: EventType, eventB: EventType) => 1 | -1;
138
+
139
+ /**
140
+ * Pointer-event state machine for the canvas board: pan the time window,
141
+ * drag events between rows/times (DOM ghost preview), resize event edges,
142
+ * change grid granularity (middle-click mode or ctrl+wheel). Event mutations
143
+ * are applied straight to the SceneStore — no React state on the hot path.
144
+ */
145
+ export declare const default_alias_8: ({ scene, rendererRef, dynamicCanvasRef, bodyRef, ghostRef, eventPromptRef, setWindowTime, setCellWidth, onDrop, onResize, onEventClick, onEventHover, eventsResize, panZoom, }: UseCanvasInteractionsArgs) => {
146
+ handlePointerDown: (pointerEvent: React_2.PointerEvent<HTMLCanvasElement>) => void;
147
+ handlePointerMove: (pointerEvent: React_2.PointerEvent<HTMLCanvasElement>) => void;
148
+ handlePointerUp: (pointerEvent: React_2.PointerEvent<HTMLCanvasElement>) => void;
149
+ handlePointerLeave: () => void;
150
+ handleAuxClick: (pointerEvent: React_2.MouseEvent<HTMLCanvasElement>) => void;
151
+ };
152
+
153
+ export declare const default_alias_9: ({ windowTime, contentWidth, }: {
154
+ windowTime: number[];
155
+ contentWidth: number | null;
156
+ }) => {
157
+ numberOfHourBlocks: number;
158
+ blockWidth: number;
159
+ };
160
+
161
+ export declare const DEFAULT_FADE_DURATION_MS = 120;
162
+
163
+ export declare const DEFAULT_LAYOUT_DURATION_MS = 200;
164
+
165
+ /** Defaults mirror the pre-0.2.0 stylesheet values. */
166
+ export declare const DEFAULT_THEME: ResolvedTheme;
167
+
168
+ /**
169
+ * Custom canvas renderer for an event. Return false to fall through to the
170
+ * library's default drawing.
171
+ */
172
+ declare type DrawEventFn = (ctx: CanvasRenderingContext2D, event: EventType, rect: Rect, state: EventState, theme: ResolvedTheme) => void | false;
173
+ export { DrawEventFn }
174
+ export { DrawEventFn as DrawEventFn_alias_1 }
175
+
176
+ /**
177
+ * All window- and viewport-visible events in one pass. Rows fully outside
178
+ * the vertical viewport are skipped without touching their events. Custom
179
+ * renderers resolve per-event drawEvent -> Timeline drawEvent -> default.
180
+ */
181
+ export declare const drawEvents: (ctx: CanvasRenderingContext2D, view: RendererView, scene: SceneStore, font: string, animator: LayoutAnimator) => void;
182
+
183
+ /**
184
+ * Vertical grid lines, one per cellWidth — canvas replacement for the ~N
185
+ * line divs of lines-canvas.tsx. Matches the legacy "hide-last-line"
186
+ * behavior: no line within 1px of the right edge.
187
+ */
188
+ export declare const drawGridLines: (ctx: CanvasRenderingContext2D, { width, height, cellWidth, color, }: {
189
+ width: number;
190
+ height: number;
191
+ cellWidth: number;
192
+ color?: string;
193
+ }) => void;
194
+
195
+ /** Horizontal row dividers — replaces .row-content border-bottom. */
196
+ export declare const drawRowDividers: (ctx: CanvasRenderingContext2D, view: RendererView, scene: SceneStore, animator: LayoutAnimator) => void;
197
+
198
+ /**
199
+ * Day row over hour row — canvas replacement for the day/hour block divs of
200
+ * time-bar.tsx. Background is left transparent so the .time-bar container
201
+ * color shows through, exactly like the DOM blocks did.
202
+ */
203
+ export declare const drawTimeBar: (ctx: CanvasRenderingContext2D, { width, height, dayBlocks, hourBlocks, font, borderColor, textColor, }: {
204
+ width: number;
205
+ height: number;
206
+ font: string;
207
+ borderColor?: string;
208
+ textColor?: string;
209
+ } & TimeBlocks) => void;
210
+
211
+ export declare const EVENT_BAR_HEIGHT = 20;
212
+
213
+ export declare const EVENT_RADIUS = 5;
214
+
215
+ /** Imperative event mutation, applied without React re-renders. */
216
+ declare type EventPatch = {
217
+ op: "upsert";
218
+ event: EventType;
219
+ } | {
220
+ op: "update";
221
+ id: string;
222
+ changes: Partial<Omit<EventType, "id">>;
223
+ } | {
224
+ op: "remove";
225
+ id: string;
226
+ };
227
+ export { EventPatch }
228
+ export { EventPatch as EventPatch_alias_1 }
229
+ export { EventPatch as EventPatch_alias_2 }
230
+
231
+ export declare type EventPromptActionsType = {
232
+ /** show the prompt for an event, anchored to its rect (viewport coords) */
233
+ show: (event: EventType, anchorRect: Rect) => void;
234
+ hide: () => void;
235
+ };
236
+
237
+ declare type EventPromptType = {
238
+ template?: (event: EventType) => JSX.Element;
239
+ };
240
+
241
+ declare type EventPropsType = {
242
+ isLocked?: boolean;
243
+ isResizable?: boolean;
244
+ showPrompt?: boolean;
245
+ /** plain-text label drawn inside the bar (was `content` before 0.2.0) */
246
+ label?: string;
247
+ /** per-event appearance (was `classNames` before 0.2.0) */
248
+ style?: EventStyle;
249
+ /** per-event custom renderer; overrides the Timeline-level drawEvent */
250
+ drawEvent?: DrawEventFn;
251
+ /** arbitrary data for eventPromptTemplate */
252
+ metadata?: unknown;
253
+ };
254
+ export { EventPropsType }
255
+ export { EventPropsType as EventPropsType_alias_1 }
256
+
257
+ /** Interaction state passed to custom drawEvent renderers. */
258
+ declare type EventState = {
259
+ hovered: boolean;
260
+ dragging: boolean;
261
+ resizing: boolean;
262
+ selected: boolean;
263
+ };
264
+ export { EventState }
265
+ export { EventState as EventState_alias_1 }
266
+
267
+ /** Per-event appearance overrides, merged over the theme defaults. */
268
+ declare type EventStyle = {
269
+ fill?: string;
270
+ stroke?: string;
271
+ strokeWidth?: number;
272
+ textColor?: string;
273
+ font?: string;
274
+ borderRadius?: number;
275
+ opacity?: number;
276
+ };
277
+ export { EventStyle }
278
+ export { EventStyle as EventStyle_alias_1 }
279
+
280
+ declare type EventType = {
281
+ id: string;
282
+ rowId: string;
283
+ startTime: number;
284
+ endTime: number;
285
+ props?: EventPropsType;
286
+ };
287
+ export { EventType }
288
+ export { EventType as EventType_alias_1 }
289
+
290
+ /**
291
+ * Coalesces invalidations into a single requestAnimationFrame callback.
292
+ * Any number of invalidate() calls within one frame produce exactly one
293
+ * onFrame() with the union of dirty layers — the backbone of 60fps under
294
+ * streaming updates.
295
+ */
296
+ export declare class FrameScheduler {
297
+ private onFrame;
298
+ private rafId;
299
+ private dirty;
300
+ constructor(onFrame: (dirty: LayerDirty) => void);
301
+ invalidate(layer: Layer | "all"): void;
302
+ /** Runs a pending frame immediately (tests, synchronous reads). */
303
+ flush(): void;
304
+ dispose(): void;
305
+ private schedule;
306
+ private run;
307
+ }
308
+
309
+ /**
310
+ * Pure extraction of the day/hour block generation previously inlined as JSX
311
+ * in use-generate-blocks.tsx. Same walk over the window, same Math.round
312
+ * block counting, same labels — but returns positioned data that both the
313
+ * canvas time bar and tests can consume.
314
+ */
315
+ export declare const generateTimeBlocks: ({ windowStart, tick, contentWidth, blockWidth, }: {
316
+ windowStart: number;
317
+ tick: number | null;
318
+ contentWidth: number | null;
319
+ blockWidth: number;
320
+ }) => TimeBlocks;
321
+
322
+ export declare type HitTarget = {
323
+ kind: "event" | "static";
324
+ event: EventType;
325
+ rowId: string;
326
+ /** rect in viewport (canvas CSS px) coordinates, scroll already applied */
327
+ rect: Rect;
328
+ };
329
+
330
+ /**
331
+ * Point query against the scene at viewport coordinates (x, y).
332
+ * Finds the row by accumulated heights, then scans that row's window-visible
333
+ * events back-to-front (interactive events sit above static ones, later
334
+ * events draw above earlier ones). Per-row event counts are small, so the
335
+ * scan after the row/window cut is cheap — no spatial index needed.
336
+ */
337
+ export declare const hitTest: (scene: SceneStore, view: HitTestView, x: number, y: number) => HitTarget | null;
338
+
339
+ export declare type HitTestView = {
340
+ windowStart: number;
341
+ windowEnd: number;
342
+ tick: number;
343
+ scrollTop: number;
344
+ };
345
+
346
+ export declare const intersectsWindow: (event: EventType, windowStart: number, windowEnd: number) => boolean;
347
+
348
+ export declare const LANE_HEIGHT = 22;
349
+
350
+ export declare const LANE_TOP_OFFSET = 10;
351
+
352
+ export declare type LaneResult = {
353
+ laneOf: Map<string, number>;
354
+ highestLane: number;
355
+ };
356
+
357
+ export declare const laneTop: (lane: number) => number;
358
+
359
+ export declare type Layer = "static" | "dynamic";
360
+
361
+ export declare type LayerDirty = {
362
+ static: boolean;
363
+ dynamic: boolean;
364
+ };
365
+
366
+ /**
367
+ * Replaces the CSS transitions the DOM renderer got for free:
368
+ * row heights and event tops tween when stacking changes, and resize
369
+ * handles fade in/out. Values are queried per frame; while any tween is
370
+ * live the renderer keeps scheduling frames.
371
+ *
372
+ * Durations are configurable via the Timeline `animations` prop; a duration
373
+ * of 0 disables that animation (values jump straight to target).
374
+ *
375
+ * Coordinate rules: row heights are content-space; event tops are
376
+ * ROW-LOCAL lane offsets. Tweens must never target a value that is itself
377
+ * animated (e.g. an absolute top including the animated row position) —
378
+ * a moving target retargets every frame and the tween lags behind it
379
+ * perpetually, desyncing the layers.
380
+ */
381
+ export declare class LayoutAnimator {
382
+ private rowHeights;
383
+ private eventTops;
384
+ private handleAlphas;
385
+ private now;
386
+ private activeUntil;
387
+ private layoutDuration;
388
+ private fadeDuration;
389
+ setDurations(layoutMs: number, fadeMs: number): void;
390
+ beginFrame(now: number): void;
391
+ rowHeight(rowId: string, target: number): number;
392
+ eventTop(eventId: string, target: number): number;
393
+ /** 0..1 opacity of an event's resize handles; target 1 = hovered. */
394
+ handleAlpha(eventId: string, target: number): number;
395
+ isAnimating(): boolean;
396
+ /**
397
+ * Drop an event's top tween so its next draw renders at the target
398
+ * instantly — used on drag-drop commit, where the ghost already previewed
399
+ * the final position and a tween would feel like a rubber-band.
400
+ */
401
+ snapEventTop(eventId: string): void;
402
+ /** Drop all state, e.g. when the scene is reset wholesale. */
403
+ reset(): void;
404
+ private value;
405
+ private current;
406
+ }
407
+
408
+ export declare type ModifableElements = {
409
+ timeBar: string;
410
+ dayRow: string;
411
+ hourRow: string;
412
+ gridLine: string;
413
+ rowsHeader: string;
414
+ };
415
+
416
+ declare type OnDropProps = {
417
+ eventId: string;
418
+ oldRowId: string;
419
+ newRowId: string;
420
+ startTime: number;
421
+ endTime: number;
422
+ };
423
+ export { OnDropProps }
424
+ export { OnDropProps as OnDropProps_alias_1 }
425
+
426
+ declare type OnEventClickProps = {
427
+ eventId: string;
428
+ rowId: string;
429
+ nativeEvent: PointerEvent;
430
+ modifiers: {
431
+ shift: boolean;
432
+ ctrl: boolean;
433
+ meta: boolean;
434
+ alt: boolean;
435
+ };
436
+ };
437
+ export { OnEventClickProps }
438
+ export { OnEventClickProps as OnEventClickProps_alias_1 }
439
+
440
+ declare type OnEventHoverProps = {
441
+ /** null when the pointer leaves all events */
442
+ eventId: string | null;
443
+ rowId: string | null;
444
+ };
445
+ export { OnEventHoverProps }
446
+ export { OnEventHoverProps as OnEventHoverProps_alias_1 }
447
+
448
+ declare type OnResizeProps = {
449
+ eventId: string;
450
+ startTime: number;
451
+ endTime: number;
452
+ };
453
+ export { OnResizeProps }
454
+ export { OnResizeProps as OnResizeProps_alias_1 }
455
+
456
+ declare type PanZoomConfig = {
457
+ /** drag the empty background to pan the time window (default true) */
458
+ panOnDragBackground?: boolean;
459
+ /** ctrl/cmd + wheel changes grid granularity (default true) */
460
+ ctrlWheelZoom?: boolean;
461
+ /** middle-click toggles wheel-granularity mode (default true) */
462
+ middleClickGranularity?: boolean;
463
+ /** seconds per granularity step (default 900 = 15 min) */
464
+ zoomStepSeconds?: number;
465
+ };
466
+ export { PanZoomConfig }
467
+ export { PanZoomConfig as PanZoomConfig_alias_1 }
468
+
469
+ export declare type PartialRecord<K extends keyof any, T> = Partial<Record<K, T>>;
470
+
471
+ declare type Rect = {
472
+ x: number;
473
+ y: number;
474
+ width: number;
475
+ height: number;
476
+ };
477
+ export { Rect }
478
+ export { Rect as Rect_alias_1 }
479
+ export { Rect as Rect_alias_2 }
480
+
481
+ export declare const rectContains: (rect: Rect, x: number, y: number) => boolean;
482
+
483
+ export declare type RendererView = {
484
+ windowTime: [number, number];
485
+ tick: number | null;
486
+ cellWidth: number;
487
+ scrollTop: number;
488
+ width: number;
489
+ height: number;
490
+ theme: ResolvedTheme;
491
+ drawEvent?: DrawEventFn;
492
+ eventsResize: boolean;
493
+ hoveredEventId: string | null;
494
+ draggedEventId: string | null;
495
+ resizePreview: ResizePreview | null;
496
+ };
497
+
498
+ export declare type ResizePreview = {
499
+ eventId: string;
500
+ deltaPx: number;
501
+ direction: "left" | "right";
502
+ };
503
+
504
+ declare type ResolvedTheme = Required<Omit<Theme, "font">> & Pick<Theme, "font">;
505
+ export { ResolvedTheme }
506
+ export { ResolvedTheme as ResolvedTheme_alias_1 }
507
+
508
+ export declare const resolveTheme: (theme?: Theme) => ResolvedTheme;
509
+
510
+ export declare const ROW_BASE_HEIGHT = 40;
511
+
512
+ export declare const rowMinHeight: (highestLane: number) => number;
513
+
514
+ declare type RowType = {
515
+ id: string;
516
+ name: string;
517
+ };
518
+ export { RowType }
519
+ export { RowType as RowType_alias_1 }
520
+
521
+ /**
522
+ * Imperative event store for the canvas renderer. Lives outside React state:
523
+ * streaming patches mutate it directly and the renderer reads from it per
524
+ * frame — React never reconciles individual event motion.
525
+ *
526
+ * Lane assignment (and therefore row height) is computed lazily per row, only
527
+ * when that row is queried for the current window. Bursts of patches against
528
+ * off-screen rows cost nothing beyond an index update.
529
+ */
530
+ export declare class SceneStore {
531
+ private rowIndexes;
532
+ private rowOrder;
533
+ private eventRow;
534
+ private listeners;
535
+ version: number;
536
+ setRows(rows: RowType[]): void;
537
+ setEvents(events: EventType[]): void;
538
+ setStaticEvents(events: EventType[]): void;
539
+ applyPatches(patches: EventPatch[]): void;
540
+ getEvent(id: string): EventType | undefined;
541
+ getRowIds(): string[];
542
+ getRow(rowId: string): RowType | undefined;
543
+ getRowEvents(rowId: string): EventType[];
544
+ getRowStaticEvents(rowId: string): EventType[];
545
+ getLanes(rowId: string, windowStart: number, windowEnd: number): LaneResult;
546
+ getRowHeight(rowId: string, windowStart: number, windowEnd: number): number;
547
+ /**
548
+ * y offset of each row's top edge (content coordinates, before scroll) plus
549
+ * the total content height — drives both drawing and the scroll spacer.
550
+ */
551
+ getRowOffsets(windowStart: number, windowEnd: number): {
552
+ offsetOf: Map<string, number>;
553
+ totalHeight: number;
554
+ };
555
+ subscribe(listener: () => void): () => void;
556
+ private insert;
557
+ private remove;
558
+ private bump;
559
+ }
560
+
561
+ /**
562
+ * Sizes a canvas backing store for the given devicePixelRatio and resets the
563
+ * context transform so ALL drawing code works in CSS pixels.
564
+ */
565
+ export declare const sizeCanvas: (canvas: HTMLCanvasElement, cssWidth: number, cssHeight: number, dpr: number) => CanvasRenderingContext2D | null;
566
+
567
+ export declare const STATIC_EVENT_BASE_HEIGHT = 20;
568
+
569
+ export declare const staticEventHeight: (highestLane: number) => number;
570
+
571
+ /** Grid granularity step: same clamp as content.tsx handleOnWheel. */
572
+ export declare const stepCellWidth: (cellWidth: number, deltaY: number, tick: number) => number;
573
+
574
+ /**
575
+ * Color/font tokens for everything drawn to canvas. Defaults mirror the
576
+ * pre-0.2.0 stylesheet. (Bar geometry — heights, lane spacing, radius — is
577
+ * not yet themeable.)
578
+ */
579
+ declare type Theme = {
580
+ eventFill?: string;
581
+ eventStroke?: string;
582
+ eventTextColor?: string;
583
+ staticEventFill?: string;
584
+ gridColor?: string;
585
+ timeBarBorder?: string;
586
+ timeBarTextColor?: string;
587
+ /** canvas text font; defaults to the canvas element's computed font */
588
+ font?: string;
589
+ };
590
+ export { Theme }
591
+ export { Theme as Theme_alias_1 }
592
+
593
+ export declare type TimeBlock = {
594
+ label: string;
595
+ x: number;
596
+ width: number;
597
+ };
598
+
599
+ export declare type TimeBlocks = {
600
+ dayBlocks: TimeBlock[];
601
+ hourBlocks: TimeBlock[];
602
+ };
603
+
604
+ declare const Timeline: React_2.ForwardRefExoticComponent<TimelineProps & React_2.RefAttributes<TimelineHandle>>;
605
+ export { Timeline }
606
+ export { Timeline as Timeline_alias_1 }
607
+
608
+ export declare const TimelineCanvas: () => React_2.JSX.Element;
609
+
610
+ /**
611
+ * Imperative handle for streaming/live updates: `const ref =
612
+ * useRef<TimelineHandle>(null); <Timeline ref={ref} ...>`.
613
+ *
614
+ * Reconciliation rule: the `events` PROP is authoritative whenever its
615
+ * reference changes — a new array resets the internal store and discards all
616
+ * imperative state. Pick one mode: declarative (swap the prop) or imperative
617
+ * (stable prop + handle calls).
618
+ */
619
+ declare type TimelineHandle = {
620
+ /** full replace of all events (does not touch the `events` prop) */
621
+ setEvents(events: EventType[]): void;
622
+ /** batched patches, coalesced into a single redraw per animation frame */
623
+ updateEvents(patches: EventPatch[]): void;
624
+ getEvent(id: string): EventType | undefined;
625
+ /** scroll vertically so the row is at the top of the viewport */
626
+ scrollToRow(rowId: string): void;
627
+ /** move the visible time window, preserving its duration */
628
+ scrollToTime(time: number): void;
629
+ /** set the visible time window explicitly (unix seconds) */
630
+ setWindow(startTime: number, endTime: number): void;
631
+ getVisibleRange(): {
632
+ startTime: number;
633
+ endTime: number;
634
+ };
635
+ /** force a full redraw of both canvas layers */
636
+ redraw(): void;
637
+ };
638
+ export { TimelineHandle }
639
+ export { TimelineHandle as TimelineHandle_alias_1 }
640
+
641
+ export declare const TimelinePrimary: () => React_2.JSX.Element;
642
+
643
+ declare type TimelineProps = {
644
+ rows: RowType[];
645
+ events: EventType[];
646
+ staticEvents?: EventType[];
647
+ startDate: Date;
648
+ endDate: Date;
649
+ onDrop?: (props: OnDropProps) => void;
650
+ onResize?: (props: OnResizeProps) => void;
651
+ onEventClick?: (props: OnEventClickProps) => void;
652
+ onEventHover?: (props: OnEventHoverProps) => void;
653
+ theme?: Theme;
654
+ drawEvent?: DrawEventFn;
655
+ /** only `rowsHeader` still applies — everything else is canvas-drawn (use `theme`) */
656
+ additionalClassNames?: PartialRecord<keyof ModifableElements, string>;
657
+ showRTIndicator?: boolean;
658
+ eventsResize?: boolean;
659
+ showEventPrompt?: boolean;
660
+ eventPromptTemplate?: (event: EventType) => JSX.Element;
661
+ panZoom?: PanZoomConfig;
662
+ /** layout animations: true (default), false to disable, or durations */
663
+ animations?: AnimationConfig;
664
+ };
665
+ export { TimelineProps }
666
+ export { TimelineProps as TimelineProps_alias_1 }
667
+
668
+ /**
669
+ * Owns the two viewport-sized canvases and the frame loop.
670
+ *
671
+ * - static layer: grid lines, day/hour bands, time bar (Phase 2)
672
+ * - dynamic layer: events (Phase 3)
673
+ *
674
+ * React pushes view-state via setView(); the SceneStore pushes data changes
675
+ * via its subscription. Both only flip dirty flags — actual drawing happens
676
+ * once per animation frame.
677
+ */
678
+ export declare class TimelineRenderer {
679
+ private staticCanvas;
680
+ private dynamicCanvas;
681
+ private scene;
682
+ private view;
683
+ readonly animator: LayoutAnimator;
684
+ private scheduler;
685
+ private unsubscribeScene;
686
+ private unwatchDpr;
687
+ private dpr;
688
+ private font;
689
+ constructor(staticCanvas: HTMLCanvasElement, dynamicCanvas: HTMLCanvasElement, scene: SceneStore);
690
+ getView(): RendererView;
691
+ setView(partial: Partial<RendererView>): void;
692
+ invalidate(layer: Layer | "all"): void;
693
+ /** Force a synchronous draw of anything pending (tests, screenshots). */
694
+ flush(): void;
695
+ dispose(): void;
696
+ private resizeCanvases;
697
+ private drawFrame;
698
+ }
699
+
700
+ /**
701
+ * 10k events across 500 rows with a fake websocket pushing 200 random
702
+ * event moves every 100ms through the imperative handle — zero React
703
+ * re-renders of the board on the hot path.
704
+ */
705
+ export declare const TimelineStreaming10k: () => React_2.JSX.Element;
706
+
707
+ /** @deprecated renamed to TimelineProps in 0.2.0 */
708
+ declare type TimelineType = TimelineProps;
709
+ export { TimelineType }
710
+ export { TimelineType as TimelineType_alias_1 }
711
+
712
+ export declare const timeToWidth: (startTime: number, endTime: number, tick: number) => number;
713
+
714
+ export declare const timeToX: (time: number, windowStart: number, tick: number) => number;
715
+
716
+ declare type UseCanvasInteractionsArgs = {
717
+ scene: SceneStore;
718
+ rendererRef: React_2.MutableRefObject<TimelineRenderer | null>;
719
+ dynamicCanvasRef: React_2.MutableRefObject<HTMLCanvasElement | null>;
720
+ bodyRef: React_2.MutableRefObject<HTMLDivElement | null>;
721
+ ghostRef: React_2.MutableRefObject<HTMLDivElement | null>;
722
+ eventPromptRef: React_2.MutableRefObject<EventPromptActionsType | null>;
723
+ setWindowTime: React_2.Dispatch<React_2.SetStateAction<number[]>>;
724
+ setCellWidth: React_2.Dispatch<React_2.SetStateAction<number>>;
725
+ onDrop?: (props: OnDropProps) => void;
726
+ onResize?: (props: OnResizeProps) => void;
727
+ onEventClick?: (props: OnEventClickProps) => void;
728
+ onEventHover?: (props: OnEventHoverProps) => void;
729
+ eventsResize: boolean;
730
+ panZoom?: PanZoomConfig;
731
+ };
732
+
733
+ /** Notifies when devicePixelRatio changes (browser zoom, monitor switch). */
734
+ export declare const watchDpr: (onChange: (dpr: number) => void) => (() => void);
735
+
736
+ export declare const xToTime: (x: number, windowStart: number, tick: number) => number;
737
+
738
+ export { }