mantine-gantt 0.3.0 → 0.4.1
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/README.md +18 -18
- package/dist/cjs/Gantt/DependencyLinks.cjs +70 -30
- package/dist/cjs/Gantt/DependencyLinks.cjs.map +1 -1
- package/dist/cjs/Gantt/Gantt.cjs +73 -29
- package/dist/cjs/Gantt/Gantt.cjs.map +1 -1
- package/dist/cjs/Gantt/Gantt.module.css.cjs +1 -1
- package/dist/cjs/Gantt/TaskBar.cjs +26 -15
- package/dist/cjs/Gantt/TaskBar.cjs.map +1 -1
- package/dist/cjs/Gantt/TaskList.cjs.map +1 -1
- package/dist/cjs/Gantt/use-gantt-drag.cjs +46 -4
- package/dist/cjs/Gantt/use-gantt-drag.cjs.map +1 -1
- package/dist/cjs/Gantt/utils.cjs +81 -1
- package/dist/cjs/Gantt/utils.cjs.map +1 -1
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/Gantt/DependencyLinks.mjs +71 -31
- package/dist/esm/Gantt/DependencyLinks.mjs.map +1 -1
- package/dist/esm/Gantt/Gantt.mjs +73 -29
- package/dist/esm/Gantt/Gantt.mjs.map +1 -1
- package/dist/esm/Gantt/Gantt.module.css.mjs +1 -1
- package/dist/esm/Gantt/TaskBar.mjs +28 -17
- package/dist/esm/Gantt/TaskBar.mjs.map +1 -1
- package/dist/esm/Gantt/TaskList.mjs.map +1 -1
- package/dist/esm/Gantt/use-gantt-drag.mjs +48 -6
- package/dist/esm/Gantt/use-gantt-drag.mjs.map +1 -1
- package/dist/esm/Gantt/utils.mjs +80 -2
- package/dist/esm/Gantt/utils.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/styles.css +2 -2
- package/dist/styles.layer.css +2 -2
- package/dist/types/Gantt/DependencyLinks.d.ts +4 -2
- package/dist/types/Gantt/TaskBar.d.ts +4 -2
- package/dist/types/Gantt/TaskList.d.ts +2 -2
- package/dist/types/Gantt/index.d.ts +1 -1
- package/dist/types/Gantt/types.d.ts +22 -8
- package/dist/types/Gantt/use-gantt-drag.d.ts +6 -3
- package/dist/types/Gantt/utils.d.ts +19 -3
- package/dist/types/index.d.mts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/package.json +1 -1
|
@@ -21,6 +21,12 @@ export interface GanttTask {
|
|
|
21
21
|
duration: number;
|
|
22
22
|
/** Progress percentage (0-100) */
|
|
23
23
|
progress: number;
|
|
24
|
+
/**
|
|
25
|
+
* Kind of row: a regular schedulable `'task'` (default) or a `'milestone'` - a
|
|
26
|
+
* zero-length marker rendered as a diamond. Milestones cannot be resized (their
|
|
27
|
+
* duration is ignored for rendering) but can be moved and linked like tasks.
|
|
28
|
+
*/
|
|
29
|
+
type?: 'task' | 'milestone';
|
|
24
30
|
/** IDs of tasks this task depends on */
|
|
25
31
|
dependencies?: string[];
|
|
26
32
|
/** Custom color for the task bar */
|
|
@@ -48,18 +54,18 @@ export interface GanttTreeRow {
|
|
|
48
54
|
/** Effective progress: own for leaves, duration-weighted child average for parents */
|
|
49
55
|
progress: number;
|
|
50
56
|
}
|
|
51
|
-
export type GanttStylesNames = 'root' | 'taskList' | 'taskListHeader' | 'taskListBody' | 'taskListContent' | 'taskListRow' | 'taskListCell' | 'expandChevron' | 'timeline' | 'timelineHeader' | 'timelineHeaderInner' | 'timelineHeaderRow' | 'timelineHeaderCell' | 'weekHeader' | 'weekHeaderCell' | 'timelineBody' | 'timelineContent' | 'timelineRow' | 'timelineGrid' | 'gridLine' | 'majorGridLine' | 'weekendBackground' | 'todayLine' | 'taskBar' | 'taskBarLabel' | 'taskBarProgress' | 'baselineBar' | 'summaryBar' | 'resizeHandle' | 'resizeHandleLeft' | 'linkConnector' | 'dependencyLinks' | 'dependencyLine' | 'linkArrow';
|
|
57
|
+
export type GanttStylesNames = 'root' | 'taskList' | 'taskListHeader' | 'taskListBody' | 'taskListContent' | 'taskListRow' | 'taskListCell' | 'expandChevron' | 'timeline' | 'timelineHeader' | 'timelineHeaderInner' | 'timelineHeaderRow' | 'timelineHeaderCell' | 'weekHeader' | 'weekHeaderCell' | 'timelineBody' | 'timelineContent' | 'timelineRow' | 'timelineGrid' | 'gridLine' | 'majorGridLine' | 'weekendBackground' | 'todayLine' | 'taskBar' | 'taskBarLabel' | 'taskBarProgress' | 'milestone' | 'baselineBar' | 'summaryBar' | 'resizeHandle' | 'resizeHandleLeft' | 'linkConnector' | 'dependencyLinks' | 'dependencyLine' | 'linkArrow';
|
|
52
58
|
export type GanttCssVariables = {
|
|
53
59
|
root: '--gantt-column-width' | '--gantt-row-height' | '--gantt-header-height' | '--gantt-task-list-width' | '--gantt-critical-color';
|
|
54
60
|
};
|
|
55
61
|
export interface GanttBaseProps {
|
|
56
62
|
/**
|
|
57
|
-
* Tasks to display
|
|
63
|
+
* Tasks to display - controlled mode. The component keeps no copy of its own: every
|
|
58
64
|
* drag/resize/link/keyboard change is reported through `onTasksChange` and the bars only
|
|
59
65
|
* move once this prop comes back updated.
|
|
60
66
|
*/
|
|
61
67
|
tasks?: GanttTask[];
|
|
62
|
-
/** Initial tasks
|
|
68
|
+
/** Initial tasks - uncontrolled mode. The component owns the task list from then on. */
|
|
63
69
|
defaultTasks?: GanttTask[];
|
|
64
70
|
/** Called with the full new task list after any change (drag, resize, link, keyboard) */
|
|
65
71
|
onTasksChange?: (tasks: GanttTask[]) => void;
|
|
@@ -71,12 +77,20 @@ export interface GanttBaseProps {
|
|
|
71
77
|
onTaskClick?: (task: GanttTask) => void;
|
|
72
78
|
/** Callback when a dependency link is created (fromTaskId, toTaskId) */
|
|
73
79
|
onLinkCreate?: (fromTaskId: string, toTaskId: string) => void;
|
|
80
|
+
/** Callback when a dependency link is deleted by clicking it (fromTaskId, toTaskId) */
|
|
81
|
+
onLinkDelete?: (fromTaskId: string, toTaskId: string) => void;
|
|
82
|
+
/**
|
|
83
|
+
* Automatically shift dependent tasks (finish-to-start, zero lag) when a task is
|
|
84
|
+
* moved or resized, so successors never start before their predecessors finish.
|
|
85
|
+
* Default false.
|
|
86
|
+
*/
|
|
87
|
+
autoSchedule?: boolean;
|
|
74
88
|
/** Width of each day column in pixels, default 40 */
|
|
75
89
|
columnWidth?: number;
|
|
76
90
|
/** Height of each task row in pixels, default 44 */
|
|
77
91
|
rowHeight?: number;
|
|
78
92
|
/**
|
|
79
|
-
* Width of the task list panel in pixels. Omitted: computed from `columns`
|
|
93
|
+
* Width of the task list panel in pixels. Omitted: computed from `columns` - fixed columns
|
|
80
94
|
* at their `width`, flexible ones at 200px (so the default set gives 460px). Set it only to
|
|
81
95
|
* override; a value narrower than the columns need squeezes the flexible column.
|
|
82
96
|
*/
|
|
@@ -84,20 +98,20 @@ export interface GanttBaseProps {
|
|
|
84
98
|
/**
|
|
85
99
|
* Start date of the timeline, defaults to earliest task start - 7 days.
|
|
86
100
|
* Interpreted as a local calendar day (its local getFullYear/getMonth/getDate), so
|
|
87
|
-
* construct it with `new Date(year, monthIndex, day)`
|
|
88
|
-
* midnight
|
|
101
|
+
* construct it with `new Date(year, monthIndex, day)` - or otherwise ensure it is local
|
|
102
|
+
* midnight - rather than `new Date('YYYY-MM-DD')`, which is UTC midnight and can resolve
|
|
89
103
|
* to the previous local day in timezones behind UTC.
|
|
90
104
|
*/
|
|
91
105
|
startDate?: Date;
|
|
92
106
|
/**
|
|
93
107
|
* End date of the timeline, defaults to latest task end + 7 days.
|
|
94
|
-
* Interpreted as a local calendar day
|
|
108
|
+
* Interpreted as a local calendar day - see `startDate` for construction guidance.
|
|
95
109
|
*/
|
|
96
110
|
endDate?: Date;
|
|
97
111
|
/** View mode: 'day' | 'week' | 'month', default 'day' */
|
|
98
112
|
viewMode?: 'day' | 'week' | 'month';
|
|
99
113
|
/**
|
|
100
|
-
* First day of the week
|
|
114
|
+
* First day of the week - 0 = Sunday, 1 = Monday, default 1. Drives both the week numbers
|
|
101
115
|
* in the header (ISO numbering) and the week separators in the grid.
|
|
102
116
|
*/
|
|
103
117
|
weekStart?: 0 | 1;
|
|
@@ -19,12 +19,15 @@ export interface UseGanttDragOptions {
|
|
|
19
19
|
commitTasks: (next: GanttTask[]) => void;
|
|
20
20
|
/** Effective column width in px (already adjusted for viewMode). */
|
|
21
21
|
columnWidth: number;
|
|
22
|
-
/** Scroll container
|
|
22
|
+
/** Scroll container - drives scroll-adjusted delta and auto-scroll. */
|
|
23
23
|
bodyRef: React.RefObject<HTMLDivElement | null>;
|
|
24
|
-
/** Positioned content
|
|
24
|
+
/** Positioned content - its rect maps client coords to timeline pixels. */
|
|
25
25
|
contentRef: React.RefObject<HTMLDivElement | null>;
|
|
26
26
|
onTaskUpdate?: (task: GanttTask) => void;
|
|
27
27
|
onLinkCreate?: (fromTaskId: string, toTaskId: string) => void;
|
|
28
|
+
onLinkDelete?: (fromTaskId: string, toTaskId: string) => void;
|
|
29
|
+
/** Cascade finish-to-start successors after a move/resize commit. */
|
|
30
|
+
autoSchedule?: boolean;
|
|
28
31
|
/** Push a message to the aria-live region (drag/keyboard commits). */
|
|
29
32
|
announce?: (message: string) => void;
|
|
30
33
|
}
|
|
@@ -39,7 +42,7 @@ export interface UseGanttDragReturn {
|
|
|
39
42
|
}
|
|
40
43
|
/**
|
|
41
44
|
* Owns every drag interaction (move / resize-start / resize-end / link) on plain pointer
|
|
42
|
-
* events
|
|
45
|
+
* events - no @dnd-kit. pointerdown → document pointermove → pointerup, snapping to whole
|
|
43
46
|
* days only on release. Auto-scrolls the viewport near its edges and keeps delta correct
|
|
44
47
|
* across that scroll, so the bar follows the cursor. Modeled on @mantine/schedule's
|
|
45
48
|
* use-horizontal-event-resize + use-auto-scroll-on-drag.
|
|
@@ -54,11 +54,12 @@ export declare function calculateTimelineBounds(tasks: GanttTask[], startDate?:
|
|
|
54
54
|
*/
|
|
55
55
|
export declare function formatTaskDate(date: string | Date | Dayjs): string;
|
|
56
56
|
/**
|
|
57
|
-
* Calculate end date from start date and duration
|
|
57
|
+
* Calculate end date from start date and duration. Duration is inclusive of the start
|
|
58
|
+
* day; a milestone (duration 0) starts and ends on the same day.
|
|
58
59
|
*/
|
|
59
60
|
export declare function getTaskEndDate(startDate: string, duration: number): Dayjs;
|
|
60
61
|
/**
|
|
61
|
-
* True when making `toId` depend on `fromId` would close a dependency cycle
|
|
62
|
+
* True when making `toId` depend on `fromId` would close a dependency cycle - i.e. `fromId`
|
|
62
63
|
* already depends on `toId`, directly or transitively. Self-links count as a cycle. Tolerates
|
|
63
64
|
* an already-cyclic input graph (visited set), unknown ids are ignored.
|
|
64
65
|
*/
|
|
@@ -81,6 +82,21 @@ export declare function getEffectiveTask(row: GanttTreeRow): GanttTask;
|
|
|
81
82
|
* (summary parents) are excluded from the graph entirely.
|
|
82
83
|
*/
|
|
83
84
|
export declare function getCriticalPath(tasks: GanttTask[]): Set<string>;
|
|
85
|
+
/**
|
|
86
|
+
* Map of task id → ids of tasks that depend on it (successors). Unknown dependency ids
|
|
87
|
+
* are ignored; edges that would close a cycle are skipped, so the result is always a DAG
|
|
88
|
+
* even for cyclic input. Shared by CPM and auto-scheduling.
|
|
89
|
+
*/
|
|
90
|
+
export declare function buildSuccessorMap(tasks: GanttTask[]): Map<string, string[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Auto-scheduling cascade: after `movedTaskId` moved/resized, push every transitive
|
|
93
|
+
* finish-to-start successor so it never starts before its predecessors end. Only leaves
|
|
94
|
+
* are cascaded - summary parents derive their schedule from children. Returns the input
|
|
95
|
+
* array unchanged when nothing needs to move. Assumes an acyclic dependency graph
|
|
96
|
+
* (guaranteed upstream by wouldCreateCycle); tolerates cyclic input without hanging by
|
|
97
|
+
* cascading only the DAG-reachable, topologically ordered part.
|
|
98
|
+
*/
|
|
99
|
+
export declare function applyAutoSchedule(tasks: GanttTask[], movedTaskId: string): GanttTask[];
|
|
84
100
|
/**
|
|
85
101
|
* Row range `[first, last)` to render for a scroller of fixed-height rows.
|
|
86
102
|
*
|
|
@@ -88,7 +104,7 @@ export declare function getCriticalPath(tasks: GanttTask[]): Set<string>;
|
|
|
88
104
|
* side: the rendered set then only changes every `overscan` rows of scrolling instead of on
|
|
89
105
|
* every scroll event, which is what keeps rows from flickering as they come into view.
|
|
90
106
|
*
|
|
91
|
-
* `viewportHeight <= 0` means "not measured yet" (first paint, jsdom)
|
|
107
|
+
* `viewportHeight <= 0` means "not measured yet" (first paint, jsdom) - render everything,
|
|
92
108
|
* because rendering nothing would blank the chart on environments that never measure.
|
|
93
109
|
*/
|
|
94
110
|
export declare function visibleRowRange(scrollTop: number, viewportHeight: number, rowHeight: number, rowCount: number, overscan?: number): [number, number];
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Gantt } from './Gantt';
|
|
2
2
|
export type { GanttProps, GanttTask, GanttColumn, GanttStylesNames, GanttFactory, GanttCssVariables, } from './Gantt';
|
|
3
|
-
export { dateToPixel, pixelToDate, snapToGrid, durationToPixels, formatTaskDate, getTaskEndDate, calculateTimelineBounds, wouldCreateCycle, } from './Gantt';
|
|
3
|
+
export { dateToPixel, pixelToDate, snapToGrid, durationToPixels, formatTaskDate, getTaskEndDate, calculateTimelineBounds, wouldCreateCycle, buildSuccessorMap, applyAutoSchedule, } from './Gantt';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { Gantt } from './Gantt';
|
|
2
2
|
export type { GanttProps, GanttTask, GanttColumn, GanttStylesNames, GanttFactory, GanttCssVariables, } from './Gantt';
|
|
3
|
-
export { dateToPixel, pixelToDate, snapToGrid, durationToPixels, formatTaskDate, getTaskEndDate, calculateTimelineBounds, wouldCreateCycle, } from './Gantt';
|
|
3
|
+
export { dateToPixel, pixelToDate, snapToGrid, durationToPixels, formatTaskDate, getTaskEndDate, calculateTimelineBounds, wouldCreateCycle, buildSuccessorMap, applyAutoSchedule, } from './Gantt';
|