@quartzio/gantt 0.0.0-stage → 0.0.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.
Files changed (58) hide show
  1. package/API.md +533 -0
  2. package/LICENSE +21 -0
  3. package/README.md +83 -2
  4. package/dist/index.d.ts +1341 -0
  5. package/dist/index.d.ts.map +1 -0
  6. package/dist/index.js +6556 -0
  7. package/dist/index.js.map +1 -0
  8. package/dist/styles.css +1299 -0
  9. package/package.json +51 -3
  10. package/src/calendar/duration.ts +42 -0
  11. package/src/calendar/project.ts +29 -0
  12. package/src/calendar/workingCalendar.ts +218 -0
  13. package/src/data/draft.ts +78 -0
  14. package/src/data/graph.ts +215 -0
  15. package/src/data/normalize.ts +661 -0
  16. package/src/data/operations.ts +112 -0
  17. package/src/data/project.ts +194 -0
  18. package/src/data/serialize.ts +26 -0
  19. package/src/data/transaction.ts +460 -0
  20. package/src/data/tree.ts +156 -0
  21. package/src/data/types.ts +229 -0
  22. package/src/index.ts +139 -0
  23. package/src/scheduling/schedule.ts +310 -0
  24. package/src/styles.css +1299 -0
  25. package/src/timeaxis/align.ts +120 -0
  26. package/src/timeaxis/format.ts +72 -0
  27. package/src/timeaxis/presets.ts +219 -0
  28. package/src/timeaxis/timeAxis.ts +205 -0
  29. package/src/util/civil.ts +38 -0
  30. package/src/util/emitter.ts +53 -0
  31. package/src/util/equal.ts +23 -0
  32. package/src/util/errors.ts +4 -0
  33. package/src/util/parse.ts +70 -0
  34. package/src/util/time.ts +18 -0
  35. package/src/util/zone.ts +303 -0
  36. package/src/view/bars.ts +63 -0
  37. package/src/view/binding.ts +162 -0
  38. package/src/view/cellEditor.ts +239 -0
  39. package/src/view/cells.ts +89 -0
  40. package/src/view/columns.ts +197 -0
  41. package/src/view/createGantt.ts +1164 -0
  42. package/src/view/dates.ts +14 -0
  43. package/src/view/dependencies.ts +147 -0
  44. package/src/view/editing.ts +303 -0
  45. package/src/view/history.ts +72 -0
  46. package/src/view/interaction.ts +671 -0
  47. package/src/view/keyboard.ts +149 -0
  48. package/src/view/listWidth.ts +201 -0
  49. package/src/view/menu.ts +265 -0
  50. package/src/view/nonWorking.ts +113 -0
  51. package/src/view/range.ts +41 -0
  52. package/src/view/rows.ts +235 -0
  53. package/src/view/selection.ts +156 -0
  54. package/src/view/taskActions.ts +71 -0
  55. package/src/view/taskEditor.ts +553 -0
  56. package/src/view/timeline.ts +155 -0
  57. package/src/view/tooltip.ts +117 -0
  58. package/src/view/types.ts +328 -0
@@ -0,0 +1,1341 @@
1
+ //#region src/util/time.d.ts
2
+ type TimeUnit = "millisecond" | "second" | "minute" | "hour" | "day" | "week" | "month" | "quarter" | "year";
3
+ //#endregion
4
+ //#region src/util/zone.d.ts
5
+ /** `'local'` (the host's zone), `'UTC'`, or an IANA name such as `'Europe/Oslo'`. */
6
+ type TimeZone = string;
7
+ interface WallTime {
8
+ year: number;
9
+ /** 1–12 */
10
+ month: number;
11
+ /** 1–31 */
12
+ day: number;
13
+ hour: number;
14
+ minute: number;
15
+ second: number;
16
+ millisecond: number;
17
+ }
18
+ interface ZonedWallTime extends WallTime {
19
+ /** 0 = Sunday … 6 = Saturday. */
20
+ weekday: number;
21
+ }
22
+ export declare function isValidTimeZone(zone: unknown): zone is TimeZone;
23
+ export declare function toWallTime(time: number, zone: TimeZone): ZonedWallTime;
24
+ /**
25
+ * The instant a wall-clock time happens in `zone`. Out-of-range fields roll over.
26
+ * A time skipped by a DST change (e.g. 02:30 on spring-forward day) resolves to the same distance after
27
+ * the change (03:30); a time that happens twice (fall-back) resolves to the first occurrence.
28
+ */
29
+ export declare function fromWallTime(wall: Partial<WallTime> & Pick<WallTime, "year">, zone: TimeZone): number;
30
+ /**
31
+ * Start of the unit containing `time`, e.g. midnight for `'day'`, the first day of the month for `'month'`.
32
+ * `weekStartsOn`: 0 = Sunday … 6 = Saturday.
33
+ */
34
+ export declare function startOfUnit(time: number, unit: TimeUnit, zone: TimeZone, weekStartsOn?: number): number;
35
+ /**
36
+ * Adds calendar time. Units up to hours are exact durations; days and longer follow the wall clock, so
37
+ * adding a day across a DST change keeps the time of day. Month arithmetic clamps to the month's last day
38
+ * (31 January + 1 month = 28/29 February). Days and longer need whole numbers.
39
+ */
40
+ export declare function addUnits(time: number, amount: number, unit: TimeUnit, zone: TimeZone): number;
41
+ /** ISO 8601 week number: weeks start on Monday, and week 1 contains the year's first Thursday. */
42
+ export declare function isoWeek(time: number, zone: TimeZone): {
43
+ year: number;
44
+ week: number;
45
+ };
46
+ //#endregion
47
+ //#region src/data/types.d.ts
48
+ type Id = string | number;
49
+ /**
50
+ * A task as stored by the engine. Every field is always present; `null` means "not set".
51
+ * Times are epoch milliseconds. End dates are exclusive.
52
+ */
53
+ interface Task {
54
+ readonly id: Id;
55
+ readonly parentId: Id | null;
56
+ readonly name: string;
57
+ readonly startDate: number | null;
58
+ readonly endDate: number | null;
59
+ readonly duration: number | null;
60
+ readonly durationUnit: TimeUnit;
61
+ /** 0–100 */
62
+ readonly percentDone: number;
63
+ /**
64
+ * Uses its own dates: not moved by predecessors, and (for parents) not rolled up from its children. Still a
65
+ * predecessor for others. Otherwise the task is scheduled automatically, as soon as possible.
66
+ */
67
+ readonly manuallyScheduled: boolean;
68
+ /** Set together with `constraintDate` (both or neither). Ignored for manually scheduled tasks. */
69
+ readonly constraintType: ConstraintType | null;
70
+ readonly constraintDate: number | null;
71
+ }
72
+ /**
73
+ * A scheduling constraint on a task. For now only "start no earlier than" (set when an automatically scheduled
74
+ * task is dragged); the other types come with milestone 8.
75
+ */
76
+ type ConstraintType = "startnoearlierthan";
77
+ /** Finish-to-start, start-to-start, finish-to-finish, start-to-finish. */
78
+ type DependencyType = "FS" | "SS" | "FF" | "SF";
79
+ interface Dependency {
80
+ readonly id: Id;
81
+ /** The predecessor task. */
82
+ readonly from: Id;
83
+ /** The successor task. */
84
+ readonly to: Id;
85
+ readonly type: DependencyType;
86
+ readonly lag: number;
87
+ readonly lagUnit: TimeUnit;
88
+ }
89
+ type Weekday = "sunday" | "monday" | "tuesday" | "wednesday" | "thursday" | "friday" | "saturday";
90
+ /** Working time within a day, as wall-clock times "HH:mm". `end` is exclusive and may be "24:00". */
91
+ interface WorkingInterval {
92
+ readonly start: string;
93
+ readonly end: string;
94
+ }
95
+ /** Overrides the weekly schedule for a range of dates (holidays, vacations, extra working days). */
96
+ interface CalendarException {
97
+ /** "YYYY-MM-DD", a date in the project's time zone. */
98
+ readonly startDate: string;
99
+ /** "YYYY-MM-DD", inclusive. */
100
+ readonly endDate: string;
101
+ readonly name: string;
102
+ /** Working time on these dates. Empty means non-working. */
103
+ readonly intervals: readonly WorkingInterval[];
104
+ }
105
+ interface Calendar {
106
+ readonly id: Id;
107
+ readonly name: string;
108
+ readonly week: Readonly<Record<Weekday, readonly WorkingInterval[]>>;
109
+ /** Later exceptions win where they overlap earlier ones. */
110
+ readonly exceptions: readonly CalendarException[];
111
+ }
112
+ interface ProjectSettings {
113
+ /** Time zone for wall-clock logic (working hours, midnight, date strings). */
114
+ readonly timeZone: TimeZone;
115
+ /** The project calendar; `null` uses the built-in standard calendar (Mon–Fri 08:00–16:00). */
116
+ readonly calendarId: Id | null;
117
+ /** Conversion factors for durations in working time. */
118
+ readonly hoursPerDay: number;
119
+ readonly daysPerWeek: number;
120
+ readonly daysPerMonth: number;
121
+ /** 0 = Sunday … 6 = Saturday. */
122
+ readonly weekStartsOn: number;
123
+ /**
124
+ * Project start: automatically scheduled tasks start here at the earliest. When `null`, it's set to the
125
+ * earliest task start the first time the project is scheduled.
126
+ */
127
+ readonly startDate: number | null;
128
+ }
129
+ /**
130
+ * A Date, epoch milliseconds, or an ISO 8601 string. Strings without an offset ("2026-10-05",
131
+ * "2026-10-05T08:00") are wall-clock times in the project's time zone.
132
+ */
133
+ type DateInput = Date | number | string;
134
+ interface TaskInput {
135
+ id: Id;
136
+ name?: string;
137
+ /** Ignored for tasks nested in `children`, where the parent is implied. */
138
+ parentId?: Id | null;
139
+ children?: readonly TaskInput[];
140
+ startDate?: DateInput | null;
141
+ endDate?: DateInput | null;
142
+ duration?: number | null;
143
+ durationUnit?: TimeUnit;
144
+ percentDone?: number;
145
+ manuallyScheduled?: boolean;
146
+ constraintType?: ConstraintType | null;
147
+ constraintDate?: DateInput | null;
148
+ }
149
+ interface DependencyInput {
150
+ id: Id;
151
+ from: Id;
152
+ to: Id;
153
+ type?: DependencyType;
154
+ lag?: number;
155
+ lagUnit?: TimeUnit;
156
+ }
157
+ interface CalendarExceptionInput {
158
+ startDate: string;
159
+ /** Defaults to `startDate`. */
160
+ endDate?: string;
161
+ name?: string;
162
+ /** Defaults to none (a non-working day). */
163
+ intervals?: readonly WorkingInterval[];
164
+ }
165
+ interface CalendarInput {
166
+ id: Id;
167
+ name?: string;
168
+ /** Days left out are non-working. Omit entirely for Mon–Fri 08:00–16:00. */
169
+ week?: Partial<Record<Weekday, readonly WorkingInterval[]>>;
170
+ exceptions?: readonly CalendarExceptionInput[];
171
+ }
172
+ type ProjectSettingsInput = { -readonly [K in Exclude<keyof ProjectSettings, "startDate">]?: ProjectSettings[K]; } & {
173
+ /** Read in the project's time zone (the one in the same input, if given). */
174
+ startDate?: DateInput | null;
175
+ };
176
+ /** Tasks may be a flat list with `parentId`, nested via `children`, or a mix. */
177
+ interface ProjectInput {
178
+ settings?: ProjectSettingsInput;
179
+ calendars?: readonly CalendarInput[];
180
+ tasks?: readonly TaskInput[];
181
+ dependencies?: readonly DependencyInput[];
182
+ }
183
+ /**
184
+ * The canonical, JSON-serializable form of a project: flat, fully normalized records.
185
+ * It is also valid `ProjectInput`, so it can be loaded back as-is.
186
+ */
187
+ interface ProjectData {
188
+ readonly settings: ProjectSettings;
189
+ readonly calendars: readonly Calendar[];
190
+ readonly tasks: readonly Task[];
191
+ readonly dependencies: readonly Dependency[];
192
+ }
193
+ interface Table<R extends {
194
+ readonly id: Id;
195
+ }> {
196
+ readonly byId: ReadonlyMap<Id, R>;
197
+ /**
198
+ * Record order. For tasks, the order of siblings under a parent is their relative order here;
199
+ * the full list is not guaranteed to be depth-first.
200
+ */
201
+ readonly order: readonly Id[];
202
+ }
203
+ /** Immutable snapshot of a project. A new object is created on every change. */
204
+ interface ProjectState {
205
+ readonly settings: ProjectSettings;
206
+ readonly calendars: Table<Calendar>;
207
+ readonly tasks: Table<Task>;
208
+ readonly dependencies: Table<Dependency>;
209
+ }
210
+ interface StoreRecords {
211
+ calendars: Calendar;
212
+ tasks: Task;
213
+ dependencies: Dependency;
214
+ }
215
+ type StoreName = keyof StoreRecords;
216
+ type OperationFor<S extends StoreName> = {
217
+ readonly type: "add";
218
+ readonly store: S;
219
+ readonly record: StoreRecords[S];
220
+ readonly index: number;
221
+ } | {
222
+ readonly type: "remove";
223
+ readonly store: S;
224
+ readonly id: Id;
225
+ } | {
226
+ readonly type: "update";
227
+ readonly store: S;
228
+ readonly id: Id;
229
+ readonly changes: Partial<Omit<StoreRecords[S], "id">>;
230
+ } | {
231
+ readonly type: "move";
232
+ readonly store: S;
233
+ readonly id: Id;
234
+ /** Target position in `order`, counted after the record has been taken out. */
235
+ readonly index: number;
236
+ };
237
+ interface SettingsOperation {
238
+ readonly type: "settings";
239
+ readonly changes: Partial<ProjectSettings>;
240
+ }
241
+ /** One low-level, JSON-serializable change to one record or to the project settings. */
242
+ type Operation = { [S in StoreName]: OperationFor<S>; }[StoreName] | SettingsOperation;
243
+ /** The result of one transaction. Applying `inverse` after `operations` restores the previous state. */
244
+ interface Patch {
245
+ readonly operations: readonly Operation[];
246
+ readonly inverse: readonly Operation[];
247
+ }
248
+ //#endregion
249
+ //#region src/calendar/duration.d.ts
250
+ type DurationSettings = Pick<ProjectSettings, "hoursPerDay" | "daysPerWeek" | "daysPerMonth">;
251
+ /**
252
+ * Working milliseconds in one unit. Durations are working time (like MS Project): with 8 hours per day,
253
+ * "1 day" is 8 working hours, and "1 week" is `daysPerWeek` such days — not 7 calendar days.
254
+ */
255
+ export declare function workingMsPerUnit(unit: TimeUnit, settings: DurationSettings): number;
256
+ export declare function durationToWorkingMs(value: number, unit: TimeUnit, settings: DurationSettings): number;
257
+ export declare function workingMsToDuration(ms: number, unit: TimeUnit, settings: DurationSettings): number;
258
+ //#endregion
259
+ //#region src/calendar/workingCalendar.d.ts
260
+ /** A working period as instants: `[start, end)`. */
261
+ type Interval = readonly [start: number, end: number];
262
+ /**
263
+ * A calendar bound to a time zone, answering working-time questions in epoch milliseconds.
264
+ * Durations here are working milliseconds (see `durationToWorkingMs`).
265
+ */
266
+ interface WorkingCalendar {
267
+ readonly calendarId: Id;
268
+ readonly timeZone: TimeZone;
269
+ isWorking: (time: number) => boolean;
270
+ /** The earliest working instant at or after `time`. */
271
+ nextWorkingTime: (time: number) => number;
272
+ /** The latest instant at or before `time` that ends working time (working time lies just before it). */
273
+ previousWorkingTime: (time: number) => number;
274
+ /**
275
+ * Walks forward from `start` until `workingMs` of working time has passed and returns that instant.
276
+ * When the duration ends exactly at the end of a working period, that end is returned (end dates
277
+ * are exclusive). Zero returns `start` unchanged. Negative walks backwards.
278
+ */
279
+ addWorkingTime: (start: number, workingMs: number) => number;
280
+ /** Walks backwards from `end`; the mirror of `addWorkingTime`. */
281
+ subtractWorkingTime: (end: number, workingMs: number) => number;
282
+ /** Working milliseconds in `[from, to)`. Negative when `to` is before `from`. */
283
+ workingTimeBetween: (from: number, to: number) => number;
284
+ /** Working intervals overlapping `[from, to)`, clipped to it. For drawing working/non-working time. */
285
+ workingIntervals: (from: number, to: number) => Interval[];
286
+ }
287
+ //#endregion
288
+ //#region src/calendar/project.d.ts
289
+ /**
290
+ * The working calendar for a project: the calendar with `calendarId`, or the project calendar
291
+ * (`settings.calendarId`, falling back to the standard Mon–Fri 08:00–16:00 calendar), in the project's
292
+ * time zone. Instances are cached and cache their day computations. With `timeZone: 'local'`, the cached
293
+ * results assume the host's zone doesn't change while the app runs.
294
+ */
295
+ export declare function getWorkingCalendar(state: ProjectState, calendarId?: Id | null): WorkingCalendar;
296
+ //#endregion
297
+ //#region src/data/normalize.d.ts
298
+ export declare const DEFAULT_SETTINGS: ProjectSettings;
299
+ /** Used when `settings.calendarId` is `null`: Monday–Friday 08:00–16:00, no exceptions. */
300
+ export declare const STANDARD_CALENDAR: Calendar;
301
+ type TaskFieldsInput = Omit<TaskInput, "id" | "parentId" | "children">;
302
+ type DependencyFieldsInput = Omit<DependencyInput, "id" | "from" | "to">;
303
+ type CalendarFieldsInput = Omit<CalendarInput, "id">;
304
+ //#endregion
305
+ //#region src/data/transaction.d.ts
306
+ /** Where to put a task. `parentId` defaults to root (for add) or the current parent (for move); `index` to last. */
307
+ interface TaskPosition {
308
+ parentId?: Id | null;
309
+ /** Position among the new siblings. */
310
+ index?: number;
311
+ }
312
+ interface TaskAddInput extends TaskFieldsInput {
313
+ /** Generated when omitted. */
314
+ id?: Id;
315
+ }
316
+ type TaskUpdateInput = TaskFieldsInput;
317
+ interface DependencyAddInput extends DependencyFieldsInput {
318
+ /** Generated when omitted. */
319
+ id?: Id;
320
+ from: Id;
321
+ to: Id;
322
+ }
323
+ interface DependencyUpdateInput extends DependencyFieldsInput {
324
+ from?: Id;
325
+ to?: Id;
326
+ }
327
+ interface TaskTransaction {
328
+ /** Reads reflect earlier writes in the same transaction. */
329
+ get: (id: Id) => Task | undefined;
330
+ children: (parentId: Id | null) => readonly Id[];
331
+ add: (input: TaskAddInput, position?: TaskPosition) => Task;
332
+ /** Fields that equal the current value are skipped, so no-op updates produce no operations. */
333
+ update: (id: Id, changes: TaskUpdateInput) => void;
334
+ move: (id: Id, position: TaskPosition) => void;
335
+ /** Also removes all descendants and every dependency connected to them. */
336
+ remove: (id: Id) => void;
337
+ }
338
+ interface DependencyTransaction {
339
+ get: (id: Id) => Dependency | undefined;
340
+ add: (input: DependencyAddInput) => Dependency;
341
+ update: (id: Id, changes: DependencyUpdateInput) => void;
342
+ remove: (id: Id) => void;
343
+ }
344
+ interface CalendarAddInput extends CalendarFieldsInput {
345
+ /** Generated when omitted. */
346
+ id?: Id;
347
+ }
348
+ type CalendarUpdateInput = CalendarFieldsInput;
349
+ interface CalendarTransaction {
350
+ get: (id: Id) => Calendar | undefined;
351
+ add: (input: CalendarAddInput) => Calendar;
352
+ update: (id: Id, changes: CalendarUpdateInput) => void;
353
+ /** Fails while the calendar is the project calendar. */
354
+ remove: (id: Id) => void;
355
+ }
356
+ interface SettingsTransaction {
357
+ get: () => ProjectSettings;
358
+ /**
359
+ * Changing `timeZone` does not move existing dates (they are instants), but it changes how wall-clock
360
+ * logic and date strings in later input are interpreted.
361
+ */
362
+ update: (changes: ProjectSettingsInput) => void;
363
+ }
364
+ interface Transaction {
365
+ readonly settings: SettingsTransaction;
366
+ readonly calendars: CalendarTransaction;
367
+ readonly tasks: TaskTransaction;
368
+ readonly dependencies: DependencyTransaction;
369
+ }
370
+ type IdGenerator = (store: StoreName, exists: (id: Id) => boolean) => Id;
371
+ //#endregion
372
+ //#region src/data/project.d.ts
373
+ interface ProjectChange {
374
+ readonly state: ProjectState;
375
+ /** `null` when the whole project was replaced via `load()`. */
376
+ readonly patch: Patch | null;
377
+ }
378
+ interface PlannedChange {
379
+ readonly state: ProjectState;
380
+ readonly patch: Patch;
381
+ }
382
+ interface ProjectOptions {
383
+ /** Creates ids for records added without one. Defaults to `task-1`, `dependency-1`, ... */
384
+ generateId?: IdGenerator;
385
+ /**
386
+ * Completes every change (transactions, `apply`, `load` and the initial data) with more operations, applied
387
+ * in the same change and included in its patch: this is how the scheduler writes computed dates back.
388
+ * Gets the operations that were applied, or `null` for loaded data. Must be pure, and return nothing for a
389
+ * state it already completed; if it throws, the change is rejected.
390
+ */
391
+ propagate?: (state: ProjectState, operations: readonly Operation[] | null) => readonly Operation[];
392
+ }
393
+ interface Project {
394
+ getState: () => ProjectState;
395
+ subscribe: (listener: (change: ProjectChange) => void) => () => void;
396
+ /**
397
+ * Replaces the whole project. Returns the operations `propagate` added to the loaded data (e.g. computed
398
+ * dates), or `null` when it added none.
399
+ */
400
+ load: (input: ProjectInput) => Patch | null;
401
+ /**
402
+ * Runs `fn` against a draft and commits all its changes at once, emitting a single change.
403
+ * If `fn` throws, nothing is changed. Returns `null` when nothing changed.
404
+ */
405
+ transact: (fn: (tx: Transaction) => void) => Patch | null;
406
+ /**
407
+ * Like `transact`, but only computes the result without committing it.
408
+ * `base` plans on top of another state than the current one (e.g. an earlier planned change).
409
+ */
410
+ plan: (fn: (tx: Transaction) => void, base?: ProjectState) => PlannedChange | null;
411
+ /**
412
+ * Applies operations, e.g. a patch's `inverse` for undo or operations received from a server.
413
+ * The result is validated (parents and dependency ends must exist, no cycles); on failure nothing changes.
414
+ */
415
+ apply: (operations: readonly Operation[]) => Patch | null;
416
+ /** Like `apply`, but only computes the result without committing it (`base` as for `plan`). */
417
+ planApply: (operations: readonly Operation[], base?: ProjectState) => PlannedChange | null;
418
+ toData: () => ProjectData;
419
+ }
420
+ export declare function createProject(input?: ProjectInput, options?: ProjectOptions): Project;
421
+ //#endregion
422
+ //#region src/data/serialize.d.ts
423
+ /** Converts a state snapshot to the canonical, JSON-serializable data format. */
424
+ export declare function toProjectData(state: ProjectState): ProjectData;
425
+ /**
426
+ * Returns new project data with the patch applied; the input is not modified.
427
+ * Meant for controlled usage: `onChange={({ patch }) => setData((data) => applyPatch(data, patch))}`.
428
+ */
429
+ export declare function applyPatch(data: ProjectData, patch: Patch): ProjectData;
430
+ //#endregion
431
+ //#region src/data/tree.d.ts
432
+ /** Derived hierarchy for a task table. Built in O(n); cached per table so repeated lookups are cheap. */
433
+ interface TreeIndex {
434
+ /** Child ids in sibling order. `null` returns the root tasks. */
435
+ children: (parentId: Id | null) => readonly Id[];
436
+ /** Position of each task in the table's `order`. */
437
+ position: (id: Id) => number;
438
+ /** Ancestors from the direct parent up to the root. */
439
+ ancestors: (id: Id) => Id[];
440
+ /** All descendants, depth-first in sibling order. */
441
+ descendants: (id: Id) => Id[];
442
+ depth: (id: Id) => number;
443
+ isLeaf: (id: Id) => boolean;
444
+ /** Tasks depth-first in sibling order: the order rows appear in when everything is expanded. */
445
+ flatten: () => readonly Id[];
446
+ }
447
+ export declare function getTreeIndex(tasks: Table<Task>): TreeIndex;
448
+ //#endregion
449
+ //#region src/timeaxis/presets.d.ts
450
+ interface HeaderCellContext {
451
+ start: number;
452
+ end: number;
453
+ unit: TimeUnit;
454
+ increment: number;
455
+ timeZone: TimeZone;
456
+ /** BCP 47 locale, e.g. "nb-NO"; `undefined` uses the runtime default. */
457
+ locale: string | undefined;
458
+ }
459
+ /** Built-in label formats. Month and weekday names follow the locale. */
460
+ type HeaderFormatName = "year" | "quarter" | "quarterYear" | "month" | "monthShort" | "monthYear" | "monthShortYear" | "week" | "day" | "weekdayShort" | "weekdayNarrow" | "weekdayDay" | "dayMonth" | "weekdayDayMonth" | "hour" | "hourMinute";
461
+ /** A built-in format, or a function. Functions should be pure and must not throw (errors leave the label empty). */
462
+ type HeaderFormat = HeaderFormatName | ((cell: HeaderCellContext) => string);
463
+ interface HeaderRow {
464
+ unit: TimeUnit;
465
+ /** Units per cell. Defaults to 1. */
466
+ increment?: number;
467
+ format: HeaderFormat;
468
+ }
469
+ interface ViewPreset {
470
+ id: string;
471
+ /** The smallest column. Every tick gets the same width, however long it is in time. */
472
+ tickUnit: TimeUnit;
473
+ tickIncrement: number;
474
+ /** Pixels per tick. */
475
+ tickWidth: number;
476
+ /** Header rows from top to bottom. */
477
+ headers: readonly HeaderRow[];
478
+ /** Resolution for snapping when dragging and resizing. */
479
+ timeResolution: {
480
+ unit: TimeUnit;
481
+ increment: number;
482
+ };
483
+ }
484
+ /** Built-in presets, from most zoomed in to most zoomed out. */
485
+ export declare const VIEW_PRESETS: readonly ViewPreset[];
486
+ export declare const DEFAULT_PRESET_ID = "weekAndDay";
487
+ /** Looks up a built-in preset by id, or validates a custom one. */
488
+ export declare function resolvePreset(preset?: string | ViewPreset): ViewPreset;
489
+ //#endregion
490
+ //#region src/timeaxis/timeAxis.d.ts
491
+ interface TimeAxisOptions {
492
+ /** The axis is widened to whole ticks around `[start, end)`. */
493
+ start: number;
494
+ end: number;
495
+ preset: ViewPreset;
496
+ timeZone: TimeZone;
497
+ /** 0 = Sunday … 6 = Saturday. */
498
+ weekStartsOn: number;
499
+ locale?: string | undefined;
500
+ /** Adds ticks after `end` until the axis is at least this many pixels wide (e.g. to fill a viewport). */
501
+ minWidth?: number | undefined;
502
+ /**
503
+ * When the range needs more than `MAX_TICKS` ticks: stop there (the axis ends early) instead of
504
+ * throwing. Used by the controller, which must never fail while rendering.
505
+ */
506
+ truncate?: boolean | undefined;
507
+ }
508
+ interface Tick {
509
+ index: number;
510
+ start: number;
511
+ end: number;
512
+ x: number;
513
+ width: number;
514
+ }
515
+ interface HeaderCell {
516
+ /** Stable key for rendering lists. */
517
+ key: string;
518
+ /** The cell's full time span; it may extend beyond the axis at the edges. */
519
+ start: number;
520
+ end: number;
521
+ /** Position and width, clipped to the axis. */
522
+ x: number;
523
+ width: number;
524
+ label: string;
525
+ }
526
+ /**
527
+ * Maps time to pixels and back. Every tick has the same width; within a tick, position is linear in
528
+ * time. So a 23-hour DST day is as wide as any other day, and every month is as wide as every other.
529
+ */
530
+ interface TimeAxis {
531
+ readonly preset: ViewPreset;
532
+ readonly timeZone: TimeZone;
533
+ readonly locale: string | undefined;
534
+ readonly weekStartsOn: number;
535
+ /** First tick start and last tick end. */
536
+ readonly start: number;
537
+ readonly end: number;
538
+ readonly tickCount: number;
539
+ readonly tickWidth: number;
540
+ readonly totalWidth: number;
541
+ tick: (index: number) => Tick;
542
+ /** Pixel position of a time. Times outside the axis are extrapolated from the edge ticks. */
543
+ dateToX: (time: number) => number;
544
+ /** Time at a pixel position; the inverse of `dateToX`, rounded to whole milliseconds. */
545
+ xToDate: (x: number) => number;
546
+ /** Ticks overlapping `[fromX, toX)`. */
547
+ ticksInRange: (fromX: number, toX: number) => Tick[];
548
+ /**
549
+ * Cells of header row `row` (0 = top) overlapping `[fromX, toX)`, clipped to the axis. Always aligned to
550
+ * natural boundaries, so the same cells come back whatever window is asked for. At most 10 000 cells.
551
+ */
552
+ headerCells: (row: number, fromX: number, toX: number) => HeaderCell[];
553
+ /** Rounds to the nearest `timeResolution` boundary of the preset. */
554
+ snap: (time: number) => number;
555
+ }
556
+ export declare function createTimeAxis(options: TimeAxisOptions): TimeAxis;
557
+ //#endregion
558
+ //#region src/util/errors.d.ts
559
+ /** Thrown for invalid input or operations, e.g. unknown ids or a task moved into its own subtree. */
560
+ export declare class QuartzioError extends Error {
561
+ override name: string;
562
+ }
563
+ //#endregion
564
+ //#region src/util/parse.d.ts
565
+ /**
566
+ * Parses an ISO 8601 date string. Without an offset ("2026-10-05", "2026-10-05T08:00") the string is a
567
+ * wall-clock time in `zone`; with one ("…Z", "…+02:00") it is an absolute instant.
568
+ * Returns `null` for anything else, including impossible dates like 2026-02-30.
569
+ */
570
+ export declare function parseDateString(value: string, zone: TimeZone): number | null;
571
+ //#endregion
572
+ //#region src/scheduling/schedule.d.ts
573
+ /**
574
+ * Schedules the project and returns the operations that write the results back: for automatically scheduled
575
+ * tasks, dates as soon as possible after the project start and their predecessors' requirements; for parents,
576
+ * the span of their children; start, end and duration kept consistent everywhere.
577
+ *
578
+ * `operations` are the ones just applied (to tell a new end from a new duration), or `null` for loaded data.
579
+ * Pure, idempotent (nothing to add to a state it scheduled), and doesn't throw for calendar trouble: a task
580
+ * whose dates can't be computed (e.g. no working time at all) keeps its dates.
581
+ */
582
+ export declare function scheduleProject(state: ProjectState, operations: readonly Operation[] | null): Operation[];
583
+ //#endregion
584
+ //#region src/view/dates.d.ts
585
+ /** A task's dates as shown (scheduling keeps them in the task itself). */
586
+ interface TaskDates {
587
+ readonly start: number;
588
+ readonly end: number;
589
+ }
590
+ /** Start and end; zero-length when only one is set (unscheduled data); `null` when neither is. */
591
+ declare function taskDates$1(task: Task): TaskDates | null;
592
+ //#endregion
593
+ //#region src/view/bars.d.ts
594
+ type BarKind = "task" | "summary" | "milestone";
595
+ /** A task's bar on the timeline, in timeline coordinates (x = 0 is the start of the axis). */
596
+ interface Bar {
597
+ readonly kind: BarKind;
598
+ /**
599
+ * Left edge; for milestones, the center of the diamond. May be outside the axis for tasks that extend beyond
600
+ * it, but is kept within one axis width on either side (`start` and `end` keep the real dates).
601
+ */
602
+ readonly x: number;
603
+ /** 0 for milestones. */
604
+ readonly width: number;
605
+ readonly start: number;
606
+ readonly end: number;
607
+ /** 0–1. */
608
+ readonly progress: number;
609
+ readonly label: string;
610
+ }
611
+ //#endregion
612
+ //#region src/view/columns.d.ts
613
+ type BuiltInColumnId = "name" | "startDate" | "endDate" | "duration" | "percentDone";
614
+ /** What a cell's value function gets. */
615
+ interface CellContext {
616
+ readonly task: Task;
617
+ /** Whether the task has children (its dates then span its descendants). */
618
+ readonly isParent: boolean;
619
+ /** Computed display dates, or `null` for unscheduled tasks. */
620
+ readonly dates: TaskDates | null;
621
+ readonly settings: ProjectSettings;
622
+ readonly locale: string | undefined;
623
+ /** The project calendar, e.g. to measure working time. Absent if it can't be used. */
624
+ readonly calendar: WorkingCalendar | undefined;
625
+ }
626
+ interface ColumnDefinition {
627
+ id: string;
628
+ title?: string;
629
+ /** Pixels. */
630
+ width?: number;
631
+ /** A built-in column to base this one on (its title, width and value). */
632
+ field?: BuiltInColumnId;
633
+ align?: "start" | "end";
634
+ /** Cell text. Must not throw (errors leave the cell empty). */
635
+ value?: (cell: CellContext) => string;
636
+ /**
637
+ * Whether cells can be edited (double-click, Enter/F2). Default `true` for columns with a `field` (the edit
638
+ * writes that field), and always `false` without one.
639
+ */
640
+ editable?: boolean;
641
+ }
642
+ type ColumnInput = BuiltInColumnId | ColumnDefinition;
643
+ interface Column {
644
+ readonly id: string;
645
+ readonly title: string;
646
+ readonly width: number;
647
+ /** Left edge within the task list. */
648
+ readonly x: number;
649
+ readonly align: "start" | "end";
650
+ /** The column that shows the tree (indentation and expand/collapse). */
651
+ readonly tree: boolean;
652
+ /** Its cells can be edited (some cells still can't, e.g. a parent's dates). */
653
+ readonly editable: boolean;
654
+ }
655
+ interface ColumnsState {
656
+ readonly items: readonly Column[];
657
+ /** Width of the task list. */
658
+ readonly totalWidth: number;
659
+ }
660
+ export declare const DEFAULT_COLUMNS: readonly BuiltInColumnId[];
661
+ //#endregion
662
+ //#region src/view/selection.d.ts
663
+ /** Which keys were held, for clicks and key presses. Ctrl and Cmd (meta) mean the same. */
664
+ interface KeyModifiers {
665
+ readonly shift?: boolean | undefined;
666
+ readonly ctrl?: boolean | undefined;
667
+ readonly meta?: boolean | undefined;
668
+ readonly alt?: boolean | undefined;
669
+ }
670
+ //#endregion
671
+ //#region src/view/interaction.d.ts
672
+ /** A point on the timeline body: x from the start of the axis, y from the top of the first row. */
673
+ interface TimelinePoint {
674
+ readonly x: number;
675
+ readonly y: number;
676
+ }
677
+ /**
678
+ * What a press would grab: a bar to move, its end to resize, its progress handle, an empty row of an
679
+ * unscheduled task to draw a bar in, or a link handle at either end of a bar to draw a dependency from.
680
+ */
681
+ type HitArea = "bar" | "resize-end" | "progress" | "create" | "link-start" | "link-end";
682
+ /** What's under a point (only what's enabled). */
683
+ interface TimelineHit {
684
+ readonly taskId: Id;
685
+ readonly area: HitArea;
686
+ }
687
+ /** A change an interaction proposes, for `validateChange`. */
688
+ type ProposedChange = {
689
+ readonly kind: "move" | "resize" | "create";
690
+ readonly task: Task;
691
+ readonly start: number;
692
+ readonly end: number;
693
+ } | {
694
+ readonly kind: "progress";
695
+ readonly task: Task;
696
+ readonly percentDone: number;
697
+ } | {
698
+ readonly kind: "link";
699
+ readonly from: Task;
700
+ readonly to: Task;
701
+ readonly type: DependencyType;
702
+ };
703
+ interface InteractionBase {
704
+ /** Whether the drop would be applied: `validateChange` (and, for links, the rules) allow it. */
705
+ readonly valid: boolean;
706
+ /** Why it isn't valid, if there's a reason to show. */
707
+ readonly message: string | null;
708
+ /** Text for a tooltip: the new dates, the percentage, or the link. */
709
+ readonly label: string;
710
+ /**
711
+ * Pixels per frame to scroll by, while the pointer is near or past an edge of the visible timeline. The
712
+ * renderer scrolls and then sends the pointer position again.
713
+ */
714
+ readonly autoScroll: {
715
+ readonly x: number;
716
+ readonly y: number;
717
+ };
718
+ }
719
+ /** A bar being moved, resized, drawn (created) or having its progress dragged: where it would land. */
720
+ interface BarInteraction extends InteractionBase {
721
+ readonly kind: "move" | "resize" | "create" | "progress";
722
+ readonly taskId: Id;
723
+ /** Key of the task's row, to set the original bar apart. */
724
+ readonly rowKey: string;
725
+ /** The bar at its new place (snapped), in timeline coordinates, in the task's row. */
726
+ readonly bar: Bar;
727
+ readonly start: number;
728
+ readonly end: number;
729
+ /** 0–100; for progress. */
730
+ readonly percent: number;
731
+ }
732
+ /** A dependency being drawn from a bar's end (or start) to the pointer. */
733
+ interface LinkInteraction extends InteractionBase {
734
+ readonly kind: "link";
735
+ readonly from: Id;
736
+ /** The bar under the pointer, if any. */
737
+ readonly to: Id | null;
738
+ /** The type the drop would create (from the sides), when over a bar. */
739
+ readonly type: DependencyType | null;
740
+ /** SVG path data of the line, in timeline coordinates. */
741
+ readonly path: string;
742
+ /** Where the line ends (the pointer), e.g. to put a tooltip there. */
743
+ readonly end: TimelinePoint;
744
+ }
745
+ type TaskInteraction = BarInteraction | LinkInteraction;
746
+ //#endregion
747
+ //#region src/view/history.d.ts
748
+ interface HistoryState {
749
+ readonly canUndo: boolean;
750
+ readonly canRedo: boolean;
751
+ }
752
+ //#endregion
753
+ //#region src/view/editing.d.ts
754
+ /** The kind of field a cell is edited in. */
755
+ type EditKind = "text" | "duration" | "percent" | "date" | "datetime";
756
+ /** The cell being edited. */
757
+ interface CellEdit {
758
+ readonly taskId: Id;
759
+ /** Key of the task's row. */
760
+ readonly rowKey: string;
761
+ readonly columnId: string;
762
+ readonly kind: EditKind;
763
+ /** What's in the field now. */
764
+ readonly text: string;
765
+ /** Why the last attempt to save was refused, until the text changes. */
766
+ readonly error: string | null;
767
+ }
768
+ //#endregion
769
+ //#region src/view/keyboard.d.ts
770
+ /** A key press, as `KeyboardEvent.key` plus the modifiers held. */
771
+ interface KeyInput extends KeyModifiers {
772
+ readonly key: string;
773
+ /** `KeyboardEvent.code`: finds shortcuts (Ctrl+Z, Ctrl+A) on layouts without latin letters. */
774
+ readonly code?: string | undefined;
775
+ }
776
+ //#endregion
777
+ //#region src/view/menu.d.ts
778
+ /** What a menu is for: a task (its row or bar), or the time axis (its header). */
779
+ type MenuTarget = {
780
+ readonly kind: "task";
781
+ readonly id: Id;
782
+ } | {
783
+ readonly kind: "timeAxis";
784
+ };
785
+ /** What an item's `action` (and the item customizers) get. */
786
+ interface MenuContext {
787
+ readonly target: MenuTarget;
788
+ /** The task the menu is for, or `null` for the time axis. */
789
+ readonly task: Task | null;
790
+ readonly selection: readonly Id[];
791
+ readonly preset: ViewPreset;
792
+ }
793
+ interface MenuItem {
794
+ readonly id: string;
795
+ readonly label: string;
796
+ readonly disabled?: boolean | undefined;
797
+ /** Shown checked (e.g. the current preset). */
798
+ readonly checked?: boolean | undefined;
799
+ /** A line before it. */
800
+ readonly separator?: boolean | undefined;
801
+ /** A submenu (one level). */
802
+ readonly items?: readonly MenuItem[] | undefined;
803
+ /** For your own items: what choosing it does. Built-in items are carried out by the engine. */
804
+ readonly action?: ((context: MenuContext) => void) | undefined;
805
+ }
806
+ /** The open menu. */
807
+ interface MenuState {
808
+ readonly kind: "task" | "timeAxis";
809
+ readonly taskId: Id | null;
810
+ /** Where it opens, in the chart's coordinates (from the root element's corner). */
811
+ readonly x: number;
812
+ readonly y: number;
813
+ readonly items: readonly MenuItem[];
814
+ /** The highlighted item (in the open submenu, if there is one). */
815
+ readonly active: string | null;
816
+ /** The item whose submenu is open. */
817
+ readonly submenu: string | null;
818
+ }
819
+ type MenuCustomizer = (items: readonly MenuItem[], context: MenuContext) => readonly MenuItem[];
820
+ /** A task menu's built-in item ids, carried out by the engine. */
821
+ type TaskMenuItemId = "edit" | "addTaskAbove" | "addTaskBelow" | "addSubtask" | "addMilestone" | "addSuccessor" | "addPredecessor" | "indent" | "outdent" | "convertToMilestone" | "delete";
822
+ //#endregion
823
+ //#region src/view/taskEditor.d.ts
824
+ type TaskEditorTab = "general" | "predecessors" | "successors" | "advanced";
825
+ type TaskEditorField = "name" | "startDate" | "endDate" | "duration" | "percentDone" | "constraintDate";
826
+ type TaskEditorSide = "predecessors" | "successors";
827
+ type TaskEditorConstraint = "none" | "startnoearlierthan";
828
+ interface TaskEditorFieldState {
829
+ readonly text: string;
830
+ readonly kind: EditKind;
831
+ readonly error: string | null;
832
+ /** Can't be edited (e.g. a parent's dates, which roll up). */
833
+ readonly disabled: boolean;
834
+ }
835
+ /** A predecessor or successor in the editor. */
836
+ interface TaskEditorDependency {
837
+ /** Stable key for rendering and actions. */
838
+ readonly key: string;
839
+ /** The dependency it edits, or `null` for a new one. */
840
+ readonly dependencyId: Id | null;
841
+ /** The other task, or `null` until one is chosen. */
842
+ readonly taskId: Id | null;
843
+ readonly type: DependencyType;
844
+ /** Lag as text, e.g. `2d` or `-1d`. */
845
+ readonly lag: string;
846
+ readonly error: string | null;
847
+ }
848
+ /** The open task editor. */
849
+ interface TaskEditorState {
850
+ readonly taskId: Id;
851
+ /** The task as it is now. */
852
+ readonly task: Task;
853
+ readonly tab: TaskEditorTab;
854
+ readonly fields: Readonly<Record<TaskEditorField, TaskEditorFieldState>>;
855
+ readonly manuallyScheduled: boolean;
856
+ readonly constraintType: TaskEditorConstraint;
857
+ readonly predecessors: readonly TaskEditorDependency[];
858
+ readonly successors: readonly TaskEditorDependency[];
859
+ /** Tasks a dependency can link to, in tree order. */
860
+ readonly candidates: readonly {
861
+ readonly id: Id;
862
+ readonly name: string;
863
+ readonly depth: number;
864
+ }[];
865
+ /** Why saving failed as a whole (e.g. a dependency cycle). */
866
+ readonly error: string | null;
867
+ }
868
+ type TaskEditorAction = {
869
+ readonly type: "input";
870
+ readonly field: TaskEditorField;
871
+ readonly value: string;
872
+ } | {
873
+ readonly type: "input";
874
+ readonly field: "manuallyScheduled";
875
+ readonly value: boolean;
876
+ } | {
877
+ readonly type: "input";
878
+ readonly field: "constraintType";
879
+ readonly value: TaskEditorConstraint;
880
+ } | {
881
+ readonly type: "tab";
882
+ readonly tab: TaskEditorTab;
883
+ } | {
884
+ readonly type: "addDependency";
885
+ readonly side: TaskEditorSide;
886
+ } | {
887
+ readonly type: "updateDependency";
888
+ readonly side: TaskEditorSide;
889
+ readonly key: string;
890
+ readonly changes: {
891
+ readonly taskId?: Id | null | undefined;
892
+ readonly type?: DependencyType | undefined;
893
+ readonly lag?: string | undefined;
894
+ };
895
+ } | {
896
+ readonly type: "removeDependency";
897
+ readonly side: TaskEditorSide;
898
+ readonly key: string;
899
+ } | {
900
+ readonly type: "save";
901
+ } | {
902
+ readonly type: "close";
903
+ };
904
+ //#endregion
905
+ //#region src/view/listWidth.d.ts
906
+ /**
907
+ * The width of the task list (its pane, border included), as the divider between it and the timeline sets it.
908
+ * `width: null` means automatic: as wide as the columns, up to `--qz-list-max-width`.
909
+ */
910
+ interface ListPaneState {
911
+ readonly width: number | null;
912
+ /** The divider is being dragged. */
913
+ readonly resizing: boolean;
914
+ /** Bounds for the divider: at most as wide as the columns (the chart may show it narrower). */
915
+ readonly min: number;
916
+ readonly max: number;
917
+ }
918
+ /**
919
+ * What the divider does, sent from the renderer with measured sizes: `width` is the list pane as shown now,
920
+ * `chartWidth` the whole chart's. `x` is any horizontal coordinate that moves with the pointer.
921
+ */
922
+ type ListResizeAction = {
923
+ readonly type: "start";
924
+ readonly x: number;
925
+ readonly width: number;
926
+ readonly chartWidth: number;
927
+ } | {
928
+ readonly type: "move";
929
+ readonly x: number;
930
+ } | {
931
+ readonly type: "end";
932
+ } | {
933
+ readonly type: "cancel";
934
+ } | {
935
+ readonly type: "key";
936
+ readonly key: string;
937
+ readonly shift?: boolean | undefined;
938
+ readonly width: number;
939
+ readonly chartWidth: number;
940
+ } | {
941
+ readonly type: "reset";
942
+ };
943
+ //#endregion
944
+ //#region src/view/nonWorking.d.ts
945
+ /** A time range drawn on the timeline, in timeline coordinates. */
946
+ interface TimeSpan {
947
+ /** Stable key for rendering lists. */
948
+ readonly key: string;
949
+ readonly start: number;
950
+ readonly end: number;
951
+ readonly x: number;
952
+ readonly width: number;
953
+ }
954
+ //#endregion
955
+ //#region src/view/tooltip.d.ts
956
+ /** The tooltip for the task under the pointer: what to show, and where. */
957
+ interface TaskTooltip {
958
+ readonly taskId: Id;
959
+ /** Key of the task's row. */
960
+ readonly rowKey: string;
961
+ readonly task: Task;
962
+ readonly title: string;
963
+ /** Formatted values, in order. */
964
+ readonly fields: readonly {
965
+ readonly label: string;
966
+ readonly value: string;
967
+ }[];
968
+ /**
969
+ * Where it points to, in timeline coordinates: the start of the visible part of the bar (`align: 'start'`) or
970
+ * its end (`'end'`, the tooltip's right edge there).
971
+ */
972
+ readonly x: number;
973
+ readonly align: "start" | "end";
974
+ /** The room (px) from `x` to the edge of the visible timeline it runs towards; `null` before measuring. */
975
+ readonly room: number | null;
976
+ /**
977
+ * The top of the row (the tooltip above it), or its bottom when `below`: when there's no room above it in the
978
+ * visible rows (the header would cover it) and more below.
979
+ */
980
+ readonly y: number;
981
+ readonly below: boolean;
982
+ }
983
+ //#endregion
984
+ //#region src/view/types.d.ts
985
+ /**
986
+ * The visible part of the timeline body: its size (excluding the task list and the header) and the scroll
987
+ * position of the shared scroll area.
988
+ */
989
+ interface Viewport {
990
+ readonly width: number;
991
+ readonly height: number;
992
+ readonly scrollLeft: number;
993
+ readonly scrollTop: number;
994
+ }
995
+ interface HeaderState {
996
+ /**
997
+ * Cells per header row (top to bottom), only around the visible part of the timeline. The arrays keep
998
+ * their identity while scrolling within the rendered window, so rows can be memoized.
999
+ */
1000
+ readonly rows: readonly (readonly HeaderCell[])[];
1001
+ readonly rowHeight: number;
1002
+ /** All header rows together. */
1003
+ readonly height: number;
1004
+ }
1005
+ /** Everything a renderer needs to draw the chart. Plain data — no DOM, no framework types. */
1006
+ interface ViewState {
1007
+ readonly viewport: Viewport;
1008
+ readonly project: ProjectState;
1009
+ readonly timeAxis: TimeAxis;
1010
+ readonly header: HeaderState;
1011
+ /** Columns of the task list on the left. */
1012
+ readonly columns: ColumnsState;
1013
+ /** Visible task rows (virtualized), in tree order, with their bars. */
1014
+ readonly rows: RowsState;
1015
+ /** Dependency arrows near the rendered rows (virtualized with them). */
1016
+ readonly dependencies: readonly DependencyLine[];
1017
+ /** Where "now" is on the timeline, or `null` when outside it (or turned off). */
1018
+ readonly today: TodayLine | null;
1019
+ /** Non-working time to shade, around the visible part of the timeline. */
1020
+ readonly nonWorkingTime: readonly TimeSpan[];
1021
+ /** What's being dragged, and where it would land; `null` when nothing is. */
1022
+ readonly interaction: TaskInteraction | null;
1023
+ /** Which drag interactions are on (from the options), e.g. to show their handles. The same object while unchanged. */
1024
+ readonly interactions: Interactions;
1025
+ /** Whether there's something to undo or redo. The same object while unchanged. */
1026
+ readonly history: HistoryState;
1027
+ /** Selected task ids, in the order they were selected. The same array while unchanged. */
1028
+ readonly selection: readonly Id[];
1029
+ /** The task the keyboard cursor is on, or `null`. */
1030
+ readonly activeId: Id | null;
1031
+ /** The tooltip for the task under the pointer, or `null`. The same object while it shows the same. */
1032
+ readonly tooltip: TaskTooltip | null;
1033
+ /** The cell being edited, or `null`. */
1034
+ readonly editing: CellEdit | null;
1035
+ /** The open context menu, or `null`. */
1036
+ readonly menu: MenuState | null;
1037
+ /** The open task editor, or `null`. */
1038
+ readonly taskEditor: TaskEditorState | null;
1039
+ /**
1040
+ * Where the renderer should scroll to (after zooming, or to show a new task). A new object for each request:
1041
+ * scroll when it changes.
1042
+ */
1043
+ readonly scrollTo: ScrollRequest | null;
1044
+ /** The task list's width, set with the divider between it and the timeline. */
1045
+ readonly list: ListPaneState;
1046
+ }
1047
+ interface ScrollRequest {
1048
+ readonly left?: number;
1049
+ readonly top?: number;
1050
+ }
1051
+ interface Interactions {
1052
+ readonly drag: boolean;
1053
+ readonly resize: boolean;
1054
+ readonly create: boolean;
1055
+ readonly progress: boolean;
1056
+ readonly link: boolean;
1057
+ }
1058
+ interface TodayLine {
1059
+ /** When the line was placed; it only moves once it reaches the next pixel. */
1060
+ readonly time: number;
1061
+ /** Whole pixels. */
1062
+ readonly x: number;
1063
+ }
1064
+ /**
1065
+ * Where a data change comes from: `'load'` is scheduling written back into data that was loaded (the initial
1066
+ * data, or other data passed in), `'edit'` any edit (in the chart, or `transact`), `'undo'` and `'redo'` the
1067
+ * history.
1068
+ */
1069
+ type GanttChangeSource = "load" | "edit" | "undo" | "redo";
1070
+ interface GanttDataChange {
1071
+ readonly patch: Patch;
1072
+ /** The project data with the change applied. */
1073
+ readonly data: ProjectData;
1074
+ /** Where the change comes from, e.g. to not mark a plan as unsaved for `'load'`. */
1075
+ readonly source: GanttChangeSource;
1076
+ }
1077
+ interface GanttOptions {
1078
+ /**
1079
+ * Controlled data. The engine never changes it on its own: edits are reported through `onChange`,
1080
+ * and only show up once new `data` is passed back in.
1081
+ *
1082
+ * Having the `data` key makes the chart controlled, even when the value is `undefined` (shown as an
1083
+ * empty project, e.g. while data is loading). Leave the key out entirely for uncontrolled usage.
1084
+ */
1085
+ data?: ProjectInput | undefined;
1086
+ /** Initial data for uncontrolled usage, where the engine keeps the edited data itself. */
1087
+ defaultData?: ProjectInput | undefined;
1088
+ onChange?: ((change: GanttDataChange) => void) | undefined;
1089
+ /**
1090
+ * A built-in preset id (`'hourAndDay'` … `'manyYears'`, default `'weekAndDay'`) or a custom preset. Custom
1091
+ * presets are compared by value, but a label function is compared by identity: define custom presets outside
1092
+ * render (or memoize them), or an inline function makes every render a change that rebuilds the time axis.
1093
+ */
1094
+ preset?: string | ViewPreset | undefined;
1095
+ /**
1096
+ * The timeline range. Defaults to the tasks' dates with a little padding. Strings without an offset are
1097
+ * read in the project's time zone. The timeline is always at least as wide as the viewport.
1098
+ */
1099
+ startDate?: DateInput | undefined;
1100
+ endDate?: DateInput | undefined;
1101
+ /** Locale for header labels and cells, e.g. `'nb-NO'`. Defaults to the runtime's locale. */
1102
+ locale?: string | undefined;
1103
+ /** Task list columns. Defaults to name, start, end and duration. */
1104
+ columns?: readonly ColumnInput[] | undefined;
1105
+ /** Height of a task row in pixels. Default 44. */
1106
+ rowHeight?: number | undefined;
1107
+ /** Height of each header row in pixels. Default 28. */
1108
+ headerRowHeight?: number | undefined;
1109
+ /** Show a line at the current time. Default `true`. */
1110
+ showToday?: boolean | undefined;
1111
+ /**
1112
+ * Shade non-working time from the project calendar. Default `true`. With ticks under a day, every non-working
1113
+ * interval is shaded; with day ticks, whole non-working days; with longer ticks, nothing.
1114
+ */
1115
+ showNonWorkingTime?: boolean | undefined;
1116
+ /**
1117
+ * Move tasks by dragging their bars. Default `true`. A drop is one change; an automatically scheduled task gets
1118
+ * a "start no earlier than" constraint at its new start.
1119
+ */
1120
+ taskDrag?: boolean | undefined;
1121
+ /** Change a task's duration by dragging the end of its bar. Default `true`. */
1122
+ taskResize?: boolean | undefined;
1123
+ /** Give an unscheduled task dates by drawing its bar in its row. Default `true`. */
1124
+ taskDragCreate?: boolean | undefined;
1125
+ /** Change a task's percentage done by dragging the handle at its progress. Default `true`. */
1126
+ progressDrag?: boolean | undefined;
1127
+ /** Add dependencies by dragging from a handle at either end of a bar to another bar. Default `true`. */
1128
+ dependencyCreate?: boolean | undefined;
1129
+ /**
1130
+ * Called for every change a drag proposes (move, resize, create, progress, link), while dragging and on the
1131
+ * drop. Return `false`, or a message to show, to refuse it: the preview shows it as invalid and the drop
1132
+ * changes nothing.
1133
+ */
1134
+ validateChange?: ((change: ProposedChange) => boolean | string) | undefined;
1135
+ /**
1136
+ * Keep a history of changes for `undo`/`redo` (the last 100). Default `true`. Turning it off forgets the
1137
+ * history. Controlled: a change counts once the app passes its data back; other data clears the history.
1138
+ */
1139
+ undoRedo?: boolean | undefined;
1140
+ /** Select several tasks (Ctrl/Cmd-click, Shift-click, Shift+arrows). Default `true`. */
1141
+ multiSelect?: boolean | undefined;
1142
+ /** Delete the selected tasks (with their subtasks) with Delete or Backspace. Default `true`. */
1143
+ deleteKey?: boolean | undefined;
1144
+ /** Called with the selected ids whenever the selection changes (also when deleted tasks drop out of it). */
1145
+ onSelectionChange?: ((selection: readonly Id[]) => void) | undefined;
1146
+ /** Show a tooltip for the task under the pointer (see `hover`). Default `true`. */
1147
+ taskTooltip?: boolean | undefined;
1148
+ /** Edit cells in the task list (double-click, Enter/F2). Default `true`. Each edit is one change. */
1149
+ cellEdit?: boolean | undefined;
1150
+ /** A context menu on tasks (right-click, the ContextMenu key or Shift+F10). Default `true`. */
1151
+ taskMenu?: boolean | undefined;
1152
+ /** A context menu on the time axis header, for zooming. Default `true`. */
1153
+ timeAxisMenu?: boolean | undefined;
1154
+ /** Change the task menu: gets the built-in items, returns the items to show. */
1155
+ taskMenuItems?: MenuCustomizer | undefined;
1156
+ /** Change the time axis menu: gets the built-in items, returns the items to show. */
1157
+ timeAxisMenuItems?: MenuCustomizer | undefined;
1158
+ /** Edit tasks in a dialog (the menu's Edit, or double-clicking a bar). Default `true`. */
1159
+ taskEdit?: boolean | undefined;
1160
+ /** Ids for tasks added from the menu. Defaults to unique ids like `task-12`. */
1161
+ createTaskId?: (() => Id) | undefined;
1162
+ /** Called with the preset's id after zooming (a zoom lasts until the `preset` option changes). */
1163
+ onPresetChange?: ((presetId: string) => void) | undefined;
1164
+ /**
1165
+ * Width of the task list in pixels (its pane, border included), or `null` for automatic: as wide as the
1166
+ * columns, up to `--qz-list-max-width`. Dragging the divider overrides it until the option changes.
1167
+ */
1168
+ listWidth?: number | null | undefined;
1169
+ /** Called after the divider changed the list's width (`null`: back to automatic, by double-clicking it). */
1170
+ onListWidthChange?: ((width: number | null) => void) | undefined;
1171
+ }
1172
+ interface GanttController {
1173
+ /** Returns the same object until the state changes, so it can back `useSyncExternalStore`. */
1174
+ getState: () => ViewState;
1175
+ /**
1176
+ * The first subscription also reports (through `onChange`, after a microtask) what scheduling changed in the
1177
+ * initial data, so the app can keep the scheduled data.
1178
+ */
1179
+ subscribe: (listener: (state: ViewState) => void) => () => void;
1180
+ /**
1181
+ * Updates options after creation. All options are validated first: an invalid one throws and changes
1182
+ * nothing. `data` is only honoured in controlled mode; controlled vs. uncontrolled is decided at creation.
1183
+ */
1184
+ setOptions: (options: GanttOptions) => void;
1185
+ setViewport: (viewport: Partial<Viewport>) => void;
1186
+ /**
1187
+ * What's under a point of the timeline body (x from the start of the axis, y from the top of the first
1188
+ * row): a bar to move or a bar end to resize, if enabled. For the pointer cursor.
1189
+ */
1190
+ hitTest: (point: TimelinePoint) => TimelineHit | null;
1191
+ /**
1192
+ * Pointer events on the timeline body, in the same coordinates. `pointerDown` returns whether the press
1193
+ * counts (so the renderer can capture the pointer until `pointerUp`). Moves under 3 px are a click, which
1194
+ * selects the row (with the modifiers held at the press); a drop is one transaction.
1195
+ */
1196
+ pointerDown: (point: TimelinePoint, modifiers?: KeyModifiers) => boolean;
1197
+ pointerMove: (point: TimelinePoint) => void;
1198
+ pointerUp: (point: TimelinePoint) => void;
1199
+ /** Drops the current drag without changing anything (e.g. on Escape). Returns whether there was one. */
1200
+ cancelInteraction: () => boolean;
1201
+ /**
1202
+ * Changes project data. Uncontrolled: applied immediately. Controlled: only reported through
1203
+ * `onChange`; edits in the same synchronous run build on each other, later edits build on the last
1204
+ * `data` passed in. Returns the patch, or `null` if nothing changed.
1205
+ */
1206
+ transact: (fn: (tx: Transaction) => void) => Patch | null;
1207
+ /**
1208
+ * Reverts the last change (exactly, scheduling included), as a change of its own: reported through
1209
+ * `onChange`, and in controlled mode shown once the data comes back. Returns whether there was one.
1210
+ */
1211
+ undo: () => boolean;
1212
+ /** Applies the last undone change again. Returns whether there was one. */
1213
+ redo: () => boolean;
1214
+ /**
1215
+ * A click on a row in the task list: selects it; Ctrl/Cmd toggles it, Shift selects the rows from the last
1216
+ * clicked one. Unknown and hidden rows are ignored.
1217
+ */
1218
+ rowClick: (id: Id, modifiers?: KeyModifiers) => void;
1219
+ /** Selects these tasks (unknown ids are skipped); the last one gets the keyboard cursor. */
1220
+ select: (ids: readonly Id[]) => void;
1221
+ clearSelection: () => void;
1222
+ /**
1223
+ * A key pressed while the chart has focus: moves the cursor and selection, expands and collapses, deletes,
1224
+ * undoes. Returns whether the key was used, so the renderer can stop it.
1225
+ */
1226
+ keyDown: (key: KeyInput) => boolean;
1227
+ /**
1228
+ * The `scrollTop` that brings a visible row into view (e.g. the active one after a key press), or `null`
1229
+ * when it's in view already, hidden or unknown.
1230
+ */
1231
+ revealTop: (id: Id) => number | null;
1232
+ /**
1233
+ * The pointer over the timeline body (mouse or pen), for the task tooltip; `null` when it leaves. In the
1234
+ * same coordinates as `pointerDown`.
1235
+ */
1236
+ hover: (point: TimelinePoint | null) => void;
1237
+ /**
1238
+ * Starts editing a cell (the first editable one of the row without a column). Returns whether it can be
1239
+ * edited; an open edit is closed either way.
1240
+ */
1241
+ startEdit: (id: Id, columnId?: string) => boolean;
1242
+ /** The text in the cell's field, as it's typed. */
1243
+ editInput: (text: string) => void;
1244
+ /**
1245
+ * A key pressed in the cell's field: Enter saves, Escape cancels, Tab and Shift+Tab save and move on.
1246
+ * Returns whether the key was used (other keys belong to the field).
1247
+ */
1248
+ editKeyDown: (key: KeyInput) => boolean;
1249
+ /** Saves the edit. Returns `false` (and keeps it open, with the reason in `error`) when it's refused. */
1250
+ commitEdit: () => boolean;
1251
+ cancelEdit: () => void;
1252
+ /**
1253
+ * Opens a context menu for a task or the time axis, at a point in the chart's coordinates (from the root
1254
+ * element's corner); without one, at the active row. Returns whether it opened.
1255
+ */
1256
+ openMenu: (target: MenuTarget, point?: {
1257
+ x: number;
1258
+ y: number;
1259
+ }) => boolean;
1260
+ /** A key pressed while the menu has focus. Returns whether it was used. */
1261
+ menuKeyDown: (key: KeyInput) => boolean;
1262
+ /** The pointer over a menu item: highlights it (and opens its submenu). */
1263
+ menuHover: (id: string) => void;
1264
+ /** Picks a menu item (and closes the menu). Disabled and unknown items are ignored. */
1265
+ menuAction: (id: string) => void;
1266
+ closeMenu: () => void;
1267
+ /** Zooms one step (`'in'` or `'out'`) or to a built-in preset by id, keeping the middle of the view. */
1268
+ zoom: (target: string) => boolean;
1269
+ /** Opens the task editor. Returns whether it opened. */
1270
+ openTaskEditor: (id: Id) => boolean;
1271
+ /** Everything done in the task editor: typing, tabs, dependencies, saving, closing. */
1272
+ taskEditorAction: (action: TaskEditorAction) => boolean;
1273
+ /**
1274
+ * The divider between the task list and the timeline: drag it (start, move, end or cancel), move it with keys
1275
+ * (arrows, with Shift for bigger steps, Home and End), or reset it to automatic. Returns whether it was used.
1276
+ */
1277
+ resizeList: (action: ListResizeAction) => boolean;
1278
+ /** A double-click on the timeline body: opens the editor for the bar there. Returns whether it did. */
1279
+ doubleClick: (point: TimelinePoint) => boolean;
1280
+ /** Expands a collapsed task or collapses an expanded one. Unknown ids and leaf tasks are ignored. */
1281
+ toggle: (id: Id) => void;
1282
+ setExpanded: (id: Id, expanded: boolean) => void;
1283
+ expandAll: () => void;
1284
+ collapseAll: () => void;
1285
+ destroy: () => void;
1286
+ }
1287
+ //#endregion
1288
+ //#region src/view/rows.d.ts
1289
+ interface Row {
1290
+ readonly id: Id;
1291
+ /** Unique string key for rendering lists (ids 1 and "1" are different tasks). */
1292
+ readonly key: string;
1293
+ /** Position among the visible rows. */
1294
+ readonly index: number;
1295
+ readonly y: number;
1296
+ readonly height: number;
1297
+ /** 0 for root tasks. */
1298
+ readonly depth: number;
1299
+ readonly task: Task;
1300
+ readonly hasChildren: boolean;
1301
+ readonly expanded: boolean;
1302
+ /** Computed display dates, or `null` for unscheduled tasks. */
1303
+ readonly dates: TaskDates | null;
1304
+ /** Cell texts, one per column. */
1305
+ readonly cells: readonly string[];
1306
+ /** The task's bar on the timeline, or `null` for unscheduled tasks. */
1307
+ readonly bar: Bar | null;
1308
+ readonly selected: boolean;
1309
+ /** The keyboard cursor is on this row. */
1310
+ readonly active: boolean;
1311
+ }
1312
+ interface RowsState {
1313
+ readonly rowHeight: number;
1314
+ /** Visible rows in total (not counting collapsed descendants). */
1315
+ readonly count: number;
1316
+ readonly totalHeight: number;
1317
+ /**
1318
+ * Rows around the visible part only (virtualized). Unchanged rows keep their identity, so they can be
1319
+ * memoized, and the array itself is reused while scrolling within the rendered window.
1320
+ */
1321
+ readonly items: readonly Row[];
1322
+ }
1323
+ //#endregion
1324
+ //#region src/view/dependencies.d.ts
1325
+ /** A dependency drawn as an arrow between two bars, in timeline coordinates. */
1326
+ interface DependencyLine {
1327
+ /** Unique string key for rendering lists (ids 1 and "1" are different dependencies). */
1328
+ readonly key: string;
1329
+ readonly id: Id;
1330
+ readonly from: Id;
1331
+ readonly to: Id;
1332
+ readonly type: DependencyType;
1333
+ /** SVG path data, orthogonal, ending at the successor (put the arrowhead there with `marker-end`). */
1334
+ readonly path: string;
1335
+ }
1336
+ //#endregion
1337
+ //#region src/view/createGantt.d.ts
1338
+ export declare function createGantt(options?: GanttOptions): GanttController;
1339
+ //#endregion
1340
+ export { type Bar, type BarInteraction, type BarKind, type BuiltInColumnId, type Calendar, type CalendarAddInput, type CalendarException, type CalendarExceptionInput, type CalendarInput, type CalendarTransaction, type CalendarUpdateInput, type CellContext, type CellEdit, type Column, type ColumnDefinition, type ColumnInput, type ColumnsState, type ConstraintType, type DateInput, type Dependency, type DependencyAddInput, type DependencyInput, type DependencyLine, type DependencyTransaction, type DependencyType, type DependencyUpdateInput, type DurationSettings, type EditKind, type GanttChangeSource, type GanttController, type GanttDataChange, type GanttOptions, type HeaderCell, type HeaderCellContext, type HeaderFormat, type HeaderFormatName, type HeaderRow, type HeaderState, type HistoryState, type HitArea, type Id, type IdGenerator, type Interactions, type Interval, type KeyInput, type KeyModifiers, type LinkInteraction, type ListPaneState, type ListResizeAction, type MenuContext, type MenuCustomizer, type MenuItem, type MenuState, type MenuTarget, type Operation, type Patch, type PlannedChange, type Project, type ProjectChange, type ProjectData, type ProjectInput, type ProjectOptions, type ProjectSettings, type ProjectSettingsInput, type ProjectState, type ProposedChange, type Row, type RowsState, type ScrollRequest, type SettingsOperation, type SettingsTransaction, type StoreName, type Table, type Task, type TaskAddInput, type TaskDates, type TaskEditorAction, type TaskEditorConstraint, type TaskEditorDependency, type TaskEditorField, type TaskEditorFieldState, type TaskEditorSide, type TaskEditorState, type TaskEditorTab, type TaskInput, type TaskInteraction, type TaskMenuItemId, type TaskPosition, type TaskTooltip, type TaskTransaction, type TaskUpdateInput, type Tick, type TimeAxis, type TimeAxisOptions, type TimeSpan, type TimeUnit, type TimeZone, type TimelineHit, type TimelinePoint, type TodayLine, type Transaction, type TreeIndex, type ViewPreset, type ViewState, type Viewport, type WallTime, type Weekday, type WorkingCalendar, type WorkingInterval, type ZonedWallTime, taskDates$1 as taskDates };
1341
+ //# sourceMappingURL=index.d.ts.map