mantine-gantt 0.4.1 → 0.6.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/README.md +60 -17
- package/dist/cjs/Gantt/DependencyLinks.cjs +28 -25
- package/dist/cjs/Gantt/DependencyLinks.cjs.map +1 -1
- package/dist/cjs/Gantt/Gantt.cjs +192 -53
- 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 +36 -12
- package/dist/cjs/Gantt/TaskBar.cjs.map +1 -1
- package/dist/cjs/Gantt/TaskList.cjs +51 -38
- package/dist/cjs/Gantt/TaskList.cjs.map +1 -1
- package/dist/cjs/Gantt/TimelineGrid.cjs +7 -27
- package/dist/cjs/Gantt/TimelineGrid.cjs.map +1 -1
- package/dist/cjs/Gantt/TimelineHeader.cjs +21 -38
- package/dist/cjs/Gantt/TimelineHeader.cjs.map +1 -1
- package/dist/cjs/Gantt/use-gantt-drag.cjs +65 -61
- package/dist/cjs/Gantt/use-gantt-drag.cjs.map +1 -1
- package/dist/cjs/Gantt/utils.cjs +163 -81
- package/dist/cjs/Gantt/utils.cjs.map +1 -1
- package/dist/cjs/index.cjs +3 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/Gantt/DependencyLinks.mjs +29 -26
- package/dist/esm/Gantt/DependencyLinks.mjs.map +1 -1
- package/dist/esm/Gantt/Gantt.mjs +196 -57
- 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 +37 -13
- package/dist/esm/Gantt/TaskBar.mjs.map +1 -1
- package/dist/esm/Gantt/TaskList.mjs +52 -39
- package/dist/esm/Gantt/TaskList.mjs.map +1 -1
- package/dist/esm/Gantt/TimelineGrid.mjs +7 -27
- package/dist/esm/Gantt/TimelineGrid.mjs.map +1 -1
- package/dist/esm/Gantt/TimelineHeader.mjs +22 -39
- package/dist/esm/Gantt/TimelineHeader.mjs.map +1 -1
- package/dist/esm/Gantt/use-gantt-drag.mjs +66 -62
- package/dist/esm/Gantt/use-gantt-drag.mjs.map +1 -1
- package/dist/esm/Gantt/utils.mjs +157 -82
- package/dist/esm/Gantt/utils.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -5
- package/dist/esm/index.mjs.map +1 -1
- package/dist/styles.css +2 -2
- package/dist/styles.layer.css +2 -2
- package/dist/types/Gantt/DependencyLinks.d.ts +3 -3
- package/dist/types/Gantt/TaskBar.d.ts +12 -1
- package/dist/types/Gantt/TaskList.d.ts +3 -1
- package/dist/types/Gantt/TimelineGrid.d.ts +2 -1
- package/dist/types/Gantt/TimelineHeader.d.ts +3 -1
- package/dist/types/Gantt/index.d.ts +2 -6
- package/dist/types/Gantt/types.d.ts +127 -19
- package/dist/types/Gantt/use-gantt-drag.d.ts +4 -2
- package/dist/types/Gantt/utils.d.ts +51 -12
- package/dist/types/index.d.mts +2 -2
- package/dist/types/index.d.ts +2 -2
- package/package.json +1 -1
package/dist/cjs/Gantt/utils.cjs
CHANGED
|
@@ -5,6 +5,16 @@ var dayjs = require('dayjs');
|
|
|
5
5
|
var isoWeek = require('dayjs/plugin/isoWeek');
|
|
6
6
|
|
|
7
7
|
dayjs.extend(isoWeek);
|
|
8
|
+
const formatters = /* @__PURE__ */ new Map();
|
|
9
|
+
function formatDate(date, locale, options) {
|
|
10
|
+
const key = locale + JSON.stringify(options);
|
|
11
|
+
let formatter = formatters.get(key);
|
|
12
|
+
if (!formatter) {
|
|
13
|
+
formatter = new Intl.DateTimeFormat(locale, options);
|
|
14
|
+
formatters.set(key, formatter);
|
|
15
|
+
}
|
|
16
|
+
return formatter.format(dayjs(date).toDate());
|
|
17
|
+
}
|
|
8
18
|
function dateToPixel(date, startDate, columnWidth) {
|
|
9
19
|
const d = dayjs(date);
|
|
10
20
|
const diffDays = d.diff(startDate, "day");
|
|
@@ -20,15 +30,27 @@ function snapToGrid(value, gridSize) {
|
|
|
20
30
|
function durationToPixels(duration, columnWidth) {
|
|
21
31
|
return duration * columnWidth;
|
|
22
32
|
}
|
|
23
|
-
function
|
|
33
|
+
function barAnchors(task, timelineStart, columnWidth, rowHeight) {
|
|
34
|
+
const left = dateToPixel(task.startDate, timelineStart, columnWidth);
|
|
35
|
+
if (task.type === "milestone") {
|
|
36
|
+
const center = left + columnWidth / 2;
|
|
37
|
+
const diamondHalf = (rowHeight - 16) * 0.7 / Math.SQRT2;
|
|
38
|
+
return { left: center - diamondHalf, right: center + diamondHalf };
|
|
39
|
+
}
|
|
40
|
+
return { left, right: left + durationToPixels(task.duration, columnWidth) };
|
|
41
|
+
}
|
|
42
|
+
function isWeekend(date) {
|
|
43
|
+
const day = date.getDay();
|
|
44
|
+
return day === 0 || day === 6;
|
|
45
|
+
}
|
|
46
|
+
function generateDayHeaders(startDate, endDate, isNonWorkingDay = isWeekend) {
|
|
24
47
|
const headers = [];
|
|
25
48
|
let current = startDate;
|
|
26
49
|
while (current.isBefore(endDate) || current.isSame(endDate, "day")) {
|
|
27
|
-
const dayOfWeek = current.day();
|
|
28
50
|
headers.push({
|
|
29
51
|
date: current,
|
|
30
52
|
label: current.format("D"),
|
|
31
|
-
isWeekend:
|
|
53
|
+
isWeekend: isNonWorkingDay(current.toDate())
|
|
32
54
|
});
|
|
33
55
|
current = current.add(1, "day");
|
|
34
56
|
}
|
|
@@ -37,7 +59,7 @@ function generateDayHeaders(startDate, endDate) {
|
|
|
37
59
|
function startOfWeek(date, weekStart = 1) {
|
|
38
60
|
return date.subtract((date.day() - weekStart + 7) % 7, "day").startOf("day");
|
|
39
61
|
}
|
|
40
|
-
function generateWeekHeaders(startDate, endDate, weekStart = 1) {
|
|
62
|
+
function generateWeekHeaders(startDate, endDate, weekStart = 1, locale = "en") {
|
|
41
63
|
const weeks = [];
|
|
42
64
|
let current = startOfWeek(startDate, weekStart);
|
|
43
65
|
while (current.isBefore(endDate)) {
|
|
@@ -45,7 +67,7 @@ function generateWeekHeaders(startDate, endDate, weekStart = 1) {
|
|
|
45
67
|
const actualEnd = weekEnd.isAfter(endDate) ? endDate : weekEnd;
|
|
46
68
|
const actualStart = current.isBefore(startDate) ? startDate : current;
|
|
47
69
|
const days = actualEnd.diff(actualStart, "day") + 1;
|
|
48
|
-
const label = actualStart
|
|
70
|
+
const label = formatDate(actualStart, locale, { month: "short" });
|
|
49
71
|
const weekNumber = current.add(weekStart === 0 ? 1 : 0, "day").isoWeek();
|
|
50
72
|
weeks.push({
|
|
51
73
|
startDate: actualStart,
|
|
@@ -58,7 +80,7 @@ function generateWeekHeaders(startDate, endDate, weekStart = 1) {
|
|
|
58
80
|
}
|
|
59
81
|
return weeks;
|
|
60
82
|
}
|
|
61
|
-
function calculateTimelineBounds(tasks, startDate, endDate, padding = 7) {
|
|
83
|
+
function calculateTimelineBounds(tasks, startDate, endDate, padding = 7, isNonWorkingDay) {
|
|
62
84
|
const normalize = (date) => dayjs(new Date(date.getFullYear(), date.getMonth(), date.getDate()));
|
|
63
85
|
if (startDate && endDate) {
|
|
64
86
|
return { start: normalize(startDate), end: normalize(endDate) };
|
|
@@ -71,10 +93,10 @@ function calculateTimelineBounds(tasks, startDate, endDate, padding = 7) {
|
|
|
71
93
|
};
|
|
72
94
|
}
|
|
73
95
|
let earliest = dayjs(tasks[0].startDate);
|
|
74
|
-
let latest = getTaskEndDate(tasks[0].startDate, tasks[0].duration);
|
|
96
|
+
let latest = getTaskEndDate(tasks[0].startDate, tasks[0].duration, isNonWorkingDay);
|
|
75
97
|
tasks.forEach((task) => {
|
|
76
98
|
const taskStart = dayjs(task.startDate);
|
|
77
|
-
const taskEnd = getTaskEndDate(task.startDate, task.duration);
|
|
99
|
+
const taskEnd = getTaskEndDate(task.startDate, task.duration, isNonWorkingDay);
|
|
78
100
|
if (taskStart.isBefore(earliest)) {
|
|
79
101
|
earliest = taskStart;
|
|
80
102
|
}
|
|
@@ -83,7 +105,11 @@ function calculateTimelineBounds(tasks, startDate, endDate, padding = 7) {
|
|
|
83
105
|
}
|
|
84
106
|
if (task.baseline) {
|
|
85
107
|
const baseStart = dayjs(task.baseline.startDate);
|
|
86
|
-
const baseEnd = getTaskEndDate(
|
|
108
|
+
const baseEnd = getTaskEndDate(
|
|
109
|
+
task.baseline.startDate,
|
|
110
|
+
task.baseline.duration,
|
|
111
|
+
isNonWorkingDay
|
|
112
|
+
);
|
|
87
113
|
if (baseStart.isBefore(earliest)) {
|
|
88
114
|
earliest = baseStart;
|
|
89
115
|
}
|
|
@@ -97,11 +123,83 @@ function calculateTimelineBounds(tasks, startDate, endDate, padding = 7) {
|
|
|
97
123
|
end: endDate ? normalize(endDate) : latest.add(padding, "day")
|
|
98
124
|
};
|
|
99
125
|
}
|
|
100
|
-
function formatTaskDate(date) {
|
|
101
|
-
return
|
|
126
|
+
function formatTaskDate(date, locale = "en") {
|
|
127
|
+
return formatDate(date, locale, { month: "short", day: "numeric", year: "numeric" });
|
|
128
|
+
}
|
|
129
|
+
function snapToWorkingDay(date, step, isNonWorkingDay) {
|
|
130
|
+
let d = date;
|
|
131
|
+
for (let i = 0; i < 366 && isNonWorkingDay(d.toDate()); i++) {
|
|
132
|
+
d = d.add(step, "day");
|
|
133
|
+
}
|
|
134
|
+
return d;
|
|
135
|
+
}
|
|
136
|
+
function addWorkingDays(date, days, isNonWorkingDay) {
|
|
137
|
+
if (!isNonWorkingDay) {
|
|
138
|
+
return date.add(days, "day");
|
|
139
|
+
}
|
|
140
|
+
const step = days < 0 ? -1 : 1;
|
|
141
|
+
let d = snapToWorkingDay(date, step, isNonWorkingDay);
|
|
142
|
+
for (let left = Math.abs(days); left > 0; left--) {
|
|
143
|
+
d = snapToWorkingDay(d.add(step, "day"), step, isNonWorkingDay);
|
|
144
|
+
}
|
|
145
|
+
return d;
|
|
102
146
|
}
|
|
103
|
-
function
|
|
104
|
-
|
|
147
|
+
function countWorkingDays(start, end, isNonWorkingDay) {
|
|
148
|
+
let count = 0;
|
|
149
|
+
for (let d = start; !d.isAfter(end); d = d.add(1, "day")) {
|
|
150
|
+
if (!isNonWorkingDay(d.toDate())) {
|
|
151
|
+
count++;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return count;
|
|
155
|
+
}
|
|
156
|
+
function getTaskEndDate(startDate, duration, isNonWorkingDay) {
|
|
157
|
+
return addWorkingDays(dayjs(startDate), Math.max(0, duration - 1), isNonWorkingDay);
|
|
158
|
+
}
|
|
159
|
+
function getTaskSpan(startDate, duration, isNonWorkingDay) {
|
|
160
|
+
if (!isNonWorkingDay || duration <= 0) {
|
|
161
|
+
return duration;
|
|
162
|
+
}
|
|
163
|
+
return getTaskEndDate(startDate, duration, isNonWorkingDay).diff(dayjs(startDate), "day") + 1;
|
|
164
|
+
}
|
|
165
|
+
function shiftTask(task, action, days, isNonWorkingDay) {
|
|
166
|
+
const start = dayjs(task.startDate);
|
|
167
|
+
const format = (d) => d.format("YYYY-MM-DD");
|
|
168
|
+
if (action === "move") {
|
|
169
|
+
const moved2 = start.add(days, "day");
|
|
170
|
+
const snapped = isNonWorkingDay ? snapToWorkingDay(moved2, days < 0 ? -1 : 1, isNonWorkingDay) : moved2;
|
|
171
|
+
return { startDate: format(snapped), duration: task.duration };
|
|
172
|
+
}
|
|
173
|
+
if (!isNonWorkingDay) {
|
|
174
|
+
return action === "resize-end" ? { startDate: task.startDate, duration: Math.max(1, task.duration + days) } : (
|
|
175
|
+
// resize-start: shift start, keep the right edge (duration shrinks/grows by -days).
|
|
176
|
+
// Like the working-day branch, the start can never pass the end.
|
|
177
|
+
{
|
|
178
|
+
startDate: format(start.add(Math.min(days, task.duration - 1), "day")),
|
|
179
|
+
duration: Math.max(1, task.duration - days)
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const end = getTaskEndDate(task.startDate, task.duration, isNonWorkingDay);
|
|
184
|
+
if (action === "resize-end") {
|
|
185
|
+
const newEnd = end.add(days, "day");
|
|
186
|
+
return {
|
|
187
|
+
startDate: task.startDate,
|
|
188
|
+
duration: Math.max(1, countWorkingDays(start, newEnd, isNonWorkingDay))
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const moved = start.add(days, "day");
|
|
192
|
+
const newStart = snapToWorkingDay(moved.isAfter(end) ? end : moved, 1, isNonWorkingDay);
|
|
193
|
+
return {
|
|
194
|
+
startDate: format(newStart),
|
|
195
|
+
duration: Math.max(1, countWorkingDays(newStart, end, isNonWorkingDay))
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function normalizeDependency(dependency) {
|
|
199
|
+
return typeof dependency === "string" ? { taskId: dependency, type: "FS", lag: 0 } : { taskId: dependency.taskId, type: dependency.type ?? "FS", lag: dependency.lag ?? 0 };
|
|
200
|
+
}
|
|
201
|
+
function dependencyIds(task) {
|
|
202
|
+
return (task?.dependencies ?? []).map((dep) => normalizeDependency(dep).taskId);
|
|
105
203
|
}
|
|
106
204
|
function wouldCreateCycle(tasks, fromId, toId) {
|
|
107
205
|
if (fromId === toId) {
|
|
@@ -119,11 +217,11 @@ function wouldCreateCycle(tasks, fromId, toId) {
|
|
|
119
217
|
continue;
|
|
120
218
|
}
|
|
121
219
|
visited.add(id);
|
|
122
|
-
stack.push(...byId.get(id)
|
|
220
|
+
stack.push(...dependencyIds(byId.get(id)));
|
|
123
221
|
}
|
|
124
222
|
return false;
|
|
125
223
|
}
|
|
126
|
-
function buildTaskTree(tasks, collapsedIds) {
|
|
224
|
+
function buildTaskTree(tasks, collapsedIds, isNonWorkingDay) {
|
|
127
225
|
const ids = new Set(tasks.map((t) => t.id));
|
|
128
226
|
const parentOf = /* @__PURE__ */ new Map();
|
|
129
227
|
tasks.forEach((t) => {
|
|
@@ -165,7 +263,7 @@ function buildTaskTree(tasks, collapsedIds) {
|
|
|
165
263
|
const start = dayjs(task.startDate);
|
|
166
264
|
env = {
|
|
167
265
|
start,
|
|
168
|
-
end: start.add(task.duration, "day"),
|
|
266
|
+
end: start.add(getTaskSpan(task.startDate, task.duration, isNonWorkingDay), "day"),
|
|
169
267
|
duration: task.duration,
|
|
170
268
|
progress: task.progress
|
|
171
269
|
};
|
|
@@ -187,7 +285,8 @@ function buildTaskTree(tasks, collapsedIds) {
|
|
|
187
285
|
env = {
|
|
188
286
|
start,
|
|
189
287
|
end,
|
|
190
|
-
|
|
288
|
+
// `end` is exclusive, hence the day subtracted for the inclusive count.
|
|
289
|
+
duration: isNonWorkingDay ? countWorkingDays(start, end.subtract(1, "day"), isNonWorkingDay) : end.diff(start, "day"),
|
|
191
290
|
progress: total > 0 ? Math.round(weighted / total) : 0
|
|
192
291
|
};
|
|
193
292
|
}
|
|
@@ -204,6 +303,7 @@ function buildTaskTree(tasks, collapsedIds) {
|
|
|
204
303
|
hasChildren: children.length > 0,
|
|
205
304
|
startDate: env.start.format("YYYY-MM-DD"),
|
|
206
305
|
duration: env.duration,
|
|
306
|
+
span: env.end.diff(env.start, "day"),
|
|
207
307
|
progress: env.progress
|
|
208
308
|
});
|
|
209
309
|
if (!collapsedIds.has(task.id)) {
|
|
@@ -222,48 +322,35 @@ function getEffectiveTask(row) {
|
|
|
222
322
|
function getCriticalPath(tasks) {
|
|
223
323
|
const leafTasks = buildTaskTree(tasks, /* @__PURE__ */ new Set()).filter((row) => !row.hasChildren).map((row) => row.task);
|
|
224
324
|
const byId = new Map(leafTasks.map((t) => [t.id, t]));
|
|
225
|
-
const
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
for (const depId of byId.get(id).dependencies ?? []) {
|
|
235
|
-
if (byId.has(depId) && !visiting.has(depId)) {
|
|
236
|
-
deps.push(depId);
|
|
237
|
-
resolveDeps(depId);
|
|
325
|
+
const successors = buildSuccessorMap(leafTasks);
|
|
326
|
+
const incoming = new Map(leafTasks.map((t) => [t.id, []]));
|
|
327
|
+
const outgoing = new Map(leafTasks.map((t) => [t.id, []]));
|
|
328
|
+
leafTasks.forEach(
|
|
329
|
+
(task) => (task.dependencies ?? []).forEach((raw) => {
|
|
330
|
+
const edge = { ...normalizeDependency(raw), to: task.id };
|
|
331
|
+
if (successors.get(edge.taskId)?.includes(task.id)) {
|
|
332
|
+
incoming.get(task.id).push(edge);
|
|
333
|
+
outgoing.get(edge.taskId).push(edge);
|
|
238
334
|
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
const earliestFinish = /* @__PURE__ */ new Map();
|
|
246
|
-
const getEF = (id) => {
|
|
247
|
-
const cached = earliestFinish.get(id);
|
|
335
|
+
})
|
|
336
|
+
);
|
|
337
|
+
const duration = (id) => byId.get(id).duration;
|
|
338
|
+
const earliestStart = /* @__PURE__ */ new Map();
|
|
339
|
+
const getES = (id) => {
|
|
340
|
+
const cached = earliestStart.get(id);
|
|
248
341
|
if (cached !== void 0) {
|
|
249
342
|
return cached;
|
|
250
343
|
}
|
|
251
344
|
let es = 0;
|
|
252
|
-
for (const
|
|
253
|
-
|
|
345
|
+
for (const edge of incoming.get(id)) {
|
|
346
|
+
const from = getES(edge.taskId) + (edge.type[0] === "F" ? duration(edge.taskId) : 0);
|
|
347
|
+
es = Math.max(es, from + edge.lag - (edge.type[1] === "F" ? duration(id) : 0));
|
|
254
348
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
return ef;
|
|
349
|
+
earliestStart.set(id, es);
|
|
350
|
+
return es;
|
|
258
351
|
};
|
|
259
|
-
leafTasks.
|
|
352
|
+
const earliestFinish = new Map(leafTasks.map((t) => [t.id, getES(t.id) + t.duration]));
|
|
260
353
|
const projectEnd = leafTasks.length === 0 ? 0 : Math.max(...earliestFinish.values());
|
|
261
|
-
const successors = /* @__PURE__ */ new Map();
|
|
262
|
-
leafTasks.forEach((t) => {
|
|
263
|
-
dagDeps.get(t.id).forEach((depId) => {
|
|
264
|
-
successors.set(depId, [...successors.get(depId) ?? [], t.id]);
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
354
|
const latestFinish = /* @__PURE__ */ new Map();
|
|
268
355
|
const getLF = (id) => {
|
|
269
356
|
const cached = latestFinish.get(id);
|
|
@@ -271,8 +358,9 @@ function getCriticalPath(tasks) {
|
|
|
271
358
|
return cached;
|
|
272
359
|
}
|
|
273
360
|
let lf = projectEnd;
|
|
274
|
-
for (const
|
|
275
|
-
|
|
361
|
+
for (const edge of outgoing.get(id)) {
|
|
362
|
+
const to = getLF(edge.to) - (edge.type[1] === "S" ? duration(edge.to) : 0);
|
|
363
|
+
lf = Math.min(lf, to - edge.lag + (edge.type[0] === "S" ? duration(id) : 0));
|
|
276
364
|
}
|
|
277
365
|
latestFinish.set(id, lf);
|
|
278
366
|
return lf;
|
|
@@ -288,29 +376,10 @@ function getCriticalPath(tasks) {
|
|
|
288
376
|
}
|
|
289
377
|
function buildSuccessorMap(tasks) {
|
|
290
378
|
const successors = /* @__PURE__ */ new Map();
|
|
291
|
-
const
|
|
292
|
-
const dependsOn = (fromId, toId) => {
|
|
293
|
-
if (fromId === toId) {
|
|
294
|
-
return true;
|
|
295
|
-
}
|
|
296
|
-
const seen = /* @__PURE__ */ new Set();
|
|
297
|
-
const stack = [fromId];
|
|
298
|
-
while (stack.length > 0) {
|
|
299
|
-
const id = stack.pop();
|
|
300
|
-
if (id === toId) {
|
|
301
|
-
return true;
|
|
302
|
-
}
|
|
303
|
-
if (seen.has(id)) {
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
seen.add(id);
|
|
307
|
-
stack.push(...byId.get(id)?.dependencies ?? []);
|
|
308
|
-
}
|
|
309
|
-
return false;
|
|
310
|
-
};
|
|
379
|
+
const ids = new Set(tasks.map((t) => t.id));
|
|
311
380
|
tasks.forEach((task) => {
|
|
312
|
-
(task
|
|
313
|
-
if (!
|
|
381
|
+
dependencyIds(task).forEach((depId) => {
|
|
382
|
+
if (!ids.has(depId) || wouldCreateCycle(tasks, depId, task.id)) {
|
|
314
383
|
return;
|
|
315
384
|
}
|
|
316
385
|
successors.set(depId, [...successors.get(depId) ?? [], task.id]);
|
|
@@ -318,7 +387,7 @@ function buildSuccessorMap(tasks) {
|
|
|
318
387
|
});
|
|
319
388
|
return successors;
|
|
320
389
|
}
|
|
321
|
-
function applyAutoSchedule(tasks, movedTaskId) {
|
|
390
|
+
function applyAutoSchedule(tasks, movedTaskId, isNonWorkingDay) {
|
|
322
391
|
const byId = new Map(tasks.map((t) => [t.id, t]));
|
|
323
392
|
const successors = buildSuccessorMap(tasks);
|
|
324
393
|
const next = new Map(byId);
|
|
@@ -344,14 +413,20 @@ function applyAutoSchedule(tasks, movedTaskId) {
|
|
|
344
413
|
continue;
|
|
345
414
|
}
|
|
346
415
|
let earliestStart = null;
|
|
347
|
-
for (const
|
|
348
|
-
const
|
|
416
|
+
for (const raw of task.dependencies ?? []) {
|
|
417
|
+
const { taskId, type, lag } = normalizeDependency(raw);
|
|
418
|
+
const dep = next.get(taskId);
|
|
349
419
|
if (!dep) {
|
|
350
420
|
continue;
|
|
351
421
|
}
|
|
352
|
-
const
|
|
353
|
-
|
|
354
|
-
|
|
422
|
+
const from = type[0] === "F" ? getTaskEndDate(dep.startDate, dep.duration, isNonWorkingDay) : dayjs(dep.startDate);
|
|
423
|
+
const offset = lag + (type === "FS" ? 1 : 0) - (type === "SF" ? 1 : 0);
|
|
424
|
+
let minStart = addWorkingDays(from, offset, isNonWorkingDay);
|
|
425
|
+
if (type[1] === "F") {
|
|
426
|
+
minStart = addWorkingDays(minStart, -Math.max(0, task.duration - 1), isNonWorkingDay);
|
|
427
|
+
}
|
|
428
|
+
if (!earliestStart || minStart.isAfter(earliestStart)) {
|
|
429
|
+
earliestStart = minStart;
|
|
355
430
|
}
|
|
356
431
|
}
|
|
357
432
|
if (!earliestStart) {
|
|
@@ -375,19 +450,26 @@ function visibleRowRange(scrollTop, viewportHeight, rowHeight, rowCount, oversca
|
|
|
375
450
|
return [Math.min(first, last), last];
|
|
376
451
|
}
|
|
377
452
|
|
|
453
|
+
exports.addWorkingDays = addWorkingDays;
|
|
378
454
|
exports.applyAutoSchedule = applyAutoSchedule;
|
|
455
|
+
exports.barAnchors = barAnchors;
|
|
379
456
|
exports.buildSuccessorMap = buildSuccessorMap;
|
|
380
457
|
exports.buildTaskTree = buildTaskTree;
|
|
381
458
|
exports.calculateTimelineBounds = calculateTimelineBounds;
|
|
382
459
|
exports.dateToPixel = dateToPixel;
|
|
383
460
|
exports.durationToPixels = durationToPixels;
|
|
461
|
+
exports.formatDate = formatDate;
|
|
384
462
|
exports.formatTaskDate = formatTaskDate;
|
|
385
463
|
exports.generateDayHeaders = generateDayHeaders;
|
|
386
464
|
exports.generateWeekHeaders = generateWeekHeaders;
|
|
387
465
|
exports.getCriticalPath = getCriticalPath;
|
|
388
466
|
exports.getEffectiveTask = getEffectiveTask;
|
|
389
467
|
exports.getTaskEndDate = getTaskEndDate;
|
|
468
|
+
exports.getTaskSpan = getTaskSpan;
|
|
469
|
+
exports.isWeekend = isWeekend;
|
|
470
|
+
exports.normalizeDependency = normalizeDependency;
|
|
390
471
|
exports.pixelToDate = pixelToDate;
|
|
472
|
+
exports.shiftTask = shiftTask;
|
|
391
473
|
exports.snapToGrid = snapToGrid;
|
|
392
474
|
exports.startOfWeek = startOfWeek;
|
|
393
475
|
exports.visibleRowRange = visibleRowRange;
|