zegantt 0.3.0 → 1.1.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 +245 -58
- package/dist/index.d.ts +17 -0
- package/dist/zegantt.cjs +7 -0
- package/dist/zegantt.css +1 -1
- package/dist/zegantt.js +2870 -1523
- package/package.json +26 -9
- package/dist/zegantt.umd.cjs +0 -1
package/README.md
CHANGED
|
@@ -1,73 +1,260 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ZeGantt
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
ZeGantt is a React Gantt chart library focused on construction and project planning workflows.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Highlights
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
7
|
+
- Virtualized rows and day-columns for large datasets (thousands of tasks)
|
|
8
|
+
- Drag, resize and dependency creation with mouse and touch support
|
|
9
|
+
- Keyboard navigation and accessibility attributes for enterprise use
|
|
10
|
+
- Theme tokens via CSS variables
|
|
11
|
+
- i18n with robust English fallback
|
|
12
|
+
- ESM + CJS builds with TypeScript declarations
|
|
9
13
|
|
|
10
|
-
##
|
|
14
|
+
## Install
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
```bash
|
|
17
|
+
npm install zegantt
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
### Required peer dependencies
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
npm install react react-dom lucide-react
|
|
24
|
+
```
|
|
13
25
|
|
|
14
|
-
##
|
|
26
|
+
## Minimal usage
|
|
15
27
|
|
|
16
|
-
|
|
28
|
+
```tsx
|
|
29
|
+
import { ProjectGantt, ptBR, type GanttStep } from 'zegantt';
|
|
30
|
+
import 'zegantt/style.css';
|
|
17
31
|
|
|
18
|
-
|
|
19
|
-
export default defineConfig([
|
|
20
|
-
globalIgnores(['dist']),
|
|
32
|
+
const steps: GanttStep[] = [
|
|
21
33
|
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
tseslint.configs.strictTypeChecked,
|
|
30
|
-
// Optionally, add this for stylistic rules
|
|
31
|
-
tseslint.configs.stylisticTypeChecked,
|
|
32
|
-
|
|
33
|
-
// Other configs...
|
|
34
|
-
],
|
|
35
|
-
languageOptions: {
|
|
36
|
-
parserOptions: {
|
|
37
|
-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
-
tsconfigRootDir: import.meta.dirname,
|
|
39
|
-
},
|
|
40
|
-
// other options...
|
|
41
|
-
},
|
|
34
|
+
id: 's1',
|
|
35
|
+
name: 'Foundation',
|
|
36
|
+
startDate: '2026-01-10',
|
|
37
|
+
finishDate: '2026-01-20',
|
|
38
|
+
conclusionPercent: 45,
|
|
39
|
+
projectId: 'p1',
|
|
40
|
+
projectTitle: 'Residential Tower',
|
|
42
41
|
},
|
|
43
|
-
]
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
export function Example() {
|
|
45
|
+
return (
|
|
46
|
+
<ProjectGantt
|
|
47
|
+
steps={steps}
|
|
48
|
+
locale="pt-BR"
|
|
49
|
+
translations={ptBR}
|
|
50
|
+
groupByProject
|
|
51
|
+
onTaskChange={(task) => console.log('Task updated', task)}
|
|
52
|
+
/>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
44
55
|
```
|
|
45
56
|
|
|
46
|
-
|
|
57
|
+
## Data contracts
|
|
47
58
|
|
|
48
|
-
|
|
49
|
-
// eslint.config.js
|
|
50
|
-
import reactX from 'eslint-plugin-react-x'
|
|
51
|
-
import reactDom from 'eslint-plugin-react-dom'
|
|
59
|
+
### Steps
|
|
52
60
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
61
|
+
```ts
|
|
62
|
+
interface GanttStep {
|
|
63
|
+
id: string;
|
|
64
|
+
name: string;
|
|
65
|
+
startDate?: Date | string;
|
|
66
|
+
finishDate?: Date | string;
|
|
67
|
+
previsionStartDate?: Date | string;
|
|
68
|
+
previsionFinishDate?: Date | string;
|
|
69
|
+
conclusionPercent?: number | string;
|
|
70
|
+
projectId?: string;
|
|
71
|
+
projectTitle?: string;
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Milestones
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
interface GanttMilestone {
|
|
79
|
+
id: string;
|
|
80
|
+
name: string;
|
|
81
|
+
date?: Date | string;
|
|
82
|
+
finished?: boolean;
|
|
83
|
+
projectId?: string;
|
|
84
|
+
projectTitle?: string;
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Events
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
interface GanttEvent {
|
|
92
|
+
id: string;
|
|
93
|
+
title: string;
|
|
94
|
+
date?: Date | string;
|
|
95
|
+
finished?: boolean;
|
|
96
|
+
projectId?: string;
|
|
97
|
+
projectTitle?: string;
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### Notes
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
interface GanttNote {
|
|
105
|
+
id: string;
|
|
106
|
+
title: string;
|
|
107
|
+
targetId?: string;
|
|
108
|
+
predecessorId?: string;
|
|
109
|
+
description?: string;
|
|
110
|
+
author?: string;
|
|
111
|
+
date?: Date | string;
|
|
112
|
+
color?: string;
|
|
113
|
+
filesCount?: number;
|
|
114
|
+
projectId?: string;
|
|
115
|
+
projectTitle?: string;
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### Dependencies
|
|
120
|
+
|
|
121
|
+
```ts
|
|
122
|
+
type PredecessorType = 'STEP' | 'MILESTONE';
|
|
123
|
+
type DependencyType = 'FS' | 'SS' | 'FF' | 'SF';
|
|
124
|
+
|
|
125
|
+
interface GanttDependency {
|
|
126
|
+
id: string;
|
|
127
|
+
predecessorId: string;
|
|
128
|
+
predecessorType: PredecessorType;
|
|
129
|
+
successorId: string;
|
|
130
|
+
successorType: PredecessorType;
|
|
131
|
+
type: DependencyType;
|
|
132
|
+
lag: number;
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Main props
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
interface ProjectGanttProps {
|
|
140
|
+
steps: GanttStep[];
|
|
141
|
+
milestones?: GanttMilestone[];
|
|
142
|
+
events?: GanttEvent[];
|
|
143
|
+
notes?: GanttNote[];
|
|
144
|
+
dependencies?: GanttDependency[];
|
|
145
|
+
|
|
146
|
+
loading?: boolean;
|
|
147
|
+
locale?: string;
|
|
148
|
+
groupByProject?: boolean;
|
|
149
|
+
translations?: Record<string, string> | ((key: string, fallback?: string) => string);
|
|
150
|
+
|
|
151
|
+
onTaskChange?: (task: GanttTask) => void;
|
|
152
|
+
onTaskClick?: (task: GanttTask) => void;
|
|
153
|
+
onCreateDependency?: (params: CreateDependencyParams) => Promise<void>;
|
|
154
|
+
onDeleteDependency?: (dependencyId: string) => Promise<void>;
|
|
155
|
+
onDependencyError?: (error: DependencyValidationError) => void;
|
|
156
|
+
|
|
157
|
+
onAddNewStage?: (date?: Date, projectId?: string) => void;
|
|
158
|
+
onAddMilestone?: (date?: Date, projectId?: string) => void;
|
|
159
|
+
onAddEvent?: (date?: Date, projectId?: string) => void;
|
|
160
|
+
onAddNote?: (date?: Date, projectId?: string) => void;
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Dependency cycle protection
|
|
165
|
+
|
|
166
|
+
ZeGantt blocks creation of circular dependencies (for example A -> B -> C -> A).
|
|
167
|
+
|
|
168
|
+
- If `onDependencyError` is provided, it receives a `CYCLIC_DEPENDENCY` error payload.
|
|
169
|
+
- If not provided, ZeGantt shows a default alert message.
|
|
170
|
+
|
|
171
|
+
## Accessibility and keyboard
|
|
172
|
+
|
|
173
|
+
- Interactive rows include semantic roles and keyboard handling
|
|
174
|
+
- Row navigation with arrow keys
|
|
175
|
+
- `Enter` opens task details (when callback exists)
|
|
176
|
+
- Focus-visible ring is provided by default CSS
|
|
177
|
+
|
|
178
|
+
## Mobile and touch
|
|
179
|
+
|
|
180
|
+
The library supports touch interactions for:
|
|
181
|
+
|
|
182
|
+
- Bar dragging
|
|
183
|
+
- Bar resizing
|
|
184
|
+
- Dependency connection handles
|
|
185
|
+
- Timeline panning
|
|
186
|
+
|
|
187
|
+
## Theming
|
|
188
|
+
|
|
189
|
+
ZeGantt exposes CSS variables that can be overridden globally or in a wrapper:
|
|
190
|
+
|
|
191
|
+
```css
|
|
192
|
+
.my-gantt-theme {
|
|
193
|
+
--zg-surface: #ffffff;
|
|
194
|
+
--zg-surface-alt: #f4f7f6;
|
|
195
|
+
--zg-header-bg: #e9efec;
|
|
196
|
+
--zg-border: #c9d2ce;
|
|
197
|
+
--zg-border-light: #dbe3df;
|
|
198
|
+
--zg-primary-color: #0f3d2f;
|
|
199
|
+
--zg-note-color: #ffd44d;
|
|
200
|
+
--zg-shadow-panel: 0 10px 30px rgba(0, 0, 0, 0.08);
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
Apply theme:
|
|
205
|
+
|
|
206
|
+
```tsx
|
|
207
|
+
<div className="my-gantt-theme">
|
|
208
|
+
<ProjectGantt steps={steps} />
|
|
209
|
+
</div>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
## i18n
|
|
213
|
+
|
|
214
|
+
- Use `locale` (BCP 47, ex: `en-US`, `pt-BR`) to format dates and month labels.
|
|
215
|
+
- Provide `translations` as object or function.
|
|
216
|
+
- Missing keys fall back to English automatically.
|
|
217
|
+
|
|
218
|
+
Built-in helper export:
|
|
219
|
+
|
|
220
|
+
```ts
|
|
221
|
+
import { ptBR } from 'zegantt';
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
## Testing
|
|
225
|
+
|
|
226
|
+
Included scripts:
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
npm run test
|
|
230
|
+
npm run test:watch
|
|
73
231
|
```
|
|
232
|
+
|
|
233
|
+
Current suite includes:
|
|
234
|
+
|
|
235
|
+
- Unit tests for `utils/date.ts`, `utils/timeline.ts`, `utils/criticalPath.ts`, `utils/dependencies.ts`
|
|
236
|
+
- Component tests for context menu and task bar rendering behavior
|
|
237
|
+
|
|
238
|
+
## Build and publish
|
|
239
|
+
|
|
240
|
+
Build outputs:
|
|
241
|
+
|
|
242
|
+
- ESM: `dist/zegantt.js`
|
|
243
|
+
- CJS: `dist/zegantt.cjs`
|
|
244
|
+
- Types: `dist/index.d.ts`
|
|
245
|
+
- Styles: `dist/zegantt.css`
|
|
246
|
+
|
|
247
|
+
Before publishing:
|
|
248
|
+
|
|
249
|
+
1. Run `npm run test`
|
|
250
|
+
2. Run `npm run build`
|
|
251
|
+
3. Verify `peerDependencies` resolution in consuming projects
|
|
252
|
+
|
|
253
|
+
## Storybook recommendation
|
|
254
|
+
|
|
255
|
+
For consumer-facing documentation, Storybook is strongly recommended to demonstrate:
|
|
256
|
+
|
|
257
|
+
- Large dataset performance scenarios
|
|
258
|
+
- Interaction flows (drag, resize, dependency creation)
|
|
259
|
+
- Theme variants
|
|
260
|
+
- Locale variants
|
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,16 @@ export declare interface CreateDependencyParams {
|
|
|
11
11
|
|
|
12
12
|
export declare type DependencyType = "FS" | "SS" | "FF" | "SF";
|
|
13
13
|
|
|
14
|
+
export declare interface DependencyValidationError {
|
|
15
|
+
code: 'CYCLIC_DEPENDENCY';
|
|
16
|
+
message: string;
|
|
17
|
+
predecessorId: string;
|
|
18
|
+
successorId: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** English translation strings for ZeGantt */
|
|
22
|
+
export declare const enUS: Record<string, string>;
|
|
23
|
+
|
|
14
24
|
export declare interface GanttDependency {
|
|
15
25
|
id: string;
|
|
16
26
|
predecessorId: string;
|
|
@@ -118,6 +128,12 @@ export declare interface ProjectGanttProps {
|
|
|
118
128
|
translations?: Record<string, string> | ((key: string, fallback?: string) => string);
|
|
119
129
|
/** When true renders one project-header row per project and groups tasks by project */
|
|
120
130
|
groupByProject?: boolean;
|
|
131
|
+
/** Enables infinite-canvas interaction model (zoom + pan viewport). */
|
|
132
|
+
infiniteCanvas?: boolean;
|
|
133
|
+
/** Hides left task list/sidebar and keeps only timeline viewport. */
|
|
134
|
+
hideSidebar?: boolean;
|
|
135
|
+
/** Applies automatic fit-to-screen on first paint in infinite-canvas mode. */
|
|
136
|
+
initialFitToScreen?: boolean;
|
|
121
137
|
onTaskChange?: (task: GanttTask) => void;
|
|
122
138
|
onTaskClick?: (task: GanttTask) => void;
|
|
123
139
|
onAddNewStage?: (date?: Date, projectId?: string) => void;
|
|
@@ -126,6 +142,7 @@ export declare interface ProjectGanttProps {
|
|
|
126
142
|
onDeleteStage?: (taskId: string) => void;
|
|
127
143
|
onCreateDependency?: (params: CreateDependencyParams) => Promise<void>;
|
|
128
144
|
onDeleteDependency?: (dependencyId: string) => Promise<void>;
|
|
145
|
+
onDependencyError?: (error: DependencyValidationError) => void;
|
|
129
146
|
onAddMilestone?: (date?: Date, projectId?: string) => void;
|
|
130
147
|
onAddEvent?: (date?: Date, projectId?: string) => void;
|
|
131
148
|
onAddNote?: (date?: Date, projectId?: string) => void;
|