gantt-lib 0.7.0 → 0.8.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
@@ -216,8 +216,8 @@ interface GanttChartProps {
216
216
  headerHeight?: number;
217
217
  /** Container height. Can be pixels (600), string ("90vh", "100%", "500px"), or undefined for auto height */
218
218
  containerHeight?: number | string;
219
- /** Callback when tasks are modified via drag/resize. Can receive either the new tasks array or a functional updater. */
220
- onChange?: (tasks: Task[] | ((currentTasks: Task[]) => Task[])) => void;
219
+ /** Callback when tasks are modified. Receives ONLY the changed tasks as full objects with all properties. */
220
+ onTasksChange?: (tasks: Task[]) => void;
221
221
  /** Optional callback for dependency validation results */
222
222
  onValidateDependencies?: (result: ValidationResult) => void;
223
223
  /** Enable automatic shifting of dependent tasks when predecessor moves (default: false) */
@@ -289,8 +289,8 @@ interface TaskRowProps {
289
289
  dayWidth: number;
290
290
  /** Height of the task row in pixels */
291
291
  rowHeight: number;
292
- /** Callback when task is modified via drag/resize */
293
- onChange?: (updatedTask: Task) => void;
292
+ /** Callback when task is modified via drag/resize. Receives array of changed tasks. */
293
+ onTasksChange?: (tasks: Task[]) => void;
294
294
  /** Callback when task drag state changes (for rendering guide lines) */
295
295
  onDragStateChange?: (state: {
296
296
  isDragging: boolean;
@@ -401,8 +401,8 @@ interface TaskListProps {
401
401
  headerHeight: number;
402
402
  /** Width of the task list overlay in pixels (default: 400) */
403
403
  taskListWidth?: number;
404
- /** Callback when task is modified via inline edit */
405
- onTaskChange?: (task: Task) => void;
404
+ /** Callback when tasks are modified via inline edit. Receives array of changed tasks. */
405
+ onTasksChange?: (tasks: Task[]) => void;
406
406
  /** ID of currently selected task */
407
407
  selectedTaskId?: string;
408
408
  /** Callback when task row is clicked */
@@ -678,6 +678,17 @@ declare const getMonthSpans: (dateRange: Date[]) => Array<{
678
678
  * @returns Formatted date string in DD.MM format
679
679
  */
680
680
  declare const formatDateLabel: (date: Date | string) => string;
681
+ /**
682
+ * Normalize task dates to ensure startDate is always before or equal to endDate.
683
+ * If dates are swapped (endDate < startDate), they are automatically swapped.
684
+ * @param startDate - Task start date (string or Date)
685
+ * @param endDate - Task end date (string or Date)
686
+ * @returns Object with normalized startDate and endDate as ISO date strings (YYYY-MM-DD)
687
+ */
688
+ declare const normalizeTaskDates: (startDate: string | Date, endDate: string | Date) => {
689
+ startDate: string;
690
+ endDate: string;
691
+ };
681
692
 
682
693
  /**
683
694
  * Build adjacency list for dependency graph (task -> successors)
@@ -936,6 +947,7 @@ declare function flattenHierarchy<T extends Task$1>(tasks: T[]): T[];
936
947
  * Normalize hierarchy-aware display fields.
937
948
  * Parent task dates and progress are always recomputed from children,
938
949
  * taking precedence over any hardcoded parent values from the input.
950
+ * Also normalizes task dates to ensure startDate is always before or equal to endDate.
939
951
  */
940
952
  declare function normalizeHierarchyTasks<T extends Task$1>(tasks: T[]): T[];
941
953
 
@@ -952,4 +964,4 @@ interface VisibleReorderPosition {
952
964
  */
953
965
  declare function getVisibleReorderPosition(orderedTasks: TaskLike[], visibleTasks: TaskLike[], movedTaskId: string, originVisibleIndex: number, dropVisibleIndex: number): VisibleReorderPosition | null;
954
966
 
955
- export { Button, type ButtonProps, Calendar, type CalendarProps, DatePicker, type DatePickerProps, DragGuideLines, GanttChart, type GanttChartHandle, type GanttChartProps, type GanttDateRange, GridBackground, type GridConfig, type GridLine, Input, type InputProps, type MonthSpan, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type Task, type TaskBarGeometry, type TaskDependency, TaskList, type TaskListProps, TaskRow, TimeScaleHeader, TodayIndicator, type VisibleReorderPosition, type WeekendBlock, buildAdjacencyList, calculateBezierPath, calculateDependencyPath, calculateGridLines, calculateGridWidth, calculateOrthogonalPath, calculateSuccessorDate, calculateTaskBar, calculateWeekendBlocks, cascadeByLinks, computeLagFromDates, computeParentDates, computeParentProgress, detectCycles, detectEdgeZone, findParentId, flattenHierarchy, formatDateLabel, getAllDependencyEdges, getChildren, getCursorForPosition, getDayOffset, getMonthDays, getMonthSpans, getMultiMonthDays, getSuccessorChain, getTransitiveCascadeChain, getVisibleReorderPosition, isTaskParent, isToday, isWeekend, normalizeHierarchyTasks, parseUTCDate, pixelsToDate, recalculateIncomingLags, removeDependenciesBetweenTasks, useTaskDrag, validateDependencies };
967
+ export { Button, type ButtonProps, Calendar, type CalendarProps, DatePicker, type DatePickerProps, DragGuideLines, GanttChart, type GanttChartHandle, type GanttChartProps, type GanttDateRange, GridBackground, type GridConfig, type GridLine, Input, type InputProps, type MonthSpan, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type Task, type TaskBarGeometry, type TaskDependency, TaskList, type TaskListProps, TaskRow, TimeScaleHeader, TodayIndicator, type VisibleReorderPosition, type WeekendBlock, buildAdjacencyList, calculateBezierPath, calculateDependencyPath, calculateGridLines, calculateGridWidth, calculateOrthogonalPath, calculateSuccessorDate, calculateTaskBar, calculateWeekendBlocks, cascadeByLinks, computeLagFromDates, computeParentDates, computeParentProgress, detectCycles, detectEdgeZone, findParentId, flattenHierarchy, formatDateLabel, getAllDependencyEdges, getChildren, getCursorForPosition, getDayOffset, getMonthDays, getMonthSpans, getMultiMonthDays, getSuccessorChain, getTransitiveCascadeChain, getVisibleReorderPosition, isTaskParent, isToday, isWeekend, normalizeHierarchyTasks, normalizeTaskDates, parseUTCDate, pixelsToDate, recalculateIncomingLags, removeDependenciesBetweenTasks, useTaskDrag, validateDependencies };
package/dist/index.d.ts CHANGED
@@ -216,8 +216,8 @@ interface GanttChartProps {
216
216
  headerHeight?: number;
217
217
  /** Container height. Can be pixels (600), string ("90vh", "100%", "500px"), or undefined for auto height */
218
218
  containerHeight?: number | string;
219
- /** Callback when tasks are modified via drag/resize. Can receive either the new tasks array or a functional updater. */
220
- onChange?: (tasks: Task[] | ((currentTasks: Task[]) => Task[])) => void;
219
+ /** Callback when tasks are modified. Receives ONLY the changed tasks as full objects with all properties. */
220
+ onTasksChange?: (tasks: Task[]) => void;
221
221
  /** Optional callback for dependency validation results */
222
222
  onValidateDependencies?: (result: ValidationResult) => void;
223
223
  /** Enable automatic shifting of dependent tasks when predecessor moves (default: false) */
@@ -289,8 +289,8 @@ interface TaskRowProps {
289
289
  dayWidth: number;
290
290
  /** Height of the task row in pixels */
291
291
  rowHeight: number;
292
- /** Callback when task is modified via drag/resize */
293
- onChange?: (updatedTask: Task) => void;
292
+ /** Callback when task is modified via drag/resize. Receives array of changed tasks. */
293
+ onTasksChange?: (tasks: Task[]) => void;
294
294
  /** Callback when task drag state changes (for rendering guide lines) */
295
295
  onDragStateChange?: (state: {
296
296
  isDragging: boolean;
@@ -401,8 +401,8 @@ interface TaskListProps {
401
401
  headerHeight: number;
402
402
  /** Width of the task list overlay in pixels (default: 400) */
403
403
  taskListWidth?: number;
404
- /** Callback when task is modified via inline edit */
405
- onTaskChange?: (task: Task) => void;
404
+ /** Callback when tasks are modified via inline edit. Receives array of changed tasks. */
405
+ onTasksChange?: (tasks: Task[]) => void;
406
406
  /** ID of currently selected task */
407
407
  selectedTaskId?: string;
408
408
  /** Callback when task row is clicked */
@@ -678,6 +678,17 @@ declare const getMonthSpans: (dateRange: Date[]) => Array<{
678
678
  * @returns Formatted date string in DD.MM format
679
679
  */
680
680
  declare const formatDateLabel: (date: Date | string) => string;
681
+ /**
682
+ * Normalize task dates to ensure startDate is always before or equal to endDate.
683
+ * If dates are swapped (endDate < startDate), they are automatically swapped.
684
+ * @param startDate - Task start date (string or Date)
685
+ * @param endDate - Task end date (string or Date)
686
+ * @returns Object with normalized startDate and endDate as ISO date strings (YYYY-MM-DD)
687
+ */
688
+ declare const normalizeTaskDates: (startDate: string | Date, endDate: string | Date) => {
689
+ startDate: string;
690
+ endDate: string;
691
+ };
681
692
 
682
693
  /**
683
694
  * Build adjacency list for dependency graph (task -> successors)
@@ -936,6 +947,7 @@ declare function flattenHierarchy<T extends Task$1>(tasks: T[]): T[];
936
947
  * Normalize hierarchy-aware display fields.
937
948
  * Parent task dates and progress are always recomputed from children,
938
949
  * taking precedence over any hardcoded parent values from the input.
950
+ * Also normalizes task dates to ensure startDate is always before or equal to endDate.
939
951
  */
940
952
  declare function normalizeHierarchyTasks<T extends Task$1>(tasks: T[]): T[];
941
953
 
@@ -952,4 +964,4 @@ interface VisibleReorderPosition {
952
964
  */
953
965
  declare function getVisibleReorderPosition(orderedTasks: TaskLike[], visibleTasks: TaskLike[], movedTaskId: string, originVisibleIndex: number, dropVisibleIndex: number): VisibleReorderPosition | null;
954
966
 
955
- export { Button, type ButtonProps, Calendar, type CalendarProps, DatePicker, type DatePickerProps, DragGuideLines, GanttChart, type GanttChartHandle, type GanttChartProps, type GanttDateRange, GridBackground, type GridConfig, type GridLine, Input, type InputProps, type MonthSpan, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type Task, type TaskBarGeometry, type TaskDependency, TaskList, type TaskListProps, TaskRow, TimeScaleHeader, TodayIndicator, type VisibleReorderPosition, type WeekendBlock, buildAdjacencyList, calculateBezierPath, calculateDependencyPath, calculateGridLines, calculateGridWidth, calculateOrthogonalPath, calculateSuccessorDate, calculateTaskBar, calculateWeekendBlocks, cascadeByLinks, computeLagFromDates, computeParentDates, computeParentProgress, detectCycles, detectEdgeZone, findParentId, flattenHierarchy, formatDateLabel, getAllDependencyEdges, getChildren, getCursorForPosition, getDayOffset, getMonthDays, getMonthSpans, getMultiMonthDays, getSuccessorChain, getTransitiveCascadeChain, getVisibleReorderPosition, isTaskParent, isToday, isWeekend, normalizeHierarchyTasks, parseUTCDate, pixelsToDate, recalculateIncomingLags, removeDependenciesBetweenTasks, useTaskDrag, validateDependencies };
967
+ export { Button, type ButtonProps, Calendar, type CalendarProps, DatePicker, type DatePickerProps, DragGuideLines, GanttChart, type GanttChartHandle, type GanttChartProps, type GanttDateRange, GridBackground, type GridConfig, type GridLine, Input, type InputProps, type MonthSpan, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type Task, type TaskBarGeometry, type TaskDependency, TaskList, type TaskListProps, TaskRow, TimeScaleHeader, TodayIndicator, type VisibleReorderPosition, type WeekendBlock, buildAdjacencyList, calculateBezierPath, calculateDependencyPath, calculateGridLines, calculateGridWidth, calculateOrthogonalPath, calculateSuccessorDate, calculateTaskBar, calculateWeekendBlocks, cascadeByLinks, computeLagFromDates, computeParentDates, computeParentProgress, detectCycles, detectEdgeZone, findParentId, flattenHierarchy, formatDateLabel, getAllDependencyEdges, getChildren, getCursorForPosition, getDayOffset, getMonthDays, getMonthSpans, getMultiMonthDays, getSuccessorChain, getTransitiveCascadeChain, getVisibleReorderPosition, isTaskParent, isToday, isWeekend, normalizeHierarchyTasks, normalizeTaskDates, parseUTCDate, pixelsToDate, recalculateIncomingLags, removeDependenciesBetweenTasks, useTaskDrag, validateDependencies };