gantt-lib 0.102.0 → 0.104.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/README.md CHANGED
@@ -2,21 +2,44 @@
2
2
 
3
3
  [![Demo](https://img.shields.io/badge/demo-online-brightgreen)](https://gantt-lib-demo.vercel.app/)
4
4
 
5
- ![Screenshot](https://raw.githubusercontent.com/simon100500/gantt-lib/refs/heads/master/docs/images/screen.png)
5
+ `gantt-lib` is a React/Next.js library for planning interfaces. It covers classic Gantt timelines, resource planning screens, and period-based table-matrix views such as finance plans, budgets, and plan-vs-actual layouts.
6
6
 
7
- Lightweight React Gantt chart component library with drag-and-drop task management.
7
+ ### Project Timeline
8
+
9
+ Classic Gantt-style planning for phases, tasks, dates, and dependencies.
10
+
11
+ ![Gantt](https://raw.githubusercontent.com/simon100500/gantt-lib/refs/heads/master/docs/images/screen.png)
12
+
13
+ ### Resource Planner
14
+
15
+ Dedicated scheduling mode for people, equipment, materials, rooms, and other resources with load visibility and reassignment flows.
16
+
17
+ ![Resources](https://raw.githubusercontent.com/simon100500/gantt-lib/refs/heads/master/docs/images/resource.png)
18
+
19
+ ### Finance Matrix
20
+
21
+ Period-based table view for budgets, plan-vs-actual, KPIs, and other data-matrix scenarios.
22
+
23
+ ![Finance Matrix](https://raw.githubusercontent.com/simon100500/gantt-lib/refs/heads/master/docs/images/finance.png)
24
+
25
+ Use it for project timelines, delivery planning, resource allocation, capacity views, and spreadsheet-like matrices that stay aligned with the same left-side task list and time context.
26
+
27
+ Production-style example: [ai.getgantt.ru](https://ai.getgantt.ru/)
8
28
 
9
29
  ## Features
10
30
 
11
- - 📊 **Interactive Gantt chart** with drag-and-drop task management
12
- - 🎨 **Customizable** via CSS variables
13
- - 📅 **Multi-month calendar grid** with two-row header (month + day)
14
- - 🌈 **Weekend highlighting** with customizable colors
15
- - 📍 **Today indicator** vertical line
16
- - 📈 **Progress bars** with accepted/completed states
17
- - **Performance optimized** for ~100 tasks at 60fps
18
- - 📦 **Tree-shakeable** ESM + CJS builds
19
- - **TypeScript** types included
31
+ - 📊 **Classic Gantt chart mode** with tasks, phases, hierarchy, and progress
32
+ - **Drag-and-drop schedule editing** for moving and resizing timeline bars
33
+ - 🔗 **Task dependencies and cascade scheduling** for linked plans
34
+ - 🗓️ **Calendar and business-day modes** with weekend and custom-day support
35
+ - 📋 **Integrated left-side task list** with configurable and hideable columns
36
+ - 🔎 **Task filtering, search, and focus flows** for large schedules
37
+ - 👥 **Resource planner mode** for people, equipment, rooms, crews, and assignments
38
+ - ↔️ **Resource reassignment and date moves** directly on the calendar
39
+ - ⚠️ **Resource grouping and conflict-oriented workflows** for capacity views
40
+ - 💰 **Table matrix mode** for finance plans, budgets, KPIs, and other period-based data views
41
+ - 🎨 **Customizable styling** via CSS variables
42
+ - 📦 **Tree-shakeable ESM + CJS builds** with TypeScript types included
20
43
 
21
44
  ## Installation
22
45
 
@@ -29,8 +52,9 @@ npm install gantt-lib
29
52
  ```tsx
30
53
  import { GanttChart, type Task } from "gantt-lib";
31
54
  import "gantt-lib/styles.css";
55
+ import { useState } from "react";
32
56
 
33
- const tasks: Task[] = [
57
+ const initialTasks: Task[] = [
34
58
  {
35
59
  id: "1",
36
60
  name: "Project Kickoff",
@@ -47,17 +71,23 @@ const tasks: Task[] = [
47
71
  ];
48
72
 
49
73
  export default function App() {
50
- const handleChange = (updated: Task[] | ((prev: Task[]) => Task[])) => {
51
- // Handle task updates
52
- setTasks(updated);
53
- };
74
+ const [tasks, setTasks] = useState(initialTasks);
54
75
 
55
76
  return (
56
77
  <GanttChart
57
78
  tasks={tasks}
79
+ showTaskList
58
80
  dayWidth={30}
59
81
  rowHeight={36}
60
- onChange={handleChange}
82
+ onTasksChange={(changedTasks) => {
83
+ setTasks((prev) => {
84
+ const byId = new Map(prev.map((task) => [task.id, task]));
85
+ for (const task of changedTasks) {
86
+ byId.set(task.id, task);
87
+ }
88
+ return [...byId.values()];
89
+ });
90
+ }}
61
91
  />
62
92
  );
63
93
  }
@@ -110,7 +140,7 @@ export default function Planner() {
110
140
 
111
141
  `ResourceTimelineChart` is also exported for consumers who want the specialized renderer directly. Resource mode does not render task list editing, dependency lines, hierarchy/cascade scheduling, or task reorder behavior.
112
142
 
113
- See the full guide: [Resource Planner Mode](../../docs/reference/15-resource-planner.md).
143
+ See the full guide: [Resource Planner Mode](https://github.com/simon100500/gantt-lib/blob/master/docs/reference/15-resource-planner.md).
114
144
 
115
145
  ## API
116
146
 
@@ -118,18 +148,32 @@ See the full guide: [Resource Planner Mode](../../docs/reference/15-resource-pla
118
148
 
119
149
  Main component that renders the interactive Gantt chart.
120
150
 
121
- | Prop | Type | Default | Description |
122
- | ----------------------- | --------------------------------------------- | ---------- | ------------------------------------------------------- |
123
- | `tasks` | `Task[]` | _required_ | Array of tasks to display |
124
- | `dayWidth` | `number` | `40` | Width of each day column in pixels |
125
- | `rowHeight` | `number` | `40` | Height of each task row in pixels |
126
- | `headerHeight` | `number` | `40` | Height of the header row in pixels |
127
- | `containerHeight` | `number` | `600` | Container height for vertical scrolling |
128
- | `onChange` | `(tasks: Task[] \| Task[] => Task[]) => void` | _required_ | Callback when tasks are modified |
129
- | `enableAutoSchedule` | `boolean` | `false` | Enable automatic shifting of dependent tasks when predecessor moves (cascade) |
130
- | `onCascade` | `(tasks: Task[]) => void` | _undefined_ | Callback when cascade drag completes; receives all shifted tasks including the dragged task |
131
- | `disableConstraints` | `boolean` | `false` | Disable dependency constraint checking during drag (allows violations during editing) |
132
- | `onValidateDependencies`| `(result: ValidationResult) => void` | _undefined_ | Callback for dependency validation results (cycles, missing tasks, constraint violations) |
151
+ | Prop | Type | Default | Description |
152
+ | --- | --- | --- | --- |
153
+ | `tasks` | `Task[]` | _required_ | Array of task rows shown in gantt mode. |
154
+ | `viewMode` | `'day' \| 'week' \| 'month'` | `'day'` | Time scale mode. |
155
+ | `dayWidth` | `number` | `40` | Width of one day column in pixels. |
156
+ | `rowHeight` | `number` | `40` | Height of one task row. |
157
+ | `headerHeight` | `number` | `40` | Height of the time-scale header. |
158
+ | `containerHeight` | `number \| string` | `undefined` | Container height in px, `%`, `vh`, or auto. |
159
+ | `showTaskList` | `boolean` | `false` | Shows the left-side task list. |
160
+ | `showChart` | `boolean` | `true` | Hides the chart area when set to `false`. |
161
+ | `showBaseline` | `boolean` | `false` | Renders baselines for tasks with `baselineStartDate` and `baselineEndDate`. |
162
+ | `taskListWidth` | `number` | `660` | Requested width of the task list panel. |
163
+ | `taskListColumnWidths` | `TaskListColumnWidthMap` | `undefined` | Width overrides for built-in and custom TaskList columns. |
164
+ | `businessDays` | `boolean` | `true` | Uses working days instead of calendar days for duration and drag behavior. |
165
+ | `disableTaskDrag` | `boolean` | `false` | Disables drag and resize interactions. |
166
+ | `onTasksChange` | `(tasks: Task[]) => void` | `undefined` | Receives only changed tasks. Merge them into your state. |
167
+ | `enableAutoSchedule` | `boolean` | `false` | Enables dependency-aware cascade scheduling. |
168
+ | `disableConstraints` | `boolean` | `false` | Lets tasks move freely, ignoring dependency rules. |
169
+ | `onCascade` | `(tasks: Task[]) => void` | `undefined` | Fires with all shifted tasks after a hard cascade drag. |
170
+ | `onValidateDependencies` | `(result: ValidationResult) => void` | `undefined` | Receives cycles, missing references, and constraint violations. |
171
+
172
+ More props, mode-specific APIs, and examples:
173
+
174
+ - [GanttChart Props](https://github.com/simon100500/gantt-lib/blob/master/docs/reference/04-props.md)
175
+ - [Resource Planner Mode](https://github.com/simon100500/gantt-lib/blob/master/docs/reference/15-resource-planner.md)
176
+ - [Table Matrix Mode](https://github.com/simon100500/gantt-lib/blob/master/docs/reference/16-table-matrix.md)
133
177
 
134
178
  ### Task
135
179
 
@@ -137,15 +181,23 @@ Main component that renders the interactive Gantt chart.
137
181
  interface Task {
138
182
  id: string;
139
183
  name: string;
140
- startDate: string; // ISO date format: YYYY-MM-DD
141
- endDate: string; // ISO date format: YYYY-MM-DD
184
+ startDate: string | Date;
185
+ endDate: string | Date;
186
+ baselineStartDate?: string | Date;
187
+ baselineEndDate?: string | Date;
188
+ type?: 'task' | 'milestone';
142
189
  color?: string; // Optional bar color (CSS color value)
143
- progress?: number; // Optional progress 0–100. Renders a progress bar overlay inside the task bar.
144
- accepted?: boolean; // Optional. Only meaningful when progress is 100. true = green bar, false/undefined = yellow bar.
145
- dependencies?: TaskDependency[]; // Optional array of predecessor dependencies
190
+ progress?: number;
191
+ accepted?: boolean;
192
+ dependencies?: TaskDependency[];
193
+ locked?: boolean;
194
+ divider?: 'top' | 'bottom';
195
+ parentId?: string;
146
196
  }
147
197
  ```
148
198
 
199
+ Tasks accept ISO strings or `Date` objects, but internal calculations are UTC-safe. Milestones use `type: 'milestone'`. Hierarchy uses `parentId`. Locked tasks cannot be dragged or edited.
200
+
149
201
  ### Dependencies
150
202
 
151
203
  Tasks can have dependencies on predecessor tasks using 4 link types following PM standards:
@@ -210,7 +262,10 @@ Example with cascade scheduling enabled:
210
262
  onCascade={(shiftedTasks) => {
211
263
  console.log(`${shiftedTasks.length} tasks were shifted`);
212
264
  }}
213
- onChange={handleChange}
265
+ onTasksChange={(changedTasks) => {
266
+ // Keep your normal merge handler for non-cascade edits.
267
+ console.log(changedTasks);
268
+ }}
214
269
  />
215
270
  ```
216
271