gantt-lib 0.24.1 → 0.25.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 +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -573,6 +573,8 @@ interface GanttChartProps {
|
|
|
573
573
|
collapsedParentIds?: Set<string>;
|
|
574
574
|
/** Callback when collapse/expand button is clicked (controlled mode) */
|
|
575
575
|
onToggleCollapse?: (parentId: string) => void;
|
|
576
|
+
/** Task IDs to highlight in the task list (for search results) */
|
|
577
|
+
highlightedTaskIds?: Set<string>;
|
|
576
578
|
}
|
|
577
579
|
/**
|
|
578
580
|
* Ref handle type for GanttChart — exposes imperative scroll methods.
|
|
@@ -580,6 +582,7 @@ interface GanttChartProps {
|
|
|
580
582
|
interface GanttChartHandle {
|
|
581
583
|
scrollToToday: () => void;
|
|
582
584
|
scrollToTask: (taskId: string) => void;
|
|
585
|
+
scrollToRow: (taskId: string) => void;
|
|
583
586
|
collapseAll: () => void;
|
|
584
587
|
expandAll: () => void;
|
|
585
588
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -573,6 +573,8 @@ interface GanttChartProps {
|
|
|
573
573
|
collapsedParentIds?: Set<string>;
|
|
574
574
|
/** Callback when collapse/expand button is clicked (controlled mode) */
|
|
575
575
|
onToggleCollapse?: (parentId: string) => void;
|
|
576
|
+
/** Task IDs to highlight in the task list (for search results) */
|
|
577
|
+
highlightedTaskIds?: Set<string>;
|
|
576
578
|
}
|
|
577
579
|
/**
|
|
578
580
|
* Ref handle type for GanttChart — exposes imperative scroll methods.
|
|
@@ -580,6 +582,7 @@ interface GanttChartProps {
|
|
|
580
582
|
interface GanttChartHandle {
|
|
581
583
|
scrollToToday: () => void;
|
|
582
584
|
scrollToTask: (taskId: string) => void;
|
|
585
|
+
scrollToRow: (taskId: string) => void;
|
|
583
586
|
collapseAll: () => void;
|
|
584
587
|
expandAll: () => void;
|
|
585
588
|
}
|
package/dist/index.js
CHANGED
|
@@ -5916,6 +5916,7 @@ var TaskList = ({
|
|
|
5916
5916
|
|
|
5917
5917
|
// src/components/GanttChart/GanttChart.tsx
|
|
5918
5918
|
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
5919
|
+
var SCROLL_TO_ROW_CONTEXT_ROWS = 2;
|
|
5919
5920
|
var GanttChart = (0, import_react13.forwardRef)(({
|
|
5920
5921
|
tasks,
|
|
5921
5922
|
dayWidth = 40,
|
|
@@ -5945,7 +5946,8 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
5945
5946
|
businessDays = true,
|
|
5946
5947
|
taskFilter,
|
|
5947
5948
|
collapsedParentIds: externalCollapsedParentIds,
|
|
5948
|
-
onToggleCollapse: externalOnToggleCollapse
|
|
5949
|
+
onToggleCollapse: externalOnToggleCollapse,
|
|
5950
|
+
highlightedTaskIds
|
|
5949
5951
|
}, ref) => {
|
|
5950
5952
|
const scrollContainerRef = (0, import_react13.useRef)(null);
|
|
5951
5953
|
const [selectedTaskId, setSelectedTaskId] = (0, import_react13.useState)(null);
|
|
@@ -5982,6 +5984,14 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
5982
5984
|
if (!taskFilter) return /* @__PURE__ */ new Set();
|
|
5983
5985
|
return new Set(visibleTasks.filter(taskFilter).map((task) => task.id));
|
|
5984
5986
|
}, [visibleTasks, taskFilter]);
|
|
5987
|
+
const taskListHighlightedTaskIds = (0, import_react13.useMemo)(() => {
|
|
5988
|
+
if ((!highlightedTaskIds || highlightedTaskIds.size === 0) && matchedTaskIds.size === 0) {
|
|
5989
|
+
return /* @__PURE__ */ new Set();
|
|
5990
|
+
}
|
|
5991
|
+
const mergedHighlightedTaskIds = new Set(highlightedTaskIds ?? []);
|
|
5992
|
+
matchedTaskIds.forEach((taskId) => mergedHighlightedTaskIds.add(taskId));
|
|
5993
|
+
return mergedHighlightedTaskIds;
|
|
5994
|
+
}, [highlightedTaskIds, matchedTaskIds]);
|
|
5985
5995
|
const totalGridHeight = (0, import_react13.useMemo)(
|
|
5986
5996
|
() => visibleTasks.length * rowHeight,
|
|
5987
5997
|
[visibleTasks.length, rowHeight]
|
|
@@ -6051,6 +6061,18 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
6051
6061
|
const scrollLeft = Math.round(taskOffset - dayWidth * 2);
|
|
6052
6062
|
container.scrollTo({ left: Math.max(0, scrollLeft), behavior: "smooth" });
|
|
6053
6063
|
}, [tasks, dateRange, dayWidth]);
|
|
6064
|
+
const scrollToRow = (0, import_react13.useCallback)((taskId) => {
|
|
6065
|
+
const container = scrollContainerRef.current;
|
|
6066
|
+
if (!container) return;
|
|
6067
|
+
const task = tasks.find((t) => t.id === taskId);
|
|
6068
|
+
if (!task) return;
|
|
6069
|
+
const rowIndex = visibleTasks.findIndex((visibleTask) => visibleTask.id === task.id);
|
|
6070
|
+
if (rowIndex === -1) return;
|
|
6071
|
+
const paddedRowIndex = Math.max(0, rowIndex - SCROLL_TO_ROW_CONTEXT_ROWS);
|
|
6072
|
+
const scrollTop = Math.max(0, rowHeight * paddedRowIndex);
|
|
6073
|
+
setSelectedTaskId(taskId);
|
|
6074
|
+
container.scrollTo({ top: scrollTop, behavior: "smooth" });
|
|
6075
|
+
}, [tasks, visibleTasks, rowHeight]);
|
|
6054
6076
|
const [dragGuideLines, setDragGuideLines] = (0, import_react13.useState)(null);
|
|
6055
6077
|
const [draggedTaskOverride, setDraggedTaskOverride] = (0, import_react13.useState)(null);
|
|
6056
6078
|
const [previewTasksById, setPreviewTasksById] = (0, import_react13.useState)(/* @__PURE__ */ new Map());
|
|
@@ -6216,10 +6238,11 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
6216
6238
|
() => ({
|
|
6217
6239
|
scrollToToday,
|
|
6218
6240
|
scrollToTask,
|
|
6241
|
+
scrollToRow,
|
|
6219
6242
|
collapseAll: handleCollapseAll,
|
|
6220
6243
|
expandAll: handleExpandAll
|
|
6221
6244
|
}),
|
|
6222
|
-
[scrollToToday, scrollToTask, handleCollapseAll, handleExpandAll]
|
|
6245
|
+
[scrollToToday, scrollToTask, scrollToRow, handleCollapseAll, handleExpandAll]
|
|
6223
6246
|
);
|
|
6224
6247
|
function getTaskDepth(taskId, tasks2) {
|
|
6225
6248
|
let depth = 0;
|
|
@@ -6381,7 +6404,7 @@ var GanttChart = (0, import_react13.forwardRef)(({
|
|
|
6381
6404
|
onToggleCollapse: handleToggleCollapse,
|
|
6382
6405
|
onPromoteTask: onPromoteTask ?? handlePromoteTask,
|
|
6383
6406
|
onDemoteTask: onDemoteTask ?? handleDemoteTask,
|
|
6384
|
-
highlightedTaskIds:
|
|
6407
|
+
highlightedTaskIds: taskListHighlightedTaskIds,
|
|
6385
6408
|
customDays,
|
|
6386
6409
|
isWeekend: isWeekend3,
|
|
6387
6410
|
businessDays
|