@jaeungkim/gantt-chart 0.4.0 → 1.0.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.
Files changed (103) hide show
  1. package/README.md +192 -53
  2. package/dist/Gantt.d.ts +5 -0
  3. package/dist/bars/components/GanttBar.d.ts +20 -0
  4. package/dist/bars/components/GanttBarsLayer.d.ts +24 -0
  5. package/dist/bars/components/GanttDragGuides.d.ts +1 -0
  6. package/dist/bars/hooks/useGanttBarDrag.d.ts +16 -0
  7. package/dist/bars/hooks/useGanttDrawCreate.d.ts +25 -0
  8. package/dist/{hooks → bars/hooks}/useGanttProgressDrag.d.ts +3 -8
  9. package/dist/core/calendar.d.ts +4 -22
  10. package/dist/core/dates.d.ts +5 -21
  11. package/dist/core/index.d.ts +1 -14
  12. package/dist/core/reorder.d.ts +55 -0
  13. package/dist/core/tree.d.ts +4 -12
  14. package/dist/core/types.d.ts +4 -37
  15. package/dist/{components → dependencies/components}/GanttDependencyArrows.d.ts +4 -6
  16. package/dist/{hooks → dependencies/hooks}/useGanttLinkDrag.d.ts +2 -13
  17. package/dist/dependencies/utils/arrowPath.d.ts +20 -0
  18. package/dist/dependencies/utils/link.d.ts +17 -0
  19. package/dist/detail/components/GanttDetailPanel.d.ts +21 -0
  20. package/dist/detail/hooks/useGanttDetail.d.ts +42 -0
  21. package/dist/detail/utils/edit.d.ts +21 -0
  22. package/dist/gantt-chart.css +1 -1
  23. package/dist/index.cjs +1 -4
  24. package/dist/index.d.cts +11 -13
  25. package/dist/index.d.ts +11 -13
  26. package/dist/index.js +4071 -5141
  27. package/dist/interaction/hooks/useGanttInteraction.d.ts +2 -0
  28. package/dist/interaction/hooks/useGanttKeyboardNav.d.ts +33 -0
  29. package/dist/interaction/hooks/useGanttSelection.d.ts +12 -0
  30. package/dist/interaction/utils/a11y.d.ts +84 -0
  31. package/dist/props.d.ts +121 -0
  32. package/dist/rows/components/GanttRowsLayer.d.ts +13 -0
  33. package/dist/rows/hooks/useGanttCollapse.d.ts +18 -0
  34. package/dist/rows/hooks/useGanttRowModel.d.ts +19 -0
  35. package/dist/rows/utils/rows.d.ts +21 -0
  36. package/dist/shared/constants.d.ts +24 -0
  37. package/dist/{stores → shared}/context.d.ts +1 -7
  38. package/dist/shared/hooks/useLatestRef.d.ts +2 -0
  39. package/dist/shared/hooks/useResolvedTheme.d.ts +8 -0
  40. package/dist/shared/store.d.ts +81 -0
  41. package/dist/shared/task.d.ts +55 -0
  42. package/dist/shared/types.d.ts +115 -0
  43. package/dist/shared/utils/holidays.d.ts +12 -0
  44. package/dist/shared/utils/i18n.d.ts +5 -0
  45. package/dist/shared/utils/pointerGesture.d.ts +11 -0
  46. package/dist/shared/virtual/axis.d.ts +13 -0
  47. package/dist/shared/virtual/useVirtualWindow.d.ts +16 -0
  48. package/dist/shared/virtual/window.d.ts +30 -0
  49. package/dist/task-list/components/GanttGridSplitter.d.ts +6 -0
  50. package/dist/task-list/components/GanttTaskAddRow.d.ts +7 -0
  51. package/dist/task-list/components/GanttTaskGrid.d.ts +24 -0
  52. package/dist/task-list/hooks/useGanttRowDrag.d.ts +17 -0
  53. package/dist/task-list/hooks/useGanttTaskListPane.d.ts +11 -0
  54. package/dist/task-list/hooks/useGanttTaskMove.d.ts +16 -0
  55. package/dist/timeline/components/GanttChartHeader.d.ts +10 -0
  56. package/dist/timeline/components/GanttHolidayLabels.d.ts +6 -0
  57. package/dist/timeline/components/GanttNonWorkingLayer.d.ts +6 -0
  58. package/dist/timeline/components/GanttTodayLine.d.ts +6 -0
  59. package/dist/{hooks → timeline/hooks}/useGanttScrollApi.d.ts +22 -23
  60. package/dist/timeline/hooks/useGanttViewport.d.ts +47 -0
  61. package/dist/timeline/hooks/useGanttVirtualization.d.ts +28 -0
  62. package/dist/timeline/utils/geometry.d.ts +52 -0
  63. package/dist/timeline/utils/header.d.ts +8 -0
  64. package/dist/timeline/utils/transform.d.ts +4 -0
  65. package/dist/timeline/utils/viewport.d.ts +31 -0
  66. package/dist/useGanttSelectors.d.ts +11 -0
  67. package/package.json +12 -12
  68. package/dist/components/GanttBar.d.ts +0 -23
  69. package/dist/components/GanttChartHeader.d.ts +0 -17
  70. package/dist/components/GanttDragGuides.d.ts +0 -9
  71. package/dist/components/GanttGridSplitter.d.ts +0 -14
  72. package/dist/components/GanttMarkers.d.ts +0 -18
  73. package/dist/components/GanttTaskGrid.d.ts +0 -42
  74. package/dist/components/ScaleSelector.d.ts +0 -11
  75. package/dist/constants/gantt.d.ts +0 -47
  76. package/dist/core/criticalPath.d.ts +0 -67
  77. package/dist/core/scheduling.d.ts +0 -104
  78. package/dist/hooks/useGanttBarDrag.d.ts +0 -35
  79. package/dist/hooks/useGanttDrawCreate.d.ts +0 -31
  80. package/dist/hooks/useGanttExportApi.d.ts +0 -30
  81. package/dist/hooks/useGanttHistoryApi.d.ts +0 -28
  82. package/dist/hooks/useGanttRowDrag.d.ts +0 -33
  83. package/dist/hooks/useGanttSelectors.d.ts +0 -23
  84. package/dist/hooks/useGanttVirtualization.d.ts +0 -32
  85. package/dist/hooks/useResolvedTheme.d.ts +0 -15
  86. package/dist/pages/Gantt.d.ts +0 -306
  87. package/dist/stores/store.d.ts +0 -118
  88. package/dist/types/gantt.d.ts +0 -283
  89. package/dist/types/task.d.ts +0 -111
  90. package/dist/utils/a11y.d.ts +0 -141
  91. package/dist/utils/arrowPath.d.ts +0 -66
  92. package/dist/utils/dependency.d.ts +0 -42
  93. package/dist/utils/grouping.d.ts +0 -81
  94. package/dist/utils/headerUtils.d.ts +0 -6
  95. package/dist/utils/history.d.ts +0 -56
  96. package/dist/utils/i18n.d.ts +0 -16
  97. package/dist/utils/mutation.d.ts +0 -47
  98. package/dist/utils/pngExport.d.ts +0 -67
  99. package/dist/utils/pointerGesture.d.ts +0 -31
  100. package/dist/utils/rowDrag.d.ts +0 -69
  101. package/dist/utils/timeline.d.ts +0 -161
  102. package/dist/utils/transformData.d.ts +0 -15
  103. package/dist/utils/viewport.d.ts +0 -95
package/README.md CHANGED
@@ -1,111 +1,250 @@
1
+ [![Banner](https://raw.githubusercontent.com/jaeungkim/gantt-chart/main/public/banner.png)](https://gantt.jaeungkim.com)
2
+
1
3
  # @jaeungkim/gantt-chart
2
4
 
3
5
  [![npm version](https://img.shields.io/npm/v/@jaeungkim/gantt-chart)](https://www.npmjs.com/package/@jaeungkim/gantt-chart)
4
6
  [![CI](https://github.com/jaeungkim/gantt-chart/actions/workflows/ci.yml/badge.svg)](https://github.com/jaeungkim/gantt-chart/actions/workflows/ci.yml)
5
7
  [![license](https://img.shields.io/npm/l/@jaeungkim/gantt-chart)](LICENSE)
6
8
 
7
- A Gantt chart for React: virtualized rows, editable bars, dependency arrows, and a scheduling
8
- engine that runs without a DOM.
9
+ A Gantt chart for React that you can actually edit. Virtualized rows, four dependency types, a
10
+ working-day calendar, keyboard and screen-reader support, and a date core that runs without a DOM.
11
+
12
+ **[Quick start](https://gantt.jaeungkim.com/docs/quick-start)** ·
13
+ **[Playground](https://gantt.jaeungkim.com/playground)** ·
14
+ **[Documentation](https://gantt.jaeungkim.com/docs)** ·
15
+ **[한국어 문서](https://gantt.jaeungkim.com/ko/docs)**
16
+
17
+ The package is two layers. `ReactGanttChart` renders the chart, handles every gesture, and hands
18
+ your app a new `tasks` array each time an edit commits. The tree and calendar math underneath it is
19
+ exported as plain functions, so a server, a worker or a test can call them without rendering
20
+ anything.
21
+
22
+ ## Features
23
+
24
+ ### Rendering
25
+
26
+ - Rows and time cells are virtualized together. Bars outside the window are not mounted.
27
+ - Five scales, `day` through `year`, each with its own tick unit, drag step and label format.
28
+ - A task list pane on the left with an optional row-number column, behind a draggable splitter.
29
+ - `hierarchy` derives depth and summary rows from `parentId`. A summary row's dates and progress
30
+ roll up from its children, and it collapses.
31
+ - `lane` packs tasks that never overlap onto one row, side by side.
32
+ - Dependency arrows routed as elbows for all four link types: `FS`, `SS`, `FF`, `SF`.
33
+ - A today line, weekend and holiday shading, and a hover card per bar.
34
+ - A docked detail panel that narrows the timeline instead of covering it. `renderDetail` replaces
35
+ its body; `detailTaskId` controls which task is open.
36
+
37
+ ### Editing
38
+
39
+ - Drag a bar to move it, pull either edge to resize it, drag the handle to set progress. Touch and
40
+ pen get wider grab zones.
41
+ - While a drag is live the dragged dates print in the date-axis cells they land in. Nothing floats
42
+ over the chart.
43
+ - Draw a dependency from one bar's link handle to another; click an arrow and press Delete to
44
+ remove it. `onDependencyCreate` and `onDependencyDelete` can veto either.
45
+ - Propose a new task from the **Add task** button under the task list, from `addTask()` on the ref,
46
+ or by drawing a range below the last row. The chart reports a draft through `onTaskCreate` and
47
+ never adds the row itself.
48
+ - Drag a task-list row to a new position or a new parent with `allowReorder`. `onTaskMove` can
49
+ reject the move.
50
+ - The detail panel edits too. Its built-in body changes the name, either date and the progress in
51
+ place, committing through the same `onTasksChange` and gated by the same per-task flags as the
52
+ bar gestures. A `renderDetail` body of your own commits through `update(patch)`.
53
+ - Permissions per chart and per task: `readOnly`, `allowMove`, `allowResize`,
54
+ `allowProgressChange`, `allowLinkCreate`, `allowLinkDelete`, `allowTaskCreate`, `allowReorder`,
55
+ plus `minDate` and `maxDate` drag bounds.
56
+ - Every committed gesture ends in one `onTasksChange` call with the complete next array.
57
+
58
+ ### Dates
59
+
60
+ - `workingCalendar` moves a drop forward off a weekend or a holiday. `workingWeekdays` says which
61
+ weekdays are worked and `holidays` lists the days off beyond them; both feed the calendar and the
62
+ shading, so the two cannot drift apart.
63
+ - A holiday can carry a `label` and a `color`. The name is written in the tick row over its band and
64
+ the colour tints it, so it reads apart from the weekend beside it.
65
+ - `visibleStart` and `visibleEnd` pin the range; `infiniteScroll` grows it at either end and
66
+ `onRangeChange` reports every change.
67
+ - Every date is UTC. A bare `YYYY-MM-DD` lands on the day it names in every viewer's time zone.
68
+
69
+ ### Keyboard and screen readers
70
+
71
+ - The chart is one ARIA treegrid with a single roving tab stop. Arrow keys move between rows and
72
+ cells; Home and End jump.
73
+ - Bars move, resize and step their progress from the keyboard. Rows reorder, indent and outdent.
74
+ Ctrl/Cmd + ArrowUp and ArrowDown step the scale, and edits are announced.
75
+ - A bar's accessible name is built from the task name, its dates and its progress.
76
+ - The gestures with no keyboard equivalent are written down in
77
+ [Keyboard and screen readers](https://gantt.jaeungkim.com/docs/accessibility), not hidden.
78
+
79
+ ### Locale and theme
80
+
81
+ - `locale` renders every date label through `Intl.DateTimeFormat`. `formats` overrides the tick,
82
+ header and tooltip labels per scale, and `firstDayOfWeek` picks where a week starts. No locale
83
+ package needed.
84
+ - `theme` takes `'light'`, `'dark'` or `'system'`. Omitted, the chart follows the host page's
85
+ `color-scheme`, which is what an app's own light/dark toggle already sets.
86
+ - 26 `--gantt-*` custom properties scoped to `.gantt-container`, so they cannot collide with your
87
+ own tokens.
88
+ - A per-task `color` derives the bar, its progress fill, its hover shade and a readable label color
89
+ from one value. A per-task `className` reaches the bar and its task-list row.
9
90
 
10
- **[Live demo](https://jaeungkim.com/gantt-chart)** · **[Documentation](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/README.md)** · **[한국어 문서](https://github.com/jaeungkim/gantt-chart/blob/main/docs/ko/README.md)**
91
+ ### Imperative API
11
92
 
12
- ## Motivation
93
+ A `ref` of type `GanttHandle` exposes `scrollToDate`, `scrollToToday`, `scrollToTask`, `setScale`,
94
+ `zoomToFit`, `openDetail`, `closeDetail`, `addTask` and `getScrollElement`. The chart renders no
95
+ toolbar and no scale picker; you render the control and drive it through the ref.
13
96
 
14
- I wanted Microsoft Project's Gantt chart for my own project planning, and it wanted a
15
- subscription. So I built one, borrowing ideas from MS Project, DHTMLX and Frappe Gantt.
97
+ ### Headless core
16
98
 
17
- There are not many open-source Gantt charts, so I hope this is useful to someone else too.
18
- Feedback, feature requests and pull requests are all welcome this is my first open-source
19
- project and I would like to keep improving it with whoever shows up.
99
+ `buildTaskTree`, `collectSubtreeIds`, `rollUpTasks`, `sortTasksBySequence`, `validateMove`,
100
+ `moveTask`, `createWorkingCalendar` and `CALENDAR_DAYS` import no React and touch no DOM. They are
101
+ the same functions the chart runs, so a report on the server and the bars in the browser agree.
102
+
103
+ ### Packaging
104
+
105
+ - TypeScript types for every prop, callback and helper.
106
+ - ESM and CJS builds, one stylesheet at `@jaeungkim/gantt-chart/style.css`.
107
+ - React 18 and 19 as peer dependencies. Two runtime dependencies: `dayjs` and `zustand`.
108
+ - Published from CI with npm provenance.
20
109
 
21
110
  ## Install
22
111
 
23
112
  ```bash
24
113
  pnpm add @jaeungkim/gantt-chart
114
+ # npm install @jaeungkim/gantt-chart
115
+ # yarn add @jaeungkim/gantt-chart
25
116
  ```
26
117
 
27
118
  `react` and `react-dom` (`^18` or `^19`) are peer dependencies.
28
119
 
29
- ## Usage
120
+ ## Quick example
30
121
 
31
122
  ```tsx
123
+ import { useState } from 'react';
32
124
  import { ReactGanttChart, type Task } from '@jaeungkim/gantt-chart';
33
125
  import '@jaeungkim/gantt-chart/style.css';
34
126
 
35
- const tasks: Task[] = [
127
+ const initialTasks: Task[] = [
36
128
  {
37
- id: '1',
38
- name: 'Project kickoff',
39
- startDate: '2024-06-01T09:00:00Z',
40
- endDate: '2024-06-03T17:00:00Z',
129
+ id: 'design',
130
+ name: 'Design',
131
+ startDate: '2026-03-02',
132
+ endDate: '2026-03-06',
41
133
  parentId: null,
42
134
  sequence: '1',
135
+ progress: 100,
43
136
  },
44
137
  {
45
- id: '2',
46
- name: 'Requirements',
47
- startDate: '2024-06-04T09:00:00Z',
48
- endDate: '2024-06-10T17:00:00Z',
138
+ id: 'build',
139
+ name: 'Build',
140
+ startDate: '2026-03-09',
141
+ endDate: '2026-03-20',
49
142
  parentId: null,
50
143
  sequence: '2',
51
- dependencies: [{ targetId: '1', type: 'FS' }],
144
+ progress: 40,
145
+ dependencies: [{ targetId: 'design', type: 'FS' }],
146
+ },
147
+ {
148
+ id: 'ship',
149
+ name: 'Ship',
150
+ startDate: '2026-03-23',
151
+ endDate: '2026-03-23',
152
+ parentId: null,
153
+ sequence: '3',
154
+ dependencies: [{ targetId: 'build', type: 'FS' }],
52
155
  },
53
156
  ];
54
157
 
55
- export default function App() {
158
+ export default function ProjectChart() {
159
+ const [tasks, setTasks] = useState(initialTasks);
160
+
56
161
  return (
57
162
  <ReactGanttChart
58
163
  tasks={tasks}
59
- height={600}
60
- theme="system"
164
+ onTasksChange={setTasks}
165
+ height={420}
166
+ showTaskList
61
167
  defaultScale="month"
62
- onTasksChange={(updated) => console.log(updated)}
63
168
  />
64
169
  );
65
170
  }
66
171
  ```
67
172
 
68
- The chart never stores your data. Every committed gesture ends in one `onTasksChange` call with a
69
- new array, and it is up to you to keep it.
173
+ That chart is already editable. The chart keeps no canonical copy of your data: a committed gesture
174
+ ends in one `onTasksChange` call with the complete next array, so your app stays the source of
175
+ truth.
70
176
 
71
- Full walkthrough: **[Quick start](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/quick-start.md)**.
177
+ ### Add a scale control
72
178
 
73
- ## What it does
179
+ The chart ships no toolbar, so the scale picker is a control you own: render it, and call `setScale`
180
+ on the ref. `onScaleChange` fires for every source, so your control stays in step when Ctrl/Cmd +
181
+ wheel or Ctrl/Cmd + arrow moves the scale instead.
74
182
 
75
- **Rendering** virtualized rows, a configurable task list pane with a draggable splitter, six
76
- timeline scales from hour to year, elbow-routed dependency arrows, date markers, range bands,
77
- non-working-day shading and baseline bars.
183
+ The whole recipe is in **[Imperative API](https://gantt.jaeungkim.com/docs/imperative-api)**.
78
184
 
79
- **Editing** move, resize and set progress by dragging; draw a new task on empty row space; draw
80
- and delete dependency arrows; reorder, indent and outdent rows; undo and redo.
185
+ ### Use the core without a chart
81
186
 
82
- **Scheduling** — successors reschedule on a drag under a policy you choose, a working-day calendar
83
- makes weekends and holidays stop counting, and the critical path comes with total and free slack.
84
- The same functions are exported as plain functions you can call on a server or in a worker.
187
+ ```ts
188
+ import { createWorkingCalendar, rollUpTasks, type Task } from '@jaeungkim/gantt-chart';
85
189
 
86
- **Accessibility** one ARIA treegrid with a roving tab stop; bars move, resize and step their
87
- progress from the keyboard.
190
+ const calendar = createWorkingCalendar({ holidays: ['2026-09-21'] });
191
+ const rolled = rollUpTasks(tasks); // summary rows recomputed from their children
192
+ ```
88
193
 
89
- **Theming** — `--gantt-*` custom properties scoped to the chart container, a light / dark / system
90
- theme prop, per-task colors, and four render props for replacing elements outright.
194
+ Full walkthroughs: **[Quick start](https://gantt.jaeungkim.com/docs/quick-start)** and
195
+ **[Headless core](https://gantt.jaeungkim.com/docs/headless-core)**.
91
196
 
92
- Each of these, and the honest list of what the library does **not** do, is in
93
- **[Introduction](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/introduction.md)**.
197
+ ## What it leaves to you
198
+
199
+ The chart renders the timeline and handles the gestures. Your app owns everything else:
200
+
201
+ - Data fetching and persistence. Tasks arrive as a prop; nothing is stored, not even the scale.
202
+ - Validation. Ids, date order and parseable dates are not checked before render.
203
+ - Automatic rescheduling. Moving a predecessor never moves its successors.
204
+ - Chrome. No toolbar, scale picker, zoom buttons or collapse button.
205
+ - Resources, costs, export and print.
206
+
207
+ The full boundary list is in
208
+ **[Introduction](https://gantt.jaeungkim.com/docs/introduction)**.
94
209
 
95
210
  ## Documentation
96
211
 
97
- | Page | |
212
+ | Guide | What it covers |
98
213
  |---|---|
99
- | [Quick start](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/quick-start.md) | install to a working, editable chart |
100
- | [Task data](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/task-data.md) | the `Task` shape and how the `tasks` prop is compared |
101
- | [Editing tasks](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/editing.md) | gestures, permissions, touch |
102
- | [Dependencies](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/dependencies.md) | the four link types and lag |
103
- | [Scheduling](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/scheduling.md) | policies, working calendar, critical path, baselines |
104
- | [Keyboard and screen readers](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/accessibility.md) | the key map, the ARIA tree, and the gaps |
105
- | [Theming](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/theming.md) | the CSS custom properties |
106
- | [Props](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/ref/props.md) | every prop, in one table |
107
-
108
- All 35 pages: **[English](https://github.com/jaeungkim/gantt-chart/blob/main/docs/en/README.md)** · **[한국어](https://github.com/jaeungkim/gantt-chart/blob/main/docs/ko/README.md)**
214
+ | [Introduction](https://gantt.jaeungkim.com/docs/introduction) | What the library is, and what it deliberately leaves to you |
215
+ | [Concepts and vocabulary](https://gantt.jaeungkim.com/docs/concepts) | Every term the rest of the docs use, defined once |
216
+ | [Quick start](https://gantt.jaeungkim.com/docs/quick-start) | Install to a working, editable chart |
217
+ | [Task data](https://gantt.jaeungkim.com/docs/task-data) | The `Task` shape, date handling, and how the `tasks` prop is compared |
218
+ | [Task list and hierarchy](https://gantt.jaeungkim.com/docs/task-list) | The left pane and the `parentId` tree |
219
+ | [Lanes](https://gantt.jaeungkim.com/docs/lanes) | The `lane` task field, which packs tasks that never overlap onto one row |
220
+ | [The timeline](https://gantt.jaeungkim.com/docs/timeline) | Scales, range, zoom, the today line, and non-working days |
221
+ | [Editing tasks](https://gantt.jaeungkim.com/docs/editing) | Move, resize, progress, permissions, drag bounds, and touch |
222
+ | [Creating tasks](https://gantt.jaeungkim.com/docs/task-creation) | The three ways a new task is proposed, and `onTaskCreate` |
223
+ | [Reordering rows](https://gantt.jaeungkim.com/docs/reordering) | Dragging a row to a new position or a new parent, and `onTaskMove` |
224
+ | [Dependencies](https://gantt.jaeungkim.com/docs/dependencies) | The four link types, and drawing arrows |
225
+ | [Working calendar](https://gantt.jaeungkim.com/docs/working-calendar) | Keeping a drop off weekends and holidays |
226
+ | [Detail panel](https://gantt.jaeungkim.com/docs/detail-panel) | The docked side panel: what opens it, editing in place, `renderDetail`, and controlling it |
227
+ | [Events](https://gantt.jaeungkim.com/docs/events) | Every callback a click, a drag and a keyboard edit fire |
228
+ | [Styling](https://gantt.jaeungkim.com/docs/styling) | Per-task color and class names |
229
+ | [Imperative API](https://gantt.jaeungkim.com/docs/imperative-api) | The `ref` handle: scrolling, zoom, the detail panel and task creation |
230
+ | [Keyboard and screen readers](https://gantt.jaeungkim.com/docs/accessibility) | The key map, the ARIA tree, and the gaps |
231
+ | [Locale and date formats](https://gantt.jaeungkim.com/docs/i18n) | `locale`, per-scale overrides, week start |
232
+ | [Theming](https://gantt.jaeungkim.com/docs/theming) | The theme prop and the CSS custom properties |
233
+ | [Headless core](https://gantt.jaeungkim.com/docs/headless-core) | Tree and calendar math without React or a DOM |
234
+
235
+ | Reference | Symbols |
236
+ |---|---|
237
+ | [GanttProps](https://gantt.jaeungkim.com/docs/ref/props) | `GanttProps` |
238
+ | [Task and task types](https://gantt.jaeungkim.com/docs/ref/task) | `Task`, `TaskDependency`, `DependencyType`, `TaskTransformed` |
239
+ | [GanttInteractionConfig](https://gantt.jaeungkim.com/docs/ref/interaction-config) | `GanttInteractionConfig` |
240
+ | [GanttRow](https://gantt.jaeungkim.com/docs/ref/rows) | `GanttRow` |
241
+ | [Detail renderer](https://gantt.jaeungkim.com/docs/ref/renderers) | `GanttDetailRenderer`, `GanttDetailRenderProps` |
242
+ | [GanttHandle](https://gantt.jaeungkim.com/docs/ref/handle) | `GanttHandle`, `GanttScrollApi`, `GanttDetailApi`, `GanttTaskCreateApi`, `GanttScrollOptions`, `GanttZoomAnchor` |
243
+ | [Scale and theme types](https://gantt.jaeungkim.com/docs/ref/scales) | `GanttScaleKey`, `GanttScaleFormat`, `GanttFormatOverrides`, `GanttTheme`, `Holiday` |
244
+ | [Tree helpers](https://gantt.jaeungkim.com/docs/ref/core-tree) | `buildTaskTree`, `collectSubtreeIds`, `rollUpTasks`, `moveTask`, `validateMove`, `sortTasksBySequence` |
245
+ | [Working calendar helpers](https://gantt.jaeungkim.com/docs/ref/core-calendar) | `createWorkingCalendar`, `CALENDAR_DAYS`, `WorkingCalendar` |
246
+
247
+ Full docs: **[English](https://gantt.jaeungkim.com/docs)** · **[한국어](https://gantt.jaeungkim.com/ko/docs)**
109
248
 
110
249
  ## Contributing
111
250
 
@@ -0,0 +1,5 @@
1
+ import { GanttHandle } from './timeline/hooks/useGanttScrollApi';
2
+ import { GanttProps } from './props';
3
+ /** Gantt chart component. Creates a store per instance, so two charts on one page cannot share state. */
4
+ declare const Gantt: import('react').ForwardRefExoticComponent<GanttProps & import('react').RefAttributes<GanttHandle>>;
5
+ export default Gantt;
@@ -0,0 +1,20 @@
1
+ import { GanttDependencyChange } from '../../dependencies/hooks/useGanttLinkDrag';
2
+ import { GanttBarOptions } from '../../shared/types';
3
+ import { GanttInteractionConfig, TaskTransformed } from '../../shared/task';
4
+ import { WorkingCalendar } from '../../core';
5
+ interface GanttBarProps {
6
+ currentTask: TaskTransformed;
7
+ options: GanttBarOptions;
8
+ interaction?: GanttInteractionConfig;
9
+ /** Roving tabindex of the treegrid - exactly one cell carries 0, so Tab enters the grid once */
10
+ tabIndex: number;
11
+ /** `row:column` coordinate the chart's focus manager looks the cell up by */
12
+ cellCoord?: string;
13
+ /** Working-day calendar - drag results snap forward off non-working days */
14
+ calendar?: WorkingCalendar;
15
+ /** Scroll the timeline when the drag reaches a viewport edge; Gantt.tsx owns the default */
16
+ autoScrollOnDrag: boolean;
17
+ onDependencyCreate?: (change: GanttDependencyChange) => boolean | void;
18
+ }
19
+ export default function GanttBar({ currentTask, options, interaction, tabIndex, cellCoord, calendar, autoScrollOnDrag, onDependencyCreate, }: GanttBarProps): import("react").JSX.Element;
20
+ export {};
@@ -0,0 +1,24 @@
1
+ import { VirtualItem } from '../../shared/virtual/window';
2
+ import { GanttDependencyChange } from '../../dependencies/hooks/useGanttLinkDrag';
3
+ import { GanttBarOptions } from '../../shared/types';
4
+ import { WorkingCalendar } from '../../core';
5
+ import { GanttInteractionConfig } from '../../shared/task';
6
+ import { GanttFocus } from '../../interaction/utils/a11y';
7
+ import { GanttRow } from '../../rows/utils/rows';
8
+ interface GanttBarsLayerProps {
9
+ rows: GanttRow[];
10
+ virtualItems: VirtualItem[];
11
+ /** Cells before the bars on a row - the bar's column is this plus its lane */
12
+ gridColumnCount: number;
13
+ focus: GanttFocus;
14
+ /** Horizontal culling, shared with the header so the two cannot disagree */
15
+ isBarVisible: (barLeft: number, barWidth: number) => boolean;
16
+ options: GanttBarOptions;
17
+ interaction: GanttInteractionConfig;
18
+ /** Working-day calendar - drag results snap forward off non-working days */
19
+ calendar?: WorkingCalendar;
20
+ autoScrollOnDrag: boolean;
21
+ onDependencyCreate?: (change: GanttDependencyChange) => boolean | void;
22
+ }
23
+ export default function GanttBarsLayer({ rows, virtualItems, gridColumnCount, focus, isBarVisible, options, interaction, calendar, autoScrollOnDrag, onDependencyCreate, }: GanttBarsLayerProps): (import("react").JSX.Element | null)[];
24
+ export {};
@@ -0,0 +1 @@
1
+ export default function GanttDragGuides(): import("react").JSX.Element | null;
@@ -0,0 +1,16 @@
1
+ import { GanttDragMode } from '../../shared/types';
2
+ import { GanttInteractionConfig, Task, TaskTransformed } from '../../shared/task';
3
+ import { WorkingCalendar } from '../../core';
4
+ export type DragMode = GanttDragMode;
5
+ interface GanttBarDragOptions {
6
+ onTasksChange?: (updatedTasks: Task[]) => void;
7
+ /** Scroll the timeline when the drag reaches a viewport edge (default true) */
8
+ autoScroll?: boolean;
9
+ }
10
+ /** Gantt bar drag behavior; `autoScroll` (default true) scrolls the timeline at a viewport edge. */
11
+ export declare function useGanttBarDrag(task: TaskTransformed, options?: GanttBarDragOptions, interaction?: GanttInteractionConfig, calendar?: WorkingCalendar): {
12
+ onPointerDown: import('react').PointerEventHandler<HTMLDivElement>;
13
+ dragMode: GanttDragMode | null;
14
+ consumeDragClick: () => boolean;
15
+ };
16
+ export {};
@@ -0,0 +1,25 @@
1
+ import { Dayjs } from 'dayjs';
2
+ import { GanttBottomRowCell, GanttScaleKey } from '../../shared/types';
3
+ /** The task the user drew, handed to `onTaskCreate` - nothing is committed by the chart */
4
+ export interface GanttTaskDraft {
5
+ /** UTC ISO string, snapped to the current scale */
6
+ startDate: string;
7
+ endDate: string;
8
+ }
9
+ export declare function defaultTaskDraft(now: Dayjs, timelineTicks: GanttBottomRowCell[], scaleKey: GanttScaleKey): GanttTaskDraft | null;
10
+ interface DrawGhost {
11
+ leftPx: number;
12
+ widthPx: number;
13
+ topPx: number;
14
+ }
15
+ interface UseGanttDrawCreateParams {
16
+ enabled: boolean;
17
+ rowCount: number;
18
+ onTaskCreate?: (draft: GanttTaskDraft) => void;
19
+ }
20
+ export declare function drawSlotTopPx(offsetY: number, rowCount: number): number | null;
21
+ export declare function useGanttDrawCreate({ enabled, rowCount, onTaskCreate, }: UseGanttDrawCreateParams): {
22
+ onDrawPointerDown: (e: React.PointerEvent<HTMLDivElement>) => void;
23
+ ghost: DrawGhost | null;
24
+ };
25
+ export {};
@@ -1,16 +1,11 @@
1
1
  import { default as React } from 'react';
2
- import { GanttBeforeChangeHandler } from '../types/gantt';
3
- import { Task, TaskTransformed } from '../types/task';
4
- export interface GanttProgressDragOptions {
2
+ import { Task, TaskTransformed } from '../../shared/task';
3
+ interface GanttProgressDragOptions {
5
4
  onTasksChange?: (updatedTasks: Task[]) => void;
6
- onBeforeTaskChange?: GanttBeforeChangeHandler;
7
5
  }
8
- /**
9
- * Progress handle drag hook
10
- * Previews with a local value while dragging, commits to rawTasks on pointerup
11
- */
12
6
  export declare function useGanttProgressDrag(task: TaskTransformed, barRef: React.RefObject<HTMLDivElement | null>, options?: GanttProgressDragOptions): {
13
7
  onProgressPointerDown: React.PointerEventHandler<HTMLDivElement>;
14
8
  progress: number | null;
15
9
  isDraggingProgress: boolean;
16
10
  };
11
+ export {};
@@ -1,14 +1,7 @@
1
1
  import { Dayjs } from 'dayjs';
2
- /**
3
- * The calendar every piece of date arithmetic in the core routes through.
4
- *
5
- * There is exactly one notion of "a day" in the engine: whatever this object says.
6
- * The default calendar counts every day, so the plain calendar-date behaviour is not a
7
- * separate code path - it is the same code with a calendar that never skips anything.
8
- * Turning the working-day calendar on swaps the object; nothing else changes.
9
- */
2
+ /** The calendar every piece of date arithmetic in the core routes through. */
10
3
  export interface WorkingCalendar {
11
- /** False for the default calendar (every day counts) - lets callers take the cheap path */
4
+ /** False for the default calendar (every day counts) */
12
5
  readonly skipsNonWorkingDays: boolean;
13
6
  isWorkingDay(date: Dayjs): boolean;
14
7
  /** Moves `days` days forward (or backward), skipping non-working days */
@@ -27,19 +20,8 @@ export interface WorkingCalendarOptions {
27
20
  workingWeekdays?: number[];
28
21
  /** Non-working dates as UTC `YYYY-MM-DD` strings */
29
22
  holidays?: string[];
30
- /** Replaces the weekday + holiday check entirely */
31
- isNonWorkingDay?: (date: Dayjs) => boolean;
32
23
  }
33
- /**
34
- * The default calendar: every day counts.
35
- * Date arithmetic through it is plain calendar arithmetic, so it is what keeps the
36
- * scheduling features behaviour-neutral until a host opts into working days.
37
- */
24
+ /** The default calendar: every day counts, so arithmetic through it is plain calendar arithmetic. */
38
25
  export declare const CALENDAR_DAYS: WorkingCalendar;
39
- /**
40
- * A calendar that skips weekends and holidays.
41
- *
42
- * Takes the same configuration the chart already uses to shade non-working days
43
- * (`holidays` / `isNonWorkingDay`), so what is shaded and what is skipped cannot drift.
44
- */
26
+ /** A calendar that skips weekends and holidays, configured like the chart's non-working-day shading. */
45
27
  export declare function createWorkingCalendar(options?: WorkingCalendarOptions): WorkingCalendar;
@@ -1,32 +1,16 @@
1
1
  import { default as dayjs, Dayjs } from 'dayjs';
2
2
  /**
3
- * The chart's own dayjs - always parses and displays in UTC mode.
4
- *
5
- * The contract for task dates is "UTC ISO string" (README > Task Format), so
6
- * positioning and labels follow UTC too. Parsing in local mode would draw the same
7
- * data in different date cells depending on where the viewer is (#84), and local
8
- * calendar DST days (23/25 hours) would make cell widths wobble as well (#28).
9
- *
10
- * - A string carrying a zone ('...Z', '+09:00') displays that instant as a UTC time
11
- * - A string without a zone ('2025-06-01', '2025-06-01T09:00') is read as a UTC wall
12
- * clock, so it displays exactly as written, whatever the viewer's time zone
3
+ * The chart's own dayjs - always parses and displays in UTC, so the same data lands in the
4
+ * same cells for every viewer and DST never changes a cell's width (#84, #28).
13
5
  */
14
6
  declare const ganttDayjs: typeof dayjs.utc;
15
7
  export default ganttDayjs;
16
- /**
17
- * Calendar quarter of the date, 1-4
18
- *
19
- * Written out instead of pulling in dayjs' quarterOfYear plugin - the quarter scale
20
- * needs exactly these two lines of it, and the plugin would grow the bundle for every
21
- * consumer, quarter scale in use or not.
22
- */
8
+ /** Calendar quarter of the date, 1-4 - inlined so dayjs' quarterOfYear plugin stays out of the bundle */
23
9
  export declare function quarterOfYear(date: Dayjs): number;
24
10
  /** First moment of the calendar quarter the date falls in */
25
11
  export declare function startOfQuarter(date: Dayjs): Dayjs;
26
12
  /**
27
- * First moment of the week the date falls in
28
- *
29
- * `firstDayOfWeek` is 0 = Sunday .. 6 = Saturday. dayjs' own `startOf('week')` is fixed
30
- * to the locale dayjs was loaded with (Sunday), so the week boundary is computed here.
13
+ * First moment of the week the date falls in; `firstDayOfWeek` is 0 = Sunday .. 6 = Saturday.
14
+ * Computed here because dayjs' `startOf('week')` is fixed to the loaded locale.
31
15
  */
32
16
  export declare function startOfWeek(date: Dayjs, firstDayOfWeek?: number): Dayjs;
@@ -1,16 +1,3 @@
1
- /**
2
- * The headless scheduling core.
3
- *
4
- * Everything under `src/core/` is plain data and pure functions - no React, no DOM, no
5
- * pixels - so it runs in Node, is unit-testable on its own, and could be published as a
6
- * separate entry point without dragging the renderer along. The boundary is enforced by an
7
- * eslint rule in `eslint.config.js`; keep anything that touches refs, elements or bar
8
- * geometry in `src/utils/` instead.
9
- */
10
- export { default as dayjs } from './dates';
11
- export type { DependencyType, Task, TaskDependency, TaskType, } from './types';
12
- export { isMilestoneTask, normalizeProgress } from './types';
13
1
  export { CALENDAR_DAYS, createWorkingCalendar, type WorkingCalendar, type WorkingCalendarOptions, } from './calendar';
14
- export { buildTaskGraph, canLink, findPath, linkDelta, linkKey, scheduleTasks, shiftTask, taskEnd, taskStart, type ScheduleOptions, type ScheduleResult, type SchedulingLink, type SchedulingPolicy, type TaskGraph, } from './scheduling';
15
- export { backwardPass, computeCriticalPath, forwardPass, type CriticalPathOptions, type CriticalPathResult, type EarlyDates, type LateDates, type TaskScheduleMetrics, } from './criticalPath';
16
2
  export { buildTaskTree, collectSubtreeIds, getVisibleTasks, rollUpTasks, type TaskTree, } from './tree';
3
+ export { moveTask, sortTasksBySequence, validateMove, type GanttMoveOptions, } from './reorder';
@@ -0,0 +1,55 @@
1
+ import { Task } from './types';
2
+ /** Where a task is going: a parent, and a slot among that parent's children */
3
+ export interface GanttTaskMove {
4
+ taskId: string;
5
+ /** New parent, null for the root level */
6
+ toParentId: string | null;
7
+ /** Slot among the new parent's children, counted in the list as it stands after the move */
8
+ toIndex: number;
9
+ }
10
+ /** The move that was applied - `toIndex` for an index-based API, `afterId`/`beforeId` for a position-based one */
11
+ export interface GanttTaskMoveChange extends GanttTaskMove {
12
+ fromParentId: string | null;
13
+ fromIndex: number;
14
+ /** Sibling the task now follows - null when it is the first child */
15
+ afterId: string | null;
16
+ /** Sibling the task now precedes - null when it is the last child */
17
+ beforeId: string | null;
18
+ }
19
+ /** Where a drop lands relative to the row under the pointer */
20
+ export type GanttDropMode = "before" | "after" | "child";
21
+ /** Why a move was refused - null from `validateMove` means it is allowed */
22
+ export type GanttMoveRejection = "unknown-task" | "unknown-parent" | "read-only" | "cycle" | "reparent-disabled" | "no-op";
23
+ export interface GanttMoveOptions {
24
+ /** Whether the parentId hierarchy is on - off, depth comes from `sequence` and a reparent is refused */
25
+ hierarchy: boolean;
26
+ /** Whether this task may be moved at all - left out, every task may */
27
+ canReorder?: (task: Task) => boolean;
28
+ }
29
+ /** The sibling lists a move is measured against - `toIndex` is counted against exactly these */
30
+ interface TaskOrder {
31
+ /** Normalized parent of each task - null for a root, an orphan or a cycle */
32
+ parentOf: ReadonlyMap<string, string | null>;
33
+ /** One parent's children in row order; pass null for the root list */
34
+ childrenOf: (parentId: string | null) => readonly string[];
35
+ }
36
+ /** Sort tasks by their sequence hierarchy - row order comes from this and nothing else */
37
+ export declare function sortTasksBySequence<T extends Pick<Task, "sequence">>(tasks: T[]): T[];
38
+ /** Reads the ordered forest the moves below are counted against */
39
+ export declare function buildTaskOrder(tasks: Task[], hierarchy: boolean): TaskOrder;
40
+ /**
41
+ * The move a drop on `targetId` would make: `before`/`after` make it a sibling, `child`
42
+ * appends it. Says nothing about whether the move is allowed - that is `validateMove`.
43
+ */
44
+ export declare function moveForDrop(order: TaskOrder, taskId: string, targetId: string, mode: GanttDropMode): GanttTaskMove;
45
+ /** Whether a move can be applied, and why not when it cannot - runs on every frame of a row drag */
46
+ export declare function validateMove(tasks: Task[], move: GanttTaskMove, options: GanttMoveOptions): GanttMoveRejection | null;
47
+ /**
48
+ * Applies a move, renumbering every sequence from the resulting row order; `parentId` is rewritten
49
+ * on the moved task only. Null when refused (`validateMove` says why); unchanged tasks keep identity.
50
+ */
51
+ export declare function moveTask(tasks: Task[], move: GanttTaskMove, options: GanttMoveOptions): {
52
+ tasks: Task[];
53
+ change: GanttTaskMoveChange;
54
+ } | null;
55
+ export {};
@@ -2,12 +2,8 @@ import { Task } from './types';
2
2
  /** The minimum a task needs for the tree math - TaskTransformed fits as-is */
3
3
  type TaskNode = Pick<Task, "id" | "parentId">;
4
4
  /**
5
- * A normalized tree built from parentId
6
- *
7
- * Orphans (a parent id that is not in the data), self-references and cyclic chains all get
8
- * their parent link cut and become roots. The parentOf/childIds that come out are therefore
9
- * always acyclic, so the functions below - and the render - can walk up or down without
10
- * risking an infinite loop.
5
+ * A normalized tree built from parentId. Orphans, self-references and cycles lose their
6
+ * parent link and become roots, so what comes out is always acyclic.
11
7
  */
12
8
  export interface TaskTree {
13
9
  /** parent id -> child ids (in input order) */
@@ -31,12 +27,8 @@ export declare function collectSubtreeIds(tasks: TaskNode[], rootId: string, tre
31
27
  */
32
28
  export declare function getVisibleTasks<T extends TaskNode>(tasks: T[], collapsedIds: Iterable<string>, tree?: TaskTree): T[];
33
29
  /**
34
- * The tasks with every parent recomputed as a summary row
35
- *
36
- * Start and end always come from the children, never from what the data says
37
- * (min(child start)..max(child end); a milestone child counts at its startDate alone).
38
- * Deepest first, so a grandchild's move travels up through the parent and the grandparent.
39
- * An explicit progress is left alone; only a missing one is rolled up from the children.
30
+ * The tasks with every parent recomputed as a summary row: start/end always from the children
31
+ * (deepest first, so a move travels all the way up); an explicit progress is left alone.
40
32
  */
41
33
  export declare function rollUpTasks(tasks: Task[], tree?: TaskTree): Task[];
42
34
  export {};