@timelinekit/core 1.0.8 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -64,18 +64,24 @@ npm install @timelinekit/react @timelinekit/core
64
64
  ```tsx
65
65
  import { useRef, useEffect } from 'react';
66
66
  import { GanttChart, GanttChartRef } from '@timelinekit/react';
67
- import { Task, TaskLink } from '@timelinekit/core';
68
67
  import '@timelinekit/core/styles';
69
68
 
69
+ const data = {
70
+ tasks: [
71
+ { id: '1', name: 'Design', startTime: '2027-01-05', endTime: '2027-01-09', type: 'task', progress: 100 },
72
+ { id: '2', name: 'Development', startTime: '2027-01-12', endTime: '2027-01-23', type: 'task' },
73
+ ],
74
+ links: [
75
+ { id: 'l1', from: '1', to: '2', type: 'finishToStart' },
76
+ ],
77
+ };
78
+
70
79
  function App() {
71
80
  const ref = useRef<GanttChartRef>(null);
72
81
 
73
82
  useEffect(() => {
74
- const gantt = ref.current!;
75
- const taskA = gantt.list.addTask(new Task({ id: '1', name: 'Design', startTime: '2027-01-05', endTime: '2027-01-09' }));
76
- const taskB = gantt.list.addTask(new Task({ id: '2', name: 'Development', startTime: '2027-01-12', endTime: '2027-01-23' }));
77
- gantt.list.addLink(new TaskLink({ id: 'l1', from: taskA, to: taskB, type: 'finishToStart' }));
78
- gantt.zoomToFit();
83
+ ref.current!.load(JSON.stringify(data));
84
+ ref.current!.zoomToFit();
79
85
  }, []);
80
86
 
81
87
  return <GanttChart ref={ref} style={{ height: '600px' }} />;
@@ -89,20 +95,28 @@ npm install @timelinekit/angular @timelinekit/core
89
95
  ```
90
96
 
91
97
  ```typescript
92
- import { GanttChartComponent } from '@timelinekit/angular';
93
- import { Task, TaskLink } from '@timelinekit/core';
98
+ import { Component, ViewChild, AfterViewInit } from '@angular/core';
99
+ import { GanttChart } from '@timelinekit/angular';
100
+
101
+ const data = {
102
+ tasks: [
103
+ { id: '1', name: 'Design', startTime: '2027-01-05', endTime: '2027-01-09', type: 'task', progress: 100 },
104
+ { id: '2', name: 'Development', startTime: '2027-01-12', endTime: '2027-01-23', type: 'task' },
105
+ ],
106
+ links: [
107
+ { id: 'l1', from: '1', to: '2', type: 'finishToStart' },
108
+ ],
109
+ };
94
110
 
95
111
  @Component({
96
- imports: [GanttChartComponent],
97
- template: `<tk-gantt-chart #gantt style="height: 600px" />`,
112
+ imports: [GanttChart],
113
+ template: `<gk-gantt-chart #gantt style="height: 600px" />`,
98
114
  })
99
115
  export class AppComponent implements AfterViewInit {
100
- @ViewChild('gantt') gantt!: GanttChartComponent;
116
+ @ViewChild('gantt') gantt!: GanttChart;
101
117
 
102
118
  ngAfterViewInit() {
103
- const taskA = this.gantt.list.addTask(new Task({ id: '1', name: 'Design', startTime: '2027-01-05', endTime: '2027-01-09' }));
104
- const taskB = this.gantt.list.addTask(new Task({ id: '2', name: 'Development', startTime: '2027-01-12', endTime: '2027-01-23' }));
105
- this.gantt.list.addLink(new TaskLink({ id: 'l1', from: taskA, to: taskB, type: 'finishToStart' }));
119
+ this.gantt.load(JSON.stringify(data));
106
120
  this.gantt.zoomToFit();
107
121
  }
108
122
  }
@@ -5,6 +5,8 @@ import { TaskList } from "./task-list";
5
5
  /** Adapts a TaskList to the TreeTableDataSource interface used by the sheet component. */
6
6
  export declare class TaskListAdapter implements TreeTableDataSource<Task> {
7
7
  #private;
8
+ /** Emits when a task is added to the list. */
9
+ itemAdded$: Subject<TableItemEventArgs<Task>>;
8
10
  /** Emits when a task property changes. */
9
11
  itemChanged$: Subject<TableItemEventArgs<Task>>;
10
12
  /** Emits when a task is removed from the list. */
@@ -49,6 +49,8 @@ export declare class TaskList {
49
49
  getLink(index: number): TaskLink;
50
50
  /** Get the index of a task in the list. */
51
51
  indexOf(task: Task): number;
52
+ /** Create a new Task instance wired to this list's calendar and project timeline, without adding it to the list. */
53
+ createTask(id?: string): Task;
52
54
  /** Append an empty placeholder row at the end of the list. */
53
55
  addEmptyTask(): Task;
54
56
  /** Insert an empty placeholder row at the given index. */