awesome-timeline-react 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -1
- package/dist/_tsup-dts-rollup.d.mts +230 -10
- package/dist/_tsup-dts-rollup.d.ts +230 -10
- package/dist/index.css +9 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +705 -93
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +707 -93
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -48,6 +48,8 @@ The following properties for Timeline component are available:
|
|
|
48
48
|
- `label`: `string` (plain-text label drawn inside the event bar)
|
|
49
49
|
- `style`: `EventStyle` (per-event appearance: `fill`, `stroke`, `strokeWidth`, `textColor`, `font`, `borderRadius`, `opacity`)
|
|
50
50
|
- `drawEvent`: `DrawEventFn` (per-event custom canvas renderer, see below)
|
|
51
|
+
- `groupId`: `string` (connects this event to others sharing the same tag; Cmd/Ctrl+click selects the whole group — see Selection)
|
|
52
|
+
- `isSelectable`: `boolean` (set `false` to opt this event out of selection while the Timeline is `selectable`; default selectable)
|
|
51
53
|
- `isResizable`: `boolean` (defines if event is resizable, overrides the default property `eventsResize`)
|
|
52
54
|
- `showPrompt`: `boolean` (defines if prompt will be shown after hover. Works only if `showEventPrompt` is set as true)
|
|
53
55
|
- `metadata`: `unknown` (some data that can be used by event prompt template)
|
|
@@ -72,6 +74,12 @@ The following properties for Timeline component are available:
|
|
|
72
74
|
|
|
73
75
|
- `onEventHover` – callback when the hovered event changes (`eventId`/`rowId`, `null` on hover-out).
|
|
74
76
|
|
|
77
|
+
- `selectable` – enable click selection (default `false`). See Selection.
|
|
78
|
+
|
|
79
|
+
- `defaultSelectedEventIds` – initial selection (uncontrolled).
|
|
80
|
+
|
|
81
|
+
- `onSelectionChange` – callback fired with the selected event ids whenever the selection changes.
|
|
82
|
+
|
|
75
83
|
- `theme` – color/font tokens for everything drawn to canvas (see Theming).
|
|
76
84
|
|
|
77
85
|
- `drawEvent` – custom canvas renderer for all events (see Custom event rendering).
|
|
@@ -116,6 +124,11 @@ CSS classes cannot style canvas pixels, so canvas-drawn elements are themed with
|
|
|
116
124
|
gridColor: "#e4dcdc",
|
|
117
125
|
timeBarBorder: "yellow",
|
|
118
126
|
timeBarTextColor: "white",
|
|
127
|
+
// selection visuals (see Selection)
|
|
128
|
+
dimmedOpacity: 0.35, // opacity of non-selected events while a selection is active
|
|
129
|
+
selectionShadowColor: "rgba(0,0,0,0.35)", // lift shadow of selected events
|
|
130
|
+
selectionShadowBlur: 8,
|
|
131
|
+
selectionElevation: 2, // px the selected bar is lifted
|
|
119
132
|
font: "12px Inter", // defaults to the canvas element's computed font
|
|
120
133
|
// bar geometry — themeable since 0.2.x (defaults shown)
|
|
121
134
|
barHeight: 20, // event bar height
|
|
@@ -131,6 +144,121 @@ Bar geometry tokens drive row heights, lane stacking, hit-testing, and the drag
|
|
|
131
144
|
ghost together — changing `barHeight`/`laneGap` restacks and re-measures rows
|
|
132
145
|
automatically. (Per-event `style.borderRadius` still overrides `barRadius`.)
|
|
133
146
|
|
|
147
|
+
## Selection
|
|
148
|
+
|
|
149
|
+
Set `selectable` to enable click selection. A selected event is **elevated**
|
|
150
|
+
(drawn on top with a shadow) while every other event is **dimmed**
|
|
151
|
+
(`theme.dimmedOpacity`), so the current selection reads at a glance.
|
|
152
|
+
|
|
153
|
+
- **Click** an event → selects just that event.
|
|
154
|
+
- **Cmd/Ctrl + click** → selects the whole *connected group*: every event
|
|
155
|
+
sharing the clicked event's `props.groupId`. (An event with no `groupId`
|
|
156
|
+
selects only itself.)
|
|
157
|
+
- **Background click** or **Escape** → clears the selection.
|
|
158
|
+
|
|
159
|
+
Individual events can opt out with `props.isSelectable = false`: they can't be
|
|
160
|
+
clicked into the selection, are excluded from a group selection, and are ignored
|
|
161
|
+
by `setSelection`. Clicking a non-selectable event leaves the current selection
|
|
162
|
+
unchanged (it's transparent to selection, not a clear).
|
|
163
|
+
|
|
164
|
+
`onSelectionChange(eventIds)` fires on every change. Selection is uncontrolled —
|
|
165
|
+
seed it with `defaultSelectedEventIds` and drive it imperatively:
|
|
166
|
+
|
|
167
|
+
```tsx
|
|
168
|
+
const ref = useRef<TimelineHandle>(null);
|
|
169
|
+
ref.current?.setSelection(["a1", "a2"]); // replace the selection (no group expansion)
|
|
170
|
+
ref.current?.getSelection(); // string[]
|
|
171
|
+
|
|
172
|
+
<Timeline ref={ref} selectable onSelectionChange={(ids) => …} … />
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Selection is additive to `onEventClick` (both fire). Dragging and resizing
|
|
176
|
+
always operate on the single grabbed event, regardless of how many are selected.
|
|
177
|
+
|
|
178
|
+
> Follow-ups not yet implemented: rubber-band rectangle selection, group-drag
|
|
179
|
+
> (moving a whole selection together), and a controlled `selectedEventIds` prop.
|
|
180
|
+
|
|
181
|
+
## Grouped (collapsible) rows
|
|
182
|
+
|
|
183
|
+
Rows can be nested one level: give a row a `parentId` to make it a **child** of a
|
|
184
|
+
parent row. A **group-parent event** (`props.isGroupParent`) on the parent row
|
|
185
|
+
summarizes the **child events** that point at it via `props.parentEventId`:
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
const rows = [
|
|
189
|
+
{ id: "order", name: "Order #1001" }, // parent row
|
|
190
|
+
{ id: "weld", name: "Weld", parentId: "order" }, // child rows
|
|
191
|
+
{ id: "paint", name: "Paint", parentId: "order" },
|
|
192
|
+
];
|
|
193
|
+
|
|
194
|
+
const events = [
|
|
195
|
+
// the parent's startTime/endTime are derived — supplied values are just a
|
|
196
|
+
// fallback shown until it has children
|
|
197
|
+
{ id: "P", rowId: "order", startTime: 0, endTime: 0, props: { isGroupParent: true, label: "Order #1001" } },
|
|
198
|
+
{ id: "w", rowId: "weld", startTime: t1, endTime: t2, props: { parentEventId: "P" } },
|
|
199
|
+
{ id: "p", rowId: "paint", startTime: t3, endTime: t4, props: { parentEventId: "P" } },
|
|
200
|
+
];
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
Behavior:
|
|
204
|
+
|
|
205
|
+
- **Derived span** — the parent bar spans the earliest child `startTime` to the
|
|
206
|
+
latest child `endTime`, recomputed automatically as children move. A childless
|
|
207
|
+
parent keeps its supplied times.
|
|
208
|
+
- **Read-only parent** — a group-parent is never resizable and never draggable
|
|
209
|
+
(its bounds belong to its children). It stays clickable/selectable.
|
|
210
|
+
- **Group selection** — selecting a parent event (click, `setSelection`, …) also
|
|
211
|
+
selects all of its child events. Direction is parent → children only.
|
|
212
|
+
- **Collapse** — a parent row shows a caret in its header; collapsing it hides
|
|
213
|
+
the child rows while the summary bar stays. Collapse is **uncontrolled**: seed
|
|
214
|
+
it with `defaultCollapsedRowIds` and drive it imperatively. The state lives in
|
|
215
|
+
the timeline and **survives streaming updates / `setEvents` / `events`-prop
|
|
216
|
+
resets** — only a caret click or the handle changes it.
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
const ref = useRef<TimelineHandle>(null);
|
|
220
|
+
ref.current?.toggleRow("order"); // flip collapsed/expanded
|
|
221
|
+
ref.current?.setCollapsed("order", true); // collapse explicitly
|
|
222
|
+
|
|
223
|
+
<Timeline ref={ref} rows={rows} events={events} defaultCollapsedRowIds={["order"]} … />
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
List child rows immediately after their parent row in `rows` for the clearest
|
|
227
|
+
visual nesting. Unresolved `parentEventId` links are harmless — the event just
|
|
228
|
+
draws as a plain event.
|
|
229
|
+
|
|
230
|
+
> Follow-ups not yet implemented: parent batch-drag (time-shifting all children
|
|
231
|
+
> together), child-pinning to sibling rows, deeper nesting, and a controlled
|
|
232
|
+
> `collapsedRowIds` prop.
|
|
233
|
+
|
|
234
|
+
## Restricting where an event can be dropped
|
|
235
|
+
|
|
236
|
+
Give an event `props.droppableRowIds` to limit which rows it can be dragged onto:
|
|
237
|
+
|
|
238
|
+
```tsx
|
|
239
|
+
{ id: "weld", rowId: "r1", startTime, endTime,
|
|
240
|
+
props: { droppableRowIds: ["r1", "r3"] } } // only Welder / CNC
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
- `undefined` (default) → droppable onto any row.
|
|
244
|
+
- A list → a drag only commits if the target row is in it; otherwise the event
|
|
245
|
+
**snaps back** (no `onDrop`), and the cursor shows `not-allowed` while hovering
|
|
246
|
+
a disallowed row. An **empty array** pins the event to no row.
|
|
247
|
+
|
|
248
|
+
If an event's own `rowId` is not in its `droppableRowIds` (a misconfiguration),
|
|
249
|
+
the library records the problem on `props.metadata` so your app can flag it —
|
|
250
|
+
merging into any object you already stored there, and clearing automatically
|
|
251
|
+
once the event is on an allowed row:
|
|
252
|
+
|
|
253
|
+
```ts
|
|
254
|
+
import type { DroppableError } from "awesome-timeline-react";
|
|
255
|
+
|
|
256
|
+
const meta = event.props?.metadata as { droppableError?: DroppableError };
|
|
257
|
+
if (meta?.droppableError) {
|
|
258
|
+
// { rowId: "r4", droppableRowIds: ["r1", "r2"] } — surface it in your UI
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
134
262
|
## Time bar rows
|
|
135
263
|
|
|
136
264
|
The time bar has two rows. By default the top row shows calendar days and the
|
|
@@ -237,4 +365,6 @@ Here, we will store major features planned for future releases (from highest to
|
|
|
237
365
|
4. ~~Canvas rendering engine, virtualization, streaming API~~ - published in 0.2.0 version
|
|
238
366
|
5. ~~Customizable second row of the time bar~~ - `timeBar.topRow/bottomRow` (unit + format)
|
|
239
367
|
6. ~~Themeable bar geometry (heights, lane spacing, radius)~~ - `theme.barHeight/laneGap/rowPaddingY/barRadius`
|
|
240
|
-
7.
|
|
368
|
+
7. ~~Tag-based selection & multi-select~~ — `selectable`, `props.groupId`, Cmd/Ctrl+click selects the connected group, `setSelection`/`getSelection`. (Rubber-band selection and group-drag remain follow-ups.)
|
|
369
|
+
8. ~~Grouped (collapsible) rows~~ — `row.parentId`, `props.isGroupParent` + `parentEventId`, derived read-only parent span, parent→children selection, uncontrolled collapse (`defaultCollapsedRowIds`, `toggleRow`/`setCollapsed`). (Parent batch-drag and controlled collapse remain follow-ups.)
|
|
370
|
+
9. ~~Per-event drop-target restriction~~ — `props.droppableRowIds` limits drag targets (snap-back + `not-allowed` cursor); a misconfigured row is flagged via `metadata.droppableError`. (Auto child-pinning to sibling group rows remains a follow-up.)
|
|
@@ -27,7 +27,9 @@ export declare type AnimationConfig = boolean | {
|
|
|
27
27
|
*/
|
|
28
28
|
export declare const assignLanes: (rowEvents: EventType[], windowStart: number, windowEnd: number) => LaneResult;
|
|
29
29
|
|
|
30
|
-
/** Eligibility: same expression as the legacy Event component's render guard.
|
|
30
|
+
/** Eligibility: same expression as the legacy Event component's render guard.
|
|
31
|
+
* A group-parent (summary) event is never resizable — its span is derived from
|
|
32
|
+
* its children. */
|
|
31
33
|
export declare const canResizeEvent: (event: EventType, eventsResize: boolean) => boolean;
|
|
32
34
|
|
|
33
35
|
declare type CanvasBoardProps = {
|
|
@@ -55,6 +57,9 @@ declare type CanvasBoardProps = {
|
|
|
55
57
|
layoutMs: number;
|
|
56
58
|
fadeMs: number;
|
|
57
59
|
};
|
|
60
|
+
selectable: boolean;
|
|
61
|
+
applySelection: (eventIds: string[]) => void;
|
|
62
|
+
getSelection: () => string[];
|
|
58
63
|
};
|
|
59
64
|
|
|
60
65
|
/**
|
|
@@ -162,7 +167,7 @@ export declare const default_alias_7: (eventA: EventType, eventB: EventType) =>
|
|
|
162
167
|
* change grid granularity (middle-click mode or ctrl+wheel). Event mutations
|
|
163
168
|
* are applied straight to the SceneStore — no React state on the hot path.
|
|
164
169
|
*/
|
|
165
|
-
export declare const default_alias_8: ({ scene, rendererRef, dynamicCanvasRef, bodyRef, ghostRef, eventPromptRef, setWindowTime, setCellWidth, setTick, onDrop, onResize, onEventClick, onEventHover, eventsResize, panZoom, }: UseCanvasInteractionsArgs) => {
|
|
170
|
+
export declare const default_alias_8: ({ scene, rendererRef, dynamicCanvasRef, bodyRef, ghostRef, eventPromptRef, setWindowTime, setCellWidth, setTick, onDrop, onResize, onEventClick, onEventHover, eventsResize, panZoom, selectable, applySelection, getSelection, }: UseCanvasInteractionsArgs) => {
|
|
166
171
|
handlePointerDown: (pointerEvent: React_2.PointerEvent<HTMLCanvasElement>) => void;
|
|
167
172
|
handlePointerMove: (pointerEvent: React_2.PointerEvent<HTMLCanvasElement>) => void;
|
|
168
173
|
handlePointerUp: (pointerEvent: React_2.PointerEvent<HTMLCanvasElement>) => void;
|
|
@@ -219,8 +224,16 @@ export declare const drawGridLines: (ctx: CanvasRenderingContext2D, { width, hei
|
|
|
219
224
|
color?: string;
|
|
220
225
|
}) => void;
|
|
221
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Recessed-group depth cue. For each expanded group, the contiguous block of
|
|
229
|
+
* its visible child rows is filled with a faint tint and given an inset shadow
|
|
230
|
+
* along its top (and left) edge, so the child rows read as sitting *beneath*
|
|
231
|
+
* their parent row. Drawn on the static layer beneath the grid lines/dividers.
|
|
232
|
+
*/
|
|
233
|
+
export declare const drawGroupShading: (ctx: CanvasRenderingContext2D, view: RendererView, scene: SceneStore) => void;
|
|
234
|
+
|
|
222
235
|
/** Horizontal row dividers — replaces .row-content border-bottom. */
|
|
223
|
-
export declare const drawRowDividers: (ctx: CanvasRenderingContext2D, view: RendererView, scene: SceneStore
|
|
236
|
+
export declare const drawRowDividers: (ctx: CanvasRenderingContext2D, view: RendererView, scene: SceneStore) => void;
|
|
224
237
|
|
|
225
238
|
/**
|
|
226
239
|
* Two-row time bar (top row over bottom row) — canvas replacement for the
|
|
@@ -238,6 +251,20 @@ export declare const drawTimeBar: (ctx: CanvasRenderingContext2D, { width, heigh
|
|
|
238
251
|
bottomBlocks: TimeBlock[];
|
|
239
252
|
}) => void;
|
|
240
253
|
|
|
254
|
+
/**
|
|
255
|
+
* Written by the library into `props.metadata.droppableError` when an event's
|
|
256
|
+
* current `rowId` is absent from its `droppableRowIds`. Read it off events your
|
|
257
|
+
* app holds (or via the handle's `getEvent`) to flag the misconfiguration.
|
|
258
|
+
*/
|
|
259
|
+
declare type DroppableError = {
|
|
260
|
+
/** the event's current rowId, which is not among its droppableRowIds */
|
|
261
|
+
rowId: string;
|
|
262
|
+
/** the rows the event declared it may live on */
|
|
263
|
+
droppableRowIds: string[];
|
|
264
|
+
};
|
|
265
|
+
export { DroppableError }
|
|
266
|
+
export { DroppableError as DroppableError_alias_1 }
|
|
267
|
+
|
|
241
268
|
/** Imperative event mutation, applied without React re-renders. */
|
|
242
269
|
declare type EventPatch = {
|
|
243
270
|
op: "upsert";
|
|
@@ -274,7 +301,39 @@ declare type EventPropsType = {
|
|
|
274
301
|
style?: EventStyle;
|
|
275
302
|
/** per-event custom renderer; overrides the Timeline-level drawEvent */
|
|
276
303
|
drawEvent?: DrawEventFn;
|
|
277
|
-
/**
|
|
304
|
+
/** connects this event to others sharing the same tag. Cmd/Ctrl+click on any
|
|
305
|
+
* member selects the whole connected group (requires `selectable`). */
|
|
306
|
+
groupId?: string;
|
|
307
|
+
/** opt this event out of selection while the Timeline is `selectable`
|
|
308
|
+
* (default: selectable). A non-selectable event can't be clicked into the
|
|
309
|
+
* selection, is excluded from a group selection, and is ignored by
|
|
310
|
+
* `setSelection`. */
|
|
311
|
+
isSelectable?: boolean;
|
|
312
|
+
/** mark this event as a group summary bar. Its `startTime`/`endTime` are
|
|
313
|
+
* derived by the scene from its children (earliest start → latest end) and
|
|
314
|
+
* ignored on input — supplied values are kept only as a fallback while the
|
|
315
|
+
* parent has no resolved children yet. A parent event is never resizable and
|
|
316
|
+
* (in v1) never draggable; it stays clickable/selectable. Selecting it also
|
|
317
|
+
* selects all of its children. Must live on a row that is some row's
|
|
318
|
+
* `parentId`. */
|
|
319
|
+
isGroupParent?: boolean;
|
|
320
|
+
/** child → parent-event link. The referenced parent event is expected to live
|
|
321
|
+
* on this row's `parentId` row. An unresolved link is harmless — the event
|
|
322
|
+
* draws as a plain event (a dev warning is logged). */
|
|
323
|
+
parentEventId?: string;
|
|
324
|
+
/** rows this event may be dragged/dropped onto. `undefined` = any row (the
|
|
325
|
+
* default). When set, a drag only commits if the target row is in the list —
|
|
326
|
+
* otherwise the event snaps back (no `onDrop`). An empty array therefore pins
|
|
327
|
+
* the event (every drop snaps back).
|
|
328
|
+
*
|
|
329
|
+
* If the event's own `rowId` is not in this list, the library records a
|
|
330
|
+
* `{ droppableError: DroppableError }` on `props.metadata` (merging, not
|
|
331
|
+
* clobbering, any object you already put there) so the host app can surface
|
|
332
|
+
* the misconfiguration. The error is cleared automatically once the event is
|
|
333
|
+
* on an allowed row. */
|
|
334
|
+
droppableRowIds?: string[];
|
|
335
|
+
/** arbitrary data for eventPromptTemplate. The library may merge a
|
|
336
|
+
* `droppableError` key here — see `droppableRowIds`. */
|
|
278
337
|
metadata?: unknown;
|
|
279
338
|
};
|
|
280
339
|
export { EventPropsType }
|
|
@@ -411,6 +470,12 @@ export declare type HitTestView = {
|
|
|
411
470
|
|
|
412
471
|
export declare const intersectsWindow: (event: EventType, windowStart: number, windowEnd: number) => boolean;
|
|
413
472
|
|
|
473
|
+
/**
|
|
474
|
+
* Whether an event may be dropped onto a row, given its `droppableRowIds`.
|
|
475
|
+
* `undefined` = unrestricted (any row); otherwise the target must be listed.
|
|
476
|
+
*/
|
|
477
|
+
export declare const isRowDroppable: (droppableRowIds: string[] | undefined, targetRowId: string) => boolean;
|
|
478
|
+
|
|
414
479
|
export declare type LaneResult = {
|
|
415
480
|
laneOf: Map<string, number>;
|
|
416
481
|
highestLane: number;
|
|
@@ -426,10 +491,11 @@ export declare type LayerDirty = {
|
|
|
426
491
|
};
|
|
427
492
|
|
|
428
493
|
/**
|
|
429
|
-
* Replaces the CSS transitions the DOM renderer got for free:
|
|
430
|
-
*
|
|
431
|
-
*
|
|
432
|
-
*
|
|
494
|
+
* Replaces the CSS transitions the DOM renderer got for free: event tops
|
|
495
|
+
* tween when stacking changes, and resize handles fade in/out. (Row heights
|
|
496
|
+
* apply instantly so the canvas rows stay locked to the DOM headers, which
|
|
497
|
+
* also snap.) Values are queried per frame; while any tween is live the
|
|
498
|
+
* renderer keeps scheduling frames.
|
|
433
499
|
*
|
|
434
500
|
* Durations are configurable via the Timeline `animations` prop; a duration
|
|
435
501
|
* of 0 disables that animation (values jump straight to target).
|
|
@@ -441,7 +507,6 @@ export declare type LayerDirty = {
|
|
|
441
507
|
* perpetually, desyncing the layers.
|
|
442
508
|
*/
|
|
443
509
|
export declare class LayoutAnimator {
|
|
444
|
-
private rowHeights;
|
|
445
510
|
private eventTops;
|
|
446
511
|
private handleAlphas;
|
|
447
512
|
private now;
|
|
@@ -450,7 +515,6 @@ export declare class LayoutAnimator {
|
|
|
450
515
|
private fadeDuration;
|
|
451
516
|
setDurations(layoutMs: number, fadeMs: number): void;
|
|
452
517
|
beginFrame(now: number): void;
|
|
453
|
-
rowHeight(rowId: string, target: number): number;
|
|
454
518
|
eventTop(eventId: string, target: number): number;
|
|
455
519
|
/** 0..1 opacity of an event's resize handles; target 1 = hovered. */
|
|
456
520
|
handleAlpha(eventId: string, target: number): number;
|
|
@@ -568,6 +632,7 @@ export declare type RendererView = {
|
|
|
568
632
|
hoveredEventId: string | null;
|
|
569
633
|
draggedEventId: string | null;
|
|
570
634
|
resizePreview: ResizePreview | null;
|
|
635
|
+
selectedEventIds: ReadonlySet<string>;
|
|
571
636
|
};
|
|
572
637
|
|
|
573
638
|
export declare type ResizePreview = {
|
|
@@ -587,6 +652,10 @@ export declare const rowMinHeight: (highestLane: number, g?: Geometry) => number
|
|
|
587
652
|
declare type RowType = {
|
|
588
653
|
id: string;
|
|
589
654
|
name: string;
|
|
655
|
+
/** group this row under a parent row (one level of nesting only in v1). Child
|
|
656
|
+
* rows are hidden when their parent row is collapsed. List child rows
|
|
657
|
+
* immediately after their parent row for the clearest visual nesting. */
|
|
658
|
+
parentId?: string;
|
|
590
659
|
};
|
|
591
660
|
export { RowType }
|
|
592
661
|
export { RowType as RowType_alias_1 }
|
|
@@ -604,8 +673,17 @@ export declare class SceneStore {
|
|
|
604
673
|
private rowIndexes;
|
|
605
674
|
private rowOrder;
|
|
606
675
|
private eventRow;
|
|
676
|
+
private eventGroup;
|
|
677
|
+
private groupMembers;
|
|
678
|
+
private parentOf;
|
|
679
|
+
private childRowsOf;
|
|
680
|
+
private collapsedRows;
|
|
681
|
+
private childrenOf;
|
|
682
|
+
private parentEventOf;
|
|
683
|
+
private parentSpanDirty;
|
|
607
684
|
private listeners;
|
|
608
685
|
private geometry;
|
|
686
|
+
private labelMinHeights;
|
|
609
687
|
version: number;
|
|
610
688
|
setGeometry(geometry: Geometry): void;
|
|
611
689
|
getGeometry(): Geometry;
|
|
@@ -614,11 +692,48 @@ export declare class SceneStore {
|
|
|
614
692
|
setStaticEvents(events: EventType[]): void;
|
|
615
693
|
applyPatches(patches: EventPatch[]): void;
|
|
616
694
|
getEvent(id: string): EventType | undefined;
|
|
695
|
+
/**
|
|
696
|
+
* Event ids "connected" to the given event via a shared `props.groupId`.
|
|
697
|
+
* Returns every member of the group (including the event itself), or just
|
|
698
|
+
* `[eventId]` when the event has no group / no other members / is unknown.
|
|
699
|
+
*/
|
|
700
|
+
getConnectedEventIds(eventId: string): string[];
|
|
701
|
+
/**
|
|
702
|
+
* Whether an event may enter the selection. False only when the event is
|
|
703
|
+
* present and explicitly opted out (`props.isSelectable === false`); unknown
|
|
704
|
+
* ids are treated as selectable so a selection can be set before data loads
|
|
705
|
+
* and survives streaming.
|
|
706
|
+
*/
|
|
707
|
+
isEventSelectable(id: string): boolean;
|
|
617
708
|
getRowIds(): string[];
|
|
709
|
+
/**
|
|
710
|
+
* Row ids in display order, minus rows hidden inside a collapsed parent.
|
|
711
|
+
* Drives offsets, drawing and hit-testing. The header still walks
|
|
712
|
+
* `getRowIds()` so it can draw the carets and decide which rows to skip.
|
|
713
|
+
*/
|
|
714
|
+
getVisibleRowIds(): string[];
|
|
715
|
+
/** whether a row is a parent (owns at least one child row) */
|
|
716
|
+
isRowParent(rowId: string): boolean;
|
|
717
|
+
/** whether a row is hidden because its parent row is collapsed */
|
|
718
|
+
isRowHidden(rowId: string): boolean;
|
|
719
|
+
isRowCollapsed(rowId: string): boolean;
|
|
720
|
+
getCollapsedRowIds(): string[];
|
|
721
|
+
setCollapsed(rowId: string, collapsed: boolean): void;
|
|
722
|
+
toggleCollapsed(rowId: string): void;
|
|
723
|
+
/** child event ids of a parent (summary) event; empty if it has none */
|
|
724
|
+
getChildEventIds(parentEventId: string): string[];
|
|
618
725
|
getRow(rowId: string): RowType | undefined;
|
|
619
726
|
getRowEvents(rowId: string): EventType[];
|
|
620
727
|
getRowStaticEvents(rowId: string): EventType[];
|
|
621
728
|
getLanes(rowId: string, windowStart: number, windowEnd: number): LaneResult;
|
|
729
|
+
/**
|
|
730
|
+
* Report the per-row label heights measured against the live DOM header
|
|
731
|
+
* (key: rowId, value: the minimum row height the wrapped label needs,
|
|
732
|
+
* already including vertical padding). Replaces the previous map wholesale
|
|
733
|
+
* and only bumps when a value actually changed, so re-measuring identical
|
|
734
|
+
* labels is a no-op and can't feed back into an infinite render loop.
|
|
735
|
+
*/
|
|
736
|
+
setLabelMinHeights(heights: Map<string, number>): void;
|
|
622
737
|
getRowHeight(rowId: string, windowStart: number, windowEnd: number): number;
|
|
623
738
|
/**
|
|
624
739
|
* y offset of each row's top edge (content coordinates, before scroll) plus
|
|
@@ -631,6 +746,24 @@ export declare class SceneStore {
|
|
|
631
746
|
subscribe(listener: () => void): () => void;
|
|
632
747
|
private insert;
|
|
633
748
|
private remove;
|
|
749
|
+
private addToGroup;
|
|
750
|
+
private removeFromGroup;
|
|
751
|
+
/**
|
|
752
|
+
* Enforce the authoring contract for `props.droppableRowIds`: if the event's
|
|
753
|
+
* current row is not among its allowed rows, record a `droppableError` on
|
|
754
|
+
* `props.metadata` (merged non-destructively); otherwise clear any stale one.
|
|
755
|
+
* Cheap no-op for events without `droppableRowIds` and no prior error.
|
|
756
|
+
*/
|
|
757
|
+
private validateDroppable;
|
|
758
|
+
private addToParentIndex;
|
|
759
|
+
private removeFromParentIndex;
|
|
760
|
+
/**
|
|
761
|
+
* Recompute the derived span of any dirty parent event living on `rowId`
|
|
762
|
+
* (earliest child start → latest child end), write it back into the parent
|
|
763
|
+
* event, and re-sort the row so the sorted-array invariant holds. Cheap no-op
|
|
764
|
+
* when nothing is dirty (the common no-groups case never touches this).
|
|
765
|
+
*/
|
|
766
|
+
private flushParentSpans;
|
|
634
767
|
private bump;
|
|
635
768
|
}
|
|
636
769
|
|
|
@@ -658,6 +791,17 @@ declare type Theme = {
|
|
|
658
791
|
gridColor?: string;
|
|
659
792
|
timeBarBorder?: string;
|
|
660
793
|
timeBarTextColor?: string;
|
|
794
|
+
/** opacity applied to NON-selected events while a selection is active, so the
|
|
795
|
+
* selection stands out (default 0.35). 1 disables dimming. */
|
|
796
|
+
dimmedOpacity?: number;
|
|
797
|
+
/** shadow color for the "lifted" look of selected events (default
|
|
798
|
+
* "rgba(0,0,0,0.35)") */
|
|
799
|
+
selectionShadowColor?: string;
|
|
800
|
+
/** shadow blur in px for selected events (default 8) */
|
|
801
|
+
selectionShadowBlur?: number;
|
|
802
|
+
/** px the selected event bar is lifted (drawn offset upward) to read as
|
|
803
|
+
* elevated above the others (default 2) */
|
|
804
|
+
selectionElevation?: number;
|
|
661
805
|
/** canvas text font; defaults to the canvas element's computed font */
|
|
662
806
|
font?: string;
|
|
663
807
|
/** event bar height in px (default 20) */
|
|
@@ -668,6 +812,15 @@ declare type Theme = {
|
|
|
668
812
|
rowPaddingY?: number;
|
|
669
813
|
/** event bar corner radius in px (default 5) */
|
|
670
814
|
barRadius?: number;
|
|
815
|
+
/** faint fill laid over the child-row block of an expanded group so it reads
|
|
816
|
+
* as recessed beneath its parent row (default "rgba(0,0,0,0.05)"). Also used
|
|
817
|
+
* to tint child row headers. */
|
|
818
|
+
groupChildBackground?: string;
|
|
819
|
+
/** color of the inset shadow drawn at the top (and left) of an expanded
|
|
820
|
+
* group's child block — the "sitting beneath the parent" depth cue (default
|
|
821
|
+
* "rgba(0,0,0,0.22)"). Also tints the header tree connector lines if no
|
|
822
|
+
* gridColor contrast is desired. */
|
|
823
|
+
groupShadowColor?: string;
|
|
671
824
|
};
|
|
672
825
|
export { Theme }
|
|
673
826
|
export { Theme as Theme_alias_1 }
|
|
@@ -709,6 +862,25 @@ export { Timeline as Timeline_alias_1 }
|
|
|
709
862
|
|
|
710
863
|
export declare const TimelineCanvas: () => React_2.JSX.Element;
|
|
711
864
|
|
|
865
|
+
/**
|
|
866
|
+
* Per-event drop-target restriction (`props.droppableRowIds`). The blue event
|
|
867
|
+
* can only be dropped onto Welder/CNC (drag it elsewhere → not-allowed cursor,
|
|
868
|
+
* snaps back). The green event is unrestricted. The red event is *misconfigured*
|
|
869
|
+
* — it sits on Paint but its droppableRowIds doesn't include Paint, so the
|
|
870
|
+
* library records `metadata.droppableError`; click "Inspect" to see it.
|
|
871
|
+
*/
|
|
872
|
+
export declare const TimelineDroppableRows: () => React_2.JSX.Element;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Grouped (collapsible) rows. A parent row owns child rows (`parentId`); a
|
|
876
|
+
* group-parent event (`isGroupParent`) on the parent row summarizes the child
|
|
877
|
+
* events that point at it (`parentEventId`). The parent's span is derived
|
|
878
|
+
* (earliest child start → latest child end) — it is never resizable or
|
|
879
|
+
* draggable. Selecting a parent also selects its children. Collapsing a parent
|
|
880
|
+
* row hides its child rows while the summary bar stays.
|
|
881
|
+
*/
|
|
882
|
+
export declare const TimelineGrouped: () => React_2.JSX.Element;
|
|
883
|
+
|
|
712
884
|
/**
|
|
713
885
|
* Imperative handle for streaming/live updates: `const ref =
|
|
714
886
|
* useRef<TimelineHandle>(null); <Timeline ref={ref} ...>`.
|
|
@@ -734,12 +906,32 @@ declare type TimelineHandle = {
|
|
|
734
906
|
startTime: number;
|
|
735
907
|
endTime: number;
|
|
736
908
|
};
|
|
909
|
+
/** replace the current selection with these event ids. No `groupId`-tag
|
|
910
|
+
* expansion (that's Cmd/Ctrl+click only), but a group-parent id still pulls
|
|
911
|
+
* in its child events (parent → children). Requires `selectable`; fires
|
|
912
|
+
* `onSelectionChange`. */
|
|
913
|
+
setSelection(eventIds: string[]): void;
|
|
914
|
+
/** the currently selected event ids */
|
|
915
|
+
getSelection(): string[];
|
|
916
|
+
/** toggle a parent row's collapsed state (hides/shows its child rows) */
|
|
917
|
+
toggleRow(rowId: string): void;
|
|
918
|
+
/** explicitly collapse or expand a parent row */
|
|
919
|
+
setCollapsed(rowId: string, collapsed: boolean): void;
|
|
737
920
|
/** force a full redraw of both canvas layers */
|
|
738
921
|
redraw(): void;
|
|
739
922
|
};
|
|
740
923
|
export { TimelineHandle }
|
|
741
924
|
export { TimelineHandle as TimelineHandle_alias_1 }
|
|
742
925
|
|
|
926
|
+
/**
|
|
927
|
+
* Long row labels: names that exceed the 100px header width wrap to multiple
|
|
928
|
+
* lines, stay centered, and grow the row height (and its canvas dividers) to
|
|
929
|
+
* fit instead of overflowing into the neighbouring row. Mixes short, multi-word,
|
|
930
|
+
* and a single unbroken token (forced to break-word) so the per-row height
|
|
931
|
+
* adapts to whichever label is tallest.
|
|
932
|
+
*/
|
|
933
|
+
export declare const TimelineLongRowLabels: () => React_2.JSX.Element;
|
|
934
|
+
|
|
743
935
|
/**
|
|
744
936
|
* A small, sub-day window (~6h). With a window narrower than a day the time
|
|
745
937
|
* bar must still track the hour labels to the actual time as you pan — pan the
|
|
@@ -760,6 +952,20 @@ declare type TimelineProps = {
|
|
|
760
952
|
onResize?: (props: OnResizeProps) => void;
|
|
761
953
|
onEventClick?: (props: OnEventClickProps) => void;
|
|
762
954
|
onEventHover?: (props: OnEventHoverProps) => void;
|
|
955
|
+
/** enable click selection: click selects one event (elevated + others dimmed),
|
|
956
|
+
* Cmd/Ctrl+click selects its whole connected group (`props.groupId`),
|
|
957
|
+
* background click / Escape clears. Default false (no selection). */
|
|
958
|
+
selectable?: boolean;
|
|
959
|
+
/** initial selection for the uncontrolled selection state */
|
|
960
|
+
defaultSelectedEventIds?: string[];
|
|
961
|
+
/** fires whenever the selection changes (click, group-click, clear, or the
|
|
962
|
+
* imperative handle) */
|
|
963
|
+
onSelectionChange?: (eventIds: string[]) => void;
|
|
964
|
+
/** rows collapsed initially (uncontrolled). After mount, collapse state lives
|
|
965
|
+
* in the scene and survives every data update — streaming patches,
|
|
966
|
+
* `setEvents`, and `events`-prop resets never change it; only a user caret
|
|
967
|
+
* click or the imperative handle (`toggleRow`/`setCollapsed`) does. */
|
|
968
|
+
defaultCollapsedRowIds?: string[];
|
|
763
969
|
theme?: Theme;
|
|
764
970
|
drawEvent?: DrawEventFn;
|
|
765
971
|
/** only `rowsHeader` still applies — everything else is canvas-drawn (use `theme`) */
|
|
@@ -809,6 +1015,16 @@ export declare class TimelineRenderer {
|
|
|
809
1015
|
private drawFrame;
|
|
810
1016
|
}
|
|
811
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* Selection: `selectable` turns on click selection. A plain click selects one
|
|
1020
|
+
* event (it lifts with a shadow while every other event dims); Cmd/Ctrl+click
|
|
1021
|
+
* selects the whole connected group (`props.groupId`). Background click or
|
|
1022
|
+
* Escape clears. The buttons drive the same state through the imperative
|
|
1023
|
+
* handle (`setSelection`/`getSelection`). Dragging/resizing still operate on a
|
|
1024
|
+
* single event regardless of how many are selected.
|
|
1025
|
+
*/
|
|
1026
|
+
export declare const TimelineSelectable: () => React_2.JSX.Element;
|
|
1027
|
+
|
|
812
1028
|
/**
|
|
813
1029
|
* Configurable time-bar rows: a day row over 8-hour "shift" blocks instead of
|
|
814
1030
|
* hours. The bottom row uses `{ stepSeconds: 8 * 3600 }` with a custom
|
|
@@ -857,6 +1073,10 @@ declare type UseCanvasInteractionsArgs = {
|
|
|
857
1073
|
onEventHover?: (props: OnEventHoverProps) => void;
|
|
858
1074
|
eventsResize: boolean;
|
|
859
1075
|
panZoom?: PanZoomConfig;
|
|
1076
|
+
selectable: boolean;
|
|
1077
|
+
/** replace the selection with exactly these ids (single write path) */
|
|
1078
|
+
applySelection: (eventIds: string[]) => void;
|
|
1079
|
+
getSelection: () => string[];
|
|
860
1080
|
};
|
|
861
1081
|
|
|
862
1082
|
/** Notifies when devicePixelRatio changes (browser zoom, monitor switch). */
|