@ganttloom/gantt-react 0.2.0 → 0.4.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,10 +1,15 @@
1
1
  # @ganttloom/gantt-react
2
2
 
3
+ [![npm](https://img.shields.io/npm/v/%40ganttloom%2Fgantt-react)](https://www.npmjs.com/package/@ganttloom/gantt-react)
4
+ [![license](https://img.shields.io/npm/l/%40ganttloom%2Fgantt-react)](../../LICENSE)
5
+
3
6
  React component wrapping [`@ganttloom/gantt-core`](../gantt-core). A thin
4
7
  wrapper: it owns no scheduling logic of its own, just React lifecycle,
5
8
  props-as-events, and an imperative handle for the escape hatches (undo/redo,
6
9
  zoom, export) that don't fit the declarative-props model.
7
10
 
11
+ ![ganttloom overview — day-view Gantt chart with dependencies, critical path, and baselines](https://raw.githubusercontent.com/santhoshkumarhari/ganttLoom/master/docs/screenshots/overview.png)
12
+
8
13
  ## Install
9
14
 
10
15
  ```bash
@@ -104,7 +109,28 @@ shift-click selects a range. Then drive it from the handle:
104
109
  ```
105
110
 
106
111
  Both off by default (same construction-time-only wiring caveat as
107
- `onTaskCreate` — pass the prop from the first render).
112
+ `onTaskCreate` — pass the prop from the first render). Double-clicking a
113
+ task bar itself fires the separate `onTaskDblClick={(task) => ...}`, same
114
+ caveat.
115
+
116
+ ## Filling the viewport at any zoom level
117
+
118
+ A short project at month/year zoom, or just a handful of tasks, naturally
119
+ renders narrow. `autoFitToViewport` stretches (never shrinks) the timeline
120
+ to fill the container instead of leaving empty space:
121
+
122
+ ```tsx
123
+ <GanttChart tasks={tasks} autoFitToViewport />
124
+ ```
125
+
126
+ Off by default — upgrading doesn't silently change an existing chart's
127
+ pixel layout for anyone who hasn't opted in.
128
+
129
+ Always on, separately: the visible range is padded to a minimum tick count
130
+ per zoom level, so a short project at year/quarter zoom never collapses
131
+ into one or two lonely columns, and the date header stays pinned to the
132
+ top while scrolling a tall task list vertically (still scrolling
133
+ horizontally in sync with the bars).
108
134
 
109
135
  ## Drag-to-create
110
136
 
@@ -137,6 +163,21 @@ See `@ganttloom/gantt-core`'s README for the full behavior of each — the
137
163
  props here are 1:1 mirrors of its `GanttOptions` fields, and `filterTasks`
138
164
  is a pure re-export.
139
165
 
166
+ ## Column sorting
167
+
168
+ Mark a column `sortable`; clicking its header cycles asc → desc → none:
169
+
170
+ ```tsx
171
+ <GanttChart
172
+ tasks={tasks}
173
+ columns={[{ id: "name", title: "Task", sortable: true }]}
174
+ onSortChange={(sort) => console.log(sort)} // { columnId, direction } | null
175
+ />
176
+ ```
177
+
178
+ `chartRef.current?.setSort(columnId, direction)` / `.getSort()` are also
179
+ available on the handle.
180
+
140
181
  ## Resource leveling and multi-page PNG export
141
182
 
142
183
  ```tsx
@@ -156,6 +197,21 @@ const svg = renderResourceHistogramSVG(buckets);
156
197
  // e.g. <div dangerouslySetInnerHTML={{ __html: svg }} />
157
198
  ```
158
199
 
200
+ ## Hover tooltips
201
+
202
+ On by default (name/dates/progress/assignees/notes), styled via plain CSS
203
+ (`.gantt-tooltip`, see `gantt-core`'s README) — not the browser's native
204
+ tooltip. `renderTooltip` fully replaces the content:
205
+
206
+ ```tsx
207
+ <GanttChart
208
+ tasks={tasks}
209
+ renderTooltip={(task) => (task.isMilestone ? null : `${task.name} — ${task.progress ?? 0}%`)}
210
+ />
211
+ ```
212
+
213
+ Set `showTooltip={false}` to disable it entirely.
214
+
159
215
  ## `useGanttChart` (lower-level hook)
160
216
 
161
217
  If you want to own the container element/DOM tree yourself instead of using
package/dist/index.cjs CHANGED
@@ -134,7 +134,8 @@ var EMPTY_RENDER_MODEL = {
134
134
  columns: [],
135
135
  theme: {},
136
136
  markers: [],
137
- rangeStart: /* @__PURE__ */ new Date(0)
137
+ rangeStart: /* @__PURE__ */ new Date(0),
138
+ sort: null
138
139
  };
139
140
  function GanttChartInner(props, ref) {
140
141
  const {
@@ -148,6 +149,7 @@ function GanttChartInner(props, ref) {
148
149
  onDependencyRemove,
149
150
  onDependencyDblClick,
150
151
  onTaskClick,
152
+ onTaskDblClick,
151
153
  onGroupToggle,
152
154
  onContextMenu,
153
155
  onTaskCreate,
@@ -155,6 +157,7 @@ function GanttChartInner(props, ref) {
155
157
  onColumnReorder,
156
158
  onTaskReorder,
157
159
  onSelectionChange,
160
+ onSortChange,
158
161
  ...rest
159
162
  } = props;
160
163
  const containerRef = (0, import_react2.useRef)(null);
@@ -172,6 +175,8 @@ function GanttChartInner(props, ref) {
172
175
  );
173
176
  const enableDependencyDblClickWiring = (0, import_react2.useRef)((_dep) => {
174
177
  });
178
+ const enableTaskDblClickWiring = (0, import_react2.useRef)((_task) => {
179
+ });
175
180
  const options = (0, import_react2.useMemo)(
176
181
  () => ({
177
182
  ...rest,
@@ -181,7 +186,10 @@ function GanttChartInner(props, ref) {
181
186
  onColumnReorder: onColumnReorder ? enableColumnReorderWiring.current : void 0,
182
187
  onTaskReorder: onTaskReorder ? enableTaskReorderWiring.current : void 0,
183
188
  onDependencyDblClick: onDependencyDblClick ? enableDependencyDblClickWiring.current : void 0,
184
- onSelectionChange
189
+ onTaskDblClick: onTaskDblClick ? enableTaskDblClickWiring.current : void 0
190
+ // onSelectionChange/onSortChange are deliberately NOT set here: gantt-core invokes them
191
+ // directly from this.options AND emits a matching event at the same call sites, and the
192
+ // effect below already subscribes to those events — including them here would double-fire.
185
193
  }),
186
194
  [
187
195
  rest.viewMode,
@@ -196,6 +204,9 @@ function GanttChartInner(props, ref) {
196
204
  rest.showCriticalPath,
197
205
  rest.showBaseline,
198
206
  rest.showDeadlines,
207
+ rest.showTooltip,
208
+ rest.renderTooltip,
209
+ rest.autoFitToViewport,
199
210
  rest.showAssigneeAvatars,
200
211
  rest.enableHistory,
201
212
  rest.keyboardAccessible,
@@ -212,7 +223,7 @@ function GanttChartInner(props, ref) {
212
223
  Boolean(onColumnReorder),
213
224
  Boolean(onTaskReorder),
214
225
  Boolean(onDependencyDblClick),
215
- onSelectionChange
226
+ Boolean(onTaskDblClick)
216
227
  ]
217
228
  );
218
229
  const { chart } = useGanttChart(containerRef, tasks, dependencies, options);
@@ -223,13 +234,15 @@ function GanttChartInner(props, ref) {
223
234
  onDependencyRemove,
224
235
  onDependencyDblClick,
225
236
  onTaskClick,
237
+ onTaskDblClick,
226
238
  onGroupToggle,
227
239
  onContextMenu,
228
240
  onTaskCreate,
229
241
  onColumnResize,
230
242
  onColumnReorder,
231
243
  onTaskReorder,
232
- onSelectionChange
244
+ onSelectionChange,
245
+ onSortChange
233
246
  });
234
247
  callbacksRef.current = {
235
248
  onDateChange,
@@ -238,13 +251,15 @@ function GanttChartInner(props, ref) {
238
251
  onDependencyRemove,
239
252
  onDependencyDblClick,
240
253
  onTaskClick,
254
+ onTaskDblClick,
241
255
  onGroupToggle,
242
256
  onContextMenu,
243
257
  onTaskCreate,
244
258
  onColumnResize,
245
259
  onColumnReorder,
246
260
  onTaskReorder,
247
- onSelectionChange
261
+ onSelectionChange,
262
+ onSortChange
248
263
  };
249
264
  (0, import_react2.useEffect)(() => {
250
265
  if (!chart) return void 0;
@@ -253,6 +268,7 @@ function GanttChartInner(props, ref) {
253
268
  const handleDependencyCreate = (dep) => callbacksRef.current.onDependencyCreate?.(dep);
254
269
  const handleDependencyRemove = (dep) => callbacksRef.current.onDependencyRemove?.(dep);
255
270
  const handleTaskClick = (p) => callbacksRef.current.onTaskClick?.(p.task);
271
+ const handleTaskDblClick = (p) => callbacksRef.current.onTaskDblClick?.(p.task);
256
272
  const handleGroupToggle = (p) => callbacksRef.current.onGroupToggle?.(p.task, p.collapsed);
257
273
  const handleContextMenu = (p) => callbacksRef.current.onContextMenu?.(p.task, p.evt);
258
274
  const handleTaskCreate = (p) => callbacksRef.current.onTaskCreate?.(p.task);
@@ -261,12 +277,14 @@ function GanttChartInner(props, ref) {
261
277
  const handleDependencyDblClick = (dep) => callbacksRef.current.onDependencyDblClick?.(dep);
262
278
  const handleTaskReorder = (p) => callbacksRef.current.onTaskReorder?.(p.draggedTaskId, p.targetTaskId, p.position);
263
279
  const handleSelectionChange = (p) => callbacksRef.current.onSelectionChange?.(p.taskIds);
280
+ const handleSortChange = (p) => callbacksRef.current.onSortChange?.(p.sort);
264
281
  chart.on("date-change", handleDateChange);
265
282
  chart.on("progress-change", handleProgressChange);
266
283
  chart.on("dependency-create", handleDependencyCreate);
267
284
  chart.on("dependency-remove", handleDependencyRemove);
268
285
  chart.on("dependency-dblclick", handleDependencyDblClick);
269
286
  chart.on("task-click", handleTaskClick);
287
+ chart.on("task-dblclick", handleTaskDblClick);
270
288
  chart.on("group-toggle", handleGroupToggle);
271
289
  chart.on("context-menu", handleContextMenu);
272
290
  chart.on("task-create", handleTaskCreate);
@@ -274,6 +292,7 @@ function GanttChartInner(props, ref) {
274
292
  chart.on("column-reorder", handleColumnReorder);
275
293
  chart.on("task-reorder", handleTaskReorder);
276
294
  chart.on("selection-change", handleSelectionChange);
295
+ chart.on("sort-change", handleSortChange);
277
296
  return () => {
278
297
  chart.off("date-change", handleDateChange);
279
298
  chart.off("progress-change", handleProgressChange);
@@ -281,6 +300,7 @@ function GanttChartInner(props, ref) {
281
300
  chart.off("dependency-remove", handleDependencyRemove);
282
301
  chart.off("dependency-dblclick", handleDependencyDblClick);
283
302
  chart.off("task-click", handleTaskClick);
303
+ chart.off("task-dblclick", handleTaskDblClick);
284
304
  chart.off("group-toggle", handleGroupToggle);
285
305
  chart.off("context-menu", handleContextMenu);
286
306
  chart.off("task-create", handleTaskCreate);
@@ -288,6 +308,7 @@ function GanttChartInner(props, ref) {
288
308
  chart.off("column-reorder", handleColumnReorder);
289
309
  chart.off("task-reorder", handleTaskReorder);
290
310
  chart.off("selection-change", handleSelectionChange);
311
+ chart.off("sort-change", handleSortChange);
291
312
  };
292
313
  }, [chart]);
293
314
  (0, import_react2.useImperativeHandle)(
@@ -319,6 +340,8 @@ function GanttChartInner(props, ref) {
319
340
  selectAllVisible: () => chart?.selectAllVisible(),
320
341
  clearSelection: () => chart?.clearSelection(),
321
342
  getSelectedTaskIds: () => chart?.getSelectedTaskIds() ?? [],
343
+ setSort: (columnId, direction) => chart?.setSort(columnId, direction),
344
+ getSort: () => chart?.getSort() ?? null,
322
345
  bulkShiftDates: (deltaMs) => chart?.bulkShiftDates(deltaMs),
323
346
  bulkDelete: () => chart?.bulkDelete(),
324
347
  toSVGString: () => chart?.toSVGString() ?? "",
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/GanttChart.tsx","../src/useGanttChart.ts"],"sourcesContent":["export { GanttChart, default } from \"./GanttChart\";\nexport type { GanttChartProps, GanttChartHandle } from \"./GanttChart\";\n\nexport { useGanttChart } from \"./useGanttChart\";\nexport type { UseGanttChartResult } from \"./useGanttChart\";\n\n// Re-exported so consumers never need to add @ganttloom/gantt-core as a direct\n// dependency just to reference its types.\nexport type {\n ViewMode,\n DependencyType,\n GanttDependency,\n GanttAssignee,\n GanttTask,\n GanttColumn,\n GanttTheme,\n GanttRenderRow,\n GanttRenderBar,\n GanttRenderLink,\n GanttRenderTick,\n GanttRenderModel,\n GanttOptions,\n GanttEventMap,\n WorkingCalendar,\n ConstraintType,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n GanttMarker,\n GanttRenderMarker,\n FilterTasksOptions,\n FilterTasksResult,\n Density,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n} from \"@ganttloom/gantt-core\";\n\nexport {\n computeWBSCodes,\n applyConstraint,\n isWorkingDay,\n isHoliday,\n isWithinWorkingHours,\n isWorkingTime,\n nextWorkingDay,\n previousWorkingDay,\n shiftToWorkingDay,\n shiftToWorkingTime,\n computeResourceHistogram,\n renderResourceHistogramSVG,\n filterTasks,\n colorByField,\n applyColorByField,\n DEFAULT_PALETTE,\n DENSITY_PRESETS,\n levelResources,\n} from \"@ganttloom/gantt-core\";\n","// Pulls in the core's default styles so consumers get a working chart out of the box.\n// This resolves through gantt-core's package.json \"exports\" map (\"./styles.css\" -> \"./dist/styles.css\").\n// If your bundler can't resolve CSS imports from a dependency's export map, import it yourself instead:\n// import \"@ganttloom/gantt-core/styles.css\";\nimport \"@ganttloom/gantt-core/styles.css\";\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n type CSSProperties,\n type Ref,\n} from \"react\";\nimport type {\n GanttChart as GanttCore,\n GanttColumn,\n GanttDependency,\n GanttMarker,\n GanttOptions,\n GanttRenderModel,\n GanttTask,\n GanttTheme,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n ViewMode,\n WorkingCalendar,\n} from \"@ganttloom/gantt-core\";\nimport { useGanttChart } from \"./useGanttChart\";\n\nexport interface GanttChartProps {\n tasks: GanttTask[];\n dependencies?: GanttDependency[];\n\n // Mirrors of GanttOptions' non-callback fields.\n viewMode?: ViewMode;\n columns?: GanttColumn[];\n theme?: Partial<GanttTheme>;\n colorScheme?: \"light\" | \"dark\" | \"auto\";\n columnWidth?: number;\n readonly?: boolean;\n showProgress?: boolean;\n showDependencies?: boolean;\n gridPanelWidth?: number;\n showCriticalPath?: boolean;\n showBaseline?: boolean;\n showDeadlines?: boolean;\n showAssigneeAvatars?: boolean;\n enableHistory?: boolean;\n keyboardAccessible?: boolean;\n virtualScroll?: boolean;\n autoSchedule?: boolean;\n pagination?: { pageSize: number; page: number };\n snapToUnit?: \"hour\" | \"day\" | \"week\" | false;\n /** working-day/holiday definition used to shade non-working time and (with autoSchedule) skip it when cascading */\n calendar?: WorkingCalendar;\n /** arbitrary labeled vertical lines on the timeline, independent of any task */\n markers?: GanttMarker[];\n /** a group task with no explicit `progress` gets a duration-weighted average of its children's progress instead of 0 */\n autoRollupProgress?: boolean;\n /** enables click/ctrl-click/shift-click multi-selection of task bars, and the handle's bulkShiftDates()/bulkDelete() */\n selectable?: boolean;\n\n // Mirrors of GanttOptions' callback fields, as normal React event props.\n onDateChange?: (task: GanttTask, start: Date, end: Date) => void;\n onProgressChange?: (task: GanttTask, progress: number) => void;\n onDependencyCreate?: (dep: GanttDependency) => void;\n onDependencyRemove?: (dep: GanttDependency) => void;\n /** called on double-click of a dependency link, for building your own \"edit this link\" UI (see the handle's updateDependency) */\n onDependencyDblClick?: (dep: GanttDependency) => void;\n onTaskClick?: (task: GanttTask) => void;\n onGroupToggle?: (task: GanttTask, collapsed: boolean) => void;\n onContextMenu?: (task: GanttTask, evt: PointerEvent) => void;\n /** called when a task is created via drag-to-create on an empty timeline row */\n onTaskCreate?: (task: GanttTask) => void;\n /** called when a grid column is resized by dragging its header's edge */\n onColumnResize?: (columnId: string, width: number) => void;\n /** called when grid columns are reordered by dragging a header; `order` is the new full list of column ids */\n onColumnReorder?: (order: string[]) => void;\n /** called when a grid row is dragged onto another; \"inside\" reparents the dragged task under the target */\n onTaskReorder?: (draggedTaskId: string, targetTaskId: string, position: \"before\" | \"after\" | \"inside\") => void;\n onSelectionChange?: (taskIds: string[]) => void;\n\n /** Applied to the wrapping container div. */\n className?: string;\n style?: CSSProperties;\n}\n\n/** Imperative escape hatches that don't need to be reactive props. */\nexport interface GanttChartHandle {\n undo(): void;\n redo(): void;\n canUndo(): boolean;\n canRedo(): boolean;\n expandAll(): void;\n collapseAll(): void;\n toggleGroup(taskId: string): void;\n removeDependency(fromId: string, toId: string): void;\n updateDependency(fromId: string, toId: string, partial: Partial<GanttDependency>): void;\n updateTask(id: string, partial: Partial<GanttTask>): void;\n setViewMode(mode: ViewMode): void;\n fitToViewport(containerWidthPx: number): void;\n scrollToToday(): void;\n scrollToRangeStart(): void;\n scrollToRangeEnd(): void;\n getPageCount(): number;\n setPage(page: number): void;\n zoomIn(factor?: number): void;\n zoomOut(factor?: number): void;\n getZoomLevel(): number;\n getResourceHistogram(options?: ResourceHistogramOptions): ResourceLoadBucket[];\n getLeveledTasks(options?: ResourceLevelingOptions): ResourceLevelingResult;\n selectTask(id: string, options?: { additive?: boolean }): void;\n selectAllVisible(): void;\n clearSelection(): void;\n getSelectedTaskIds(): string[];\n bulkShiftDates(deltaMs: number): void;\n bulkDelete(): void;\n toSVGString(): string;\n toPNGDataURL(): Promise<string>;\n toPNGDataURLs(options?: { pageWidthPx?: number; pageHeightPx?: number }): Promise<string[]>;\n getRenderModel(): GanttRenderModel | null;\n /** Direct access to the underlying framework-agnostic core instance (null before mount). */\n getInstance(): GanttCore | null;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\n\nconst EMPTY_RENDER_MODEL: GanttRenderModel = {\n width: 0,\n height: 0,\n rowHeight: 0,\n headerHeight: 0,\n rows: [],\n bars: [],\n links: [],\n ticks: [],\n columns: [],\n theme: {} as GanttTheme,\n markers: [],\n rangeStart: new Date(0),\n};\n\nfunction GanttChartInner(props: GanttChartProps, ref: Ref<GanttChartHandle>) {\n const {\n tasks,\n dependencies = EMPTY_DEPENDENCIES,\n className,\n style,\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n ...rest\n } = props;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n // The core only wires up its internal contextmenu DOM listener (and therefore only\n // ever emits the \"context-menu\" event) when options.onContextMenu is truthy AT\n // CONSTRUCTION TIME (see GanttChart#setupDom in gantt-core). We pass a stable no-op\n // here purely to force that wiring on regardless of whether the consumer supplied\n // onContextMenu, and dispatch the actual prop via the \"context-menu\" event\n // subscription below (so it stays reactive to prop changes and is never double-fired).\n const enableContextMenuWiring = useRef(() => {});\n\n // Same construction-time-only caveat as onContextMenu above: drag-to-create is only\n // wired into the core's InteractionController when options.onTaskCreate is truthy at\n // construction. A stable no-op forces it on whenever this component was given an\n // onTaskCreate prop at all; the real dispatch goes through the \"task-create\" event.\n const enableCreateWiring = useRef(() => {});\n\n // Same construction-time-only caveat: column resize/reorder DOM listeners are only\n // built into the grid header when these options are truthy at construction.\n const enableColumnResizeWiring = useRef((_columnId: string, _width: number) => {});\n const enableColumnReorderWiring = useRef((_order: string[]) => {});\n const enableTaskReorderWiring = useRef(\n (_draggedTaskId: string, _targetTaskId: string, _position: \"before\" | \"after\" | \"inside\") => {}\n );\n const enableDependencyDblClickWiring = useRef((_dep: GanttDependency) => {});\n\n const options = useMemo<GanttOptions>(\n () => ({\n ...rest,\n onContextMenu: enableContextMenuWiring.current,\n onTaskCreate: onTaskCreate ? enableCreateWiring.current : undefined,\n onColumnResize: onColumnResize ? enableColumnResizeWiring.current : undefined,\n onColumnReorder: onColumnReorder ? enableColumnReorderWiring.current : undefined,\n onTaskReorder: onTaskReorder ? enableTaskReorderWiring.current : undefined,\n onDependencyDblClick: onDependencyDblClick ? enableDependencyDblClickWiring.current : undefined,\n onSelectionChange,\n }),\n [\n rest.viewMode,\n rest.columns,\n rest.theme,\n rest.colorScheme,\n rest.columnWidth,\n rest.readonly,\n rest.showProgress,\n rest.showDependencies,\n rest.gridPanelWidth,\n rest.showCriticalPath,\n rest.showBaseline,\n rest.showDeadlines,\n rest.showAssigneeAvatars,\n rest.enableHistory,\n rest.keyboardAccessible,\n rest.virtualScroll,\n rest.autoSchedule,\n rest.pagination,\n rest.snapToUnit,\n rest.calendar,\n rest.markers,\n rest.autoRollupProgress,\n rest.selectable,\n Boolean(onTaskCreate),\n Boolean(onColumnResize),\n Boolean(onColumnReorder),\n Boolean(onTaskReorder),\n Boolean(onDependencyDblClick),\n onSelectionChange,\n ]\n );\n\n const { chart } = useGanttChart(containerRef, tasks, dependencies, options);\n\n // Keep the latest callback props in a ref so the event-subscription effect below\n // doesn't need to re-subscribe (tearing down/rebuilding listeners) on every render.\n const callbacksRef = useRef({\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n });\n callbacksRef.current = {\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n };\n\n useEffect(() => {\n if (!chart) return undefined;\n\n const handleDateChange = (p: { task: GanttTask; start: Date; end: Date }) =>\n callbacksRef.current.onDateChange?.(p.task, p.start, p.end);\n const handleProgressChange = (p: { task: GanttTask; progress: number }) =>\n callbacksRef.current.onProgressChange?.(p.task, p.progress);\n const handleDependencyCreate = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyCreate?.(dep);\n const handleDependencyRemove = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyRemove?.(dep);\n const handleTaskClick = (p: { task: GanttTask }) =>\n callbacksRef.current.onTaskClick?.(p.task);\n const handleGroupToggle = (p: { task: GanttTask; collapsed: boolean }) =>\n callbacksRef.current.onGroupToggle?.(p.task, p.collapsed);\n const handleContextMenu = (p: { task: GanttTask; evt: PointerEvent }) =>\n callbacksRef.current.onContextMenu?.(p.task, p.evt);\n const handleTaskCreate = (p: { task: GanttTask }) => callbacksRef.current.onTaskCreate?.(p.task);\n const handleColumnResize = (p: { columnId: string; width: number }) =>\n callbacksRef.current.onColumnResize?.(p.columnId, p.width);\n const handleColumnReorder = (p: { order: string[] }) =>\n callbacksRef.current.onColumnReorder?.(p.order);\n const handleDependencyDblClick = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyDblClick?.(dep);\n const handleTaskReorder = (p: {\n draggedTaskId: string;\n targetTaskId: string;\n position: \"before\" | \"after\" | \"inside\";\n }) => callbacksRef.current.onTaskReorder?.(p.draggedTaskId, p.targetTaskId, p.position);\n const handleSelectionChange = (p: { taskIds: string[] }) =>\n callbacksRef.current.onSelectionChange?.(p.taskIds);\n\n chart.on(\"date-change\", handleDateChange);\n chart.on(\"progress-change\", handleProgressChange);\n chart.on(\"dependency-create\", handleDependencyCreate);\n chart.on(\"dependency-remove\", handleDependencyRemove);\n chart.on(\"dependency-dblclick\", handleDependencyDblClick);\n chart.on(\"task-click\", handleTaskClick);\n chart.on(\"group-toggle\", handleGroupToggle);\n chart.on(\"context-menu\", handleContextMenu);\n chart.on(\"task-create\", handleTaskCreate);\n chart.on(\"column-resize\", handleColumnResize);\n chart.on(\"column-reorder\", handleColumnReorder);\n chart.on(\"task-reorder\", handleTaskReorder);\n chart.on(\"selection-change\", handleSelectionChange);\n\n return () => {\n chart.off(\"date-change\", handleDateChange);\n chart.off(\"progress-change\", handleProgressChange);\n chart.off(\"dependency-create\", handleDependencyCreate);\n chart.off(\"dependency-remove\", handleDependencyRemove);\n chart.off(\"dependency-dblclick\", handleDependencyDblClick);\n chart.off(\"task-click\", handleTaskClick);\n chart.off(\"group-toggle\", handleGroupToggle);\n chart.off(\"context-menu\", handleContextMenu);\n chart.off(\"task-create\", handleTaskCreate);\n chart.off(\"column-resize\", handleColumnResize);\n chart.off(\"column-reorder\", handleColumnReorder);\n chart.off(\"task-reorder\", handleTaskReorder);\n chart.off(\"selection-change\", handleSelectionChange);\n };\n }, [chart]);\n\n useImperativeHandle(\n ref,\n (): GanttChartHandle => ({\n undo: () => chart?.undo(),\n redo: () => chart?.redo(),\n canUndo: () => chart?.canUndo ?? false,\n canRedo: () => chart?.canRedo ?? false,\n expandAll: () => chart?.expandAll(),\n collapseAll: () => chart?.collapseAll(),\n toggleGroup: (taskId: string) => chart?.toggleGroup(taskId),\n removeDependency: (fromId: string, toId: string) => chart?.removeDependency(fromId, toId),\n updateDependency: (fromId: string, toId: string, partial: Partial<GanttDependency>) =>\n chart?.updateDependency(fromId, toId, partial),\n updateTask: (id: string, partial: Partial<GanttTask>) => chart?.updateTask(id, partial),\n setViewMode: (mode: ViewMode) => chart?.setViewMode(mode),\n fitToViewport: (containerWidthPx: number) => chart?.fitToViewport(containerWidthPx),\n scrollToToday: () => chart?.scrollToToday(),\n scrollToRangeStart: () => chart?.scrollToRangeStart(),\n scrollToRangeEnd: () => chart?.scrollToRangeEnd(),\n getPageCount: () => chart?.getPageCount() ?? 1,\n setPage: (page: number) => chart?.setPage(page),\n zoomIn: (factor?: number) => chart?.zoomIn(factor),\n zoomOut: (factor?: number) => chart?.zoomOut(factor),\n getZoomLevel: () => chart?.getZoomLevel() ?? 0,\n getResourceHistogram: (options?: ResourceHistogramOptions) =>\n chart?.getResourceHistogram(options) ?? [],\n getLeveledTasks: (options?: ResourceLevelingOptions) =>\n chart?.getLeveledTasks(options) ?? { tasks: [], shifted: [] },\n selectTask: (id: string, options?: { additive?: boolean }) => chart?.selectTask(id, options),\n selectAllVisible: () => chart?.selectAllVisible(),\n clearSelection: () => chart?.clearSelection(),\n getSelectedTaskIds: () => chart?.getSelectedTaskIds() ?? [],\n bulkShiftDates: (deltaMs: number) => chart?.bulkShiftDates(deltaMs),\n bulkDelete: () => chart?.bulkDelete(),\n toSVGString: () => chart?.toSVGString() ?? \"\",\n toPNGDataURL: () => chart?.toPNGDataURL() ?? Promise.resolve(\"\"),\n toPNGDataURLs: (options?: { pageWidthPx?: number; pageHeightPx?: number }) =>\n chart?.toPNGDataURLs(options) ?? Promise.resolve([]),\n getRenderModel: () => chart?.getRenderModel() ?? EMPTY_RENDER_MODEL,\n getInstance: () => chart,\n }),\n [chart]\n );\n\n return <div ref={containerRef} className={className} style={style} />;\n}\n\nexport const GanttChart = forwardRef(GanttChartInner);\nGanttChart.displayName = \"GanttChart\";\n\nexport default GanttChart;\n","import { useEffect, useRef, useState, type RefObject } from \"react\";\nimport { GanttChart as GanttCore } from \"@ganttloom/gantt-core\";\nimport type { GanttDependency, GanttOptions, GanttTask } from \"@ganttloom/gantt-core\";\n\nexport interface UseGanttChartResult {\n /** The underlying framework-agnostic GanttChart instance, or null before the DOM mount effect runs (or on the server). */\n chart: GanttCore | null;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canUndo: boolean;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canRedo: boolean;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\nconst EMPTY_OPTIONS: GanttOptions = {};\n\n/**\n * Lower-level escape hatch for consumers who want to own their own container element\n * and DOM tree instead of using the <GanttChart /> component. Constructs a\n * @ganttloom/gantt-core GanttChart instance against `containerRef.current` on mount,\n * keeps it in sync with `tasks` / `dependencies` / `options` via setTasks / setDependencies /\n * setOptions (reference-equality checks only — pass new arrays/objects to trigger a sync),\n * and destroys it on unmount.\n */\nexport function useGanttChart(\n containerRef: RefObject<HTMLElement | null>,\n tasks: GanttTask[],\n dependencies: GanttDependency[] = EMPTY_DEPENDENCIES,\n options: GanttOptions = EMPTY_OPTIONS\n): UseGanttChartResult {\n const [chart, setChart] = useState<GanttCore | null>(null);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n const chartRef = useRef<GanttCore | null>(null);\n\n // Latest props, read from the mount effect so it doesn't need to depend on them\n // (which would otherwise tear down and recreate the whole chart on every change).\n const initialTasksRef = useRef(tasks);\n initialTasksRef.current = tasks;\n const initialDepsRef = useRef(dependencies);\n initialDepsRef.current = dependencies;\n const initialOptionsRef = useRef(options);\n initialOptionsRef.current = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\") return undefined;\n const container = containerRef.current;\n if (!container) return undefined;\n\n const instance = new GanttCore(\n container,\n initialTasksRef.current,\n initialDepsRef.current,\n initialOptionsRef.current\n );\n chartRef.current = instance;\n setChart(instance);\n setCanUndo(instance.canUndo);\n setCanRedo(instance.canRedo);\n\n const onHistoryChange = (state: { canUndo: boolean; canRedo: boolean }) => {\n setCanUndo(state.canUndo);\n setCanRedo(state.canRedo);\n };\n instance.on(\"history-change\", onHistoryChange);\n\n return () => {\n instance.off(\"history-change\", onHistoryChange);\n instance.destroy();\n chartRef.current = null;\n setChart(null);\n setCanUndo(false);\n setCanRedo(false);\n };\n // Intentionally mount/unmount only — the container element identity is what matters.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [containerRef]);\n\n const isFirstTasksSync = useRef(true);\n useEffect(() => {\n if (isFirstTasksSync.current) {\n isFirstTasksSync.current = false;\n return;\n }\n chartRef.current?.setTasks(tasks);\n }, [tasks]);\n\n const isFirstDepsSync = useRef(true);\n useEffect(() => {\n if (isFirstDepsSync.current) {\n isFirstDepsSync.current = false;\n return;\n }\n chartRef.current?.setDependencies(dependencies);\n }, [dependencies]);\n\n const isFirstOptionsSync = useRef(true);\n useEffect(() => {\n if (isFirstOptionsSync.current) {\n isFirstOptionsSync.current = false;\n return;\n }\n chartRef.current?.setOptions(options);\n }, [options]);\n\n return { chart, canUndo, canRedo };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,oBAAO;AAEP,IAAAA,gBAQO;;;ACdP,mBAA4D;AAC5D,wBAAwC;AAYxC,IAAM,qBAAwC,CAAC;AAC/C,IAAM,gBAA8B,CAAC;AAU9B,SAAS,cACd,cACA,OACA,eAAkC,oBAClC,UAAwB,eACH;AACrB,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAA2B,IAAI;AACzD,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAE5C,QAAM,eAAW,qBAAyB,IAAI;AAI9C,QAAM,sBAAkB,qBAAO,KAAK;AACpC,kBAAgB,UAAU;AAC1B,QAAM,qBAAiB,qBAAO,YAAY;AAC1C,iBAAe,UAAU;AACzB,QAAM,wBAAoB,qBAAO,OAAO;AACxC,oBAAkB,UAAU;AAE5B,8BAAU,MAAM;AACd,QAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,UAAM,YAAY,aAAa;AAC/B,QAAI,CAAC,UAAW,QAAO;AAEvB,UAAM,WAAW,IAAI,kBAAA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,CAAC,SAAiB,OAAO,QAAQ,IAAI;AAAA,MAC9C,QAAQ,CAAC,WAAoB,OAAO,OAAO,MAAM;AAAA,MACjD,SAAS,CAAC,WAAoB,OAAO,QAAQ,MAAM;AAAA,MACnD,cAAc,MAAM,OAAO,aAAa,KAAK;AAAA,MAC7C,sBAAsB,CAACC,aACrB,OAAO,qBAAqBA,QAAO,KAAK,CAAC;AAAA,MAC3C,iBAAiB,CAACA,aAChB,OAAO,gBAAgBA,QAAO,KAAK,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC,EAAE;AAAA,MAC9D,YAAY,CAAC,IAAYA,aAAqC,OAAO,WAAW,IAAIA,QAAO;AAAA,MAC3F,kBAAkB,MAAM,OAAO,iBAAiB;AAAA,MAChD,gBAAgB,MAAM,OAAO,eAAe;AAAA,MAC5C,oBAAoB,MAAM,OAAO,mBAAmB,KAAK,CAAC;AAAA,MAC1D,gBAAgB,CAAC,YAAoB,OAAO,eAAe,OAAO;AAAA,MAClE,YAAY,MAAM,OAAO,WAAW;AAAA,MACpC,aAAa,MAAM,OAAO,YAAY,KAAK;AAAA,MAC3C,cAAc,MAAM,OAAO,aAAa,KAAK,QAAQ,QAAQ,EAAE;AAAA,MAC/D,eAAe,CAACA,aACd,OAAO,cAAcA,QAAO,KAAK,QAAQ,QAAQ,CAAC,CAAC;AAAA,MACrD,gBAAgB,MAAM,OAAO,eAAe,KAAK;AAAA,MACjD,aAAa,MAAM;AAAA,IACrB;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AAEA,SAAO,4CAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACrE;AAEO,IAAM,iBAAa,0BAAW,eAAe;AACpD,WAAW,cAAc;AAEzB,IAAO,qBAAQ;;;AD7Vf,IAAAC,qBAmBO;","names":["import_react","GanttCore","EMPTY_DEPENDENCIES","options","import_gantt_core"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/GanttChart.tsx","../src/useGanttChart.ts"],"sourcesContent":["export { GanttChart, default } from \"./GanttChart\";\nexport type { GanttChartProps, GanttChartHandle } from \"./GanttChart\";\n\nexport { useGanttChart } from \"./useGanttChart\";\nexport type { UseGanttChartResult } from \"./useGanttChart\";\n\n// Re-exported so consumers never need to add @ganttloom/gantt-core as a direct\n// dependency just to reference its types.\nexport type {\n ViewMode,\n DependencyType,\n GanttDependency,\n GanttAssignee,\n GanttTask,\n GanttColumn,\n GanttTheme,\n GanttRenderRow,\n GanttRenderBar,\n GanttRenderLink,\n GanttRenderTick,\n GanttRenderModel,\n GanttOptions,\n GanttEventMap,\n WorkingCalendar,\n ConstraintType,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n GanttMarker,\n GanttRenderMarker,\n FilterTasksOptions,\n FilterTasksResult,\n Density,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n} from \"@ganttloom/gantt-core\";\n\nexport {\n computeWBSCodes,\n applyConstraint,\n isWorkingDay,\n isHoliday,\n isWithinWorkingHours,\n isWorkingTime,\n nextWorkingDay,\n previousWorkingDay,\n shiftToWorkingDay,\n shiftToWorkingTime,\n computeResourceHistogram,\n renderResourceHistogramSVG,\n filterTasks,\n colorByField,\n applyColorByField,\n DEFAULT_PALETTE,\n DENSITY_PRESETS,\n levelResources,\n} from \"@ganttloom/gantt-core\";\n","// Pulls in the core's default styles so consumers get a working chart out of the box.\n// This resolves through gantt-core's package.json \"exports\" map (\"./styles.css\" -> \"./dist/styles.css\").\n// If your bundler can't resolve CSS imports from a dependency's export map, import it yourself instead:\n// import \"@ganttloom/gantt-core/styles.css\";\nimport \"@ganttloom/gantt-core/styles.css\";\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n type CSSProperties,\n type Ref,\n} from \"react\";\nimport type {\n GanttChart as GanttCore,\n GanttColumn,\n GanttDependency,\n GanttMarker,\n GanttOptions,\n GanttRenderModel,\n GanttTask,\n GanttTheme,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n ViewMode,\n WorkingCalendar,\n} from \"@ganttloom/gantt-core\";\nimport { useGanttChart } from \"./useGanttChart\";\n\nexport interface GanttChartProps {\n tasks: GanttTask[];\n dependencies?: GanttDependency[];\n\n // Mirrors of GanttOptions' non-callback fields.\n viewMode?: ViewMode;\n columns?: GanttColumn[];\n theme?: Partial<GanttTheme>;\n colorScheme?: \"light\" | \"dark\" | \"auto\";\n columnWidth?: number;\n readonly?: boolean;\n showProgress?: boolean;\n showDependencies?: boolean;\n gridPanelWidth?: number;\n showCriticalPath?: boolean;\n showBaseline?: boolean;\n showDeadlines?: boolean;\n /** hover tooltip on task bars, defaults to true. A floating, CSS-customizable element (`.gantt-tooltip`) - not the browser's native title tooltip. */\n showTooltip?: boolean;\n /** fully control tooltip content/markup; return null/undefined to suppress it for a specific task. Defaults to name/dates/progress/assignees/notes. */\n renderTooltip?: (task: GanttTask) => HTMLElement | string | null | undefined;\n showAssigneeAvatars?: boolean;\n enableHistory?: boolean;\n keyboardAccessible?: boolean;\n virtualScroll?: boolean;\n autoSchedule?: boolean;\n pagination?: { pageSize: number; page: number };\n snapToUnit?: \"hour\" | \"day\" | \"week\" | false;\n /** working-day/holiday definition used to shade non-working time and (with autoSchedule) skip it when cascading */\n calendar?: WorkingCalendar;\n /** arbitrary labeled vertical lines on the timeline, independent of any task */\n markers?: GanttMarker[];\n /** a group task with no explicit `progress` gets a duration-weighted average of its children's progress instead of 0 */\n autoRollupProgress?: boolean;\n /** enables click/ctrl-click/shift-click multi-selection of task bars, and the handle's bulkShiftDates()/bulkDelete() */\n selectable?: boolean;\n /**\n * Stretch (never shrink) the timeline to fill the container's width instead of leaving empty\n * space - the common \"short project at month/year zoom\" or \"just a few tasks\" case. Off by\n * default (a new chart's pixel layout shouldn't change for existing consumers who don't opt in).\n */\n autoFitToViewport?: boolean;\n\n // Mirrors of GanttOptions' callback fields, as normal React event props.\n onDateChange?: (task: GanttTask, start: Date, end: Date) => void;\n onProgressChange?: (task: GanttTask, progress: number) => void;\n onDependencyCreate?: (dep: GanttDependency) => void;\n onDependencyRemove?: (dep: GanttDependency) => void;\n /** called on double-click of a dependency link, for building your own \"edit this link\" UI (see the handle's updateDependency) */\n onDependencyDblClick?: (dep: GanttDependency) => void;\n onTaskClick?: (task: GanttTask) => void;\n /** called on double-click of a task bar (distinct from onDependencyDblClick, which is for links) */\n onTaskDblClick?: (task: GanttTask) => void;\n onGroupToggle?: (task: GanttTask, collapsed: boolean) => void;\n onContextMenu?: (task: GanttTask, evt: PointerEvent) => void;\n /** called when a task is created via drag-to-create on an empty timeline row */\n onTaskCreate?: (task: GanttTask) => void;\n /** called when a grid column is resized by dragging its header's edge */\n onColumnResize?: (columnId: string, width: number) => void;\n /** called when grid columns are reordered by dragging a header; `order` is the new full list of column ids */\n onColumnReorder?: (order: string[]) => void;\n /** called when a grid row is dragged onto another; \"inside\" reparents the dragged task under the target */\n onTaskReorder?: (draggedTaskId: string, targetTaskId: string, position: \"before\" | \"after\" | \"inside\") => void;\n onSelectionChange?: (taskIds: string[]) => void;\n /** fired whenever the sort state changes, via a sortable column header click or the handle's setSort() */\n onSortChange?: (sort: { columnId: string; direction: \"asc\" | \"desc\" } | null) => void;\n\n /** Applied to the wrapping container div. */\n className?: string;\n style?: CSSProperties;\n}\n\n/** Imperative escape hatches that don't need to be reactive props. */\nexport interface GanttChartHandle {\n undo(): void;\n redo(): void;\n canUndo(): boolean;\n canRedo(): boolean;\n expandAll(): void;\n collapseAll(): void;\n toggleGroup(taskId: string): void;\n removeDependency(fromId: string, toId: string): void;\n updateDependency(fromId: string, toId: string, partial: Partial<GanttDependency>): void;\n updateTask(id: string, partial: Partial<GanttTask>): void;\n setViewMode(mode: ViewMode): void;\n fitToViewport(containerWidthPx: number): void;\n scrollToToday(): void;\n scrollToRangeStart(): void;\n scrollToRangeEnd(): void;\n getPageCount(): number;\n setPage(page: number): void;\n zoomIn(factor?: number): void;\n zoomOut(factor?: number): void;\n getZoomLevel(): number;\n getResourceHistogram(options?: ResourceHistogramOptions): ResourceLoadBucket[];\n getLeveledTasks(options?: ResourceLevelingOptions): ResourceLevelingResult;\n selectTask(id: string, options?: { additive?: boolean }): void;\n selectAllVisible(): void;\n clearSelection(): void;\n getSelectedTaskIds(): string[];\n setSort(columnId: string | null, direction?: \"asc\" | \"desc\" | null): void;\n getSort(): { columnId: string; direction: \"asc\" | \"desc\" } | null;\n bulkShiftDates(deltaMs: number): void;\n bulkDelete(): void;\n toSVGString(): string;\n toPNGDataURL(): Promise<string>;\n toPNGDataURLs(options?: { pageWidthPx?: number; pageHeightPx?: number }): Promise<string[]>;\n getRenderModel(): GanttRenderModel | null;\n /** Direct access to the underlying framework-agnostic core instance (null before mount). */\n getInstance(): GanttCore | null;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\n\nconst EMPTY_RENDER_MODEL: GanttRenderModel = {\n width: 0,\n height: 0,\n rowHeight: 0,\n headerHeight: 0,\n rows: [],\n bars: [],\n links: [],\n ticks: [],\n columns: [],\n theme: {} as GanttTheme,\n markers: [],\n rangeStart: new Date(0),\n sort: null,\n};\n\nfunction GanttChartInner(props: GanttChartProps, ref: Ref<GanttChartHandle>) {\n const {\n tasks,\n dependencies = EMPTY_DEPENDENCIES,\n className,\n style,\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onTaskDblClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n onSortChange,\n ...rest\n } = props;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n // The core only wires up its internal contextmenu DOM listener (and therefore only\n // ever emits the \"context-menu\" event) when options.onContextMenu is truthy AT\n // CONSTRUCTION TIME (see GanttChart#setupDom in gantt-core). We pass a stable no-op\n // here purely to force that wiring on regardless of whether the consumer supplied\n // onContextMenu, and dispatch the actual prop via the \"context-menu\" event\n // subscription below (so it stays reactive to prop changes and is never double-fired).\n const enableContextMenuWiring = useRef(() => {});\n\n // Same construction-time-only caveat as onContextMenu above: drag-to-create is only\n // wired into the core's InteractionController when options.onTaskCreate is truthy at\n // construction. A stable no-op forces it on whenever this component was given an\n // onTaskCreate prop at all; the real dispatch goes through the \"task-create\" event.\n const enableCreateWiring = useRef(() => {});\n\n // Same construction-time-only caveat: column resize/reorder DOM listeners are only\n // built into the grid header when these options are truthy at construction.\n const enableColumnResizeWiring = useRef((_columnId: string, _width: number) => {});\n const enableColumnReorderWiring = useRef((_order: string[]) => {});\n const enableTaskReorderWiring = useRef(\n (_draggedTaskId: string, _targetTaskId: string, _position: \"before\" | \"after\" | \"inside\") => {}\n );\n const enableDependencyDblClickWiring = useRef((_dep: GanttDependency) => {});\n const enableTaskDblClickWiring = useRef((_task: GanttTask) => {});\n\n // Deliberately depend on Boolean(handler) rather than the handler itself below: the\n // ref-backed enableXWiring callbacks already pick up the latest handler without\n // needing the memo to re-run, so depending on the raw (often inline) callback would\n // just re-create `options` — and remount the chart — every render.\n /* eslint-disable react-hooks/exhaustive-deps */\n const options = useMemo<GanttOptions>(\n () => ({\n ...rest,\n onContextMenu: enableContextMenuWiring.current,\n onTaskCreate: onTaskCreate ? enableCreateWiring.current : undefined,\n onColumnResize: onColumnResize ? enableColumnResizeWiring.current : undefined,\n onColumnReorder: onColumnReorder ? enableColumnReorderWiring.current : undefined,\n onTaskReorder: onTaskReorder ? enableTaskReorderWiring.current : undefined,\n onDependencyDblClick: onDependencyDblClick ? enableDependencyDblClickWiring.current : undefined,\n onTaskDblClick: onTaskDblClick ? enableTaskDblClickWiring.current : undefined,\n // onSelectionChange/onSortChange are deliberately NOT set here: gantt-core invokes them\n // directly from this.options AND emits a matching event at the same call sites, and the\n // effect below already subscribes to those events — including them here would double-fire.\n }),\n [\n rest.viewMode,\n rest.columns,\n rest.theme,\n rest.colorScheme,\n rest.columnWidth,\n rest.readonly,\n rest.showProgress,\n rest.showDependencies,\n rest.gridPanelWidth,\n rest.showCriticalPath,\n rest.showBaseline,\n rest.showDeadlines,\n rest.showTooltip,\n rest.renderTooltip,\n rest.autoFitToViewport,\n rest.showAssigneeAvatars,\n rest.enableHistory,\n rest.keyboardAccessible,\n rest.virtualScroll,\n rest.autoSchedule,\n rest.pagination,\n rest.snapToUnit,\n rest.calendar,\n rest.markers,\n rest.autoRollupProgress,\n rest.selectable,\n Boolean(onTaskCreate),\n Boolean(onColumnResize),\n Boolean(onColumnReorder),\n Boolean(onTaskReorder),\n Boolean(onDependencyDblClick),\n Boolean(onTaskDblClick),\n ]\n );\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const { chart } = useGanttChart(containerRef, tasks, dependencies, options);\n\n // Keep the latest callback props in a ref so the event-subscription effect below\n // doesn't need to re-subscribe (tearing down/rebuilding listeners) on every render.\n const callbacksRef = useRef({\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onTaskDblClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n onSortChange,\n });\n callbacksRef.current = {\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onTaskDblClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n onSortChange,\n };\n\n useEffect(() => {\n if (!chart) return undefined;\n\n const handleDateChange = (p: { task: GanttTask; start: Date; end: Date }) =>\n callbacksRef.current.onDateChange?.(p.task, p.start, p.end);\n const handleProgressChange = (p: { task: GanttTask; progress: number }) =>\n callbacksRef.current.onProgressChange?.(p.task, p.progress);\n const handleDependencyCreate = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyCreate?.(dep);\n const handleDependencyRemove = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyRemove?.(dep);\n const handleTaskClick = (p: { task: GanttTask }) =>\n callbacksRef.current.onTaskClick?.(p.task);\n const handleTaskDblClick = (p: { task: GanttTask }) =>\n callbacksRef.current.onTaskDblClick?.(p.task);\n const handleGroupToggle = (p: { task: GanttTask; collapsed: boolean }) =>\n callbacksRef.current.onGroupToggle?.(p.task, p.collapsed);\n const handleContextMenu = (p: { task: GanttTask; evt: PointerEvent }) =>\n callbacksRef.current.onContextMenu?.(p.task, p.evt);\n const handleTaskCreate = (p: { task: GanttTask }) => callbacksRef.current.onTaskCreate?.(p.task);\n const handleColumnResize = (p: { columnId: string; width: number }) =>\n callbacksRef.current.onColumnResize?.(p.columnId, p.width);\n const handleColumnReorder = (p: { order: string[] }) =>\n callbacksRef.current.onColumnReorder?.(p.order);\n const handleDependencyDblClick = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyDblClick?.(dep);\n const handleTaskReorder = (p: {\n draggedTaskId: string;\n targetTaskId: string;\n position: \"before\" | \"after\" | \"inside\";\n }) => callbacksRef.current.onTaskReorder?.(p.draggedTaskId, p.targetTaskId, p.position);\n const handleSelectionChange = (p: { taskIds: string[] }) =>\n callbacksRef.current.onSelectionChange?.(p.taskIds);\n const handleSortChange = (p: { sort: { columnId: string; direction: \"asc\" | \"desc\" } | null }) =>\n callbacksRef.current.onSortChange?.(p.sort);\n\n chart.on(\"date-change\", handleDateChange);\n chart.on(\"progress-change\", handleProgressChange);\n chart.on(\"dependency-create\", handleDependencyCreate);\n chart.on(\"dependency-remove\", handleDependencyRemove);\n chart.on(\"dependency-dblclick\", handleDependencyDblClick);\n chart.on(\"task-click\", handleTaskClick);\n chart.on(\"task-dblclick\", handleTaskDblClick);\n chart.on(\"group-toggle\", handleGroupToggle);\n chart.on(\"context-menu\", handleContextMenu);\n chart.on(\"task-create\", handleTaskCreate);\n chart.on(\"column-resize\", handleColumnResize);\n chart.on(\"column-reorder\", handleColumnReorder);\n chart.on(\"task-reorder\", handleTaskReorder);\n chart.on(\"selection-change\", handleSelectionChange);\n chart.on(\"sort-change\", handleSortChange);\n\n return () => {\n chart.off(\"date-change\", handleDateChange);\n chart.off(\"progress-change\", handleProgressChange);\n chart.off(\"dependency-create\", handleDependencyCreate);\n chart.off(\"dependency-remove\", handleDependencyRemove);\n chart.off(\"dependency-dblclick\", handleDependencyDblClick);\n chart.off(\"task-click\", handleTaskClick);\n chart.off(\"task-dblclick\", handleTaskDblClick);\n chart.off(\"group-toggle\", handleGroupToggle);\n chart.off(\"context-menu\", handleContextMenu);\n chart.off(\"task-create\", handleTaskCreate);\n chart.off(\"column-resize\", handleColumnResize);\n chart.off(\"column-reorder\", handleColumnReorder);\n chart.off(\"task-reorder\", handleTaskReorder);\n chart.off(\"selection-change\", handleSelectionChange);\n chart.off(\"sort-change\", handleSortChange);\n };\n }, [chart]);\n\n useImperativeHandle(\n ref,\n (): GanttChartHandle => ({\n undo: () => chart?.undo(),\n redo: () => chart?.redo(),\n canUndo: () => chart?.canUndo ?? false,\n canRedo: () => chart?.canRedo ?? false,\n expandAll: () => chart?.expandAll(),\n collapseAll: () => chart?.collapseAll(),\n toggleGroup: (taskId: string) => chart?.toggleGroup(taskId),\n removeDependency: (fromId: string, toId: string) => chart?.removeDependency(fromId, toId),\n updateDependency: (fromId: string, toId: string, partial: Partial<GanttDependency>) =>\n chart?.updateDependency(fromId, toId, partial),\n updateTask: (id: string, partial: Partial<GanttTask>) => chart?.updateTask(id, partial),\n setViewMode: (mode: ViewMode) => chart?.setViewMode(mode),\n fitToViewport: (containerWidthPx: number) => chart?.fitToViewport(containerWidthPx),\n scrollToToday: () => chart?.scrollToToday(),\n scrollToRangeStart: () => chart?.scrollToRangeStart(),\n scrollToRangeEnd: () => chart?.scrollToRangeEnd(),\n getPageCount: () => chart?.getPageCount() ?? 1,\n setPage: (page: number) => chart?.setPage(page),\n zoomIn: (factor?: number) => chart?.zoomIn(factor),\n zoomOut: (factor?: number) => chart?.zoomOut(factor),\n getZoomLevel: () => chart?.getZoomLevel() ?? 0,\n getResourceHistogram: (options?: ResourceHistogramOptions) =>\n chart?.getResourceHistogram(options) ?? [],\n getLeveledTasks: (options?: ResourceLevelingOptions) =>\n chart?.getLeveledTasks(options) ?? { tasks: [], shifted: [] },\n selectTask: (id: string, options?: { additive?: boolean }) => chart?.selectTask(id, options),\n selectAllVisible: () => chart?.selectAllVisible(),\n clearSelection: () => chart?.clearSelection(),\n getSelectedTaskIds: () => chart?.getSelectedTaskIds() ?? [],\n setSort: (columnId: string | null, direction?: \"asc\" | \"desc\" | null) => chart?.setSort(columnId, direction),\n getSort: () => chart?.getSort() ?? null,\n bulkShiftDates: (deltaMs: number) => chart?.bulkShiftDates(deltaMs),\n bulkDelete: () => chart?.bulkDelete(),\n toSVGString: () => chart?.toSVGString() ?? \"\",\n toPNGDataURL: () => chart?.toPNGDataURL() ?? Promise.resolve(\"\"),\n toPNGDataURLs: (options?: { pageWidthPx?: number; pageHeightPx?: number }) =>\n chart?.toPNGDataURLs(options) ?? Promise.resolve([]),\n getRenderModel: () => chart?.getRenderModel() ?? EMPTY_RENDER_MODEL,\n getInstance: () => chart,\n }),\n [chart]\n );\n\n return <div ref={containerRef} className={className} style={style} />;\n}\n\nexport const GanttChart = forwardRef(GanttChartInner);\nGanttChart.displayName = \"GanttChart\";\n\nexport default GanttChart;\n","import { useEffect, useRef, useState, type RefObject } from \"react\";\nimport { GanttChart as GanttCore } from \"@ganttloom/gantt-core\";\nimport type { GanttDependency, GanttOptions, GanttTask } from \"@ganttloom/gantt-core\";\n\nexport interface UseGanttChartResult {\n /** The underlying framework-agnostic GanttChart instance, or null before the DOM mount effect runs (or on the server). */\n chart: GanttCore | null;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canUndo: boolean;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canRedo: boolean;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\nconst EMPTY_OPTIONS: GanttOptions = {};\n\n/**\n * Lower-level escape hatch for consumers who want to own their own container element\n * and DOM tree instead of using the <GanttChart /> component. Constructs a\n * @ganttloom/gantt-core GanttChart instance against `containerRef.current` on mount,\n * keeps it in sync with `tasks` / `dependencies` / `options` via setTasks / setDependencies /\n * setOptions (reference-equality checks only — pass new arrays/objects to trigger a sync),\n * and destroys it on unmount.\n */\nexport function useGanttChart(\n containerRef: RefObject<HTMLElement | null>,\n tasks: GanttTask[],\n dependencies: GanttDependency[] = EMPTY_DEPENDENCIES,\n options: GanttOptions = EMPTY_OPTIONS\n): UseGanttChartResult {\n const [chart, setChart] = useState<GanttCore | null>(null);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n const chartRef = useRef<GanttCore | null>(null);\n\n // Latest props, read from the mount effect so it doesn't need to depend on them\n // (which would otherwise tear down and recreate the whole chart on every change).\n const initialTasksRef = useRef(tasks);\n initialTasksRef.current = tasks;\n const initialDepsRef = useRef(dependencies);\n initialDepsRef.current = dependencies;\n const initialOptionsRef = useRef(options);\n initialOptionsRef.current = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\") return undefined;\n const container = containerRef.current;\n if (!container) return undefined;\n\n const instance = new GanttCore(\n container,\n initialTasksRef.current,\n initialDepsRef.current,\n initialOptionsRef.current\n );\n chartRef.current = instance;\n setChart(instance);\n setCanUndo(instance.canUndo);\n setCanRedo(instance.canRedo);\n\n const onHistoryChange = (state: { canUndo: boolean; canRedo: boolean }) => {\n setCanUndo(state.canUndo);\n setCanRedo(state.canRedo);\n };\n instance.on(\"history-change\", onHistoryChange);\n\n return () => {\n instance.off(\"history-change\", onHistoryChange);\n instance.destroy();\n chartRef.current = null;\n setChart(null);\n setCanUndo(false);\n setCanRedo(false);\n };\n // Intentionally mount/unmount only — the container element identity is what matters.\n }, [containerRef]);\n\n const isFirstTasksSync = useRef(true);\n useEffect(() => {\n if (isFirstTasksSync.current) {\n isFirstTasksSync.current = false;\n return;\n }\n chartRef.current?.setTasks(tasks);\n }, [tasks]);\n\n const isFirstDepsSync = useRef(true);\n useEffect(() => {\n if (isFirstDepsSync.current) {\n isFirstDepsSync.current = false;\n return;\n }\n chartRef.current?.setDependencies(dependencies);\n }, [dependencies]);\n\n const isFirstOptionsSync = useRef(true);\n useEffect(() => {\n if (isFirstOptionsSync.current) {\n isFirstOptionsSync.current = false;\n return;\n }\n chartRef.current?.setOptions(options);\n }, [options]);\n\n return { chart, canUndo, canRedo };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,oBAAO;AAEP,IAAAA,gBAQO;;;ACdP,mBAA4D;AAC5D,wBAAwC;AAYxC,IAAM,qBAAwC,CAAC;AAC/C,IAAM,gBAA8B,CAAC;AAU9B,SAAS,cACd,cACA,OACA,eAAkC,oBAClC,UAAwB,eACH;AACrB,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAA2B,IAAI;AACzD,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAC5C,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,KAAK;AAE5C,QAAM,eAAW,qBAAyB,IAAI;AAI9C,QAAM,sBAAkB,qBAAO,KAAK;AACpC,kBAAgB,UAAU;AAC1B,QAAM,qBAAiB,qBAAO,YAAY;AAC1C,iBAAe,UAAU;AACzB,QAAM,wBAAoB,qBAAO,OAAO;AACxC,oBAAkB,UAAU;AAE5B,8BAAU,MAAM;AACd,QAAI,OAAO,WAAW,YAAa,QAAO;AAC1C,UAAM,YAAY,aAAa;AAC/B,QAAI,CAAC,UAAW,QAAO;AAEvB,UAAM,WAAW,IAAI,kBAAAC;AAAA,MACnB;AAAA,MACA,gBAAgB;AAAA,MAChB,eAAe;AAAA,MACf,kBAAkB;AAAA,IACpB;AACA,aAAS,UAAU;AACnB,aAAS,QAAQ;AACjB,eAAW,SAAS,OAAO;AA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E;AAAA,MAC/D,eAAe,CAACA,aACd,OAAO,cAAcA,QAAO,KAAK,QAAQ,QAAQ,CAAC,CAAC;AAAA,MACrD,gBAAgB,MAAM,OAAO,eAAe,KAAK;AAAA,MACjD,aAAa,MAAM;AAAA,IACrB;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AAEA,SAAO,4CAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACrE;AAEO,IAAM,iBAAa,0BAAW,eAAe;AACpD,WAAW,cAAc;AAEzB,IAAO,qBAAQ;;;AD3Yf,IAAAC,qBAmBO;","names":["import_react","GanttCore","EMPTY_DEPENDENCIES","options","import_gantt_core"]}
package/dist/index.d.cts CHANGED
@@ -18,6 +18,10 @@ interface GanttChartProps {
18
18
  showCriticalPath?: boolean;
19
19
  showBaseline?: boolean;
20
20
  showDeadlines?: boolean;
21
+ /** hover tooltip on task bars, defaults to true. A floating, CSS-customizable element (`.gantt-tooltip`) - not the browser's native title tooltip. */
22
+ showTooltip?: boolean;
23
+ /** fully control tooltip content/markup; return null/undefined to suppress it for a specific task. Defaults to name/dates/progress/assignees/notes. */
24
+ renderTooltip?: (task: GanttTask) => HTMLElement | string | null | undefined;
21
25
  showAssigneeAvatars?: boolean;
22
26
  enableHistory?: boolean;
23
27
  keyboardAccessible?: boolean;
@@ -36,6 +40,12 @@ interface GanttChartProps {
36
40
  autoRollupProgress?: boolean;
37
41
  /** enables click/ctrl-click/shift-click multi-selection of task bars, and the handle's bulkShiftDates()/bulkDelete() */
38
42
  selectable?: boolean;
43
+ /**
44
+ * Stretch (never shrink) the timeline to fill the container's width instead of leaving empty
45
+ * space - the common "short project at month/year zoom" or "just a few tasks" case. Off by
46
+ * default (a new chart's pixel layout shouldn't change for existing consumers who don't opt in).
47
+ */
48
+ autoFitToViewport?: boolean;
39
49
  onDateChange?: (task: GanttTask, start: Date, end: Date) => void;
40
50
  onProgressChange?: (task: GanttTask, progress: number) => void;
41
51
  onDependencyCreate?: (dep: GanttDependency) => void;
@@ -43,6 +53,8 @@ interface GanttChartProps {
43
53
  /** called on double-click of a dependency link, for building your own "edit this link" UI (see the handle's updateDependency) */
44
54
  onDependencyDblClick?: (dep: GanttDependency) => void;
45
55
  onTaskClick?: (task: GanttTask) => void;
56
+ /** called on double-click of a task bar (distinct from onDependencyDblClick, which is for links) */
57
+ onTaskDblClick?: (task: GanttTask) => void;
46
58
  onGroupToggle?: (task: GanttTask, collapsed: boolean) => void;
47
59
  onContextMenu?: (task: GanttTask, evt: PointerEvent) => void;
48
60
  /** called when a task is created via drag-to-create on an empty timeline row */
@@ -54,6 +66,11 @@ interface GanttChartProps {
54
66
  /** called when a grid row is dragged onto another; "inside" reparents the dragged task under the target */
55
67
  onTaskReorder?: (draggedTaskId: string, targetTaskId: string, position: "before" | "after" | "inside") => void;
56
68
  onSelectionChange?: (taskIds: string[]) => void;
69
+ /** fired whenever the sort state changes, via a sortable column header click or the handle's setSort() */
70
+ onSortChange?: (sort: {
71
+ columnId: string;
72
+ direction: "asc" | "desc";
73
+ } | null) => void;
57
74
  /** Applied to the wrapping container div. */
58
75
  className?: string;
59
76
  style?: CSSProperties;
@@ -88,6 +105,11 @@ interface GanttChartHandle {
88
105
  selectAllVisible(): void;
89
106
  clearSelection(): void;
90
107
  getSelectedTaskIds(): string[];
108
+ setSort(columnId: string | null, direction?: "asc" | "desc" | null): void;
109
+ getSort(): {
110
+ columnId: string;
111
+ direction: "asc" | "desc";
112
+ } | null;
91
113
  bulkShiftDates(deltaMs: number): void;
92
114
  bulkDelete(): void;
93
115
  toSVGString(): string;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,10 @@ interface GanttChartProps {
18
18
  showCriticalPath?: boolean;
19
19
  showBaseline?: boolean;
20
20
  showDeadlines?: boolean;
21
+ /** hover tooltip on task bars, defaults to true. A floating, CSS-customizable element (`.gantt-tooltip`) - not the browser's native title tooltip. */
22
+ showTooltip?: boolean;
23
+ /** fully control tooltip content/markup; return null/undefined to suppress it for a specific task. Defaults to name/dates/progress/assignees/notes. */
24
+ renderTooltip?: (task: GanttTask) => HTMLElement | string | null | undefined;
21
25
  showAssigneeAvatars?: boolean;
22
26
  enableHistory?: boolean;
23
27
  keyboardAccessible?: boolean;
@@ -36,6 +40,12 @@ interface GanttChartProps {
36
40
  autoRollupProgress?: boolean;
37
41
  /** enables click/ctrl-click/shift-click multi-selection of task bars, and the handle's bulkShiftDates()/bulkDelete() */
38
42
  selectable?: boolean;
43
+ /**
44
+ * Stretch (never shrink) the timeline to fill the container's width instead of leaving empty
45
+ * space - the common "short project at month/year zoom" or "just a few tasks" case. Off by
46
+ * default (a new chart's pixel layout shouldn't change for existing consumers who don't opt in).
47
+ */
48
+ autoFitToViewport?: boolean;
39
49
  onDateChange?: (task: GanttTask, start: Date, end: Date) => void;
40
50
  onProgressChange?: (task: GanttTask, progress: number) => void;
41
51
  onDependencyCreate?: (dep: GanttDependency) => void;
@@ -43,6 +53,8 @@ interface GanttChartProps {
43
53
  /** called on double-click of a dependency link, for building your own "edit this link" UI (see the handle's updateDependency) */
44
54
  onDependencyDblClick?: (dep: GanttDependency) => void;
45
55
  onTaskClick?: (task: GanttTask) => void;
56
+ /** called on double-click of a task bar (distinct from onDependencyDblClick, which is for links) */
57
+ onTaskDblClick?: (task: GanttTask) => void;
46
58
  onGroupToggle?: (task: GanttTask, collapsed: boolean) => void;
47
59
  onContextMenu?: (task: GanttTask, evt: PointerEvent) => void;
48
60
  /** called when a task is created via drag-to-create on an empty timeline row */
@@ -54,6 +66,11 @@ interface GanttChartProps {
54
66
  /** called when a grid row is dragged onto another; "inside" reparents the dragged task under the target */
55
67
  onTaskReorder?: (draggedTaskId: string, targetTaskId: string, position: "before" | "after" | "inside") => void;
56
68
  onSelectionChange?: (taskIds: string[]) => void;
69
+ /** fired whenever the sort state changes, via a sortable column header click or the handle's setSort() */
70
+ onSortChange?: (sort: {
71
+ columnId: string;
72
+ direction: "asc" | "desc";
73
+ } | null) => void;
57
74
  /** Applied to the wrapping container div. */
58
75
  className?: string;
59
76
  style?: CSSProperties;
@@ -88,6 +105,11 @@ interface GanttChartHandle {
88
105
  selectAllVisible(): void;
89
106
  clearSelection(): void;
90
107
  getSelectedTaskIds(): string[];
108
+ setSort(columnId: string | null, direction?: "asc" | "desc" | null): void;
109
+ getSort(): {
110
+ columnId: string;
111
+ direction: "asc" | "desc";
112
+ } | null;
91
113
  bulkShiftDates(deltaMs: number): void;
92
114
  bulkDelete(): void;
93
115
  toSVGString(): string;
package/dist/index.js CHANGED
@@ -94,7 +94,8 @@ var EMPTY_RENDER_MODEL = {
94
94
  columns: [],
95
95
  theme: {},
96
96
  markers: [],
97
- rangeStart: /* @__PURE__ */ new Date(0)
97
+ rangeStart: /* @__PURE__ */ new Date(0),
98
+ sort: null
98
99
  };
99
100
  function GanttChartInner(props, ref) {
100
101
  const {
@@ -108,6 +109,7 @@ function GanttChartInner(props, ref) {
108
109
  onDependencyRemove,
109
110
  onDependencyDblClick,
110
111
  onTaskClick,
112
+ onTaskDblClick,
111
113
  onGroupToggle,
112
114
  onContextMenu,
113
115
  onTaskCreate,
@@ -115,6 +117,7 @@ function GanttChartInner(props, ref) {
115
117
  onColumnReorder,
116
118
  onTaskReorder,
117
119
  onSelectionChange,
120
+ onSortChange,
118
121
  ...rest
119
122
  } = props;
120
123
  const containerRef = useRef2(null);
@@ -132,6 +135,8 @@ function GanttChartInner(props, ref) {
132
135
  );
133
136
  const enableDependencyDblClickWiring = useRef2((_dep) => {
134
137
  });
138
+ const enableTaskDblClickWiring = useRef2((_task) => {
139
+ });
135
140
  const options = useMemo(
136
141
  () => ({
137
142
  ...rest,
@@ -141,7 +146,10 @@ function GanttChartInner(props, ref) {
141
146
  onColumnReorder: onColumnReorder ? enableColumnReorderWiring.current : void 0,
142
147
  onTaskReorder: onTaskReorder ? enableTaskReorderWiring.current : void 0,
143
148
  onDependencyDblClick: onDependencyDblClick ? enableDependencyDblClickWiring.current : void 0,
144
- onSelectionChange
149
+ onTaskDblClick: onTaskDblClick ? enableTaskDblClickWiring.current : void 0
150
+ // onSelectionChange/onSortChange are deliberately NOT set here: gantt-core invokes them
151
+ // directly from this.options AND emits a matching event at the same call sites, and the
152
+ // effect below already subscribes to those events — including them here would double-fire.
145
153
  }),
146
154
  [
147
155
  rest.viewMode,
@@ -156,6 +164,9 @@ function GanttChartInner(props, ref) {
156
164
  rest.showCriticalPath,
157
165
  rest.showBaseline,
158
166
  rest.showDeadlines,
167
+ rest.showTooltip,
168
+ rest.renderTooltip,
169
+ rest.autoFitToViewport,
159
170
  rest.showAssigneeAvatars,
160
171
  rest.enableHistory,
161
172
  rest.keyboardAccessible,
@@ -172,7 +183,7 @@ function GanttChartInner(props, ref) {
172
183
  Boolean(onColumnReorder),
173
184
  Boolean(onTaskReorder),
174
185
  Boolean(onDependencyDblClick),
175
- onSelectionChange
186
+ Boolean(onTaskDblClick)
176
187
  ]
177
188
  );
178
189
  const { chart } = useGanttChart(containerRef, tasks, dependencies, options);
@@ -183,13 +194,15 @@ function GanttChartInner(props, ref) {
183
194
  onDependencyRemove,
184
195
  onDependencyDblClick,
185
196
  onTaskClick,
197
+ onTaskDblClick,
186
198
  onGroupToggle,
187
199
  onContextMenu,
188
200
  onTaskCreate,
189
201
  onColumnResize,
190
202
  onColumnReorder,
191
203
  onTaskReorder,
192
- onSelectionChange
204
+ onSelectionChange,
205
+ onSortChange
193
206
  });
194
207
  callbacksRef.current = {
195
208
  onDateChange,
@@ -198,13 +211,15 @@ function GanttChartInner(props, ref) {
198
211
  onDependencyRemove,
199
212
  onDependencyDblClick,
200
213
  onTaskClick,
214
+ onTaskDblClick,
201
215
  onGroupToggle,
202
216
  onContextMenu,
203
217
  onTaskCreate,
204
218
  onColumnResize,
205
219
  onColumnReorder,
206
220
  onTaskReorder,
207
- onSelectionChange
221
+ onSelectionChange,
222
+ onSortChange
208
223
  };
209
224
  useEffect2(() => {
210
225
  if (!chart) return void 0;
@@ -213,6 +228,7 @@ function GanttChartInner(props, ref) {
213
228
  const handleDependencyCreate = (dep) => callbacksRef.current.onDependencyCreate?.(dep);
214
229
  const handleDependencyRemove = (dep) => callbacksRef.current.onDependencyRemove?.(dep);
215
230
  const handleTaskClick = (p) => callbacksRef.current.onTaskClick?.(p.task);
231
+ const handleTaskDblClick = (p) => callbacksRef.current.onTaskDblClick?.(p.task);
216
232
  const handleGroupToggle = (p) => callbacksRef.current.onGroupToggle?.(p.task, p.collapsed);
217
233
  const handleContextMenu = (p) => callbacksRef.current.onContextMenu?.(p.task, p.evt);
218
234
  const handleTaskCreate = (p) => callbacksRef.current.onTaskCreate?.(p.task);
@@ -221,12 +237,14 @@ function GanttChartInner(props, ref) {
221
237
  const handleDependencyDblClick = (dep) => callbacksRef.current.onDependencyDblClick?.(dep);
222
238
  const handleTaskReorder = (p) => callbacksRef.current.onTaskReorder?.(p.draggedTaskId, p.targetTaskId, p.position);
223
239
  const handleSelectionChange = (p) => callbacksRef.current.onSelectionChange?.(p.taskIds);
240
+ const handleSortChange = (p) => callbacksRef.current.onSortChange?.(p.sort);
224
241
  chart.on("date-change", handleDateChange);
225
242
  chart.on("progress-change", handleProgressChange);
226
243
  chart.on("dependency-create", handleDependencyCreate);
227
244
  chart.on("dependency-remove", handleDependencyRemove);
228
245
  chart.on("dependency-dblclick", handleDependencyDblClick);
229
246
  chart.on("task-click", handleTaskClick);
247
+ chart.on("task-dblclick", handleTaskDblClick);
230
248
  chart.on("group-toggle", handleGroupToggle);
231
249
  chart.on("context-menu", handleContextMenu);
232
250
  chart.on("task-create", handleTaskCreate);
@@ -234,6 +252,7 @@ function GanttChartInner(props, ref) {
234
252
  chart.on("column-reorder", handleColumnReorder);
235
253
  chart.on("task-reorder", handleTaskReorder);
236
254
  chart.on("selection-change", handleSelectionChange);
255
+ chart.on("sort-change", handleSortChange);
237
256
  return () => {
238
257
  chart.off("date-change", handleDateChange);
239
258
  chart.off("progress-change", handleProgressChange);
@@ -241,6 +260,7 @@ function GanttChartInner(props, ref) {
241
260
  chart.off("dependency-remove", handleDependencyRemove);
242
261
  chart.off("dependency-dblclick", handleDependencyDblClick);
243
262
  chart.off("task-click", handleTaskClick);
263
+ chart.off("task-dblclick", handleTaskDblClick);
244
264
  chart.off("group-toggle", handleGroupToggle);
245
265
  chart.off("context-menu", handleContextMenu);
246
266
  chart.off("task-create", handleTaskCreate);
@@ -248,6 +268,7 @@ function GanttChartInner(props, ref) {
248
268
  chart.off("column-reorder", handleColumnReorder);
249
269
  chart.off("task-reorder", handleTaskReorder);
250
270
  chart.off("selection-change", handleSelectionChange);
271
+ chart.off("sort-change", handleSortChange);
251
272
  };
252
273
  }, [chart]);
253
274
  useImperativeHandle(
@@ -279,6 +300,8 @@ function GanttChartInner(props, ref) {
279
300
  selectAllVisible: () => chart?.selectAllVisible(),
280
301
  clearSelection: () => chart?.clearSelection(),
281
302
  getSelectedTaskIds: () => chart?.getSelectedTaskIds() ?? [],
303
+ setSort: (columnId, direction) => chart?.setSort(columnId, direction),
304
+ getSort: () => chart?.getSort() ?? null,
282
305
  bulkShiftDates: (deltaMs) => chart?.bulkShiftDates(deltaMs),
283
306
  bulkDelete: () => chart?.bulkDelete(),
284
307
  toSVGString: () => chart?.toSVGString() ?? "",
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/GanttChart.tsx","../src/useGanttChart.ts","../src/index.ts"],"sourcesContent":["// Pulls in the core's default styles so consumers get a working chart out of the box.\n// This resolves through gantt-core's package.json \"exports\" map (\"./styles.css\" -> \"./dist/styles.css\").\n// If your bundler can't resolve CSS imports from a dependency's export map, import it yourself instead:\n// import \"@ganttloom/gantt-core/styles.css\";\nimport \"@ganttloom/gantt-core/styles.css\";\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n type CSSProperties,\n type Ref,\n} from \"react\";\nimport type {\n GanttChart as GanttCore,\n GanttColumn,\n GanttDependency,\n GanttMarker,\n GanttOptions,\n GanttRenderModel,\n GanttTask,\n GanttTheme,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n ViewMode,\n WorkingCalendar,\n} from \"@ganttloom/gantt-core\";\nimport { useGanttChart } from \"./useGanttChart\";\n\nexport interface GanttChartProps {\n tasks: GanttTask[];\n dependencies?: GanttDependency[];\n\n // Mirrors of GanttOptions' non-callback fields.\n viewMode?: ViewMode;\n columns?: GanttColumn[];\n theme?: Partial<GanttTheme>;\n colorScheme?: \"light\" | \"dark\" | \"auto\";\n columnWidth?: number;\n readonly?: boolean;\n showProgress?: boolean;\n showDependencies?: boolean;\n gridPanelWidth?: number;\n showCriticalPath?: boolean;\n showBaseline?: boolean;\n showDeadlines?: boolean;\n showAssigneeAvatars?: boolean;\n enableHistory?: boolean;\n keyboardAccessible?: boolean;\n virtualScroll?: boolean;\n autoSchedule?: boolean;\n pagination?: { pageSize: number; page: number };\n snapToUnit?: \"hour\" | \"day\" | \"week\" | false;\n /** working-day/holiday definition used to shade non-working time and (with autoSchedule) skip it when cascading */\n calendar?: WorkingCalendar;\n /** arbitrary labeled vertical lines on the timeline, independent of any task */\n markers?: GanttMarker[];\n /** a group task with no explicit `progress` gets a duration-weighted average of its children's progress instead of 0 */\n autoRollupProgress?: boolean;\n /** enables click/ctrl-click/shift-click multi-selection of task bars, and the handle's bulkShiftDates()/bulkDelete() */\n selectable?: boolean;\n\n // Mirrors of GanttOptions' callback fields, as normal React event props.\n onDateChange?: (task: GanttTask, start: Date, end: Date) => void;\n onProgressChange?: (task: GanttTask, progress: number) => void;\n onDependencyCreate?: (dep: GanttDependency) => void;\n onDependencyRemove?: (dep: GanttDependency) => void;\n /** called on double-click of a dependency link, for building your own \"edit this link\" UI (see the handle's updateDependency) */\n onDependencyDblClick?: (dep: GanttDependency) => void;\n onTaskClick?: (task: GanttTask) => void;\n onGroupToggle?: (task: GanttTask, collapsed: boolean) => void;\n onContextMenu?: (task: GanttTask, evt: PointerEvent) => void;\n /** called when a task is created via drag-to-create on an empty timeline row */\n onTaskCreate?: (task: GanttTask) => void;\n /** called when a grid column is resized by dragging its header's edge */\n onColumnResize?: (columnId: string, width: number) => void;\n /** called when grid columns are reordered by dragging a header; `order` is the new full list of column ids */\n onColumnReorder?: (order: string[]) => void;\n /** called when a grid row is dragged onto another; \"inside\" reparents the dragged task under the target */\n onTaskReorder?: (draggedTaskId: string, targetTaskId: string, position: \"before\" | \"after\" | \"inside\") => void;\n onSelectionChange?: (taskIds: string[]) => void;\n\n /** Applied to the wrapping container div. */\n className?: string;\n style?: CSSProperties;\n}\n\n/** Imperative escape hatches that don't need to be reactive props. */\nexport interface GanttChartHandle {\n undo(): void;\n redo(): void;\n canUndo(): boolean;\n canRedo(): boolean;\n expandAll(): void;\n collapseAll(): void;\n toggleGroup(taskId: string): void;\n removeDependency(fromId: string, toId: string): void;\n updateDependency(fromId: string, toId: string, partial: Partial<GanttDependency>): void;\n updateTask(id: string, partial: Partial<GanttTask>): void;\n setViewMode(mode: ViewMode): void;\n fitToViewport(containerWidthPx: number): void;\n scrollToToday(): void;\n scrollToRangeStart(): void;\n scrollToRangeEnd(): void;\n getPageCount(): number;\n setPage(page: number): void;\n zoomIn(factor?: number): void;\n zoomOut(factor?: number): void;\n getZoomLevel(): number;\n getResourceHistogram(options?: ResourceHistogramOptions): ResourceLoadBucket[];\n getLeveledTasks(options?: ResourceLevelingOptions): ResourceLevelingResult;\n selectTask(id: string, options?: { additive?: boolean }): void;\n selectAllVisible(): void;\n clearSelection(): void;\n getSelectedTaskIds(): string[];\n bulkShiftDates(deltaMs: number): void;\n bulkDelete(): void;\n toSVGString(): string;\n toPNGDataURL(): Promise<string>;\n toPNGDataURLs(options?: { pageWidthPx?: number; pageHeightPx?: number }): Promise<string[]>;\n getRenderModel(): GanttRenderModel | null;\n /** Direct access to the underlying framework-agnostic core instance (null before mount). */\n getInstance(): GanttCore | null;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\n\nconst EMPTY_RENDER_MODEL: GanttRenderModel = {\n width: 0,\n height: 0,\n rowHeight: 0,\n headerHeight: 0,\n rows: [],\n bars: [],\n links: [],\n ticks: [],\n columns: [],\n theme: {} as GanttTheme,\n markers: [],\n rangeStart: new Date(0),\n};\n\nfunction GanttChartInner(props: GanttChartProps, ref: Ref<GanttChartHandle>) {\n const {\n tasks,\n dependencies = EMPTY_DEPENDENCIES,\n className,\n style,\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n ...rest\n } = props;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n // The core only wires up its internal contextmenu DOM listener (and therefore only\n // ever emits the \"context-menu\" event) when options.onContextMenu is truthy AT\n // CONSTRUCTION TIME (see GanttChart#setupDom in gantt-core). We pass a stable no-op\n // here purely to force that wiring on regardless of whether the consumer supplied\n // onContextMenu, and dispatch the actual prop via the \"context-menu\" event\n // subscription below (so it stays reactive to prop changes and is never double-fired).\n const enableContextMenuWiring = useRef(() => {});\n\n // Same construction-time-only caveat as onContextMenu above: drag-to-create is only\n // wired into the core's InteractionController when options.onTaskCreate is truthy at\n // construction. A stable no-op forces it on whenever this component was given an\n // onTaskCreate prop at all; the real dispatch goes through the \"task-create\" event.\n const enableCreateWiring = useRef(() => {});\n\n // Same construction-time-only caveat: column resize/reorder DOM listeners are only\n // built into the grid header when these options are truthy at construction.\n const enableColumnResizeWiring = useRef((_columnId: string, _width: number) => {});\n const enableColumnReorderWiring = useRef((_order: string[]) => {});\n const enableTaskReorderWiring = useRef(\n (_draggedTaskId: string, _targetTaskId: string, _position: \"before\" | \"after\" | \"inside\") => {}\n );\n const enableDependencyDblClickWiring = useRef((_dep: GanttDependency) => {});\n\n const options = useMemo<GanttOptions>(\n () => ({\n ...rest,\n onContextMenu: enableContextMenuWiring.current,\n onTaskCreate: onTaskCreate ? enableCreateWiring.current : undefined,\n onColumnResize: onColumnResize ? enableColumnResizeWiring.current : undefined,\n onColumnReorder: onColumnReorder ? enableColumnReorderWiring.current : undefined,\n onTaskReorder: onTaskReorder ? enableTaskReorderWiring.current : undefined,\n onDependencyDblClick: onDependencyDblClick ? enableDependencyDblClickWiring.current : undefined,\n onSelectionChange,\n }),\n [\n rest.viewMode,\n rest.columns,\n rest.theme,\n rest.colorScheme,\n rest.columnWidth,\n rest.readonly,\n rest.showProgress,\n rest.showDependencies,\n rest.gridPanelWidth,\n rest.showCriticalPath,\n rest.showBaseline,\n rest.showDeadlines,\n rest.showAssigneeAvatars,\n rest.enableHistory,\n rest.keyboardAccessible,\n rest.virtualScroll,\n rest.autoSchedule,\n rest.pagination,\n rest.snapToUnit,\n rest.calendar,\n rest.markers,\n rest.autoRollupProgress,\n rest.selectable,\n Boolean(onTaskCreate),\n Boolean(onColumnResize),\n Boolean(onColumnReorder),\n Boolean(onTaskReorder),\n Boolean(onDependencyDblClick),\n onSelectionChange,\n ]\n );\n\n const { chart } = useGanttChart(containerRef, tasks, dependencies, options);\n\n // Keep the latest callback props in a ref so the event-subscription effect below\n // doesn't need to re-subscribe (tearing down/rebuilding listeners) on every render.\n const callbacksRef = useRef({\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n });\n callbacksRef.current = {\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n };\n\n useEffect(() => {\n if (!chart) return undefined;\n\n const handleDateChange = (p: { task: GanttTask; start: Date; end: Date }) =>\n callbacksRef.current.onDateChange?.(p.task, p.start, p.end);\n const handleProgressChange = (p: { task: GanttTask; progress: number }) =>\n callbacksRef.current.onProgressChange?.(p.task, p.progress);\n const handleDependencyCreate = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyCreate?.(dep);\n const handleDependencyRemove = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyRemove?.(dep);\n const handleTaskClick = (p: { task: GanttTask }) =>\n callbacksRef.current.onTaskClick?.(p.task);\n const handleGroupToggle = (p: { task: GanttTask; collapsed: boolean }) =>\n callbacksRef.current.onGroupToggle?.(p.task, p.collapsed);\n const handleContextMenu = (p: { task: GanttTask; evt: PointerEvent }) =>\n callbacksRef.current.onContextMenu?.(p.task, p.evt);\n const handleTaskCreate = (p: { task: GanttTask }) => callbacksRef.current.onTaskCreate?.(p.task);\n const handleColumnResize = (p: { columnId: string; width: number }) =>\n callbacksRef.current.onColumnResize?.(p.columnId, p.width);\n const handleColumnReorder = (p: { order: string[] }) =>\n callbacksRef.current.onColumnReorder?.(p.order);\n const handleDependencyDblClick = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyDblClick?.(dep);\n const handleTaskReorder = (p: {\n draggedTaskId: string;\n targetTaskId: string;\n position: \"before\" | \"after\" | \"inside\";\n }) => callbacksRef.current.onTaskReorder?.(p.draggedTaskId, p.targetTaskId, p.position);\n const handleSelectionChange = (p: { taskIds: string[] }) =>\n callbacksRef.current.onSelectionChange?.(p.taskIds);\n\n chart.on(\"date-change\", handleDateChange);\n chart.on(\"progress-change\", handleProgressChange);\n chart.on(\"dependency-create\", handleDependencyCreate);\n chart.on(\"dependency-remove\", handleDependencyRemove);\n chart.on(\"dependency-dblclick\", handleDependencyDblClick);\n chart.on(\"task-click\", handleTaskClick);\n chart.on(\"group-toggle\", handleGroupToggle);\n chart.on(\"context-menu\", handleContextMenu);\n chart.on(\"task-create\", handleTaskCreate);\n chart.on(\"column-resize\", handleColumnResize);\n chart.on(\"column-reorder\", handleColumnReorder);\n chart.on(\"task-reorder\", handleTaskReorder);\n chart.on(\"selection-change\", handleSelectionChange);\n\n return () => {\n chart.off(\"date-change\", handleDateChange);\n chart.off(\"progress-change\", handleProgressChange);\n chart.off(\"dependency-create\", handleDependencyCreate);\n chart.off(\"dependency-remove\", handleDependencyRemove);\n chart.off(\"dependency-dblclick\", handleDependencyDblClick);\n chart.off(\"task-click\", handleTaskClick);\n chart.off(\"group-toggle\", handleGroupToggle);\n chart.off(\"context-menu\", handleContextMenu);\n chart.off(\"task-create\", handleTaskCreate);\n chart.off(\"column-resize\", handleColumnResize);\n chart.off(\"column-reorder\", handleColumnReorder);\n chart.off(\"task-reorder\", handleTaskReorder);\n chart.off(\"selection-change\", handleSelectionChange);\n };\n }, [chart]);\n\n useImperativeHandle(\n ref,\n (): GanttChartHandle => ({\n undo: () => chart?.undo(),\n redo: () => chart?.redo(),\n canUndo: () => chart?.canUndo ?? false,\n canRedo: () => chart?.canRedo ?? false,\n expandAll: () => chart?.expandAll(),\n collapseAll: () => chart?.collapseAll(),\n toggleGroup: (taskId: string) => chart?.toggleGroup(taskId),\n removeDependency: (fromId: string, toId: string) => chart?.removeDependency(fromId, toId),\n updateDependency: (fromId: string, toId: string, partial: Partial<GanttDependency>) =>\n chart?.updateDependency(fromId, toId, partial),\n updateTask: (id: string, partial: Partial<GanttTask>) => chart?.updateTask(id, partial),\n setViewMode: (mode: ViewMode) => chart?.setViewMode(mode),\n fitToViewport: (containerWidthPx: number) => chart?.fitToViewport(containerWidthPx),\n scrollToToday: () => chart?.scrollToToday(),\n scrollToRangeStart: () => chart?.scrollToRangeStart(),\n scrollToRangeEnd: () => chart?.scrollToRangeEnd(),\n getPageCount: () => chart?.getPageCount() ?? 1,\n setPage: (page: number) => chart?.setPage(page),\n zoomIn: (factor?: number) => chart?.zoomIn(factor),\n zoomOut: (factor?: number) => chart?.zoomOut(factor),\n getZoomLevel: () => chart?.getZoomLevel() ?? 0,\n getResourceHistogram: (options?: ResourceHistogramOptions) =>\n chart?.getResourceHistogram(options) ?? [],\n getLeveledTasks: (options?: ResourceLevelingOptions) =>\n chart?.getLeveledTasks(options) ?? { tasks: [], shifted: [] },\n selectTask: (id: string, options?: { additive?: boolean }) => chart?.selectTask(id, options),\n selectAllVisible: () => chart?.selectAllVisible(),\n clearSelection: () => chart?.clearSelection(),\n getSelectedTaskIds: () => chart?.getSelectedTaskIds() ?? [],\n bulkShiftDates: (deltaMs: number) => chart?.bulkShiftDates(deltaMs),\n bulkDelete: () => chart?.bulkDelete(),\n toSVGString: () => chart?.toSVGString() ?? \"\",\n toPNGDataURL: () => chart?.toPNGDataURL() ?? Promise.resolve(\"\"),\n toPNGDataURLs: (options?: { pageWidthPx?: number; pageHeightPx?: number }) =>\n chart?.toPNGDataURLs(options) ?? Promise.resolve([]),\n getRenderModel: () => chart?.getRenderModel() ?? EMPTY_RENDER_MODEL,\n getInstance: () => chart,\n }),\n [chart]\n );\n\n return <div ref={containerRef} className={className} style={style} />;\n}\n\nexport const GanttChart = forwardRef(GanttChartInner);\nGanttChart.displayName = \"GanttChart\";\n\nexport default GanttChart;\n","import { useEffect, useRef, useState, type RefObject } from \"react\";\nimport { GanttChart as GanttCore } from \"@ganttloom/gantt-core\";\nimport type { GanttDependency, GanttOptions, GanttTask } from \"@ganttloom/gantt-core\";\n\nexport interface UseGanttChartResult {\n /** The underlying framework-agnostic GanttChart instance, or null before the DOM mount effect runs (or on the server). */\n chart: GanttCore | null;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canUndo: boolean;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canRedo: boolean;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\nconst EMPTY_OPTIONS: GanttOptions = {};\n\n/**\n * Lower-level escape hatch for consumers who want to own their own container element\n * and DOM tree instead of using the <GanttChart /> component. Constructs a\n * @ganttloom/gantt-core GanttChart instance against `containerRef.current` on mount,\n * keeps it in sync with `tasks` / `dependencies` / `options` via setTasks / setDependencies /\n * setOptions (reference-equality checks only — pass new arrays/objects to trigger a sync),\n * and destroys it on unmount.\n */\nexport function useGanttChart(\n containerRef: RefObject<HTMLElement | null>,\n tasks: GanttTask[],\n dependencies: GanttDependency[] = EMPTY_DEPENDENCIES,\n options: GanttOptions = EMPTY_OPTIONS\n): UseGanttChartResult {\n const [chart, setChart] = useState<GanttCore | null>(null);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n const chartRef = useRef<GanttCore | null>(null);\n\n // Latest props, read from the mount effect so it doesn't need to depend on them\n // (which would otherwise tear down and recreate the whole chart on every change).\n const initialTasksRef = useRef(tasks);\n initialTasksRef.current = tasks;\n const initialDepsRef = useRef(dependencies);\n initialDepsRef.current = dependencies;\n const initialOptionsRef = useRef(options);\n initialOptionsRef.current = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\") return undefined;\n const container = containerRef.current;\n if (!container) return undefined;\n\n const instance = new GanttCore(\n container,\n initialTasksRef.current,\n initialDepsRef.current,\n initialOptionsRef.current\n );\n chartRef.current = instance;\n setChart(instance);\n setCanUndo(instance.canUndo);\n setCanRedo(instance.canRedo);\n\n const onHistoryChange = (state: { canUndo: boolean; canRedo: boolean }) => {\n setCanUndo(state.canUndo);\n setCanRedo(state.canRedo);\n };\n instance.on(\"history-change\", onHistoryChange);\n\n return () => {\n instance.off(\"history-change\", onHistoryChange);\n instance.destroy();\n chartRef.current = null;\n setChart(null);\n setCanUndo(false);\n setCanRedo(false);\n };\n // Intentionally mount/unmount only — the container element identity is what matters.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [containerRef]);\n\n const isFirstTasksSync = useRef(true);\n useEffect(() => {\n if (isFirstTasksSync.current) {\n isFirstTasksSync.current = false;\n return;\n }\n chartRef.current?.setTasks(tasks);\n }, [tasks]);\n\n const isFirstDepsSync = useRef(true);\n useEffect(() => {\n if (isFirstDepsSync.current) {\n isFirstDepsSync.current = false;\n return;\n }\n chartRef.current?.setDependencies(dependencies);\n }, [dependencies]);\n\n const isFirstOptionsSync = useRef(true);\n useEffect(() => {\n if (isFirstOptionsSync.current) {\n isFirstOptionsSync.current = false;\n return;\n }\n chartRef.current?.setOptions(options);\n }, [options]);\n\n return { chart, canUndo, canRedo };\n}\n","export { GanttChart, default } from \"./GanttChart\";\nexport type { GanttChartProps, GanttChartHandle } from \"./GanttChart\";\n\nexport { useGanttChart } from \"./useGanttChart\";\nexport type { UseGanttChartResult } from \"./useGanttChart\";\n\n// Re-exported so consumers never need to add @ganttloom/gantt-core as a direct\n// dependency just to reference its types.\nexport type {\n ViewMode,\n DependencyType,\n GanttDependency,\n GanttAssignee,\n GanttTask,\n GanttColumn,\n GanttTheme,\n GanttRenderRow,\n GanttRenderBar,\n GanttRenderLink,\n GanttRenderTick,\n GanttRenderModel,\n GanttOptions,\n GanttEventMap,\n WorkingCalendar,\n ConstraintType,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n GanttMarker,\n GanttRenderMarker,\n FilterTasksOptions,\n FilterTasksResult,\n Density,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n} from \"@ganttloom/gantt-core\";\n\nexport {\n computeWBSCodes,\n applyConstraint,\n isWorkingDay,\n isHoliday,\n isWithinWorkingHours,\n isWorkingTime,\n nextWorkingDay,\n previousWorkingDay,\n shiftToWorkingDay,\n shiftToWorkingTime,\n computeResourceHistogram,\n renderResourceHistogramSVG,\n filterTasks,\n colorByField,\n applyColorByField,\n DEFAULT_PALETTE,\n DENSITY_PRESETS,\n levelResources,\n} from \"@ganttloom/gantt-core\";\n"],"mappings":";AAIA,OAAO;AAEP;AAAA,EACE;AAAA,EACA,aAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,OAGK;;;ACdP,SAAS,WAAW,QAAQ,gBAAgC;AAC5D,SAAS,cAAc,iBAAiB;AAYxC,IAAM,qBAAwC,CAAC;AAC/C,IAAM,gBAA8B,CAAC;AAU9B,SAAS,cACd,cACA,OACA,eAAkC,oBAClC,UAAwB,eACH;AACrB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA2B,IAAI;AACzD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AAC,CAAC;AAAA,MACrD,gBAAgB,MAAM,OAAO,eAAe,KAAK;AAAA,MACjD,aAAa,MAAM;AAAA,IACrB;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AAEA,SAAO,oBAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACrE;AAEO,IAAM,aAAa,WAAW,eAAe;AACpD,WAAW,cAAc;AAEzB,IAAO,qBAAQ;;;AE7Vf;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["useEffect","useRef","EMPTY_DEPENDENCIES","useRef","useEffect","options"]}
1
+ {"version":3,"sources":["../src/GanttChart.tsx","../src/useGanttChart.ts","../src/index.ts"],"sourcesContent":["// Pulls in the core's default styles so consumers get a working chart out of the box.\n// This resolves through gantt-core's package.json \"exports\" map (\"./styles.css\" -> \"./dist/styles.css\").\n// If your bundler can't resolve CSS imports from a dependency's export map, import it yourself instead:\n// import \"@ganttloom/gantt-core/styles.css\";\nimport \"@ganttloom/gantt-core/styles.css\";\n\nimport {\n forwardRef,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n type CSSProperties,\n type Ref,\n} from \"react\";\nimport type {\n GanttChart as GanttCore,\n GanttColumn,\n GanttDependency,\n GanttMarker,\n GanttOptions,\n GanttRenderModel,\n GanttTask,\n GanttTheme,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n ViewMode,\n WorkingCalendar,\n} from \"@ganttloom/gantt-core\";\nimport { useGanttChart } from \"./useGanttChart\";\n\nexport interface GanttChartProps {\n tasks: GanttTask[];\n dependencies?: GanttDependency[];\n\n // Mirrors of GanttOptions' non-callback fields.\n viewMode?: ViewMode;\n columns?: GanttColumn[];\n theme?: Partial<GanttTheme>;\n colorScheme?: \"light\" | \"dark\" | \"auto\";\n columnWidth?: number;\n readonly?: boolean;\n showProgress?: boolean;\n showDependencies?: boolean;\n gridPanelWidth?: number;\n showCriticalPath?: boolean;\n showBaseline?: boolean;\n showDeadlines?: boolean;\n /** hover tooltip on task bars, defaults to true. A floating, CSS-customizable element (`.gantt-tooltip`) - not the browser's native title tooltip. */\n showTooltip?: boolean;\n /** fully control tooltip content/markup; return null/undefined to suppress it for a specific task. Defaults to name/dates/progress/assignees/notes. */\n renderTooltip?: (task: GanttTask) => HTMLElement | string | null | undefined;\n showAssigneeAvatars?: boolean;\n enableHistory?: boolean;\n keyboardAccessible?: boolean;\n virtualScroll?: boolean;\n autoSchedule?: boolean;\n pagination?: { pageSize: number; page: number };\n snapToUnit?: \"hour\" | \"day\" | \"week\" | false;\n /** working-day/holiday definition used to shade non-working time and (with autoSchedule) skip it when cascading */\n calendar?: WorkingCalendar;\n /** arbitrary labeled vertical lines on the timeline, independent of any task */\n markers?: GanttMarker[];\n /** a group task with no explicit `progress` gets a duration-weighted average of its children's progress instead of 0 */\n autoRollupProgress?: boolean;\n /** enables click/ctrl-click/shift-click multi-selection of task bars, and the handle's bulkShiftDates()/bulkDelete() */\n selectable?: boolean;\n /**\n * Stretch (never shrink) the timeline to fill the container's width instead of leaving empty\n * space - the common \"short project at month/year zoom\" or \"just a few tasks\" case. Off by\n * default (a new chart's pixel layout shouldn't change for existing consumers who don't opt in).\n */\n autoFitToViewport?: boolean;\n\n // Mirrors of GanttOptions' callback fields, as normal React event props.\n onDateChange?: (task: GanttTask, start: Date, end: Date) => void;\n onProgressChange?: (task: GanttTask, progress: number) => void;\n onDependencyCreate?: (dep: GanttDependency) => void;\n onDependencyRemove?: (dep: GanttDependency) => void;\n /** called on double-click of a dependency link, for building your own \"edit this link\" UI (see the handle's updateDependency) */\n onDependencyDblClick?: (dep: GanttDependency) => void;\n onTaskClick?: (task: GanttTask) => void;\n /** called on double-click of a task bar (distinct from onDependencyDblClick, which is for links) */\n onTaskDblClick?: (task: GanttTask) => void;\n onGroupToggle?: (task: GanttTask, collapsed: boolean) => void;\n onContextMenu?: (task: GanttTask, evt: PointerEvent) => void;\n /** called when a task is created via drag-to-create on an empty timeline row */\n onTaskCreate?: (task: GanttTask) => void;\n /** called when a grid column is resized by dragging its header's edge */\n onColumnResize?: (columnId: string, width: number) => void;\n /** called when grid columns are reordered by dragging a header; `order` is the new full list of column ids */\n onColumnReorder?: (order: string[]) => void;\n /** called when a grid row is dragged onto another; \"inside\" reparents the dragged task under the target */\n onTaskReorder?: (draggedTaskId: string, targetTaskId: string, position: \"before\" | \"after\" | \"inside\") => void;\n onSelectionChange?: (taskIds: string[]) => void;\n /** fired whenever the sort state changes, via a sortable column header click or the handle's setSort() */\n onSortChange?: (sort: { columnId: string; direction: \"asc\" | \"desc\" } | null) => void;\n\n /** Applied to the wrapping container div. */\n className?: string;\n style?: CSSProperties;\n}\n\n/** Imperative escape hatches that don't need to be reactive props. */\nexport interface GanttChartHandle {\n undo(): void;\n redo(): void;\n canUndo(): boolean;\n canRedo(): boolean;\n expandAll(): void;\n collapseAll(): void;\n toggleGroup(taskId: string): void;\n removeDependency(fromId: string, toId: string): void;\n updateDependency(fromId: string, toId: string, partial: Partial<GanttDependency>): void;\n updateTask(id: string, partial: Partial<GanttTask>): void;\n setViewMode(mode: ViewMode): void;\n fitToViewport(containerWidthPx: number): void;\n scrollToToday(): void;\n scrollToRangeStart(): void;\n scrollToRangeEnd(): void;\n getPageCount(): number;\n setPage(page: number): void;\n zoomIn(factor?: number): void;\n zoomOut(factor?: number): void;\n getZoomLevel(): number;\n getResourceHistogram(options?: ResourceHistogramOptions): ResourceLoadBucket[];\n getLeveledTasks(options?: ResourceLevelingOptions): ResourceLevelingResult;\n selectTask(id: string, options?: { additive?: boolean }): void;\n selectAllVisible(): void;\n clearSelection(): void;\n getSelectedTaskIds(): string[];\n setSort(columnId: string | null, direction?: \"asc\" | \"desc\" | null): void;\n getSort(): { columnId: string; direction: \"asc\" | \"desc\" } | null;\n bulkShiftDates(deltaMs: number): void;\n bulkDelete(): void;\n toSVGString(): string;\n toPNGDataURL(): Promise<string>;\n toPNGDataURLs(options?: { pageWidthPx?: number; pageHeightPx?: number }): Promise<string[]>;\n getRenderModel(): GanttRenderModel | null;\n /** Direct access to the underlying framework-agnostic core instance (null before mount). */\n getInstance(): GanttCore | null;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\n\nconst EMPTY_RENDER_MODEL: GanttRenderModel = {\n width: 0,\n height: 0,\n rowHeight: 0,\n headerHeight: 0,\n rows: [],\n bars: [],\n links: [],\n ticks: [],\n columns: [],\n theme: {} as GanttTheme,\n markers: [],\n rangeStart: new Date(0),\n sort: null,\n};\n\nfunction GanttChartInner(props: GanttChartProps, ref: Ref<GanttChartHandle>) {\n const {\n tasks,\n dependencies = EMPTY_DEPENDENCIES,\n className,\n style,\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onTaskDblClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n onSortChange,\n ...rest\n } = props;\n\n const containerRef = useRef<HTMLDivElement | null>(null);\n\n // The core only wires up its internal contextmenu DOM listener (and therefore only\n // ever emits the \"context-menu\" event) when options.onContextMenu is truthy AT\n // CONSTRUCTION TIME (see GanttChart#setupDom in gantt-core). We pass a stable no-op\n // here purely to force that wiring on regardless of whether the consumer supplied\n // onContextMenu, and dispatch the actual prop via the \"context-menu\" event\n // subscription below (so it stays reactive to prop changes and is never double-fired).\n const enableContextMenuWiring = useRef(() => {});\n\n // Same construction-time-only caveat as onContextMenu above: drag-to-create is only\n // wired into the core's InteractionController when options.onTaskCreate is truthy at\n // construction. A stable no-op forces it on whenever this component was given an\n // onTaskCreate prop at all; the real dispatch goes through the \"task-create\" event.\n const enableCreateWiring = useRef(() => {});\n\n // Same construction-time-only caveat: column resize/reorder DOM listeners are only\n // built into the grid header when these options are truthy at construction.\n const enableColumnResizeWiring = useRef((_columnId: string, _width: number) => {});\n const enableColumnReorderWiring = useRef((_order: string[]) => {});\n const enableTaskReorderWiring = useRef(\n (_draggedTaskId: string, _targetTaskId: string, _position: \"before\" | \"after\" | \"inside\") => {}\n );\n const enableDependencyDblClickWiring = useRef((_dep: GanttDependency) => {});\n const enableTaskDblClickWiring = useRef((_task: GanttTask) => {});\n\n // Deliberately depend on Boolean(handler) rather than the handler itself below: the\n // ref-backed enableXWiring callbacks already pick up the latest handler without\n // needing the memo to re-run, so depending on the raw (often inline) callback would\n // just re-create `options` — and remount the chart — every render.\n /* eslint-disable react-hooks/exhaustive-deps */\n const options = useMemo<GanttOptions>(\n () => ({\n ...rest,\n onContextMenu: enableContextMenuWiring.current,\n onTaskCreate: onTaskCreate ? enableCreateWiring.current : undefined,\n onColumnResize: onColumnResize ? enableColumnResizeWiring.current : undefined,\n onColumnReorder: onColumnReorder ? enableColumnReorderWiring.current : undefined,\n onTaskReorder: onTaskReorder ? enableTaskReorderWiring.current : undefined,\n onDependencyDblClick: onDependencyDblClick ? enableDependencyDblClickWiring.current : undefined,\n onTaskDblClick: onTaskDblClick ? enableTaskDblClickWiring.current : undefined,\n // onSelectionChange/onSortChange are deliberately NOT set here: gantt-core invokes them\n // directly from this.options AND emits a matching event at the same call sites, and the\n // effect below already subscribes to those events — including them here would double-fire.\n }),\n [\n rest.viewMode,\n rest.columns,\n rest.theme,\n rest.colorScheme,\n rest.columnWidth,\n rest.readonly,\n rest.showProgress,\n rest.showDependencies,\n rest.gridPanelWidth,\n rest.showCriticalPath,\n rest.showBaseline,\n rest.showDeadlines,\n rest.showTooltip,\n rest.renderTooltip,\n rest.autoFitToViewport,\n rest.showAssigneeAvatars,\n rest.enableHistory,\n rest.keyboardAccessible,\n rest.virtualScroll,\n rest.autoSchedule,\n rest.pagination,\n rest.snapToUnit,\n rest.calendar,\n rest.markers,\n rest.autoRollupProgress,\n rest.selectable,\n Boolean(onTaskCreate),\n Boolean(onColumnResize),\n Boolean(onColumnReorder),\n Boolean(onTaskReorder),\n Boolean(onDependencyDblClick),\n Boolean(onTaskDblClick),\n ]\n );\n /* eslint-enable react-hooks/exhaustive-deps */\n\n const { chart } = useGanttChart(containerRef, tasks, dependencies, options);\n\n // Keep the latest callback props in a ref so the event-subscription effect below\n // doesn't need to re-subscribe (tearing down/rebuilding listeners) on every render.\n const callbacksRef = useRef({\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onTaskDblClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n onSortChange,\n });\n callbacksRef.current = {\n onDateChange,\n onProgressChange,\n onDependencyCreate,\n onDependencyRemove,\n onDependencyDblClick,\n onTaskClick,\n onTaskDblClick,\n onGroupToggle,\n onContextMenu,\n onTaskCreate,\n onColumnResize,\n onColumnReorder,\n onTaskReorder,\n onSelectionChange,\n onSortChange,\n };\n\n useEffect(() => {\n if (!chart) return undefined;\n\n const handleDateChange = (p: { task: GanttTask; start: Date; end: Date }) =>\n callbacksRef.current.onDateChange?.(p.task, p.start, p.end);\n const handleProgressChange = (p: { task: GanttTask; progress: number }) =>\n callbacksRef.current.onProgressChange?.(p.task, p.progress);\n const handleDependencyCreate = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyCreate?.(dep);\n const handleDependencyRemove = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyRemove?.(dep);\n const handleTaskClick = (p: { task: GanttTask }) =>\n callbacksRef.current.onTaskClick?.(p.task);\n const handleTaskDblClick = (p: { task: GanttTask }) =>\n callbacksRef.current.onTaskDblClick?.(p.task);\n const handleGroupToggle = (p: { task: GanttTask; collapsed: boolean }) =>\n callbacksRef.current.onGroupToggle?.(p.task, p.collapsed);\n const handleContextMenu = (p: { task: GanttTask; evt: PointerEvent }) =>\n callbacksRef.current.onContextMenu?.(p.task, p.evt);\n const handleTaskCreate = (p: { task: GanttTask }) => callbacksRef.current.onTaskCreate?.(p.task);\n const handleColumnResize = (p: { columnId: string; width: number }) =>\n callbacksRef.current.onColumnResize?.(p.columnId, p.width);\n const handleColumnReorder = (p: { order: string[] }) =>\n callbacksRef.current.onColumnReorder?.(p.order);\n const handleDependencyDblClick = (dep: GanttDependency) =>\n callbacksRef.current.onDependencyDblClick?.(dep);\n const handleTaskReorder = (p: {\n draggedTaskId: string;\n targetTaskId: string;\n position: \"before\" | \"after\" | \"inside\";\n }) => callbacksRef.current.onTaskReorder?.(p.draggedTaskId, p.targetTaskId, p.position);\n const handleSelectionChange = (p: { taskIds: string[] }) =>\n callbacksRef.current.onSelectionChange?.(p.taskIds);\n const handleSortChange = (p: { sort: { columnId: string; direction: \"asc\" | \"desc\" } | null }) =>\n callbacksRef.current.onSortChange?.(p.sort);\n\n chart.on(\"date-change\", handleDateChange);\n chart.on(\"progress-change\", handleProgressChange);\n chart.on(\"dependency-create\", handleDependencyCreate);\n chart.on(\"dependency-remove\", handleDependencyRemove);\n chart.on(\"dependency-dblclick\", handleDependencyDblClick);\n chart.on(\"task-click\", handleTaskClick);\n chart.on(\"task-dblclick\", handleTaskDblClick);\n chart.on(\"group-toggle\", handleGroupToggle);\n chart.on(\"context-menu\", handleContextMenu);\n chart.on(\"task-create\", handleTaskCreate);\n chart.on(\"column-resize\", handleColumnResize);\n chart.on(\"column-reorder\", handleColumnReorder);\n chart.on(\"task-reorder\", handleTaskReorder);\n chart.on(\"selection-change\", handleSelectionChange);\n chart.on(\"sort-change\", handleSortChange);\n\n return () => {\n chart.off(\"date-change\", handleDateChange);\n chart.off(\"progress-change\", handleProgressChange);\n chart.off(\"dependency-create\", handleDependencyCreate);\n chart.off(\"dependency-remove\", handleDependencyRemove);\n chart.off(\"dependency-dblclick\", handleDependencyDblClick);\n chart.off(\"task-click\", handleTaskClick);\n chart.off(\"task-dblclick\", handleTaskDblClick);\n chart.off(\"group-toggle\", handleGroupToggle);\n chart.off(\"context-menu\", handleContextMenu);\n chart.off(\"task-create\", handleTaskCreate);\n chart.off(\"column-resize\", handleColumnResize);\n chart.off(\"column-reorder\", handleColumnReorder);\n chart.off(\"task-reorder\", handleTaskReorder);\n chart.off(\"selection-change\", handleSelectionChange);\n chart.off(\"sort-change\", handleSortChange);\n };\n }, [chart]);\n\n useImperativeHandle(\n ref,\n (): GanttChartHandle => ({\n undo: () => chart?.undo(),\n redo: () => chart?.redo(),\n canUndo: () => chart?.canUndo ?? false,\n canRedo: () => chart?.canRedo ?? false,\n expandAll: () => chart?.expandAll(),\n collapseAll: () => chart?.collapseAll(),\n toggleGroup: (taskId: string) => chart?.toggleGroup(taskId),\n removeDependency: (fromId: string, toId: string) => chart?.removeDependency(fromId, toId),\n updateDependency: (fromId: string, toId: string, partial: Partial<GanttDependency>) =>\n chart?.updateDependency(fromId, toId, partial),\n updateTask: (id: string, partial: Partial<GanttTask>) => chart?.updateTask(id, partial),\n setViewMode: (mode: ViewMode) => chart?.setViewMode(mode),\n fitToViewport: (containerWidthPx: number) => chart?.fitToViewport(containerWidthPx),\n scrollToToday: () => chart?.scrollToToday(),\n scrollToRangeStart: () => chart?.scrollToRangeStart(),\n scrollToRangeEnd: () => chart?.scrollToRangeEnd(),\n getPageCount: () => chart?.getPageCount() ?? 1,\n setPage: (page: number) => chart?.setPage(page),\n zoomIn: (factor?: number) => chart?.zoomIn(factor),\n zoomOut: (factor?: number) => chart?.zoomOut(factor),\n getZoomLevel: () => chart?.getZoomLevel() ?? 0,\n getResourceHistogram: (options?: ResourceHistogramOptions) =>\n chart?.getResourceHistogram(options) ?? [],\n getLeveledTasks: (options?: ResourceLevelingOptions) =>\n chart?.getLeveledTasks(options) ?? { tasks: [], shifted: [] },\n selectTask: (id: string, options?: { additive?: boolean }) => chart?.selectTask(id, options),\n selectAllVisible: () => chart?.selectAllVisible(),\n clearSelection: () => chart?.clearSelection(),\n getSelectedTaskIds: () => chart?.getSelectedTaskIds() ?? [],\n setSort: (columnId: string | null, direction?: \"asc\" | \"desc\" | null) => chart?.setSort(columnId, direction),\n getSort: () => chart?.getSort() ?? null,\n bulkShiftDates: (deltaMs: number) => chart?.bulkShiftDates(deltaMs),\n bulkDelete: () => chart?.bulkDelete(),\n toSVGString: () => chart?.toSVGString() ?? \"\",\n toPNGDataURL: () => chart?.toPNGDataURL() ?? Promise.resolve(\"\"),\n toPNGDataURLs: (options?: { pageWidthPx?: number; pageHeightPx?: number }) =>\n chart?.toPNGDataURLs(options) ?? Promise.resolve([]),\n getRenderModel: () => chart?.getRenderModel() ?? EMPTY_RENDER_MODEL,\n getInstance: () => chart,\n }),\n [chart]\n );\n\n return <div ref={containerRef} className={className} style={style} />;\n}\n\nexport const GanttChart = forwardRef(GanttChartInner);\nGanttChart.displayName = \"GanttChart\";\n\nexport default GanttChart;\n","import { useEffect, useRef, useState, type RefObject } from \"react\";\nimport { GanttChart as GanttCore } from \"@ganttloom/gantt-core\";\nimport type { GanttDependency, GanttOptions, GanttTask } from \"@ganttloom/gantt-core\";\n\nexport interface UseGanttChartResult {\n /** The underlying framework-agnostic GanttChart instance, or null before the DOM mount effect runs (or on the server). */\n chart: GanttCore | null;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canUndo: boolean;\n /** Reactive, subscribed to the core's \"history-change\" event. Only meaningful when `enableHistory` is set in options. */\n canRedo: boolean;\n}\n\nconst EMPTY_DEPENDENCIES: GanttDependency[] = [];\nconst EMPTY_OPTIONS: GanttOptions = {};\n\n/**\n * Lower-level escape hatch for consumers who want to own their own container element\n * and DOM tree instead of using the <GanttChart /> component. Constructs a\n * @ganttloom/gantt-core GanttChart instance against `containerRef.current` on mount,\n * keeps it in sync with `tasks` / `dependencies` / `options` via setTasks / setDependencies /\n * setOptions (reference-equality checks only — pass new arrays/objects to trigger a sync),\n * and destroys it on unmount.\n */\nexport function useGanttChart(\n containerRef: RefObject<HTMLElement | null>,\n tasks: GanttTask[],\n dependencies: GanttDependency[] = EMPTY_DEPENDENCIES,\n options: GanttOptions = EMPTY_OPTIONS\n): UseGanttChartResult {\n const [chart, setChart] = useState<GanttCore | null>(null);\n const [canUndo, setCanUndo] = useState(false);\n const [canRedo, setCanRedo] = useState(false);\n\n const chartRef = useRef<GanttCore | null>(null);\n\n // Latest props, read from the mount effect so it doesn't need to depend on them\n // (which would otherwise tear down and recreate the whole chart on every change).\n const initialTasksRef = useRef(tasks);\n initialTasksRef.current = tasks;\n const initialDepsRef = useRef(dependencies);\n initialDepsRef.current = dependencies;\n const initialOptionsRef = useRef(options);\n initialOptionsRef.current = options;\n\n useEffect(() => {\n if (typeof window === \"undefined\") return undefined;\n const container = containerRef.current;\n if (!container) return undefined;\n\n const instance = new GanttCore(\n container,\n initialTasksRef.current,\n initialDepsRef.current,\n initialOptionsRef.current\n );\n chartRef.current = instance;\n setChart(instance);\n setCanUndo(instance.canUndo);\n setCanRedo(instance.canRedo);\n\n const onHistoryChange = (state: { canUndo: boolean; canRedo: boolean }) => {\n setCanUndo(state.canUndo);\n setCanRedo(state.canRedo);\n };\n instance.on(\"history-change\", onHistoryChange);\n\n return () => {\n instance.off(\"history-change\", onHistoryChange);\n instance.destroy();\n chartRef.current = null;\n setChart(null);\n setCanUndo(false);\n setCanRedo(false);\n };\n // Intentionally mount/unmount only — the container element identity is what matters.\n }, [containerRef]);\n\n const isFirstTasksSync = useRef(true);\n useEffect(() => {\n if (isFirstTasksSync.current) {\n isFirstTasksSync.current = false;\n return;\n }\n chartRef.current?.setTasks(tasks);\n }, [tasks]);\n\n const isFirstDepsSync = useRef(true);\n useEffect(() => {\n if (isFirstDepsSync.current) {\n isFirstDepsSync.current = false;\n return;\n }\n chartRef.current?.setDependencies(dependencies);\n }, [dependencies]);\n\n const isFirstOptionsSync = useRef(true);\n useEffect(() => {\n if (isFirstOptionsSync.current) {\n isFirstOptionsSync.current = false;\n return;\n }\n chartRef.current?.setOptions(options);\n }, [options]);\n\n return { chart, canUndo, canRedo };\n}\n","export { GanttChart, default } from \"./GanttChart\";\nexport type { GanttChartProps, GanttChartHandle } from \"./GanttChart\";\n\nexport { useGanttChart } from \"./useGanttChart\";\nexport type { UseGanttChartResult } from \"./useGanttChart\";\n\n// Re-exported so consumers never need to add @ganttloom/gantt-core as a direct\n// dependency just to reference its types.\nexport type {\n ViewMode,\n DependencyType,\n GanttDependency,\n GanttAssignee,\n GanttTask,\n GanttColumn,\n GanttTheme,\n GanttRenderRow,\n GanttRenderBar,\n GanttRenderLink,\n GanttRenderTick,\n GanttRenderModel,\n GanttOptions,\n GanttEventMap,\n WorkingCalendar,\n ConstraintType,\n ResourceHistogramOptions,\n ResourceLoadBucket,\n GanttMarker,\n GanttRenderMarker,\n FilterTasksOptions,\n FilterTasksResult,\n Density,\n ResourceLevelingOptions,\n ResourceLevelingResult,\n} from \"@ganttloom/gantt-core\";\n\nexport {\n computeWBSCodes,\n applyConstraint,\n isWorkingDay,\n isHoliday,\n isWithinWorkingHours,\n isWorkingTime,\n nextWorkingDay,\n previousWorkingDay,\n shiftToWorkingDay,\n shiftToWorkingTime,\n computeResourceHistogram,\n renderResourceHistogramSVG,\n filterTasks,\n colorByField,\n applyColorByField,\n DEFAULT_PALETTE,\n DENSITY_PRESETS,\n levelResources,\n} from \"@ganttloom/gantt-core\";\n"],"mappings":";AAIA,OAAO;AAEP;AAAA,EACE;AAAA,EACA,aAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAAC;AAAA,OAGK;;;ACdP,SAAS,WAAW,QAAQ,gBAAgC;AAC5D,SAAS,cAAc,iBAAiB;AAYxC,IAAM,qBAAwC,CAAC;AAC/C,IAAM,gBAA8B,CAAC;AAU9B,SAAS,cACd,cACA,OACA,eAAkC,oBAClC,UAAwB,eACH;AACrB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAA2B,IAAI;AACzD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAC5C,QAAM,C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AAE;AAAA,MAC9D,YAAY,CAAC,IAAYA,aAAqC,OAAO,WAAW,IAAIA,QAAO;AAAA,MAC3F,kBAAkB,MAAM,OAAO,iBAAiB;AAAA,MAChD,gBAAgB,MAAM,OAAO,eAAe;AAAA,MAC5C,oBAAoB,MAAM,OAAO,mBAAmB,KAAK,CAAC;AAAA,MAC1D,SAAS,CAAC,UAAyB,cAAsC,OAAO,QAAQ,UAAU,SAAS;AAAA,MAC3G,SAAS,MAAM,OAAO,QAAQ,KAAK;AAAA,MACnC,gBAAgB,CAAC,YAAoB,OAAO,eAAe,OAAO;AAAA,MAClE,YAAY,MAAM,OAAO,WAAW;AAAA,MACpC,aAAa,MAAM,OAAO,YAAY,KAAK;AAAA,MAC3C,cAAc,MAAM,OAAO,aAAa,KAAK,QAAQ,QAAQ,EAAE;AAAA,MAC/D,eAAe,CAACA,aACd,OAAO,cAAcA,QAAO,KAAK,QAAQ,QAAQ,CAAC,CAAC;AAAA,MACrD,gBAAgB,MAAM,OAAO,eAAe,KAAK;AAAA,MACjD,aAAa,MAAM;AAAA,IACrB;AAAA,IACA,CAAC,KAAK;AAAA,EACR;AAEA,SAAO,oBAAC,SAAI,KAAK,cAAc,WAAsB,OAAc;AACrE;AAEO,IAAM,aAAa,WAAW,eAAe;AACpD,WAAW,cAAc;AAEzB,IAAO,qBAAQ;;;AE3Yf;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;","names":["useEffect","useRef","EMPTY_DEPENDENCIES","useRef","useEffect","options"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ganttloom/gantt-react",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "React wrapper for @ganttloom/gantt-core — fully customizable Gantt chart component.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -40,7 +40,7 @@
40
40
  "react-dom": ">=18"
41
41
  },
42
42
  "dependencies": {
43
- "@ganttloom/gantt-core": "0.2.0"
43
+ "@ganttloom/gantt-core": "0.4.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "react": "^18.3.1",