gantt-lib 0.8.0 → 0.9.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/dist/index.d.mts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -244,6 +244,10 @@ interface GanttChartProps {
|
|
|
244
244
|
onInsertAfter?: (taskId: string, newTask: Task) => void;
|
|
245
245
|
/** Callback when tasks are reordered via drag in the task list */
|
|
246
246
|
onReorder?: (tasks: Task[], movedTaskId?: string, inferredParentId?: string) => void;
|
|
247
|
+
/** Callback when a task is promoted (parentId removed). If not provided, default internal logic is used. */
|
|
248
|
+
onPromoteTask?: (taskId: string) => void;
|
|
249
|
+
/** Callback when a task is demoted (parentId set). If not provided, default internal logic is used. */
|
|
250
|
+
onDemoteTask?: (taskId: string, newParentId: string) => void;
|
|
247
251
|
/** Enable add task button at bottom of task list (default: true) */
|
|
248
252
|
enableAddTask?: boolean;
|
|
249
253
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -244,6 +244,10 @@ interface GanttChartProps {
|
|
|
244
244
|
onInsertAfter?: (taskId: string, newTask: Task) => void;
|
|
245
245
|
/** Callback when tasks are reordered via drag in the task list */
|
|
246
246
|
onReorder?: (tasks: Task[], movedTaskId?: string, inferredParentId?: string) => void;
|
|
247
|
+
/** Callback when a task is promoted (parentId removed). If not provided, default internal logic is used. */
|
|
248
|
+
onPromoteTask?: (taskId: string) => void;
|
|
249
|
+
/** Callback when a task is demoted (parentId set). If not provided, default internal logic is used. */
|
|
250
|
+
onDemoteTask?: (taskId: string, newParentId: string) => void;
|
|
247
251
|
/** Enable add task button at bottom of task list (default: true) */
|
|
248
252
|
enableAddTask?: boolean;
|
|
249
253
|
}
|
package/dist/index.js
CHANGED
|
@@ -3824,6 +3824,8 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
3824
3824
|
onDelete,
|
|
3825
3825
|
onInsertAfter,
|
|
3826
3826
|
onReorder,
|
|
3827
|
+
onPromoteTask,
|
|
3828
|
+
onDemoteTask,
|
|
3827
3829
|
enableAddTask = true
|
|
3828
3830
|
}, ref) => {
|
|
3829
3831
|
const scrollContainerRef = (0, import_react13.useRef)(null);
|
|
@@ -4157,6 +4159,10 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
4157
4159
|
});
|
|
4158
4160
|
}, []);
|
|
4159
4161
|
const handlePromoteTask = (0, import_react13.useCallback)((taskId) => {
|
|
4162
|
+
if (onPromoteTask) {
|
|
4163
|
+
onPromoteTask(taskId);
|
|
4164
|
+
return;
|
|
4165
|
+
}
|
|
4160
4166
|
const taskToPromote = tasks.find((t) => t.id === taskId);
|
|
4161
4167
|
if (!taskToPromote || !taskToPromote.parentId) {
|
|
4162
4168
|
return;
|
|
@@ -4181,8 +4187,12 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
4181
4187
|
...tasks.filter((t) => t.id !== taskId).slice(lastSiblingIndex.index + 1)
|
|
4182
4188
|
]);
|
|
4183
4189
|
onTasksChange?.(reorderedTasks);
|
|
4184
|
-
}, [tasks, onTasksChange]);
|
|
4190
|
+
}, [tasks, onTasksChange, onPromoteTask]);
|
|
4185
4191
|
const handleDemoteTask = (0, import_react13.useCallback)((taskId, newParentId) => {
|
|
4192
|
+
if (onDemoteTask) {
|
|
4193
|
+
onDemoteTask(taskId, newParentId);
|
|
4194
|
+
return;
|
|
4195
|
+
}
|
|
4186
4196
|
const wouldCreateCircular = (targetId, parentId, tasks2) => {
|
|
4187
4197
|
if (targetId === parentId) return true;
|
|
4188
4198
|
const descendants = /* @__PURE__ */ new Set();
|
|
@@ -4214,7 +4224,7 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
4214
4224
|
progress: parentProgress
|
|
4215
4225
|
};
|
|
4216
4226
|
onTasksChange?.([updatedDemotedTask, updatedParentTask]);
|
|
4217
|
-
}, [tasks, onTasksChange]);
|
|
4227
|
+
}, [tasks, onTasksChange, onDemoteTask]);
|
|
4218
4228
|
const panStateRef = (0, import_react13.useRef)(null);
|
|
4219
4229
|
const handlePanStart = (0, import_react13.useCallback)((e) => {
|
|
4220
4230
|
if (e.button !== 0) return;
|
|
@@ -4291,8 +4301,8 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
4291
4301
|
enableAddTask,
|
|
4292
4302
|
collapsedParentIds,
|
|
4293
4303
|
onToggleCollapse: handleToggleCollapse,
|
|
4294
|
-
onPromoteTask: handlePromoteTask,
|
|
4295
|
-
onDemoteTask: handleDemoteTask
|
|
4304
|
+
onPromoteTask: onPromoteTask ?? handlePromoteTask,
|
|
4305
|
+
onDemoteTask: onDemoteTask ?? handleDemoteTask
|
|
4296
4306
|
}
|
|
4297
4307
|
),
|
|
4298
4308
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { style: { minWidth: `${gridWidth}px`, flex: 1 }, children: [
|