gantt-renderer 0.3.0 → 0.5.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,26 @@
1
- # [0.3.0](https://github.com/doberkofler/gantt-renderer/compare/v0.2.0...v0.3.0) (2026-05-08)
1
+ # [0.5.0](https://github.com/doberkofler/gantt-renderer/compare/v0.4.0...v0.5.0) (2026-05-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * add newEndDate to onTaskMove and newStartDate/newEndDate to onTaskResize callbacks ([e5fc91e](https://github.com/doberkofler/gantt-renderer/commit/e5fc91e6200c76b27db8c09aa1821765105317fa))
7
+
8
+ # [0.4.0](https://github.com/doberkofler/gantt-renderer/compare/v0.2.0...v0.4.0) (2026-05-09)
2
9
 
3
10
 
4
11
  ### Bug Fixes
5
12
 
6
13
  * correct link routing geometry and dependency layer rendering ([d00de8a](https://github.com/doberkofler/gantt-renderer/commit/d00de8a8b51d69b7b50ec4c6bf0ce6dd3657e1a8))
14
+ * improve lint rules ([1644377](https://github.com/doberkofler/gantt-renderer/commit/1644377da0294838a77386ac4d74832c289fcbfb))
7
15
  * **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)
16
+ * prevent spurious onTaskMove callback on double-click in timeline ([14976d0](https://github.com/doberkofler/gantt-renderer/commit/14976d0ca8e17bf0b47b34a91e184513e316e811))
8
17
  * **rendering:** offset multi-row link midpoint to avoid bar center slicing ([1fe09fa](https://github.com/doberkofler/gantt-renderer/commit/1fe09fa3d736cf948035c4f1619f398fa374464d))
9
18
 
10
19
 
11
20
  ### Features
12
21
 
22
+ * add custom tooltip support with onTooltipText callback ([eacc7a8](https://github.com/doberkofler/gantt-renderer/commit/eacc7a845d346f007b4c7ad5a9ed901f9d2e8d60))
23
+ * add readonly support for tasks and links ([48cd946](https://github.com/doberkofler/gantt-renderer/commit/48cd946fe0b22bbcba18cb6b8e04d62d285300a0))
13
24
  * **interaction:** add progress bar drag with progressDragEnabled option ([77833b5](https://github.com/doberkofler/gantt-renderer/commit/77833b50b5984158bd9a2ab3ddcc744d05ccb18f))
14
25
 
15
26
  # [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,50 +468,73 @@ 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>;
475
+ type OnTaskDoubleClick = (payload: {
476
+ task: Task;
477
+ instance: GanttInstance;
478
+ }) => void | Promise<void>;
466
479
  type OnTaskMove = (payload: {
467
480
  task: Task;
468
481
  newStartDate: Date;
469
- }) => boolean;
482
+ newEndDate: Date;
483
+ instance: GanttInstance;
484
+ }) => boolean | Promise<boolean>;
470
485
  type OnTaskResize = (payload: {
471
486
  task: Task;
472
487
  newDurationHours: number;
473
- }) => boolean;
488
+ newStartDate: Date;
489
+ newEndDate: Date;
490
+ instance: GanttInstance;
491
+ }) => boolean | Promise<boolean>;
474
492
  type OnTaskAdd = (payload: {
475
493
  parentTask: Task;
476
- }) => boolean;
477
- type OnTaskDoubleClick = (payload: {
478
- task: Task;
479
- }) => void;
494
+ instance: GanttInstance;
495
+ }) => boolean | Promise<boolean>;
480
496
  type OnLinkCreate = (payload: {
481
497
  type: 'FS';
482
498
  sourceTask: Task;
483
499
  targetTask: Task;
484
- }) => boolean;
500
+ instance: GanttInstance;
501
+ }) => boolean | Promise<boolean>;
485
502
  type OnLinkClick = (payload: {
486
503
  link: Link;
487
- }) => void;
504
+ instance: GanttInstance;
505
+ }) => void | Promise<void>;
488
506
  type OnLinkDblClick = (payload: {
489
507
  link: Link;
490
- }) => void;
508
+ instance: GanttInstance;
509
+ }) => void | Promise<void>;
491
510
  type OnProgressChange = (payload: {
492
511
  task: Task;
493
512
  newPercentComplete: number;
494
- }) => boolean;
513
+ instance: GanttInstance;
514
+ }) => boolean | Promise<boolean>;
515
+ type OnTooltipText = (payload: {
516
+ task: Task;
517
+ instance: GanttInstance;
518
+ }) => string | null;
495
519
  type GanttCallbacks = {
496
- onTaskSelect?: OnTaskSelect;
520
+ onTaskClick?: OnTaskClick;
521
+ onTaskDoubleClick?: OnTaskDoubleClick;
497
522
  onTaskMove?: OnTaskMove;
498
523
  onTaskResize?: OnTaskResize;
499
524
  onTaskAdd?: OnTaskAdd;
500
- onTaskDoubleClick?: OnTaskDoubleClick;
501
525
  onLinkCreate?: OnLinkCreate;
502
526
  onLinkClick?: OnLinkClick;
503
527
  onLinkDblClick?: OnLinkDblClick;
504
528
  onProgressChange?: OnProgressChange;
505
- onLeftPaneWidthChange?: (width: number) => void;
506
- onGridColumnsChange?: (columns: GridColumn[]) => void;
529
+ onTooltipText?: OnTooltipText;
530
+ onLeftPaneWidthChange?: (payload: {
531
+ width: number;
532
+ instance: GanttInstance;
533
+ }) => void | Promise<void>;
534
+ onGridColumnsChange?: (payload: {
535
+ columns: GridColumn[];
536
+ instance: GanttInstance;
537
+ }) => void | Promise<void>;
507
538
  };
508
539
  type ThemeMode = 'light' | 'dark' | 'system';
509
540
  type GanttOptions = {
@@ -530,7 +561,8 @@ type GanttOptions = {
530
561
  type GanttInstance = {
531
562
  update: (input: GanttInput) => void;
532
563
  setOptions: (opts: Partial<GanttOptions>) => void;
533
- select: (id: number | null) => void;
564
+ setCallbacks: (cbs: GanttCallbacks) => void;
565
+ select: (id: number | null, fireCallback?: boolean) => void;
534
566
  collapseAll: () => void;
535
567
  expandAll: () => void;
536
568
  destroy: () => void;
@@ -553,11 +585,20 @@ declare class GanttChart implements GanttInstance {
553
585
  /**
554
586
  * Constructs a new chart, builds the DOM, and wires internal event handling.
555
587
  * Data must be loaded via {@link update} before the chart renders.
588
+ * Callbacks must be set via {@link setCallbacks} before user interactions are handled.
556
589
  *
557
590
  * @param container - The host `HTMLElement` the chart will be appended to.
558
- * @param opts - Configuration and callback options.
591
+ * @param opts - Configuration options.
592
+ */
593
+ constructor(container: HTMLElement, opts?: GanttOptions);
594
+ /**
595
+ * Sets or replaces the chart's user-facing callbacks.
596
+ * Does not trigger a re-render.
597
+ *
598
+ * @param cbs - The {@link GanttCallbacks} to register.
599
+ * @throws {GanttError} When the instance has been destroyed.
559
600
  */
560
- constructor(container: HTMLElement, opts?: GanttOptions, cbs?: GanttCallbacks);
601
+ setCallbacks(cbs: GanttCallbacks): void;
561
602
  /**
562
603
  * Replaces the full dataset and re-renders.
563
604
  *
@@ -579,9 +620,10 @@ declare class GanttChart implements GanttInstance {
579
620
  * Programmatically selects or deselects a task.
580
621
  *
581
622
  * @param id - The task ID to select, or `null` to clear the selection.
623
+ * @param fireCallback - Whether to fire the `onTaskClick` callback. Default `true`.
582
624
  * @throws {GanttError} When the instance has been destroyed.
583
625
  */
584
- select(id: number | null): void;
626
+ select(id: number | null, fireCallback?: boolean): void;
585
627
  /**
586
628
  * Collapses all expandable groups in the task tree.
587
629
  *
@@ -615,5 +657,5 @@ declare class GanttError extends Error {
615
657
  constructor(code: GanttErrorCode, message: string);
616
658
  }
617
659
  //#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 };
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 };
619
661
  //# sourceMappingURL=index.d.mts.map