gantt-lib 0.88.2 → 0.89.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 CHANGED
@@ -543,13 +543,21 @@ interface ExportToPdfHeaderOptions {
543
543
  /** Export date shown on the right; string is rendered as-is */
544
544
  exportDate?: string | Date;
545
545
  }
546
+ interface ScrollToRowOptions {
547
+ /** Keep built-in row selection styling after scroll (default: true) */
548
+ select?: boolean;
549
+ /** Browser scroll behavior for the vertical scroll action (default: 'smooth') */
550
+ behavior?: ScrollBehavior;
551
+ /** Automatically clear built-in row selection after N milliseconds */
552
+ clearSelectionAfterMs?: number;
553
+ }
546
554
  /**
547
555
  * Ref handle type for GanttChart — exposes imperative scroll methods.
548
556
  */
549
557
  interface GanttChartHandle {
550
558
  scrollToToday: () => void;
551
559
  scrollToTask: (taskId: string) => void;
552
- scrollToRow: (taskId: string) => void;
560
+ scrollToRow: (taskId: string, options?: ScrollToRowOptions) => void;
553
561
  collapseAll: () => void;
554
562
  expandAll: () => void;
555
563
  exportToPdf: (options?: ExportToPdfOptions) => Promise<void>;
package/dist/index.d.ts CHANGED
@@ -543,13 +543,21 @@ interface ExportToPdfHeaderOptions {
543
543
  /** Export date shown on the right; string is rendered as-is */
544
544
  exportDate?: string | Date;
545
545
  }
546
+ interface ScrollToRowOptions {
547
+ /** Keep built-in row selection styling after scroll (default: true) */
548
+ select?: boolean;
549
+ /** Browser scroll behavior for the vertical scroll action (default: 'smooth') */
550
+ behavior?: ScrollBehavior;
551
+ /** Automatically clear built-in row selection after N milliseconds */
552
+ clearSelectionAfterMs?: number;
553
+ }
546
554
  /**
547
555
  * Ref handle type for GanttChart — exposes imperative scroll methods.
548
556
  */
549
557
  interface GanttChartHandle {
550
558
  scrollToToday: () => void;
551
559
  scrollToTask: (taskId: string) => void;
552
- scrollToRow: (taskId: string) => void;
560
+ scrollToRow: (taskId: string, options?: ScrollToRowOptions) => void;
553
561
  collapseAll: () => void;
554
562
  expandAll: () => void;
555
563
  exportToPdf: (options?: ExportToPdfOptions) => Promise<void>;
package/dist/index.js CHANGED
@@ -9622,6 +9622,7 @@ function TaskGanttChartInner(props, ref) {
9622
9622
  const containerRef = (0, import_react15.useRef)(null);
9623
9623
  const scrollContainerRef = (0, import_react15.useRef)(null);
9624
9624
  const scrollContentRef = (0, import_react15.useRef)(null);
9625
+ const clearSelectedTaskTimeoutRef = (0, import_react15.useRef)(null);
9625
9626
  const [selectedTaskId, setSelectedTaskId] = (0, import_react15.useState)(null);
9626
9627
  const [taskListHasRightShadow, setTaskListHasRightShadow] = (0, import_react15.useState)(false);
9627
9628
  const [selectedChip, setSelectedChip] = (0, import_react15.useState)(null);
@@ -9741,7 +9742,7 @@ function TaskGanttChartInner(props, ref) {
9741
9742
  const scrollLeft = Math.round(taskOffset - dayWidth * 2);
9742
9743
  container.scrollTo({ left: Math.max(0, scrollLeft), behavior: "smooth" });
9743
9744
  }, [tasks, dateRange, dayWidth]);
9744
- const scrollToRow = (0, import_react15.useCallback)((taskId) => {
9745
+ const scrollToRow = (0, import_react15.useCallback)((taskId, options = {}) => {
9745
9746
  const container = scrollContainerRef.current;
9746
9747
  if (!container) return;
9747
9748
  const task = tasks.find((t) => t.id === taskId);
@@ -9750,8 +9751,25 @@ function TaskGanttChartInner(props, ref) {
9750
9751
  if (rowIndex === -1) return;
9751
9752
  const paddedRowIndex = Math.max(0, rowIndex - SCROLL_TO_ROW_CONTEXT_ROWS);
9752
9753
  const scrollTop = Math.max(0, rowHeight * paddedRowIndex);
9753
- setSelectedTaskId(taskId);
9754
- container.scrollTo({ top: scrollTop, behavior: "smooth" });
9754
+ const {
9755
+ select = true,
9756
+ behavior = "smooth",
9757
+ clearSelectionAfterMs
9758
+ } = options;
9759
+ if (clearSelectedTaskTimeoutRef.current !== null) {
9760
+ window.clearTimeout(clearSelectedTaskTimeoutRef.current);
9761
+ clearSelectedTaskTimeoutRef.current = null;
9762
+ }
9763
+ if (select) {
9764
+ setSelectedTaskId(taskId);
9765
+ if (typeof clearSelectionAfterMs === "number" && clearSelectionAfterMs >= 0) {
9766
+ clearSelectedTaskTimeoutRef.current = window.setTimeout(() => {
9767
+ setSelectedTaskId((current) => current === taskId ? null : current);
9768
+ clearSelectedTaskTimeoutRef.current = null;
9769
+ }, clearSelectionAfterMs);
9770
+ }
9771
+ }
9772
+ container.scrollTo({ top: scrollTop, behavior });
9755
9773
  }, [tasks, visibleTasks, rowHeight]);
9756
9774
  const [dragGuideLines, setDragGuideLines] = (0, import_react15.useState)(null);
9757
9775
  const [draggedTaskOverride, setDraggedTaskOverride] = (0, import_react15.useState)(null);
@@ -9761,6 +9779,11 @@ function TaskGanttChartInner(props, ref) {
9761
9779
  setValidationResult(result);
9762
9780
  onValidateDependencies?.(result);
9763
9781
  }, [tasks, onValidateDependencies]);
9782
+ (0, import_react15.useEffect)(() => () => {
9783
+ if (clearSelectedTaskTimeoutRef.current !== null) {
9784
+ window.clearTimeout(clearSelectedTaskTimeoutRef.current);
9785
+ }
9786
+ }, []);
9764
9787
  const handleTaskChange = (0, import_react15.useCallback)((updatedTasks) => {
9765
9788
  const updatedTask = updatedTasks[0];
9766
9789
  if (!updatedTask) return;