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 CHANGED
@@ -1,73 +1,260 @@
1
- # React + TypeScript + Vite
1
+ # ZeGantt
2
2
 
3
- This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3
+ ZeGantt is a React Gantt chart library focused on construction and project planning workflows.
4
4
 
5
- Currently, two official plugins are available:
5
+ ## Highlights
6
6
 
7
- - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8
- - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
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
- ## React Compiler
14
+ ## Install
11
15
 
12
- The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
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
- ## Expanding the ESLint configuration
26
+ ## Minimal usage
15
27
 
16
- If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
28
+ ```tsx
29
+ import { ProjectGantt, ptBR, type GanttStep } from 'zegantt';
30
+ import 'zegantt/style.css';
17
31
 
18
- ```js
19
- export default defineConfig([
20
- globalIgnores(['dist']),
32
+ const steps: GanttStep[] = [
21
33
  {
22
- files: ['**/*.{ts,tsx}'],
23
- extends: [
24
- // Other configs...
25
-
26
- // Remove tseslint.configs.recommended and replace with this
27
- tseslint.configs.recommendedTypeChecked,
28
- // Alternatively, use this for stricter rules
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
- You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
57
+ ## Data contracts
47
58
 
48
- ```js
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
- export default defineConfig([
54
- globalIgnores(['dist']),
55
- {
56
- files: ['**/*.{ts,tsx}'],
57
- extends: [
58
- // Other configs...
59
- // Enable lint rules for React
60
- reactX.configs['recommended-typescript'],
61
- // Enable lint rules for React DOM
62
- reactDom.configs.recommended,
63
- ],
64
- languageOptions: {
65
- parserOptions: {
66
- project: ['./tsconfig.node.json', './tsconfig.app.json'],
67
- tsconfigRootDir: import.meta.dirname,
68
- },
69
- // other options...
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;