gantt-lib 0.17.2 → 0.19.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.css.map +1 -1
- package/dist/index.d.mts +95 -3
- package/dist/index.d.ts +95 -3
- package/dist/index.js +1058 -470
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1063 -471
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +15 -44
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -252,6 +252,12 @@ interface GanttChartProps {
|
|
|
252
252
|
enableAddTask?: boolean;
|
|
253
253
|
/** View mode: 'day' renders one column per day, 'week' renders one column per 7 days, 'month' renders one column per month (default: 'day') */
|
|
254
254
|
viewMode?: 'day' | 'week' | 'month';
|
|
255
|
+
/** Custom weekend dates to ADD to default weekends (e.g., holidays) */
|
|
256
|
+
weekends?: Date[];
|
|
257
|
+
/** Custom workday dates to EXCLUDE from default weekends (e.g., shifted workdays) */
|
|
258
|
+
workdays?: Date[];
|
|
259
|
+
/** Flexible weekend logic predicate (overrides arrays) */
|
|
260
|
+
isWeekend?: (date: Date) => boolean;
|
|
255
261
|
}
|
|
256
262
|
/**
|
|
257
263
|
* Ref handle type for GanttChart — exposes imperative scroll methods.
|
|
@@ -348,6 +354,8 @@ interface TimeScaleHeaderProps {
|
|
|
348
354
|
headerHeight: number;
|
|
349
355
|
/** View mode: 'day' renders individual day columns, 'week' renders 7-day week columns, 'month' renders one column per month */
|
|
350
356
|
viewMode?: 'day' | 'week' | 'month';
|
|
357
|
+
/** Optional predicate for custom weekend logic (e.g., holidays, shift patterns) */
|
|
358
|
+
isCustomWeekend?: (date: Date) => boolean;
|
|
351
359
|
}
|
|
352
360
|
/**
|
|
353
361
|
* TimeScaleHeader component - displays two-row date headers for the Gantt chart
|
|
@@ -370,6 +378,8 @@ interface GridBackgroundProps {
|
|
|
370
378
|
totalHeight: number;
|
|
371
379
|
/** View mode: 'day' renders per-day lines with weekend blocks, 'week' renders per-week lines only, 'month' renders per-month lines only */
|
|
372
380
|
viewMode?: 'day' | 'week' | 'month';
|
|
381
|
+
/** Optional predicate for custom weekend logic (e.g., holidays, shift patterns) */
|
|
382
|
+
isCustomWeekend?: (date: Date) => boolean;
|
|
373
383
|
}
|
|
374
384
|
/**
|
|
375
385
|
* GridBackground component - renders vertical grid lines and weekend background highlighting
|
|
@@ -463,6 +473,12 @@ interface TaskListProps {
|
|
|
463
473
|
onPromoteTask?: (taskId: string) => void;
|
|
464
474
|
/** Callback when task is demoted (parentId set to previous task) */
|
|
465
475
|
onDemoteTask?: (taskId: string, newParentId: string) => void;
|
|
476
|
+
/** Optional custom weekend dates (holidays) for date picker */
|
|
477
|
+
weekends?: Date[];
|
|
478
|
+
/** Optional custom workday dates - overrides weekends */
|
|
479
|
+
workdays?: Date[];
|
|
480
|
+
/** Optional predicate for custom weekend logic in date picker */
|
|
481
|
+
isWeekend?: (date: Date) => boolean;
|
|
466
482
|
}
|
|
467
483
|
/**
|
|
468
484
|
* TaskList component - displays tasks in a table format as an overlay
|
|
@@ -537,6 +553,12 @@ interface CalendarProps {
|
|
|
537
553
|
initialDate?: Date;
|
|
538
554
|
mode?: 'single' | 'range';
|
|
539
555
|
disabled?: boolean;
|
|
556
|
+
/** Optional predicate for custom weekend logic (e.g., holidays, shift patterns) */
|
|
557
|
+
isWeekend?: (date: Date) => boolean;
|
|
558
|
+
/** Optional custom weekend dates (holidays) - takes precedence over default weekends */
|
|
559
|
+
weekends?: Date[];
|
|
560
|
+
/** Optional custom workday dates - overrides both default and custom weekends */
|
|
561
|
+
workdays?: Date[];
|
|
540
562
|
}
|
|
541
563
|
declare const Calendar: React$1.FC<CalendarProps>;
|
|
542
564
|
|
|
@@ -555,6 +577,12 @@ interface DatePickerProps {
|
|
|
555
577
|
className?: string;
|
|
556
578
|
/** Whether the picker is disabled */
|
|
557
579
|
disabled?: boolean;
|
|
580
|
+
/** Optional custom weekend dates (holidays) */
|
|
581
|
+
weekends?: Date[];
|
|
582
|
+
/** Optional custom workday dates - overrides weekends */
|
|
583
|
+
workdays?: Date[];
|
|
584
|
+
/** Optional predicate for custom weekend logic */
|
|
585
|
+
isWeekend?: (date: Date) => boolean;
|
|
558
586
|
}
|
|
559
587
|
/**
|
|
560
588
|
* DatePicker component — shows formatted date as a button, opens calendar popup on click.
|
|
@@ -672,6 +700,58 @@ declare const isToday: (date: Date) => boolean;
|
|
|
672
700
|
* @returns True if date is Saturday (6) or Sunday (0), false otherwise
|
|
673
701
|
*/
|
|
674
702
|
declare const isWeekend: (date: Date) => boolean;
|
|
703
|
+
/**
|
|
704
|
+
* Create a UTC-safe key for Set-based date lookup
|
|
705
|
+
* @param date - Date object to create key from
|
|
706
|
+
* @returns String key in "YYYY-M-D" format using UTC date components
|
|
707
|
+
*
|
|
708
|
+
* Example:
|
|
709
|
+
* createDateKey(new Date(Date.UTC(2026, 2, 15))) // "2026-2-15"
|
|
710
|
+
*
|
|
711
|
+
* Note: Uses UTC methods to prevent DST and timezone issues.
|
|
712
|
+
* Month is 0-indexed (0=January, 11=December) per JavaScript Date convention.
|
|
713
|
+
*/
|
|
714
|
+
declare const createDateKey: (date: Date) => string;
|
|
715
|
+
/**
|
|
716
|
+
* Configuration for custom weekend calendar
|
|
717
|
+
*/
|
|
718
|
+
interface WeekendConfig {
|
|
719
|
+
/** Array of dates to ADD to default weekends (e.g., holidays) */
|
|
720
|
+
weekends?: Date[];
|
|
721
|
+
/** Array of dates to EXCLUDE from default weekends (e.g., shifted workdays) */
|
|
722
|
+
workdays?: Date[];
|
|
723
|
+
/** Custom predicate for flexible weekend logic (overrides arrays) */
|
|
724
|
+
isWeekend?: (date: Date) => boolean;
|
|
725
|
+
}
|
|
726
|
+
/**
|
|
727
|
+
* Create a weekend predicate with custom calendar support
|
|
728
|
+
*
|
|
729
|
+
* Precedence order (highest to lowest):
|
|
730
|
+
* 1. isWeekend (custom predicate) - use directly, ignore arrays
|
|
731
|
+
* 2. workdays - exclude these dates from default weekends
|
|
732
|
+
* 3. weekends - add these dates to default weekends
|
|
733
|
+
* 4. default - Saturday (6) and Sunday (0)
|
|
734
|
+
*
|
|
735
|
+
* @param config - Weekend configuration with optional arrays and predicate
|
|
736
|
+
* @returns Predicate function (date: Date) => boolean
|
|
737
|
+
*
|
|
738
|
+
* Example:
|
|
739
|
+
* // Add March 8 as holiday (Monday becomes weekend)
|
|
740
|
+
* const predicate = createIsWeekendPredicate({
|
|
741
|
+
* weekends: [new Date(Date.UTC(2026, 2, 8))]
|
|
742
|
+
* });
|
|
743
|
+
*
|
|
744
|
+
* // Make March 15 a workday (Saturday becomes workday)
|
|
745
|
+
* const predicate2 = createIsWeekendPredicate({
|
|
746
|
+
* workdays: [new Date(Date.UTC(2026, 2, 15))]
|
|
747
|
+
* });
|
|
748
|
+
*
|
|
749
|
+
* // Custom shift pattern (Sunday-only weekends)
|
|
750
|
+
* const predicate3 = createIsWeekendPredicate({
|
|
751
|
+
* isWeekend: (date) => date.getUTCDay() === 0
|
|
752
|
+
* });
|
|
753
|
+
*/
|
|
754
|
+
declare const createIsWeekendPredicate: (config: WeekendConfig) => ((date: Date) => boolean);
|
|
675
755
|
/**
|
|
676
756
|
* Calculate multi-month date range from task dates
|
|
677
757
|
* Expands range to include full months with padding on both ends for drag flexibility
|
|
@@ -993,9 +1073,21 @@ declare const calculateGridLines: (dateRange: Date[], dayWidth: number) => Array
|
|
|
993
1073
|
* Calculate weekend background blocks for a date range
|
|
994
1074
|
* @param dateRange - Array of Date objects representing the visible range
|
|
995
1075
|
* @param dayWidth - Width of each day column in pixels
|
|
1076
|
+
* @param isCustomWeekend - Optional predicate for custom weekend logic (e.g., holidays, shift patterns)
|
|
996
1077
|
* @returns Array of weekend block objects with left position and width
|
|
997
|
-
|
|
998
|
-
|
|
1078
|
+
*
|
|
1079
|
+
* Example:
|
|
1080
|
+
* // Default behavior (Saturday/Sunday)
|
|
1081
|
+
* calculateWeekendBlocks(dateRange, dayWidth)
|
|
1082
|
+
*
|
|
1083
|
+
* // Custom weekends (holidays, shifted workdays)
|
|
1084
|
+
* const isCustomWeekend = createIsWeekendPredicate({
|
|
1085
|
+
* weekends: [new Date(Date.UTC(2026, 2, 8))], // March 8 holiday
|
|
1086
|
+
* workdays: [new Date(Date.UTC(2026, 2, 15))] // March 15 workday
|
|
1087
|
+
* });
|
|
1088
|
+
* calculateWeekendBlocks(dateRange, dayWidth, isCustomWeekend)
|
|
1089
|
+
*/
|
|
1090
|
+
declare const calculateWeekendBlocks: (dateRange: Date[], dayWidth: number, isCustomWeekend?: (date: Date) => boolean) => Array<{
|
|
999
1091
|
left: number;
|
|
1000
1092
|
width: number;
|
|
1001
1093
|
}>;
|
|
@@ -1107,4 +1199,4 @@ interface VisibleReorderPosition {
|
|
|
1107
1199
|
*/
|
|
1108
1200
|
declare function getVisibleReorderPosition(orderedTasks: TaskLike[], visibleTasks: TaskLike[], movedTaskId: string, originVisibleIndex: number, dropVisibleIndex: number): VisibleReorderPosition | null;
|
|
1109
1201
|
|
|
1110
|
-
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 MonthBlock, type MonthSpan, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type Task, type TaskBarGeometry, type TaskDependency, TaskList, type TaskListProps, TaskRow, TimeScaleHeader, TodayIndicator, type VisibleReorderPosition, type WeekBlock, type WeekSpan, type WeekendBlock, type YearSpan, buildAdjacencyList, calculateBezierPath, calculateDependencyPath, calculateGridLines, calculateGridWidth, calculateMonthGridLines, calculateOrthogonalPath, calculateSuccessorDate, calculateTaskBar, calculateWeekGridLines, calculateWeekendBlocks, cascadeByLinks, computeLagFromDates, computeParentDates, computeParentProgress, detectCycles, detectEdgeZone, findParentId, flattenHierarchy, formatDateLabel, getAllDependencyEdges, getChildren, getCursorForPosition, getDayOffset, getMonthBlocks, getMonthDays, getMonthSpans, getMultiMonthDays, getSuccessorChain, getTransitiveCascadeChain, getVisibleReorderPosition, getWeekBlocks, getWeekSpans, getYearSpans, isTaskParent, isToday, isWeekend, normalizeHierarchyTasks, normalizeTaskDates, parseUTCDate, pixelsToDate, recalculateIncomingLags, removeDependenciesBetweenTasks, universalCascade, useTaskDrag, validateDependencies };
|
|
1202
|
+
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 MonthBlock, type MonthSpan, Popover, PopoverContent, type PopoverContentProps, type PopoverProps, PopoverTrigger, type Task, type TaskBarGeometry, type TaskDependency, TaskList, type TaskListProps, TaskRow, TimeScaleHeader, TodayIndicator, type VisibleReorderPosition, type WeekBlock, type WeekSpan, type WeekendBlock, type WeekendConfig, type YearSpan, buildAdjacencyList, calculateBezierPath, calculateDependencyPath, calculateGridLines, calculateGridWidth, calculateMonthGridLines, calculateOrthogonalPath, calculateSuccessorDate, calculateTaskBar, calculateWeekGridLines, calculateWeekendBlocks, cascadeByLinks, computeLagFromDates, computeParentDates, computeParentProgress, createDateKey, createIsWeekendPredicate, detectCycles, detectEdgeZone, findParentId, flattenHierarchy, formatDateLabel, getAllDependencyEdges, getChildren, getCursorForPosition, getDayOffset, getMonthBlocks, getMonthDays, getMonthSpans, getMultiMonthDays, getSuccessorChain, getTransitiveCascadeChain, getVisibleReorderPosition, getWeekBlocks, getWeekSpans, getYearSpans, isTaskParent, isToday, isWeekend, normalizeHierarchyTasks, normalizeTaskDates, parseUTCDate, pixelsToDate, recalculateIncomingLags, removeDependenciesBetweenTasks, universalCascade, useTaskDrag, validateDependencies };
|