gantt-renderer 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,15 +1,19 @@
1
- # [0.3.0](https://github.com/doberkofler/gantt-renderer/compare/v0.2.0...v0.3.0) (2026-05-08)
1
+ # [0.4.0](https://github.com/doberkofler/gantt-renderer/compare/v0.2.0...v0.4.0) (2026-05-09)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
6
  * correct link routing geometry and dependency layer rendering ([d00de8a](https://github.com/doberkofler/gantt-renderer/commit/d00de8a8b51d69b7b50ec4c6bf0ce6dd3657e1a8))
7
+ * improve lint rules ([1644377](https://github.com/doberkofler/gantt-renderer/commit/1644377da0294838a77386ac4d74832c289fcbfb))
7
8
  * **interaction:** deep-clone input in update() to prevent drag mutations leaking to consumer data ([ce814a0](https://github.com/doberkofler/gantt-renderer/commit/ce814a02bb87230108635ae663f165497f522f7e)), closes [#patchTask](https://github.com/doberkofler/gantt-renderer/issues/patchTask)
9
+ * prevent spurious onTaskMove callback on double-click in timeline ([14976d0](https://github.com/doberkofler/gantt-renderer/commit/14976d0ca8e17bf0b47b34a91e184513e316e811))
8
10
  * **rendering:** offset multi-row link midpoint to avoid bar center slicing ([1fe09fa](https://github.com/doberkofler/gantt-renderer/commit/1fe09fa3d736cf948035c4f1619f398fa374464d))
9
11
 
10
12
 
11
13
  ### Features
12
14
 
15
+ * add custom tooltip support with onTooltipText callback ([eacc7a8](https://github.com/doberkofler/gantt-renderer/commit/eacc7a845d346f007b4c7ad5a9ed901f9d2e8d60))
16
+ * add readonly support for tasks and links ([48cd946](https://github.com/doberkofler/gantt-renderer/commit/48cd946fe0b22bbcba18cb6b8e04d62d285300a0))
13
17
  * **interaction:** add progress bar drag with progressDragEnabled option ([77833b5](https://github.com/doberkofler/gantt-renderer/commit/77833b50b5984158bd9a2ab3ddcc744d05ccb18f))
14
18
 
15
19
  # [0.2.0](https://github.com/doberkofler/gantt-renderer/compare/v0.1.3...v0.2.0) (2026-05-07)
package/dist/index.d.mts CHANGED
@@ -34,6 +34,7 @@ declare const TaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
34
34
  startDate: z.ZodString;
35
35
  parent: z.ZodOptional<z.ZodNumber>;
36
36
  color: z.ZodOptional<z.ZodString>;
37
+ readonly: z.ZodOptional<z.ZodBoolean>;
37
38
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
39
  }, z.core.$strip>, z.ZodObject<{
39
40
  kind: z.ZodLiteral<"project">;
@@ -45,6 +46,7 @@ declare const TaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
45
46
  startDate: z.ZodString;
46
47
  parent: z.ZodOptional<z.ZodNumber>;
47
48
  color: z.ZodOptional<z.ZodString>;
49
+ readonly: z.ZodOptional<z.ZodBoolean>;
48
50
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
49
51
  }, z.core.$strip>, z.ZodObject<{
50
52
  kind: z.ZodLiteral<"milestone">;
@@ -53,6 +55,7 @@ declare const TaskSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
53
55
  startDate: z.ZodString;
54
56
  parent: z.ZodOptional<z.ZodNumber>;
55
57
  color: z.ZodOptional<z.ZodString>;
58
+ readonly: z.ZodOptional<z.ZodBoolean>;
56
59
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
57
60
  }, z.core.$strip>], "kind">;
58
61
  declare const LinkSchema: z.ZodObject<{
@@ -65,6 +68,7 @@ declare const LinkSchema: z.ZodObject<{
65
68
  FF: "FF";
66
69
  SF: "SF";
67
70
  }>>;
71
+ readonly: z.ZodOptional<z.ZodBoolean>;
68
72
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
69
73
  }, z.core.$strip>;
70
74
  declare const GanttInputSchema: z.ZodObject<{
@@ -77,6 +81,7 @@ declare const GanttInputSchema: z.ZodObject<{
77
81
  startDate: z.ZodString;
78
82
  parent: z.ZodOptional<z.ZodNumber>;
79
83
  color: z.ZodOptional<z.ZodString>;
84
+ readonly: z.ZodOptional<z.ZodBoolean>;
80
85
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
81
86
  }, z.core.$strip>, z.ZodObject<{
82
87
  kind: z.ZodLiteral<"project">;
@@ -88,6 +93,7 @@ declare const GanttInputSchema: z.ZodObject<{
88
93
  startDate: z.ZodString;
89
94
  parent: z.ZodOptional<z.ZodNumber>;
90
95
  color: z.ZodOptional<z.ZodString>;
96
+ readonly: z.ZodOptional<z.ZodBoolean>;
91
97
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
92
98
  }, z.core.$strip>, z.ZodObject<{
93
99
  kind: z.ZodLiteral<"milestone">;
@@ -96,6 +102,7 @@ declare const GanttInputSchema: z.ZodObject<{
96
102
  startDate: z.ZodString;
97
103
  parent: z.ZodOptional<z.ZodNumber>;
98
104
  color: z.ZodOptional<z.ZodString>;
105
+ readonly: z.ZodOptional<z.ZodBoolean>;
99
106
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
100
107
  }, z.core.$strip>], "kind">>;
101
108
  links: z.ZodDefault<z.ZodArray<z.ZodObject<{
@@ -108,6 +115,7 @@ declare const GanttInputSchema: z.ZodObject<{
108
115
  FF: "FF";
109
116
  SF: "SF";
110
117
  }>>;
118
+ readonly: z.ZodOptional<z.ZodBoolean>;
111
119
  data: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
112
120
  }, z.core.$strip>>>;
113
121
  }, z.core.$strip>;
@@ -460,40 +468,53 @@ declare const GRID_COLUMN_FR_MIN_WIDTH = 120;
460
468
  declare function gridNaturalWidth(columns: GridColumn[]): number;
461
469
  //#endregion
462
470
  //#region src/lib/vanilla/gantt-chart.d.ts
463
- type OnTaskSelect = (payload: {
471
+ type OnTaskClick = (payload: {
464
472
  task: Task;
465
- }) => void;
473
+ instance: GanttInstance;
474
+ }) => void | Promise<void>;
466
475
  type OnTaskMove = (payload: {
467
476
  task: Task;
468
477
  newStartDate: Date;
469
- }) => boolean;
478
+ instance: GanttInstance;
479
+ }) => boolean | Promise<boolean>;
470
480
  type OnTaskResize = (payload: {
471
481
  task: Task;
472
482
  newDurationHours: number;
473
- }) => boolean;
483
+ instance: GanttInstance;
484
+ }) => boolean | Promise<boolean>;
474
485
  type OnTaskAdd = (payload: {
475
486
  parentTask: Task;
476
- }) => boolean;
487
+ instance: GanttInstance;
488
+ }) => boolean | Promise<boolean>;
477
489
  type OnTaskDoubleClick = (payload: {
478
490
  task: Task;
479
- }) => void;
491
+ instance: GanttInstance;
492
+ }) => void | Promise<void>;
480
493
  type OnLinkCreate = (payload: {
481
494
  type: 'FS';
482
495
  sourceTask: Task;
483
496
  targetTask: Task;
484
- }) => boolean;
497
+ instance: GanttInstance;
498
+ }) => boolean | Promise<boolean>;
485
499
  type OnLinkClick = (payload: {
486
500
  link: Link;
487
- }) => void;
501
+ instance: GanttInstance;
502
+ }) => void | Promise<void>;
488
503
  type OnLinkDblClick = (payload: {
489
504
  link: Link;
490
- }) => void;
505
+ instance: GanttInstance;
506
+ }) => void | Promise<void>;
491
507
  type OnProgressChange = (payload: {
492
508
  task: Task;
493
509
  newPercentComplete: number;
494
- }) => boolean;
510
+ instance: GanttInstance;
511
+ }) => boolean | Promise<boolean>;
512
+ type OnTooltipText = (payload: {
513
+ task: Task;
514
+ instance: GanttInstance;
515
+ }) => string | null;
495
516
  type GanttCallbacks = {
496
- onTaskSelect?: OnTaskSelect;
517
+ onTaskClick?: OnTaskClick;
497
518
  onTaskMove?: OnTaskMove;
498
519
  onTaskResize?: OnTaskResize;
499
520
  onTaskAdd?: OnTaskAdd;
@@ -502,8 +523,15 @@ type GanttCallbacks = {
502
523
  onLinkClick?: OnLinkClick;
503
524
  onLinkDblClick?: OnLinkDblClick;
504
525
  onProgressChange?: OnProgressChange;
505
- onLeftPaneWidthChange?: (width: number) => void;
506
- onGridColumnsChange?: (columns: GridColumn[]) => void;
526
+ onTooltipText?: OnTooltipText;
527
+ onLeftPaneWidthChange?: (payload: {
528
+ width: number;
529
+ instance: GanttInstance;
530
+ }) => void | Promise<void>;
531
+ onGridColumnsChange?: (payload: {
532
+ columns: GridColumn[];
533
+ instance: GanttInstance;
534
+ }) => void | Promise<void>;
507
535
  };
508
536
  type ThemeMode = 'light' | 'dark' | 'system';
509
537
  type GanttOptions = {
@@ -530,7 +558,8 @@ type GanttOptions = {
530
558
  type GanttInstance = {
531
559
  update: (input: GanttInput) => void;
532
560
  setOptions: (opts: Partial<GanttOptions>) => void;
533
- select: (id: number | null) => void;
561
+ setCallbacks: (cbs: GanttCallbacks) => void;
562
+ select: (id: number | null, fireCallback?: boolean) => void;
534
563
  collapseAll: () => void;
535
564
  expandAll: () => void;
536
565
  destroy: () => void;
@@ -553,11 +582,20 @@ declare class GanttChart implements GanttInstance {
553
582
  /**
554
583
  * Constructs a new chart, builds the DOM, and wires internal event handling.
555
584
  * Data must be loaded via {@link update} before the chart renders.
585
+ * Callbacks must be set via {@link setCallbacks} before user interactions are handled.
556
586
  *
557
587
  * @param container - The host `HTMLElement` the chart will be appended to.
558
- * @param opts - Configuration and callback options.
588
+ * @param opts - Configuration options.
589
+ */
590
+ constructor(container: HTMLElement, opts?: GanttOptions);
591
+ /**
592
+ * Sets or replaces the chart's user-facing callbacks.
593
+ * Does not trigger a re-render.
594
+ *
595
+ * @param cbs - The {@link GanttCallbacks} to register.
596
+ * @throws {GanttError} When the instance has been destroyed.
559
597
  */
560
- constructor(container: HTMLElement, opts?: GanttOptions, cbs?: GanttCallbacks);
598
+ setCallbacks(cbs: GanttCallbacks): void;
561
599
  /**
562
600
  * Replaces the full dataset and re-renders.
563
601
  *
@@ -579,9 +617,10 @@ declare class GanttChart implements GanttInstance {
579
617
  * Programmatically selects or deselects a task.
580
618
  *
581
619
  * @param id - The task ID to select, or `null` to clear the selection.
620
+ * @param fireCallback - Whether to fire the `onTaskClick` callback. Default `true`.
582
621
  * @throws {GanttError} When the instance has been destroyed.
583
622
  */
584
- select(id: number | null): void;
623
+ select(id: number | null, fireCallback?: boolean): void;
585
624
  /**
586
625
  * Collapses all expandable groups in the task tree.
587
626
  *
@@ -615,5 +654,5 @@ declare class GanttError extends Error {
615
654
  constructor(code: GanttErrorCode, message: string);
616
655
  }
617
656
  //#endregion
618
- 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 OnTaskDoubleClick, type OnTaskMove, type OnTaskResize, type OnTaskSelect, 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 };
657
+ 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 };
619
658
  //# sourceMappingURL=index.d.mts.map