gantt-renderer 0.5.0 → 0.7.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/CHANGELOG.md +10 -0
- package/dist/index.d.mts +155 -88
- package/dist/index.mjs +213 -66
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
# [0.7.0](https://github.com/doberkofler/gantt-renderer/compare/v0.6.0...v0.7.0) (2026-05-11)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **gantt:** simplify default grid columns and add showAddTaskButton option ([800c3cd](https://github.com/doberkofler/gantt-renderer/commit/800c3cdb02d42dfc266823e1d56c0c6cd0eaf009))
|
|
7
|
+
* **locale:** add built-in locale constants for 9 languages ([712254a](https://github.com/doberkofler/gantt-renderer/commit/712254acecc4110ad53de9de14833b2feb1ef16f))
|
|
8
|
+
* **types:** add generic type params to Task, Link, GanttInput, GanttChart ([561ebcf](https://github.com/doberkofler/gantt-renderer/commit/561ebcf01dd1610f0f80739bd29509a05e7848c5))
|
|
9
|
+
* **types:** make GanttInputRaw and parseGanttInput generic ([e665221](https://github.com/doberkofler/gantt-renderer/commit/e665221cd13ed58138770365079884cfcc5067fe))
|
|
10
|
+
|
|
1
11
|
# [0.5.0](https://github.com/doberkofler/gantt-renderer/compare/v0.4.0...v0.5.0) (2026-05-09)
|
|
2
12
|
|
|
3
13
|
|
package/dist/index.d.mts
CHANGED
|
@@ -27,7 +27,7 @@ declare const SpecialDaySchema: z.ZodObject<{
|
|
|
27
27
|
}, z.core.$strip>;
|
|
28
28
|
declare const TaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
29
29
|
kind: z.ZodLiteral<"task">;
|
|
30
|
-
|
|
30
|
+
endDate: z.ZodString;
|
|
31
31
|
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
32
32
|
id: z.ZodNumber;
|
|
33
33
|
text: z.ZodString;
|
|
@@ -38,7 +38,7 @@ declare const TaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
38
38
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
39
39
|
}, z.core.$strip>, z.ZodObject<{
|
|
40
40
|
kind: z.ZodLiteral<"project">;
|
|
41
|
-
|
|
41
|
+
endDate: z.ZodString;
|
|
42
42
|
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
43
43
|
open: z.ZodDefault<z.ZodBoolean>;
|
|
44
44
|
id: z.ZodNumber;
|
|
@@ -74,7 +74,7 @@ declare const LinkSchema: z.ZodObject<{
|
|
|
74
74
|
declare const GanttInputSchema: z.ZodObject<{
|
|
75
75
|
tasks: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
76
76
|
kind: z.ZodLiteral<"task">;
|
|
77
|
-
|
|
77
|
+
endDate: z.ZodString;
|
|
78
78
|
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
79
79
|
id: z.ZodNumber;
|
|
80
80
|
text: z.ZodString;
|
|
@@ -85,7 +85,7 @@ declare const GanttInputSchema: z.ZodObject<{
|
|
|
85
85
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
86
86
|
}, z.core.$strip>, z.ZodObject<{
|
|
87
87
|
kind: z.ZodLiteral<"project">;
|
|
88
|
-
|
|
88
|
+
endDate: z.ZodString;
|
|
89
89
|
percentComplete: z.ZodDefault<z.ZodNumber>;
|
|
90
90
|
open: z.ZodDefault<z.ZodBoolean>;
|
|
91
91
|
id: z.ZodNumber;
|
|
@@ -119,43 +119,98 @@ declare const GanttInputSchema: z.ZodObject<{
|
|
|
119
119
|
data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
120
120
|
}, z.core.$strip>>>;
|
|
121
121
|
}, z.core.$strip>;
|
|
122
|
-
/**
|
|
123
|
-
type
|
|
124
|
-
/**
|
|
125
|
-
type
|
|
126
|
-
/**
|
|
127
|
-
type
|
|
128
|
-
|
|
129
|
-
type
|
|
122
|
+
/** @internal */
|
|
123
|
+
type ZodTaskInferred = z.infer<typeof TaskSchema>;
|
|
124
|
+
/** @internal */
|
|
125
|
+
type ZodLinkInferred = z.infer<typeof LinkSchema>;
|
|
126
|
+
/** @internal */
|
|
127
|
+
type ZodTaskInput = z.input<typeof TaskSchema>;
|
|
128
|
+
/** @internal */
|
|
129
|
+
type ZodLinkInput = z.input<typeof LinkSchema>;
|
|
130
|
+
/** Raw input version of a task — uses zod's input shape where fields with defaults are optional. */
|
|
131
|
+
type TaskRaw<TData = never> = WithoutData<ZodTaskInput> & WithData<TData>;
|
|
132
|
+
/** Raw input version of a link — uses zod's input shape where fields with defaults are optional. */
|
|
133
|
+
type LinkRaw<TData = never> = WithoutData<ZodLinkInput> & WithData<TData>;
|
|
134
|
+
/**
|
|
135
|
+
* Conditional data property helper.
|
|
136
|
+
* When `T` is `never`, adds nothing. Otherwise adds `{data?: T | undefined}`.
|
|
137
|
+
*/
|
|
138
|
+
type WithData<T> = [T] extends [never] ? Record<never, never> : {
|
|
139
|
+
data?: T | undefined;
|
|
140
|
+
};
|
|
130
141
|
/**
|
|
131
|
-
*
|
|
142
|
+
* Distributes `Omit` over union members so variant-specific properties
|
|
143
|
+
* (e.g. `endDate`, `percentComplete`, `open`) are preserved in discriminated unions.
|
|
144
|
+
*/
|
|
145
|
+
type WithoutData<T> = T extends unknown ? Omit<T, 'data'> : never;
|
|
146
|
+
/**
|
|
147
|
+
* A task in the Gantt chart — discriminated by `kind` into leaf tasks,
|
|
132
148
|
* summary projects, and milestones.
|
|
133
149
|
*
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* -
|
|
150
|
+
* @param TData - The type of the optional `data` property. Defaults to `never`,
|
|
151
|
+
* which omits the `data` property from the type. Specify a concrete type to enable
|
|
152
|
+
* compile-time-checked task data in both input and callback payloads.
|
|
153
|
+
*
|
|
154
|
+
* @example
|
|
155
|
+
* ```ts
|
|
156
|
+
* // Default: no `data` property
|
|
157
|
+
* const task: Task = { id: 1, text: 'Build', startDate: '2026-01-01', endDate: '2026-01-03', kind: 'task' };
|
|
158
|
+
*
|
|
159
|
+
* // With typed data
|
|
160
|
+
* interface TaskMeta { priority: number; label: string }
|
|
161
|
+
* const typedTask: Task<TaskMeta> = {
|
|
162
|
+
* id: 1, text: 'Build', startDate: '2026-01-01', endDate: '2026-01-03',
|
|
163
|
+
* kind: 'task', data: { priority: 1, label: 'critical' }
|
|
164
|
+
* };
|
|
165
|
+
* ```
|
|
137
166
|
*/
|
|
138
|
-
type Task =
|
|
167
|
+
type Task<TData = never> = WithoutData<ZodTaskInferred> & WithData<TData>;
|
|
139
168
|
/**
|
|
140
|
-
* A dependency link between two tasks.
|
|
141
|
-
*
|
|
169
|
+
* A dependency link between two tasks.
|
|
170
|
+
*
|
|
171
|
+
* @param TData - The type of the optional `data` property. Defaults to `never`.
|
|
142
172
|
*/
|
|
143
|
-
type Link =
|
|
173
|
+
type Link<TData = never> = WithoutData<ZodLinkInferred> & WithData<TData>;
|
|
144
174
|
/**
|
|
145
175
|
* The complete input data for the chart.
|
|
146
176
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
177
|
+
* @param TTaskData - The type of the `data` property on tasks. Defaults to `never`.
|
|
178
|
+
* @param TLinkData - The type of the `data` property on links. Defaults to `never`.
|
|
149
179
|
*/
|
|
150
|
-
type GanttInput =
|
|
180
|
+
type GanttInput<TTaskData = never, TLinkData = never> = {
|
|
181
|
+
tasks: Task<TTaskData>[];
|
|
182
|
+
links: Link<TLinkData>[];
|
|
183
|
+
};
|
|
184
|
+
/**
|
|
185
|
+
* The raw, unvalidated input shape that consumers pass to {@link parseGanttInput}.
|
|
186
|
+
*
|
|
187
|
+
* Fields with defaults in the schema (e.g. `percentComplete`, `type`) remain optional here.
|
|
188
|
+
*
|
|
189
|
+
* @param TTaskData - The type of the `data` property on tasks. Defaults to `never`.
|
|
190
|
+
* @param TLinkData - The type of the `data` property on links. Defaults to `never`.
|
|
191
|
+
*/
|
|
192
|
+
type GanttInputRaw<TTaskData = never, TLinkData = never> = {
|
|
193
|
+
tasks: TaskRaw<TTaskData>[];
|
|
194
|
+
links?: LinkRaw<TLinkData>[];
|
|
195
|
+
};
|
|
196
|
+
/** Allowed dependency link type values: `'FS'`, `'SS'`, `'FF'`, or `'SF'`. */
|
|
197
|
+
type LinkType = z.infer<typeof LinkTypeSchema>;
|
|
198
|
+
/** Allowed task kind values: `'task'`, `'project'`, or `'milestone'`. */
|
|
199
|
+
type TaskKind = z.infer<typeof TaskKindSchema>;
|
|
200
|
+
type SpecialDayKind = z.infer<typeof SpecialDayKindSchema>;
|
|
201
|
+
type SpecialDay = z.infer<typeof SpecialDaySchema>;
|
|
151
202
|
/**
|
|
152
203
|
* Parses raw external data.
|
|
153
204
|
*
|
|
205
|
+
* Compile-time generics enforce the `data` shape on tasks and links.
|
|
206
|
+
* Runtime validation is done by the zod schemas; the `data` field is
|
|
207
|
+
* validated as a generic object at runtime regardless of the type parameter.
|
|
208
|
+
*
|
|
154
209
|
* @param raw - The unvalidated input from the consumer.
|
|
155
|
-
* @returns The parsed and validated
|
|
210
|
+
* @returns The parsed and validated input with `data` typed per the type parameters.
|
|
156
211
|
* @throws {import('zod').ZodError} On schema validation failure.
|
|
157
212
|
*/
|
|
158
|
-
declare function parseGanttInput(raw: GanttInputRaw): GanttInput
|
|
213
|
+
declare function parseGanttInput<TTaskData = never, TLinkData = never>(raw: GanttInputRaw<TTaskData, TLinkData>): GanttInput<TTaskData, TLinkData>;
|
|
159
214
|
//#endregion
|
|
160
215
|
//#region src/lib/timeline/scale.d.ts
|
|
161
216
|
type TimeScale = 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year';
|
|
@@ -174,7 +229,7 @@ declare const SCALE_CONFIGS: Record<TimeScale, ScaleConfig>;
|
|
|
174
229
|
* Produced by {@link buildTaskTree}; consumed by virtualized row rendering
|
|
175
230
|
* and the timeline layout engine.
|
|
176
231
|
*/
|
|
177
|
-
type TaskNode =
|
|
232
|
+
type TaskNode = ZodTaskInferred & {
|
|
178
233
|
/** Array of child task nodes in the tree hierarchy. */children: TaskNode[]; /** 0 = root */
|
|
179
234
|
depth: number;
|
|
180
235
|
};
|
|
@@ -188,7 +243,7 @@ type TaskNode = Task & {
|
|
|
188
243
|
* when a parent cycle is detected, or when a `parent` points to a
|
|
189
244
|
* milestone or leaf task.
|
|
190
245
|
*/
|
|
191
|
-
declare function buildTaskTree(tasks:
|
|
246
|
+
declare function buildTaskTree(tasks: ZodTaskInferred[]): TaskNode[];
|
|
192
247
|
/**
|
|
193
248
|
* Flattens a tree into a visible row list.
|
|
194
249
|
* A node's children are included only when its id is in `expandedIds`.
|
|
@@ -209,9 +264,9 @@ declare function isParent(node: TaskNode): boolean;
|
|
|
209
264
|
//#region src/lib/timeline/pixelMapper.d.ts
|
|
210
265
|
type PixelMapper = {
|
|
211
266
|
/** Date → x pixel offset from viewport start */toX: (date: Date) => number; /** x pixel offset → Date */
|
|
212
|
-
toDate: (x: number) => Date; /**
|
|
213
|
-
|
|
214
|
-
|
|
267
|
+
toDate: (x: number) => Date; /** Days → pixel width */
|
|
268
|
+
durationDaysToWidth: (days: number) => number; /** Pixel width → days (float) */
|
|
269
|
+
widthToDurationDays: (px: number) => number; /** The origin timestamp used for this mapper */
|
|
215
270
|
originMs: number; /** Pixel width of one column unit */
|
|
216
271
|
columnWidth: number;
|
|
217
272
|
};
|
|
@@ -268,7 +323,7 @@ declare function computeLayout(rows: TaskNode[], mapper: PixelMapper): Map<numbe
|
|
|
268
323
|
declare function deriveViewport(tasks: TaskNode[], paddingHours?: number): [Date, Date];
|
|
269
324
|
//#endregion
|
|
270
325
|
//#region src/lib/locale.d.ts
|
|
271
|
-
type LocaleLabelKey = 'ariaTask' | 'ariaMilestone' | 'addSubtaskTitle' | 'columnTaskName' | 'columnStartDate' | 'columnDuration' | 'columnQuarter';
|
|
326
|
+
type LocaleLabelKey = 'ariaTask' | 'ariaMilestone' | 'addSubtaskTitle' | 'columnTaskName' | 'columnStartDate' | 'columnEndDate' | 'columnDuration' | 'columnQuarter';
|
|
272
327
|
type ChartLocale = {
|
|
273
328
|
code: string;
|
|
274
329
|
labels?: Partial<Record<LocaleLabelKey, string>>;
|
|
@@ -278,6 +333,14 @@ type ChartLocale = {
|
|
|
278
333
|
};
|
|
279
334
|
declare const EN_US_LABELS: Record<LocaleLabelKey, string>;
|
|
280
335
|
declare const CHART_LOCALE_EN_US: ChartLocale;
|
|
336
|
+
declare const CHART_LOCALE_EN_GB: ChartLocale;
|
|
337
|
+
declare const CHART_LOCALE_DE_DE: ChartLocale;
|
|
338
|
+
declare const CHART_LOCALE_FR_FR: ChartLocale;
|
|
339
|
+
declare const CHART_LOCALE_ES_ES: ChartLocale;
|
|
340
|
+
declare const CHART_LOCALE_IT_IT: ChartLocale;
|
|
341
|
+
declare const CHART_LOCALE_PT_PT: ChartLocale;
|
|
342
|
+
declare const CHART_LOCALE_ZH_CN: ChartLocale;
|
|
343
|
+
declare const CHART_LOCALE_JA_JP: ChartLocale;
|
|
281
344
|
/**
|
|
282
345
|
* Derives the first day of week (0=Sun, 1=Mon, 6=Sat) from a BCP 47 code.
|
|
283
346
|
* Uses `Intl.Locale.getWeekInfo()` where available (Chromium, Safari 15.4+),
|
|
@@ -340,7 +403,7 @@ declare function formatLabel(template: string, arg: string): string;
|
|
|
340
403
|
* @param links - The dependency links defining the directed edges.
|
|
341
404
|
* @throws {GanttError} When a cycle is detected, with a human-readable cycle path.
|
|
342
405
|
*/
|
|
343
|
-
declare function detectCycles(tasks:
|
|
406
|
+
declare function detectCycles(tasks: ZodTaskInferred[], links: ZodLinkInferred[]): void;
|
|
344
407
|
/**
|
|
345
408
|
* Validates that every link references existing task IDs and that no
|
|
346
409
|
* duplicate (source, target) pairs exist.
|
|
@@ -351,7 +414,7 @@ declare function detectCycles(tasks: Task[], links: Link[]): void;
|
|
|
351
414
|
* when a non-FS link connects to/from a milestone, or when duplicate
|
|
352
415
|
* (source, target) pairs exist.
|
|
353
416
|
*/
|
|
354
|
-
declare function validateLinkRefs(tasks:
|
|
417
|
+
declare function validateLinkRefs(tasks: ZodTaskInferred[], links: ZodLinkInferred[]): void;
|
|
355
418
|
//#endregion
|
|
356
419
|
//#region src/lib/domain/dateMath.d.ts
|
|
357
420
|
/**
|
|
@@ -416,7 +479,7 @@ type RoutedLink = {
|
|
|
416
479
|
* @param layouts - A map from task ID to its computed {@link BarLayout}.
|
|
417
480
|
* @returns An array of {@link RoutedLink} objects with computed vertex paths.
|
|
418
481
|
*/
|
|
419
|
-
declare function routeLinks(links:
|
|
482
|
+
declare function routeLinks(links: ZodLinkInferred[], layouts: Map<number, BarLayout>): RoutedLink[];
|
|
420
483
|
//#endregion
|
|
421
484
|
//#region src/lib/vanilla/dom/gridColumns.d.ts
|
|
422
485
|
/**
|
|
@@ -424,7 +487,7 @@ declare function routeLinks(links: Link[], layouts: Map<number, BarLayout>): Rou
|
|
|
424
487
|
* Use when referencing task fields in grid column schemas that apply
|
|
425
488
|
* across a heterogeneous set of task kinds.
|
|
426
489
|
*/
|
|
427
|
-
type TaskDataField = keyof
|
|
490
|
+
type TaskDataField = keyof ZodTaskInferred | 'endDate' | 'percentComplete' | 'open';
|
|
428
491
|
type GridColumn = {
|
|
429
492
|
id: string;
|
|
430
493
|
header: string;
|
|
@@ -432,7 +495,7 @@ type GridColumn = {
|
|
|
432
495
|
align?: 'left' | 'center' | 'right';
|
|
433
496
|
visible?: boolean;
|
|
434
497
|
field?: TaskDataField;
|
|
435
|
-
format?: (value: unknown, task:
|
|
498
|
+
format?: (value: unknown, task: ZodTaskInferred, row: TaskNode, locale: ChartLocale) => string;
|
|
436
499
|
};
|
|
437
500
|
declare const DEFAULT_GRID_COLUMNS: GridColumn[];
|
|
438
501
|
/**
|
|
@@ -468,72 +531,72 @@ declare const GRID_COLUMN_FR_MIN_WIDTH = 120;
|
|
|
468
531
|
declare function gridNaturalWidth(columns: GridColumn[]): number;
|
|
469
532
|
//#endregion
|
|
470
533
|
//#region src/lib/vanilla/gantt-chart.d.ts
|
|
471
|
-
type OnTaskClick = (payload: {
|
|
472
|
-
task: Task
|
|
473
|
-
instance: GanttInstance
|
|
534
|
+
type OnTaskClick<TTaskData = never, TLinkData = never> = (payload: {
|
|
535
|
+
task: Task<TTaskData>;
|
|
536
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
474
537
|
}) => void | Promise<void>;
|
|
475
|
-
type OnTaskDoubleClick = (payload: {
|
|
476
|
-
task: Task
|
|
477
|
-
instance: GanttInstance
|
|
538
|
+
type OnTaskDoubleClick<TTaskData = never, TLinkData = never> = (payload: {
|
|
539
|
+
task: Task<TTaskData>;
|
|
540
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
478
541
|
}) => void | Promise<void>;
|
|
479
|
-
type OnTaskMove = (payload: {
|
|
480
|
-
task: Task
|
|
542
|
+
type OnTaskMove<TTaskData = never, TLinkData = never> = (payload: {
|
|
543
|
+
task: Task<TTaskData>;
|
|
481
544
|
newStartDate: Date;
|
|
482
545
|
newEndDate: Date;
|
|
483
|
-
instance: GanttInstance
|
|
546
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
484
547
|
}) => boolean | Promise<boolean>;
|
|
485
|
-
type OnTaskResize = (payload: {
|
|
486
|
-
task: Task
|
|
548
|
+
type OnTaskResize<TTaskData = never, TLinkData = never> = (payload: {
|
|
549
|
+
task: Task<TTaskData>;
|
|
487
550
|
newDurationHours: number;
|
|
488
551
|
newStartDate: Date;
|
|
489
552
|
newEndDate: Date;
|
|
490
|
-
instance: GanttInstance
|
|
553
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
491
554
|
}) => boolean | Promise<boolean>;
|
|
492
|
-
type OnTaskAdd = (payload: {
|
|
493
|
-
parentTask: Task
|
|
494
|
-
instance: GanttInstance
|
|
555
|
+
type OnTaskAdd<TTaskData = never, TLinkData = never> = (payload: {
|
|
556
|
+
parentTask: Task<TTaskData>;
|
|
557
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
495
558
|
}) => boolean | Promise<boolean>;
|
|
496
|
-
type OnLinkCreate = (payload: {
|
|
559
|
+
type OnLinkCreate<TTaskData = never, TLinkData = never> = (payload: {
|
|
497
560
|
type: 'FS';
|
|
498
|
-
sourceTask: Task
|
|
499
|
-
targetTask: Task
|
|
500
|
-
instance: GanttInstance
|
|
561
|
+
sourceTask: Task<TTaskData>;
|
|
562
|
+
targetTask: Task<TTaskData>;
|
|
563
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
501
564
|
}) => boolean | Promise<boolean>;
|
|
502
|
-
type OnLinkClick = (payload: {
|
|
503
|
-
link: Link
|
|
504
|
-
instance: GanttInstance
|
|
565
|
+
type OnLinkClick<TTaskData = never, TLinkData = never> = (payload: {
|
|
566
|
+
link: Link<TLinkData>;
|
|
567
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
505
568
|
}) => void | Promise<void>;
|
|
506
|
-
type OnLinkDblClick = (payload: {
|
|
507
|
-
link: Link
|
|
508
|
-
instance: GanttInstance
|
|
569
|
+
type OnLinkDblClick<TTaskData = never, TLinkData = never> = (payload: {
|
|
570
|
+
link: Link<TLinkData>;
|
|
571
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
509
572
|
}) => void | Promise<void>;
|
|
510
|
-
type OnProgressChange = (payload: {
|
|
511
|
-
task: Task
|
|
573
|
+
type OnProgressChange<TTaskData = never, TLinkData = never> = (payload: {
|
|
574
|
+
task: Task<TTaskData>;
|
|
512
575
|
newPercentComplete: number;
|
|
513
|
-
instance: GanttInstance
|
|
576
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
514
577
|
}) => boolean | Promise<boolean>;
|
|
515
|
-
type OnTooltipText = (payload: {
|
|
516
|
-
task: Task
|
|
517
|
-
instance: GanttInstance
|
|
578
|
+
type OnTooltipText<TTaskData = never, TLinkData = never> = (payload: {
|
|
579
|
+
task: Task<TTaskData>;
|
|
580
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
518
581
|
}) => string | null;
|
|
519
|
-
type GanttCallbacks = {
|
|
520
|
-
onTaskClick?: OnTaskClick
|
|
521
|
-
onTaskDoubleClick?: OnTaskDoubleClick
|
|
522
|
-
onTaskMove?: OnTaskMove
|
|
523
|
-
onTaskResize?: OnTaskResize
|
|
524
|
-
onTaskAdd?: OnTaskAdd
|
|
525
|
-
onLinkCreate?: OnLinkCreate
|
|
526
|
-
onLinkClick?: OnLinkClick
|
|
527
|
-
onLinkDblClick?: OnLinkDblClick
|
|
528
|
-
onProgressChange?: OnProgressChange
|
|
529
|
-
onTooltipText?: OnTooltipText
|
|
582
|
+
type GanttCallbacks<TTaskData = never, TLinkData = never> = {
|
|
583
|
+
onTaskClick?: OnTaskClick<TTaskData, TLinkData>;
|
|
584
|
+
onTaskDoubleClick?: OnTaskDoubleClick<TTaskData, TLinkData>;
|
|
585
|
+
onTaskMove?: OnTaskMove<TTaskData, TLinkData>;
|
|
586
|
+
onTaskResize?: OnTaskResize<TTaskData, TLinkData>;
|
|
587
|
+
onTaskAdd?: OnTaskAdd<TTaskData, TLinkData>;
|
|
588
|
+
onLinkCreate?: OnLinkCreate<TTaskData, TLinkData>;
|
|
589
|
+
onLinkClick?: OnLinkClick<TTaskData, TLinkData>;
|
|
590
|
+
onLinkDblClick?: OnLinkDblClick<TTaskData, TLinkData>;
|
|
591
|
+
onProgressChange?: OnProgressChange<TTaskData, TLinkData>;
|
|
592
|
+
onTooltipText?: OnTooltipText<TTaskData, TLinkData>;
|
|
530
593
|
onLeftPaneWidthChange?: (payload: {
|
|
531
594
|
width: number;
|
|
532
|
-
instance: GanttInstance
|
|
595
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
533
596
|
}) => void | Promise<void>;
|
|
534
597
|
onGridColumnsChange?: (payload: {
|
|
535
598
|
columns: GridColumn[];
|
|
536
|
-
instance: GanttInstance
|
|
599
|
+
instance: GanttInstance<TTaskData, TLinkData>;
|
|
537
600
|
}) => void | Promise<void>;
|
|
538
601
|
};
|
|
539
602
|
type ThemeMode = 'light' | 'dark' | 'system';
|
|
@@ -557,11 +620,12 @@ type GanttOptions = {
|
|
|
557
620
|
specialDays?: SpecialDay[];
|
|
558
621
|
gridColumns?: GridColumn[];
|
|
559
622
|
theme?: ThemeMode;
|
|
623
|
+
showAddTaskButton?: boolean;
|
|
560
624
|
};
|
|
561
|
-
type GanttInstance = {
|
|
562
|
-
update: (input: GanttInput) => void;
|
|
625
|
+
type GanttInstance<TTaskData = never, TLinkData = never> = {
|
|
626
|
+
update: (input: GanttInput<TTaskData, TLinkData>) => void;
|
|
563
627
|
setOptions: (opts: Partial<GanttOptions>) => void;
|
|
564
|
-
setCallbacks: (cbs: GanttCallbacks) => void;
|
|
628
|
+
setCallbacks: (cbs: GanttCallbacks<TTaskData, TLinkData>) => void;
|
|
565
629
|
select: (id: number | null, fireCallback?: boolean) => void;
|
|
566
630
|
collapseAll: () => void;
|
|
567
631
|
expandAll: () => void;
|
|
@@ -572,15 +636,18 @@ type GanttInstance = {
|
|
|
572
636
|
* Validates input, builds a DOM tree, and renders a full interactive chart
|
|
573
637
|
* inside the given container element.
|
|
574
638
|
*
|
|
639
|
+
* @param TTaskData - The type of the optional `data` property on tasks. Defaults to `never`.
|
|
640
|
+
* @param TLinkData - The type of the optional `data` property on links. Defaults to `never`.
|
|
641
|
+
*
|
|
575
642
|
* @example
|
|
576
643
|
* ```ts
|
|
577
|
-
* const chart = new GanttChart(document.getElementById('chart')!,
|
|
644
|
+
* const chart = new GanttChart(document.getElementById('chart')!, {
|
|
578
645
|
* locale: 'de-DE',
|
|
579
646
|
* theme: 'dark',
|
|
580
647
|
* });
|
|
581
648
|
* ```
|
|
582
649
|
*/
|
|
583
|
-
declare class GanttChart implements GanttInstance {
|
|
650
|
+
declare class GanttChart<TTaskData = never, TLinkData = never> implements GanttInstance<TTaskData, TLinkData> {
|
|
584
651
|
#private;
|
|
585
652
|
/**
|
|
586
653
|
* Constructs a new chart, builds the DOM, and wires internal event handling.
|
|
@@ -598,14 +665,14 @@ declare class GanttChart implements GanttInstance {
|
|
|
598
665
|
* @param cbs - The {@link GanttCallbacks} to register.
|
|
599
666
|
* @throws {GanttError} When the instance has been destroyed.
|
|
600
667
|
*/
|
|
601
|
-
setCallbacks(cbs: GanttCallbacks): void;
|
|
668
|
+
setCallbacks(cbs: GanttCallbacks<TTaskData, TLinkData>): void;
|
|
602
669
|
/**
|
|
603
670
|
* Replaces the full dataset and re-renders.
|
|
604
671
|
*
|
|
605
672
|
* @param newInput - The new {@link GanttInput} to apply.
|
|
606
673
|
* @throws {GanttError} When the instance has been destroyed.
|
|
607
674
|
*/
|
|
608
|
-
update(newInput: GanttInput): void;
|
|
675
|
+
update(newInput: GanttInput<TTaskData, TLinkData>): void;
|
|
609
676
|
/**
|
|
610
677
|
* Merges the supplied options into the current configuration and re-renders
|
|
611
678
|
* only the panes affected by the changed options.
|
|
@@ -657,5 +724,5 @@ declare class GanttError extends Error {
|
|
|
657
724
|
constructor(code: GanttErrorCode, message: string);
|
|
658
725
|
}
|
|
659
726
|
//#endregion
|
|
660
|
-
export { BAR_HEIGHT, BAR_Y_OFFSET, type BarLayout, CHART_LOCALE_EN_US, type ChartLocale, DEFAULT_GRID_COLUMNS, DENSITY, EN_US_LABELS, GRID_COLUMN_FR_MIN_WIDTH, type GanttCallbacks, GanttChart, GanttError, type GanttErrorCode, type GanttInput, type GanttInputRaw, GanttInputSchema, type GanttInstance, type GanttOptions, type GridColumn, type Link, LinkSchema, type LinkType, LinkTypeSchema, type LocaleLabelKey, MILESTONE_HALF, MILESTONE_SIZE, type OnLinkClick, type OnLinkCreate, type OnLinkDblClick, type OnProgressChange, type OnTaskAdd, type OnTaskClick, type OnTaskDoubleClick, type OnTaskMove, type OnTaskResize, type OnTooltipText, type PixelMapper, type Point, ROW_HEIGHT, type RoutedLink, SCALE_CONFIGS, type ScaleConfig, type SpecialDay, type SpecialDayKind, SpecialDayKindSchema, SpecialDaySchema, type Task, type TaskDataField, type TaskKind, TaskKindSchema, type TaskNode, TaskSchema, type ThemeMode, type TimeScale, addDays, addHours, buildTaskTree, computeLayout, createPixelMapper, deriveViewport, deriveWeekNumbering, deriveWeekStartsOn, deriveWeekendDays, detectCycles, diffDays, diffHours, flattenTree, formatLabel, formatWeekNumber, gridColumnDefaults, gridNaturalWidth, gridTemplateColumns, isParent, parseDate, parseGanttInput, resolveChartLocale, routeLinks, validateLinkRefs, visibleColumns };
|
|
727
|
+
export { BAR_HEIGHT, BAR_Y_OFFSET, type BarLayout, CHART_LOCALE_DE_DE, CHART_LOCALE_EN_GB, CHART_LOCALE_EN_US, CHART_LOCALE_ES_ES, CHART_LOCALE_FR_FR, CHART_LOCALE_IT_IT, CHART_LOCALE_JA_JP, CHART_LOCALE_PT_PT, CHART_LOCALE_ZH_CN, type ChartLocale, DEFAULT_GRID_COLUMNS, DENSITY, EN_US_LABELS, GRID_COLUMN_FR_MIN_WIDTH, type GanttCallbacks, GanttChart, GanttError, type GanttErrorCode, type GanttInput, type GanttInputRaw, GanttInputSchema, type GanttInstance, type GanttOptions, type GridColumn, type Link, LinkSchema, type LinkType, LinkTypeSchema, type LocaleLabelKey, MILESTONE_HALF, MILESTONE_SIZE, type OnLinkClick, type OnLinkCreate, type OnLinkDblClick, type OnProgressChange, type OnTaskAdd, type OnTaskClick, type OnTaskDoubleClick, type OnTaskMove, type OnTaskResize, type OnTooltipText, type PixelMapper, type Point, ROW_HEIGHT, type RoutedLink, SCALE_CONFIGS, type ScaleConfig, type SpecialDay, type SpecialDayKind, SpecialDayKindSchema, SpecialDaySchema, type Task, type TaskDataField, type TaskKind, TaskKindSchema, type TaskNode, TaskSchema, type ThemeMode, type TimeScale, addDays, addHours, buildTaskTree, computeLayout, createPixelMapper, deriveViewport, deriveWeekNumbering, deriveWeekStartsOn, deriveWeekendDays, detectCycles, diffDays, diffHours, flattenTree, formatLabel, formatWeekNumber, gridColumnDefaults, gridNaturalWidth, gridTemplateColumns, isParent, parseDate, parseGanttInput, resolveChartLocale, routeLinks, validateLinkRefs, visibleColumns };
|
|
661
728
|
//# sourceMappingURL=index.d.mts.map
|