gantt-task-react-v 1.6.17 → 1.6.19
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.
|
@@ -10283,10 +10283,33 @@ function formatForInput(value, editType) {
|
|
|
10283
10283
|
return "";
|
|
10284
10284
|
if (editType === "date") {
|
|
10285
10285
|
if (value instanceof Date) {
|
|
10286
|
-
return value.toISOString().slice(0, 10);
|
|
10286
|
+
return Number.isNaN(value.getTime()) ? "" : value.toISOString().slice(0, 10);
|
|
10287
10287
|
}
|
|
10288
|
-
if (typeof value === "
|
|
10288
|
+
if (typeof value === "number") {
|
|
10289
|
+
const d = new Date(value);
|
|
10290
|
+
return Number.isNaN(d.getTime()) ? "" : d.toISOString().slice(0, 10);
|
|
10291
|
+
}
|
|
10292
|
+
if (typeof value === "string") {
|
|
10293
|
+
const d = new Date(value);
|
|
10294
|
+
if (!Number.isNaN(d.getTime())) {
|
|
10295
|
+
return d.toISOString().slice(0, 10);
|
|
10296
|
+
}
|
|
10289
10297
|
return value.slice(0, 10);
|
|
10298
|
+
}
|
|
10299
|
+
return "";
|
|
10300
|
+
}
|
|
10301
|
+
if (editType === "number") {
|
|
10302
|
+
if (typeof value === "number") {
|
|
10303
|
+
return Number.isNaN(value) ? "" : String(value);
|
|
10304
|
+
}
|
|
10305
|
+
if (typeof value === "string") {
|
|
10306
|
+
const n = Number(value);
|
|
10307
|
+
return Number.isNaN(n) ? value : String(n);
|
|
10308
|
+
}
|
|
10309
|
+
return String(value);
|
|
10310
|
+
}
|
|
10311
|
+
if (editType === "select") {
|
|
10312
|
+
return String(value);
|
|
10290
10313
|
}
|
|
10291
10314
|
return String(value);
|
|
10292
10315
|
}
|
|
@@ -10498,9 +10521,26 @@ const TaskListTableRowInner = forwardRef(
|
|
|
10498
10521
|
const t = columnData.task;
|
|
10499
10522
|
if (c.getValueFromTask)
|
|
10500
10523
|
return c.getValueFromTask(t);
|
|
10501
|
-
if (t.type !== "empty" && t.payload
|
|
10502
|
-
|
|
10503
|
-
|
|
10524
|
+
if (t.type !== "empty" && t.payload) {
|
|
10525
|
+
if (c.id in t.payload)
|
|
10526
|
+
return t.payload[c.id];
|
|
10527
|
+
}
|
|
10528
|
+
if (c.id in t)
|
|
10529
|
+
return t[c.id];
|
|
10530
|
+
if (t.type !== "empty") {
|
|
10531
|
+
const task2 = t;
|
|
10532
|
+
const aliasMap = {
|
|
10533
|
+
startDate: task2.start,
|
|
10534
|
+
finishDate: task2.end,
|
|
10535
|
+
endDate: task2.end,
|
|
10536
|
+
duration: task2.end && task2.start ? Math.round(
|
|
10537
|
+
(task2.end.getTime() - task2.start.getTime()) / (1e3 * 60 * 60 * 24)
|
|
10538
|
+
) : void 0
|
|
10539
|
+
};
|
|
10540
|
+
if (c.id in aliasMap)
|
|
10541
|
+
return aliasMap[c.id];
|
|
10542
|
+
}
|
|
10543
|
+
return void 0;
|
|
10504
10544
|
};
|
|
10505
10545
|
const handleStartEdit = () => {
|
|
10506
10546
|
if (col.editable && onTaskInlineEdit) {
|
|
@@ -11340,322 +11380,544 @@ const styles$d = {
|
|
|
11340
11380
|
ganttToday,
|
|
11341
11381
|
ganttTodayCircle
|
|
11342
11382
|
};
|
|
11343
|
-
const
|
|
11344
|
-
additionalLeftSpace,
|
|
11345
|
-
distances: { columnWidth },
|
|
11346
|
-
ganttFullHeight,
|
|
11347
|
-
isUnknownDates,
|
|
11348
|
-
rtl,
|
|
11349
|
-
startDate,
|
|
11350
|
-
viewMode,
|
|
11351
|
-
showTodayLine = true,
|
|
11352
|
-
showDataDateLine = false,
|
|
11353
|
-
dataDate = null,
|
|
11354
|
-
todayColor = null,
|
|
11355
|
-
dataDateColor = null,
|
|
11356
|
-
todayLabel = "Today",
|
|
11357
|
-
dataDateLabel = "Data Date"
|
|
11358
|
-
}) => {
|
|
11359
|
-
const todayElement = useMemo(() => {
|
|
11360
|
-
if (isUnknownDates || !showTodayLine) {
|
|
11361
|
-
return null;
|
|
11362
|
-
}
|
|
11363
|
-
const today = /* @__PURE__ */ new Date();
|
|
11364
|
-
const todayIndex = getDatesDiff(today, startDate, viewMode);
|
|
11365
|
-
const extraMultiplier = () => {
|
|
11366
|
-
switch (viewMode) {
|
|
11367
|
-
case ViewMode.Week: {
|
|
11368
|
-
const percent = today.getDay() / 7;
|
|
11369
|
-
return 1 + percent * 0.2;
|
|
11370
|
-
}
|
|
11371
|
-
case ViewMode.Month: {
|
|
11372
|
-
const dayInMonth = today.getDate();
|
|
11373
|
-
const maxDaysInMonth = getDaysInMonth(
|
|
11374
|
-
today.getMonth(),
|
|
11375
|
-
today.getFullYear()
|
|
11376
|
-
);
|
|
11377
|
-
const percent = dayInMonth / maxDaysInMonth;
|
|
11378
|
-
return 1 + percent * 0.5;
|
|
11379
|
-
}
|
|
11380
|
-
case ViewMode.Year: {
|
|
11381
|
-
const percent = today.getMonth() / 12;
|
|
11382
|
-
return 1 + percent * 0.5;
|
|
11383
|
-
}
|
|
11384
|
-
default:
|
|
11385
|
-
return 1;
|
|
11386
|
-
}
|
|
11387
|
-
};
|
|
11388
|
-
const tickX = todayIndex * columnWidth * extraMultiplier();
|
|
11389
|
-
const x = rtl ? tickX + columnWidth : tickX;
|
|
11390
|
-
const color = todayColor || "var(--gantt-calendar-today-color)";
|
|
11391
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11392
|
-
/* @__PURE__ */ jsx(
|
|
11393
|
-
"rect",
|
|
11394
|
-
{
|
|
11395
|
-
x: additionalLeftSpace + x,
|
|
11396
|
-
y: 0,
|
|
11397
|
-
width: 2,
|
|
11398
|
-
height: ganttFullHeight,
|
|
11399
|
-
fill: color
|
|
11400
|
-
}
|
|
11401
|
-
),
|
|
11402
|
-
/* @__PURE__ */ jsx(
|
|
11403
|
-
"circle",
|
|
11404
|
-
{
|
|
11405
|
-
className: styles$d.ganttTodayCircle,
|
|
11406
|
-
cx: x + 1,
|
|
11407
|
-
cy: 6,
|
|
11408
|
-
r: 6,
|
|
11409
|
-
fill: color
|
|
11410
|
-
}
|
|
11411
|
-
),
|
|
11412
|
-
/* @__PURE__ */ jsx(
|
|
11413
|
-
"text",
|
|
11414
|
-
{
|
|
11415
|
-
x: additionalLeftSpace + x + 8,
|
|
11416
|
-
y: 10,
|
|
11417
|
-
fill: color,
|
|
11418
|
-
fontSize: 12,
|
|
11419
|
-
fontWeight: 600,
|
|
11420
|
-
children: todayLabel
|
|
11421
|
-
}
|
|
11422
|
-
)
|
|
11423
|
-
] });
|
|
11424
|
-
}, [
|
|
11425
|
-
additionalLeftSpace,
|
|
11426
|
-
columnWidth,
|
|
11427
|
-
ganttFullHeight,
|
|
11428
|
-
isUnknownDates,
|
|
11429
|
-
rtl,
|
|
11430
|
-
startDate,
|
|
11431
|
-
viewMode,
|
|
11432
|
-
showTodayLine,
|
|
11433
|
-
todayColor,
|
|
11434
|
-
todayLabel
|
|
11435
|
-
]);
|
|
11436
|
-
const dataDateElement = useMemo(() => {
|
|
11437
|
-
if (!showDataDateLine || !dataDate) {
|
|
11438
|
-
return null;
|
|
11439
|
-
}
|
|
11440
|
-
const dataIndex = getDatesDiff(dataDate, startDate, viewMode);
|
|
11441
|
-
const extraMultiplier = () => {
|
|
11442
|
-
switch (viewMode) {
|
|
11443
|
-
case ViewMode.Week: {
|
|
11444
|
-
const percent = dataDate.getDay() / 7;
|
|
11445
|
-
return 1 + percent * 0.2;
|
|
11446
|
-
}
|
|
11447
|
-
case ViewMode.Month: {
|
|
11448
|
-
const dayInMonth = dataDate.getDate();
|
|
11449
|
-
const maxDaysInMonth = getDaysInMonth(
|
|
11450
|
-
dataDate.getMonth(),
|
|
11451
|
-
dataDate.getFullYear()
|
|
11452
|
-
);
|
|
11453
|
-
const percent = dayInMonth / maxDaysInMonth;
|
|
11454
|
-
return 1 + percent * 0.5;
|
|
11455
|
-
}
|
|
11456
|
-
case ViewMode.Year: {
|
|
11457
|
-
const percent = dataDate.getMonth() / 12;
|
|
11458
|
-
return 1 + percent * 0.5;
|
|
11459
|
-
}
|
|
11460
|
-
default:
|
|
11461
|
-
return 1;
|
|
11462
|
-
}
|
|
11463
|
-
};
|
|
11464
|
-
const tickX = dataIndex * columnWidth * extraMultiplier();
|
|
11465
|
-
const x = rtl ? tickX + columnWidth : tickX;
|
|
11466
|
-
const color = dataDateColor || "var(--gantt-calendar-today-color)";
|
|
11467
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11468
|
-
/* @__PURE__ */ jsx(
|
|
11469
|
-
"rect",
|
|
11470
|
-
{
|
|
11471
|
-
x: additionalLeftSpace + x,
|
|
11472
|
-
y: 0,
|
|
11473
|
-
width: 2,
|
|
11474
|
-
height: ganttFullHeight,
|
|
11475
|
-
fill: color,
|
|
11476
|
-
opacity: 0.9
|
|
11477
|
-
}
|
|
11478
|
-
),
|
|
11479
|
-
/* @__PURE__ */ jsx(
|
|
11480
|
-
"circle",
|
|
11481
|
-
{
|
|
11482
|
-
className: styles$d.ganttTodayCircle,
|
|
11483
|
-
cx: x + 1,
|
|
11484
|
-
cy: 6,
|
|
11485
|
-
r: 6,
|
|
11486
|
-
fill: color
|
|
11487
|
-
}
|
|
11488
|
-
),
|
|
11489
|
-
/* @__PURE__ */ jsx(
|
|
11490
|
-
"text",
|
|
11491
|
-
{
|
|
11492
|
-
x: additionalLeftSpace + x + 8,
|
|
11493
|
-
y: 10,
|
|
11494
|
-
fill: color,
|
|
11495
|
-
fontSize: 12,
|
|
11496
|
-
fontWeight: 600,
|
|
11497
|
-
children: dataDateLabel || "Data Date"
|
|
11498
|
-
}
|
|
11499
|
-
)
|
|
11500
|
-
] });
|
|
11501
|
-
}, [
|
|
11502
|
-
additionalLeftSpace,
|
|
11503
|
-
columnWidth,
|
|
11504
|
-
ganttFullHeight,
|
|
11505
|
-
rtl,
|
|
11506
|
-
startDate,
|
|
11507
|
-
viewMode,
|
|
11508
|
-
showDataDateLine,
|
|
11509
|
-
dataDate,
|
|
11510
|
-
dataDateColor,
|
|
11511
|
-
dataDateLabel
|
|
11512
|
-
]);
|
|
11513
|
-
return /* @__PURE__ */ jsxs("g", { className: "today", children: [
|
|
11514
|
-
dataDateElement,
|
|
11515
|
-
todayElement
|
|
11516
|
-
] });
|
|
11517
|
-
};
|
|
11518
|
-
const GanttToday = memo(GanttTodayInner);
|
|
11519
|
-
const calendarBottomText = "_calendarBottomText_15t8b_1";
|
|
11520
|
-
const calendarTopTick = "_calendarTopTick_15t8b_25";
|
|
11521
|
-
const calendarTopText = "_calendarTopText_15t8b_35";
|
|
11522
|
-
const calendarHeader = "_calendarHeader_15t8b_61";
|
|
11523
|
-
const calendar = "_calendar_15t8b_1";
|
|
11524
|
-
const calendarDragging$1 = "_calendarDragging_15t8b_85";
|
|
11525
|
-
const styles$c = {
|
|
11526
|
-
calendarBottomText,
|
|
11527
|
-
calendarTopTick,
|
|
11528
|
-
calendarTopText,
|
|
11529
|
-
calendarHeader,
|
|
11530
|
-
calendar,
|
|
11531
|
-
calendarDragging: calendarDragging$1
|
|
11532
|
-
};
|
|
11533
|
-
const TopPartOfCalendar = ({
|
|
11534
|
-
value,
|
|
11535
|
-
x1Line,
|
|
11536
|
-
y1Line,
|
|
11537
|
-
y2Line,
|
|
11538
|
-
xText,
|
|
11539
|
-
yText,
|
|
11540
|
-
language
|
|
11541
|
-
}) => {
|
|
11542
|
-
const { t, i18n } = useTranslation();
|
|
11543
|
-
useEffect(() => {
|
|
11544
|
-
if (language) {
|
|
11545
|
-
i18n.changeLanguage(language);
|
|
11546
|
-
}
|
|
11547
|
-
}, []);
|
|
11548
|
-
return /* @__PURE__ */ jsxs("g", { className: "calendarTop", children: [
|
|
11549
|
-
/* @__PURE__ */ jsx(
|
|
11550
|
-
"line",
|
|
11551
|
-
{
|
|
11552
|
-
x1: x1Line,
|
|
11553
|
-
y1: y1Line,
|
|
11554
|
-
x2: x1Line,
|
|
11555
|
-
y2: y2Line,
|
|
11556
|
-
className: styles$c.calendarTopTick
|
|
11557
|
-
}
|
|
11558
|
-
),
|
|
11559
|
-
value !== null && /* @__PURE__ */ jsx("text", { y: yText - 4, x: xText, className: styles$c.calendarTopText, children: value.toString().split(",")[1] ? t(value.toString().split(",")[0]) + "," + value.toString().split(",")[1] : value.toString().length >= 3 ? t(value.toString()) : value })
|
|
11560
|
-
] });
|
|
11561
|
-
};
|
|
11562
|
-
const defaultRenderBottomHeader = (date, viewMode, dateSetup, index2, isUnknownDates) => {
|
|
11563
|
-
if (isUnknownDates) {
|
|
11564
|
-
const {
|
|
11565
|
-
dateLocale: { formatDistance: formatDistance2 },
|
|
11566
|
-
preStepsCount
|
|
11567
|
-
} = dateSetup;
|
|
11568
|
-
const offsetFromStart = index2 - preStepsCount;
|
|
11569
|
-
if (offsetFromStart === 0) {
|
|
11570
|
-
return "0";
|
|
11571
|
-
}
|
|
11572
|
-
let value = "";
|
|
11573
|
-
if (!formatDistance2) {
|
|
11574
|
-
value = `${offsetFromStart}`;
|
|
11575
|
-
} else {
|
|
11576
|
-
switch (viewMode) {
|
|
11577
|
-
case ViewMode.Year:
|
|
11578
|
-
value = formatDistance2("xYears", offsetFromStart);
|
|
11579
|
-
break;
|
|
11580
|
-
case ViewMode.Month:
|
|
11581
|
-
value = formatDistance2("xMonths", offsetFromStart);
|
|
11582
|
-
break;
|
|
11583
|
-
case ViewMode.Week:
|
|
11584
|
-
value = formatDistance2("xWeeks", offsetFromStart);
|
|
11585
|
-
break;
|
|
11586
|
-
case ViewMode.Day:
|
|
11587
|
-
value = formatDistance2("xDays", offsetFromStart);
|
|
11588
|
-
break;
|
|
11589
|
-
case ViewMode.QuarterDay:
|
|
11590
|
-
value = formatDistance2("xHours", offsetFromStart * 6);
|
|
11591
|
-
break;
|
|
11592
|
-
case ViewMode.HalfDay:
|
|
11593
|
-
value = formatDistance2("xHours", offsetFromStart * 12);
|
|
11594
|
-
break;
|
|
11595
|
-
case ViewMode.Hour:
|
|
11596
|
-
value = formatDistance2("xHours", offsetFromStart);
|
|
11597
|
-
break;
|
|
11598
|
-
default:
|
|
11599
|
-
throw new Error("Unknown viewMode");
|
|
11600
|
-
}
|
|
11601
|
-
}
|
|
11602
|
-
if (offsetFromStart > 0) {
|
|
11603
|
-
return `+${value}`;
|
|
11604
|
-
}
|
|
11605
|
-
return value;
|
|
11606
|
-
}
|
|
11383
|
+
const getDateByOffset = (startDate, offset2, viewMode) => {
|
|
11607
11384
|
switch (viewMode) {
|
|
11608
|
-
case ViewMode.Year:
|
|
11609
|
-
return date.getFullYear();
|
|
11610
|
-
case ViewMode.Month:
|
|
11611
|
-
try {
|
|
11612
|
-
return format(date, dateSetup.dateFormats.monthBottomHeaderFormat, {
|
|
11613
|
-
locale: dateSetup.dateLocale
|
|
11614
|
-
});
|
|
11615
|
-
} catch (e) {
|
|
11616
|
-
return date.toLocaleString("default", { month: "long" });
|
|
11617
|
-
}
|
|
11618
|
-
case ViewMode.Week:
|
|
11619
|
-
return dateSetup.dateFormats.weekBottomHeader(
|
|
11620
|
-
date,
|
|
11621
|
-
getWeekNumberISO8601(date),
|
|
11622
|
-
dateSetup.dateLocale
|
|
11623
|
-
);
|
|
11624
11385
|
case ViewMode.Day:
|
|
11625
|
-
|
|
11626
|
-
return format(date, dateSetup.dateFormats.dayBottomHeaderFormat, {
|
|
11627
|
-
locale: dateSetup.dateLocale
|
|
11628
|
-
});
|
|
11629
|
-
} catch (e) {
|
|
11630
|
-
return String(date.getDate());
|
|
11631
|
-
}
|
|
11632
|
-
case ViewMode.QuarterDay:
|
|
11386
|
+
return addDays(startDate, offset2);
|
|
11633
11387
|
case ViewMode.HalfDay:
|
|
11388
|
+
return addHours(startDate, offset2 * 12);
|
|
11389
|
+
case ViewMode.QuarterDay:
|
|
11390
|
+
return addHours(startDate, offset2 * 6);
|
|
11634
11391
|
case ViewMode.Hour:
|
|
11635
|
-
|
|
11636
|
-
|
|
11637
|
-
|
|
11638
|
-
|
|
11639
|
-
|
|
11640
|
-
|
|
11641
|
-
|
|
11392
|
+
return addHours(startDate, offset2);
|
|
11393
|
+
case ViewMode.Month:
|
|
11394
|
+
return addMonths(startDate, offset2);
|
|
11395
|
+
case ViewMode.Week:
|
|
11396
|
+
return addWeeks(startDate, offset2);
|
|
11397
|
+
case ViewMode.Year:
|
|
11398
|
+
return addYears(startDate, offset2);
|
|
11642
11399
|
default:
|
|
11643
|
-
throw new Error("Unknown
|
|
11400
|
+
throw new Error("Unknown view mode");
|
|
11644
11401
|
}
|
|
11645
11402
|
};
|
|
11646
|
-
const
|
|
11647
|
-
|
|
11648
|
-
|
|
11649
|
-
|
|
11650
|
-
|
|
11651
|
-
|
|
11652
|
-
|
|
11653
|
-
|
|
11403
|
+
const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
|
|
11404
|
+
const index2 = getDatesDiff(xDate, startDate, viewMode);
|
|
11405
|
+
const currentDate = getDateByOffset(startDate, index2, viewMode);
|
|
11406
|
+
const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
|
|
11407
|
+
const remainderMillis = xDate.getTime() - currentDate.getTime();
|
|
11408
|
+
const intervalDuration = nextDate.getTime() - currentDate.getTime();
|
|
11409
|
+
const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
|
|
11410
|
+
const result = index2 * columnWidth + percentOfInterval * columnWidth;
|
|
11411
|
+
return isNaN(result) || !isFinite(result) ? 0 : result;
|
|
11654
11412
|
};
|
|
11655
|
-
const
|
|
11656
|
-
|
|
11657
|
-
|
|
11658
|
-
|
|
11413
|
+
const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
|
|
11414
|
+
const index2 = getDatesDiff(xDate, startDate, viewMode);
|
|
11415
|
+
const currentDate = getDateByOffset(startDate, index2, viewMode);
|
|
11416
|
+
const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
|
|
11417
|
+
const remainderMillis = xDate.getTime() - currentDate.getTime();
|
|
11418
|
+
const intervalDuration = nextDate.getTime() - currentDate.getTime();
|
|
11419
|
+
const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
|
|
11420
|
+
const result = index2 * columnWidth + percentOfInterval * columnWidth;
|
|
11421
|
+
return isNaN(result) || !isFinite(result) ? 0 : result;
|
|
11422
|
+
};
|
|
11423
|
+
const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
|
|
11424
|
+
const safeTaskX1 = isNaN(taskX1) || !isFinite(taskX1) ? 0 : taskX1;
|
|
11425
|
+
const safeTaskX2 = isNaN(taskX2) || !isFinite(taskX2) ? 0 : taskX2;
|
|
11426
|
+
const safeProgress = isNaN(progress) || !isFinite(progress) ? 0 : progress;
|
|
11427
|
+
const progressWidth = Math.max(
|
|
11428
|
+
(safeTaskX2 - safeTaskX1) * safeProgress * 0.01,
|
|
11429
|
+
0
|
|
11430
|
+
);
|
|
11431
|
+
let progressX;
|
|
11432
|
+
if (rtl) {
|
|
11433
|
+
progressX = safeTaskX2 - progressWidth;
|
|
11434
|
+
} else {
|
|
11435
|
+
progressX = safeTaskX1;
|
|
11436
|
+
}
|
|
11437
|
+
return [progressWidth, progressX];
|
|
11438
|
+
};
|
|
11439
|
+
const getProgressPoint = (progressX, taskY, taskHeight) => {
|
|
11440
|
+
const point = [
|
|
11441
|
+
progressX - 5,
|
|
11442
|
+
taskY + taskHeight,
|
|
11443
|
+
progressX + 5,
|
|
11444
|
+
taskY + taskHeight,
|
|
11445
|
+
progressX,
|
|
11446
|
+
taskY + taskHeight - 8.66
|
|
11447
|
+
];
|
|
11448
|
+
return point.join(",");
|
|
11449
|
+
};
|
|
11450
|
+
const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
|
|
11451
|
+
const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
|
|
11452
|
+
const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
|
|
11453
|
+
const safeXStep = isNaN(xStep) || !isFinite(xStep) || xStep === 0 ? 1 : xStep;
|
|
11454
|
+
const safeTimeStep = isNaN(timeStep) || !isFinite(timeStep) ? 0 : timeStep;
|
|
11455
|
+
let newDate = new Date(
|
|
11456
|
+
(safeX - safeTaskX) / safeXStep * safeTimeStep + taskDate.getTime()
|
|
11457
|
+
);
|
|
11458
|
+
newDate = new Date(
|
|
11459
|
+
newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
|
|
11460
|
+
);
|
|
11461
|
+
return newDate;
|
|
11462
|
+
};
|
|
11463
|
+
const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
|
|
11464
|
+
let result;
|
|
11465
|
+
switch (selectedTask.type) {
|
|
11466
|
+
case "milestone":
|
|
11467
|
+
result = handleTaskBySVGMouseEventForMilestone(
|
|
11468
|
+
action,
|
|
11469
|
+
selectedTask,
|
|
11470
|
+
initialCoordinates,
|
|
11471
|
+
coordinates,
|
|
11472
|
+
xStep,
|
|
11473
|
+
timeStep
|
|
11474
|
+
);
|
|
11475
|
+
break;
|
|
11476
|
+
default:
|
|
11477
|
+
result = handleTaskBySVGMouseEventForBar(
|
|
11478
|
+
action,
|
|
11479
|
+
selectedTask,
|
|
11480
|
+
initialCoordinates,
|
|
11481
|
+
coordinates,
|
|
11482
|
+
xStep,
|
|
11483
|
+
timeStep,
|
|
11484
|
+
rtl
|
|
11485
|
+
);
|
|
11486
|
+
break;
|
|
11487
|
+
}
|
|
11488
|
+
return result;
|
|
11489
|
+
};
|
|
11490
|
+
const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
|
|
11491
|
+
const changedTask = { ...selectedTask };
|
|
11492
|
+
let isChanged = false;
|
|
11493
|
+
switch (action) {
|
|
11494
|
+
case "progress":
|
|
11495
|
+
isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
|
|
11496
|
+
if (isChanged) {
|
|
11497
|
+
changedTask.progress = Math.round(
|
|
11498
|
+
coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
|
|
11499
|
+
);
|
|
11500
|
+
}
|
|
11501
|
+
break;
|
|
11502
|
+
case "start": {
|
|
11503
|
+
isChanged = initialCoordinates.x1 !== coordinates.x1;
|
|
11504
|
+
if (isChanged) {
|
|
11505
|
+
if (rtl) {
|
|
11506
|
+
changedTask.end = dateByX(
|
|
11507
|
+
coordinates.x1,
|
|
11508
|
+
initialCoordinates.x1,
|
|
11509
|
+
selectedTask.end,
|
|
11510
|
+
xStep,
|
|
11511
|
+
timeStep
|
|
11512
|
+
);
|
|
11513
|
+
} else {
|
|
11514
|
+
changedTask.start = dateByX(
|
|
11515
|
+
coordinates.x1,
|
|
11516
|
+
initialCoordinates.x1,
|
|
11517
|
+
selectedTask.start,
|
|
11518
|
+
xStep,
|
|
11519
|
+
timeStep
|
|
11520
|
+
);
|
|
11521
|
+
}
|
|
11522
|
+
}
|
|
11523
|
+
break;
|
|
11524
|
+
}
|
|
11525
|
+
case "end": {
|
|
11526
|
+
isChanged = initialCoordinates.x2 !== coordinates.x2;
|
|
11527
|
+
if (isChanged) {
|
|
11528
|
+
if (rtl) {
|
|
11529
|
+
changedTask.start = dateByX(
|
|
11530
|
+
coordinates.x2,
|
|
11531
|
+
initialCoordinates.x2,
|
|
11532
|
+
selectedTask.start,
|
|
11533
|
+
xStep,
|
|
11534
|
+
timeStep
|
|
11535
|
+
);
|
|
11536
|
+
} else {
|
|
11537
|
+
changedTask.end = dateByX(
|
|
11538
|
+
coordinates.x2,
|
|
11539
|
+
initialCoordinates.x2,
|
|
11540
|
+
selectedTask.end,
|
|
11541
|
+
xStep,
|
|
11542
|
+
timeStep
|
|
11543
|
+
);
|
|
11544
|
+
}
|
|
11545
|
+
}
|
|
11546
|
+
break;
|
|
11547
|
+
}
|
|
11548
|
+
case "move": {
|
|
11549
|
+
isChanged = initialCoordinates.x1 !== coordinates.x1;
|
|
11550
|
+
if (isChanged) {
|
|
11551
|
+
if (rtl) {
|
|
11552
|
+
changedTask.end = dateByX(
|
|
11553
|
+
coordinates.x1,
|
|
11554
|
+
initialCoordinates.x1,
|
|
11555
|
+
selectedTask.end,
|
|
11556
|
+
xStep,
|
|
11557
|
+
timeStep
|
|
11558
|
+
);
|
|
11559
|
+
changedTask.start = dateByX(
|
|
11560
|
+
coordinates.x2,
|
|
11561
|
+
initialCoordinates.x2,
|
|
11562
|
+
selectedTask.start,
|
|
11563
|
+
xStep,
|
|
11564
|
+
timeStep
|
|
11565
|
+
);
|
|
11566
|
+
} else {
|
|
11567
|
+
changedTask.start = dateByX(
|
|
11568
|
+
coordinates.x1,
|
|
11569
|
+
initialCoordinates.x1,
|
|
11570
|
+
selectedTask.start,
|
|
11571
|
+
xStep,
|
|
11572
|
+
timeStep
|
|
11573
|
+
);
|
|
11574
|
+
changedTask.end = dateByX(
|
|
11575
|
+
coordinates.x2,
|
|
11576
|
+
initialCoordinates.x2,
|
|
11577
|
+
selectedTask.end,
|
|
11578
|
+
xStep,
|
|
11579
|
+
timeStep
|
|
11580
|
+
);
|
|
11581
|
+
}
|
|
11582
|
+
}
|
|
11583
|
+
break;
|
|
11584
|
+
}
|
|
11585
|
+
}
|
|
11586
|
+
return { isChanged, changedTask };
|
|
11587
|
+
};
|
|
11588
|
+
const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
|
|
11589
|
+
const changedTask = { ...selectedTask };
|
|
11590
|
+
const isChanged = coordinates.x1 !== initialCoordinates.x1;
|
|
11591
|
+
if (isChanged) {
|
|
11592
|
+
switch (action) {
|
|
11593
|
+
case "move": {
|
|
11594
|
+
changedTask.start = dateByX(
|
|
11595
|
+
coordinates.x1,
|
|
11596
|
+
initialCoordinates.x1,
|
|
11597
|
+
selectedTask.start,
|
|
11598
|
+
xStep,
|
|
11599
|
+
timeStep
|
|
11600
|
+
);
|
|
11601
|
+
changedTask.end = changedTask.start;
|
|
11602
|
+
break;
|
|
11603
|
+
}
|
|
11604
|
+
}
|
|
11605
|
+
}
|
|
11606
|
+
return { isChanged, changedTask };
|
|
11607
|
+
};
|
|
11608
|
+
const DateLine = ({
|
|
11609
|
+
config,
|
|
11610
|
+
additionalLeftSpace,
|
|
11611
|
+
startDate,
|
|
11612
|
+
viewMode,
|
|
11613
|
+
columnWidth,
|
|
11614
|
+
rtl,
|
|
11615
|
+
ganttFullHeight
|
|
11616
|
+
}) => {
|
|
11617
|
+
const tickX = taskXCoordinate(config.date, startDate, viewMode, columnWidth);
|
|
11618
|
+
const x = rtl ? tickX + columnWidth : tickX;
|
|
11619
|
+
const absX = additionalLeftSpace + x;
|
|
11620
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
11621
|
+
/* @__PURE__ */ jsx(
|
|
11622
|
+
"rect",
|
|
11623
|
+
{
|
|
11624
|
+
x: absX,
|
|
11625
|
+
y: 0,
|
|
11626
|
+
width: 2,
|
|
11627
|
+
height: ganttFullHeight,
|
|
11628
|
+
fill: config.color,
|
|
11629
|
+
strokeDasharray: config.dashArray
|
|
11630
|
+
}
|
|
11631
|
+
),
|
|
11632
|
+
/* @__PURE__ */ jsx(
|
|
11633
|
+
"circle",
|
|
11634
|
+
{
|
|
11635
|
+
className: styles$d.ganttTodayCircle,
|
|
11636
|
+
cx: absX + 1,
|
|
11637
|
+
cy: 6,
|
|
11638
|
+
r: 6,
|
|
11639
|
+
fill: config.color
|
|
11640
|
+
}
|
|
11641
|
+
),
|
|
11642
|
+
/* @__PURE__ */ jsx(
|
|
11643
|
+
"text",
|
|
11644
|
+
{
|
|
11645
|
+
x: absX + 10,
|
|
11646
|
+
y: 10,
|
|
11647
|
+
fill: config.color,
|
|
11648
|
+
fontSize: 12,
|
|
11649
|
+
fontWeight: 600,
|
|
11650
|
+
children: config.label
|
|
11651
|
+
}
|
|
11652
|
+
)
|
|
11653
|
+
] });
|
|
11654
|
+
};
|
|
11655
|
+
const GanttTodayInner = ({
|
|
11656
|
+
additionalLeftSpace,
|
|
11657
|
+
distances: { columnWidth },
|
|
11658
|
+
ganttFullHeight,
|
|
11659
|
+
isUnknownDates,
|
|
11660
|
+
rtl,
|
|
11661
|
+
startDate,
|
|
11662
|
+
viewMode,
|
|
11663
|
+
showTodayLine = true,
|
|
11664
|
+
showDataDateLine = false,
|
|
11665
|
+
showProjectStartLine = false,
|
|
11666
|
+
showProjectEndLine = false,
|
|
11667
|
+
dataDate = null,
|
|
11668
|
+
projectStartDate = null,
|
|
11669
|
+
projectEndDate = null,
|
|
11670
|
+
todayColor = null,
|
|
11671
|
+
dataDateColor = null,
|
|
11672
|
+
projectStartColor = null,
|
|
11673
|
+
projectEndColor = null,
|
|
11674
|
+
todayLabel = "Today",
|
|
11675
|
+
dataDateLabel = "Data Date",
|
|
11676
|
+
projectStartLabel = "Project Start",
|
|
11677
|
+
projectEndLabel = "Project End"
|
|
11678
|
+
}) => {
|
|
11679
|
+
const lineProps = useMemo(
|
|
11680
|
+
() => ({
|
|
11681
|
+
additionalLeftSpace,
|
|
11682
|
+
startDate,
|
|
11683
|
+
viewMode,
|
|
11684
|
+
columnWidth,
|
|
11685
|
+
rtl,
|
|
11686
|
+
ganttFullHeight
|
|
11687
|
+
}),
|
|
11688
|
+
[
|
|
11689
|
+
additionalLeftSpace,
|
|
11690
|
+
startDate,
|
|
11691
|
+
viewMode,
|
|
11692
|
+
columnWidth,
|
|
11693
|
+
rtl,
|
|
11694
|
+
ganttFullHeight
|
|
11695
|
+
]
|
|
11696
|
+
);
|
|
11697
|
+
const todayElement = useMemo(() => {
|
|
11698
|
+
if (isUnknownDates || !showTodayLine) {
|
|
11699
|
+
return null;
|
|
11700
|
+
}
|
|
11701
|
+
return /* @__PURE__ */ jsx(
|
|
11702
|
+
DateLine,
|
|
11703
|
+
{
|
|
11704
|
+
config: {
|
|
11705
|
+
date: /* @__PURE__ */ new Date(),
|
|
11706
|
+
color: todayColor || "var(--gantt-calendar-today-color)",
|
|
11707
|
+
label: todayLabel
|
|
11708
|
+
},
|
|
11709
|
+
...lineProps
|
|
11710
|
+
}
|
|
11711
|
+
);
|
|
11712
|
+
}, [isUnknownDates, showTodayLine, todayColor, todayLabel, lineProps]);
|
|
11713
|
+
const dataDateElement = useMemo(() => {
|
|
11714
|
+
if (!showDataDateLine || !dataDate) {
|
|
11715
|
+
return null;
|
|
11716
|
+
}
|
|
11717
|
+
return /* @__PURE__ */ jsx(
|
|
11718
|
+
DateLine,
|
|
11719
|
+
{
|
|
11720
|
+
config: {
|
|
11721
|
+
date: dataDate,
|
|
11722
|
+
color: dataDateColor || "#ff6600",
|
|
11723
|
+
label: dataDateLabel
|
|
11724
|
+
},
|
|
11725
|
+
...lineProps
|
|
11726
|
+
}
|
|
11727
|
+
);
|
|
11728
|
+
}, [showDataDateLine, dataDate, dataDateColor, dataDateLabel, lineProps]);
|
|
11729
|
+
const projectStartElement = useMemo(() => {
|
|
11730
|
+
if (!showProjectStartLine || !projectStartDate) {
|
|
11731
|
+
return null;
|
|
11732
|
+
}
|
|
11733
|
+
return /* @__PURE__ */ jsx(
|
|
11734
|
+
DateLine,
|
|
11735
|
+
{
|
|
11736
|
+
config: {
|
|
11737
|
+
date: projectStartDate,
|
|
11738
|
+
color: projectStartColor || "#4caf50",
|
|
11739
|
+
label: projectStartLabel
|
|
11740
|
+
},
|
|
11741
|
+
...lineProps
|
|
11742
|
+
}
|
|
11743
|
+
);
|
|
11744
|
+
}, [
|
|
11745
|
+
showProjectStartLine,
|
|
11746
|
+
projectStartDate,
|
|
11747
|
+
projectStartColor,
|
|
11748
|
+
projectStartLabel,
|
|
11749
|
+
lineProps
|
|
11750
|
+
]);
|
|
11751
|
+
const projectEndElement = useMemo(() => {
|
|
11752
|
+
if (!showProjectEndLine || !projectEndDate) {
|
|
11753
|
+
return null;
|
|
11754
|
+
}
|
|
11755
|
+
return /* @__PURE__ */ jsx(
|
|
11756
|
+
DateLine,
|
|
11757
|
+
{
|
|
11758
|
+
config: {
|
|
11759
|
+
date: projectEndDate,
|
|
11760
|
+
color: projectEndColor || "#f44336",
|
|
11761
|
+
label: projectEndLabel
|
|
11762
|
+
},
|
|
11763
|
+
...lineProps
|
|
11764
|
+
}
|
|
11765
|
+
);
|
|
11766
|
+
}, [
|
|
11767
|
+
showProjectEndLine,
|
|
11768
|
+
projectEndDate,
|
|
11769
|
+
projectEndColor,
|
|
11770
|
+
projectEndLabel,
|
|
11771
|
+
lineProps
|
|
11772
|
+
]);
|
|
11773
|
+
return /* @__PURE__ */ jsxs("g", { className: "today", children: [
|
|
11774
|
+
projectStartElement,
|
|
11775
|
+
projectEndElement,
|
|
11776
|
+
dataDateElement,
|
|
11777
|
+
todayElement
|
|
11778
|
+
] });
|
|
11779
|
+
};
|
|
11780
|
+
const GanttToday = memo(GanttTodayInner);
|
|
11781
|
+
const calendarBottomText = "_calendarBottomText_15t8b_1";
|
|
11782
|
+
const calendarTopTick = "_calendarTopTick_15t8b_25";
|
|
11783
|
+
const calendarTopText = "_calendarTopText_15t8b_35";
|
|
11784
|
+
const calendarHeader = "_calendarHeader_15t8b_61";
|
|
11785
|
+
const calendar = "_calendar_15t8b_1";
|
|
11786
|
+
const calendarDragging$1 = "_calendarDragging_15t8b_85";
|
|
11787
|
+
const styles$c = {
|
|
11788
|
+
calendarBottomText,
|
|
11789
|
+
calendarTopTick,
|
|
11790
|
+
calendarTopText,
|
|
11791
|
+
calendarHeader,
|
|
11792
|
+
calendar,
|
|
11793
|
+
calendarDragging: calendarDragging$1
|
|
11794
|
+
};
|
|
11795
|
+
const TopPartOfCalendar = ({
|
|
11796
|
+
value,
|
|
11797
|
+
x1Line,
|
|
11798
|
+
y1Line,
|
|
11799
|
+
y2Line,
|
|
11800
|
+
xText,
|
|
11801
|
+
yText,
|
|
11802
|
+
language
|
|
11803
|
+
}) => {
|
|
11804
|
+
const { t, i18n } = useTranslation();
|
|
11805
|
+
useEffect(() => {
|
|
11806
|
+
if (language) {
|
|
11807
|
+
i18n.changeLanguage(language);
|
|
11808
|
+
}
|
|
11809
|
+
}, []);
|
|
11810
|
+
return /* @__PURE__ */ jsxs("g", { className: "calendarTop", children: [
|
|
11811
|
+
/* @__PURE__ */ jsx(
|
|
11812
|
+
"line",
|
|
11813
|
+
{
|
|
11814
|
+
x1: x1Line,
|
|
11815
|
+
y1: y1Line,
|
|
11816
|
+
x2: x1Line,
|
|
11817
|
+
y2: y2Line,
|
|
11818
|
+
className: styles$c.calendarTopTick
|
|
11819
|
+
}
|
|
11820
|
+
),
|
|
11821
|
+
value !== null && /* @__PURE__ */ jsx("text", { y: yText - 4, x: xText, className: styles$c.calendarTopText, children: value.toString().split(",")[1] ? t(value.toString().split(",")[0]) + "," + value.toString().split(",")[1] : value.toString().length >= 3 ? t(value.toString()) : value })
|
|
11822
|
+
] });
|
|
11823
|
+
};
|
|
11824
|
+
const defaultRenderBottomHeader = (date, viewMode, dateSetup, index2, isUnknownDates) => {
|
|
11825
|
+
if (isUnknownDates) {
|
|
11826
|
+
const {
|
|
11827
|
+
dateLocale: { formatDistance: formatDistance2 },
|
|
11828
|
+
preStepsCount
|
|
11829
|
+
} = dateSetup;
|
|
11830
|
+
const offsetFromStart = index2 - preStepsCount;
|
|
11831
|
+
if (offsetFromStart === 0) {
|
|
11832
|
+
return "0";
|
|
11833
|
+
}
|
|
11834
|
+
let value = "";
|
|
11835
|
+
if (!formatDistance2) {
|
|
11836
|
+
value = `${offsetFromStart}`;
|
|
11837
|
+
} else {
|
|
11838
|
+
switch (viewMode) {
|
|
11839
|
+
case ViewMode.Year:
|
|
11840
|
+
value = formatDistance2("xYears", offsetFromStart);
|
|
11841
|
+
break;
|
|
11842
|
+
case ViewMode.Month:
|
|
11843
|
+
value = formatDistance2("xMonths", offsetFromStart);
|
|
11844
|
+
break;
|
|
11845
|
+
case ViewMode.Week:
|
|
11846
|
+
value = formatDistance2("xWeeks", offsetFromStart);
|
|
11847
|
+
break;
|
|
11848
|
+
case ViewMode.Day:
|
|
11849
|
+
value = formatDistance2("xDays", offsetFromStart);
|
|
11850
|
+
break;
|
|
11851
|
+
case ViewMode.QuarterDay:
|
|
11852
|
+
value = formatDistance2("xHours", offsetFromStart * 6);
|
|
11853
|
+
break;
|
|
11854
|
+
case ViewMode.HalfDay:
|
|
11855
|
+
value = formatDistance2("xHours", offsetFromStart * 12);
|
|
11856
|
+
break;
|
|
11857
|
+
case ViewMode.Hour:
|
|
11858
|
+
value = formatDistance2("xHours", offsetFromStart);
|
|
11859
|
+
break;
|
|
11860
|
+
default:
|
|
11861
|
+
throw new Error("Unknown viewMode");
|
|
11862
|
+
}
|
|
11863
|
+
}
|
|
11864
|
+
if (offsetFromStart > 0) {
|
|
11865
|
+
return `+${value}`;
|
|
11866
|
+
}
|
|
11867
|
+
return value;
|
|
11868
|
+
}
|
|
11869
|
+
switch (viewMode) {
|
|
11870
|
+
case ViewMode.Year:
|
|
11871
|
+
return date.getFullYear();
|
|
11872
|
+
case ViewMode.Month:
|
|
11873
|
+
try {
|
|
11874
|
+
return format(date, dateSetup.dateFormats.monthBottomHeaderFormat, {
|
|
11875
|
+
locale: dateSetup.dateLocale
|
|
11876
|
+
});
|
|
11877
|
+
} catch (e) {
|
|
11878
|
+
return date.toLocaleString("default", { month: "long" });
|
|
11879
|
+
}
|
|
11880
|
+
case ViewMode.Week:
|
|
11881
|
+
return dateSetup.dateFormats.weekBottomHeader(
|
|
11882
|
+
date,
|
|
11883
|
+
getWeekNumberISO8601(date),
|
|
11884
|
+
dateSetup.dateLocale
|
|
11885
|
+
);
|
|
11886
|
+
case ViewMode.Day:
|
|
11887
|
+
try {
|
|
11888
|
+
return format(date, dateSetup.dateFormats.dayBottomHeaderFormat, {
|
|
11889
|
+
locale: dateSetup.dateLocale
|
|
11890
|
+
});
|
|
11891
|
+
} catch (e) {
|
|
11892
|
+
return String(date.getDate());
|
|
11893
|
+
}
|
|
11894
|
+
case ViewMode.QuarterDay:
|
|
11895
|
+
case ViewMode.HalfDay:
|
|
11896
|
+
case ViewMode.Hour:
|
|
11897
|
+
try {
|
|
11898
|
+
return format(date, dateSetup.dateFormats.hourBottomHeaderFormat, {
|
|
11899
|
+
locale: dateSetup.dateLocale
|
|
11900
|
+
});
|
|
11901
|
+
} catch (e) {
|
|
11902
|
+
return String(date.getDate());
|
|
11903
|
+
}
|
|
11904
|
+
default:
|
|
11905
|
+
throw new Error("Unknown viewMode");
|
|
11906
|
+
}
|
|
11907
|
+
};
|
|
11908
|
+
const getDayText = (date, dateSetup) => {
|
|
11909
|
+
try {
|
|
11910
|
+
return format(date, dateSetup.dateFormats.dayTopHeaderFormat, {
|
|
11911
|
+
locale: dateSetup.dateLocale
|
|
11912
|
+
});
|
|
11913
|
+
} catch (e) {
|
|
11914
|
+
return String(date.getDate());
|
|
11915
|
+
}
|
|
11916
|
+
};
|
|
11917
|
+
const getMonthText = (date, dateSetup) => {
|
|
11918
|
+
try {
|
|
11919
|
+
return format(date, dateSetup.dateFormats.monthTopHeaderFormat, {
|
|
11920
|
+
locale: dateSetup.dateLocale
|
|
11659
11921
|
});
|
|
11660
11922
|
} catch (e) {
|
|
11661
11923
|
return date.toLocaleString("default", { month: "long" });
|
|
@@ -12298,231 +12560,6 @@ const RelationLine = ({
|
|
|
12298
12560
|
}
|
|
12299
12561
|
);
|
|
12300
12562
|
};
|
|
12301
|
-
const getDateByOffset = (startDate, offset2, viewMode) => {
|
|
12302
|
-
switch (viewMode) {
|
|
12303
|
-
case ViewMode.Day:
|
|
12304
|
-
return addDays(startDate, offset2);
|
|
12305
|
-
case ViewMode.HalfDay:
|
|
12306
|
-
return addHours(startDate, offset2 * 12);
|
|
12307
|
-
case ViewMode.QuarterDay:
|
|
12308
|
-
return addHours(startDate, offset2 * 6);
|
|
12309
|
-
case ViewMode.Hour:
|
|
12310
|
-
return addHours(startDate, offset2);
|
|
12311
|
-
case ViewMode.Month:
|
|
12312
|
-
return addMonths(startDate, offset2);
|
|
12313
|
-
case ViewMode.Week:
|
|
12314
|
-
return addWeeks(startDate, offset2);
|
|
12315
|
-
case ViewMode.Year:
|
|
12316
|
-
return addYears(startDate, offset2);
|
|
12317
|
-
default:
|
|
12318
|
-
throw new Error("Unknown view mode");
|
|
12319
|
-
}
|
|
12320
|
-
};
|
|
12321
|
-
const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
|
|
12322
|
-
const index2 = getDatesDiff(xDate, startDate, viewMode);
|
|
12323
|
-
const currentDate = getDateByOffset(startDate, index2, viewMode);
|
|
12324
|
-
const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
|
|
12325
|
-
const remainderMillis = xDate.getTime() - currentDate.getTime();
|
|
12326
|
-
const intervalDuration = nextDate.getTime() - currentDate.getTime();
|
|
12327
|
-
const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
|
|
12328
|
-
const result = index2 * columnWidth + percentOfInterval * columnWidth;
|
|
12329
|
-
return isNaN(result) || !isFinite(result) ? 0 : result;
|
|
12330
|
-
};
|
|
12331
|
-
const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
|
|
12332
|
-
const index2 = getDatesDiff(xDate, startDate, viewMode);
|
|
12333
|
-
const currentDate = getDateByOffset(startDate, index2, viewMode);
|
|
12334
|
-
const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
|
|
12335
|
-
const remainderMillis = xDate.getTime() - currentDate.getTime();
|
|
12336
|
-
const intervalDuration = nextDate.getTime() - currentDate.getTime();
|
|
12337
|
-
const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
|
|
12338
|
-
const result = index2 * columnWidth + percentOfInterval * columnWidth;
|
|
12339
|
-
return isNaN(result) || !isFinite(result) ? 0 : result;
|
|
12340
|
-
};
|
|
12341
|
-
const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
|
|
12342
|
-
const safeTaskX1 = isNaN(taskX1) || !isFinite(taskX1) ? 0 : taskX1;
|
|
12343
|
-
const safeTaskX2 = isNaN(taskX2) || !isFinite(taskX2) ? 0 : taskX2;
|
|
12344
|
-
const safeProgress = isNaN(progress) || !isFinite(progress) ? 0 : progress;
|
|
12345
|
-
const progressWidth = Math.max(
|
|
12346
|
-
(safeTaskX2 - safeTaskX1) * safeProgress * 0.01,
|
|
12347
|
-
0
|
|
12348
|
-
);
|
|
12349
|
-
let progressX;
|
|
12350
|
-
if (rtl) {
|
|
12351
|
-
progressX = safeTaskX2 - progressWidth;
|
|
12352
|
-
} else {
|
|
12353
|
-
progressX = safeTaskX1;
|
|
12354
|
-
}
|
|
12355
|
-
return [progressWidth, progressX];
|
|
12356
|
-
};
|
|
12357
|
-
const getProgressPoint = (progressX, taskY, taskHeight) => {
|
|
12358
|
-
const point = [
|
|
12359
|
-
progressX - 5,
|
|
12360
|
-
taskY + taskHeight,
|
|
12361
|
-
progressX + 5,
|
|
12362
|
-
taskY + taskHeight,
|
|
12363
|
-
progressX,
|
|
12364
|
-
taskY + taskHeight - 8.66
|
|
12365
|
-
];
|
|
12366
|
-
return point.join(",");
|
|
12367
|
-
};
|
|
12368
|
-
const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
|
|
12369
|
-
const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
|
|
12370
|
-
const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
|
|
12371
|
-
const safeXStep = isNaN(xStep) || !isFinite(xStep) || xStep === 0 ? 1 : xStep;
|
|
12372
|
-
const safeTimeStep = isNaN(timeStep) || !isFinite(timeStep) ? 0 : timeStep;
|
|
12373
|
-
let newDate = new Date(
|
|
12374
|
-
(safeX - safeTaskX) / safeXStep * safeTimeStep + taskDate.getTime()
|
|
12375
|
-
);
|
|
12376
|
-
newDate = new Date(
|
|
12377
|
-
newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
|
|
12378
|
-
);
|
|
12379
|
-
return newDate;
|
|
12380
|
-
};
|
|
12381
|
-
const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
|
|
12382
|
-
let result;
|
|
12383
|
-
switch (selectedTask.type) {
|
|
12384
|
-
case "milestone":
|
|
12385
|
-
result = handleTaskBySVGMouseEventForMilestone(
|
|
12386
|
-
action,
|
|
12387
|
-
selectedTask,
|
|
12388
|
-
initialCoordinates,
|
|
12389
|
-
coordinates,
|
|
12390
|
-
xStep,
|
|
12391
|
-
timeStep
|
|
12392
|
-
);
|
|
12393
|
-
break;
|
|
12394
|
-
default:
|
|
12395
|
-
result = handleTaskBySVGMouseEventForBar(
|
|
12396
|
-
action,
|
|
12397
|
-
selectedTask,
|
|
12398
|
-
initialCoordinates,
|
|
12399
|
-
coordinates,
|
|
12400
|
-
xStep,
|
|
12401
|
-
timeStep,
|
|
12402
|
-
rtl
|
|
12403
|
-
);
|
|
12404
|
-
break;
|
|
12405
|
-
}
|
|
12406
|
-
return result;
|
|
12407
|
-
};
|
|
12408
|
-
const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
|
|
12409
|
-
const changedTask = { ...selectedTask };
|
|
12410
|
-
let isChanged = false;
|
|
12411
|
-
switch (action) {
|
|
12412
|
-
case "progress":
|
|
12413
|
-
isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
|
|
12414
|
-
if (isChanged) {
|
|
12415
|
-
changedTask.progress = Math.round(
|
|
12416
|
-
coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
|
|
12417
|
-
);
|
|
12418
|
-
}
|
|
12419
|
-
break;
|
|
12420
|
-
case "start": {
|
|
12421
|
-
isChanged = initialCoordinates.x1 !== coordinates.x1;
|
|
12422
|
-
if (isChanged) {
|
|
12423
|
-
if (rtl) {
|
|
12424
|
-
changedTask.end = dateByX(
|
|
12425
|
-
coordinates.x1,
|
|
12426
|
-
initialCoordinates.x1,
|
|
12427
|
-
selectedTask.end,
|
|
12428
|
-
xStep,
|
|
12429
|
-
timeStep
|
|
12430
|
-
);
|
|
12431
|
-
} else {
|
|
12432
|
-
changedTask.start = dateByX(
|
|
12433
|
-
coordinates.x1,
|
|
12434
|
-
initialCoordinates.x1,
|
|
12435
|
-
selectedTask.start,
|
|
12436
|
-
xStep,
|
|
12437
|
-
timeStep
|
|
12438
|
-
);
|
|
12439
|
-
}
|
|
12440
|
-
}
|
|
12441
|
-
break;
|
|
12442
|
-
}
|
|
12443
|
-
case "end": {
|
|
12444
|
-
isChanged = initialCoordinates.x2 !== coordinates.x2;
|
|
12445
|
-
if (isChanged) {
|
|
12446
|
-
if (rtl) {
|
|
12447
|
-
changedTask.start = dateByX(
|
|
12448
|
-
coordinates.x2,
|
|
12449
|
-
initialCoordinates.x2,
|
|
12450
|
-
selectedTask.start,
|
|
12451
|
-
xStep,
|
|
12452
|
-
timeStep
|
|
12453
|
-
);
|
|
12454
|
-
} else {
|
|
12455
|
-
changedTask.end = dateByX(
|
|
12456
|
-
coordinates.x2,
|
|
12457
|
-
initialCoordinates.x2,
|
|
12458
|
-
selectedTask.end,
|
|
12459
|
-
xStep,
|
|
12460
|
-
timeStep
|
|
12461
|
-
);
|
|
12462
|
-
}
|
|
12463
|
-
}
|
|
12464
|
-
break;
|
|
12465
|
-
}
|
|
12466
|
-
case "move": {
|
|
12467
|
-
isChanged = initialCoordinates.x1 !== coordinates.x1;
|
|
12468
|
-
if (isChanged) {
|
|
12469
|
-
if (rtl) {
|
|
12470
|
-
changedTask.end = dateByX(
|
|
12471
|
-
coordinates.x1,
|
|
12472
|
-
initialCoordinates.x1,
|
|
12473
|
-
selectedTask.end,
|
|
12474
|
-
xStep,
|
|
12475
|
-
timeStep
|
|
12476
|
-
);
|
|
12477
|
-
changedTask.start = dateByX(
|
|
12478
|
-
coordinates.x2,
|
|
12479
|
-
initialCoordinates.x2,
|
|
12480
|
-
selectedTask.start,
|
|
12481
|
-
xStep,
|
|
12482
|
-
timeStep
|
|
12483
|
-
);
|
|
12484
|
-
} else {
|
|
12485
|
-
changedTask.start = dateByX(
|
|
12486
|
-
coordinates.x1,
|
|
12487
|
-
initialCoordinates.x1,
|
|
12488
|
-
selectedTask.start,
|
|
12489
|
-
xStep,
|
|
12490
|
-
timeStep
|
|
12491
|
-
);
|
|
12492
|
-
changedTask.end = dateByX(
|
|
12493
|
-
coordinates.x2,
|
|
12494
|
-
initialCoordinates.x2,
|
|
12495
|
-
selectedTask.end,
|
|
12496
|
-
xStep,
|
|
12497
|
-
timeStep
|
|
12498
|
-
);
|
|
12499
|
-
}
|
|
12500
|
-
}
|
|
12501
|
-
break;
|
|
12502
|
-
}
|
|
12503
|
-
}
|
|
12504
|
-
return { isChanged, changedTask };
|
|
12505
|
-
};
|
|
12506
|
-
const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
|
|
12507
|
-
const changedTask = { ...selectedTask };
|
|
12508
|
-
const isChanged = coordinates.x1 !== initialCoordinates.x1;
|
|
12509
|
-
if (isChanged) {
|
|
12510
|
-
switch (action) {
|
|
12511
|
-
case "move": {
|
|
12512
|
-
changedTask.start = dateByX(
|
|
12513
|
-
coordinates.x1,
|
|
12514
|
-
initialCoordinates.x1,
|
|
12515
|
-
selectedTask.start,
|
|
12516
|
-
xStep,
|
|
12517
|
-
timeStep
|
|
12518
|
-
);
|
|
12519
|
-
changedTask.end = changedTask.start;
|
|
12520
|
-
break;
|
|
12521
|
-
}
|
|
12522
|
-
}
|
|
12523
|
-
}
|
|
12524
|
-
return { isChanged, changedTask };
|
|
12525
|
-
};
|
|
12526
12563
|
const barWrapper = "_barWrapper_5jhkr_1";
|
|
12527
12564
|
const barHandle = "_barHandle_5jhkr_11";
|
|
12528
12565
|
const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
|
|
@@ -19938,11 +19975,19 @@ const Gantt = (props) => {
|
|
|
19938
19975
|
rowHeight,
|
|
19939
19976
|
showTodayLine = true,
|
|
19940
19977
|
showDataDateLine = false,
|
|
19978
|
+
showProjectStartLine = false,
|
|
19979
|
+
showProjectEndLine = false,
|
|
19941
19980
|
dataDate = null,
|
|
19981
|
+
projectStartDate = null,
|
|
19982
|
+
projectEndDate = null,
|
|
19942
19983
|
todayColor,
|
|
19943
19984
|
dataDateColor,
|
|
19985
|
+
projectStartColor,
|
|
19986
|
+
projectEndColor,
|
|
19944
19987
|
todayLabel = "Today",
|
|
19945
19988
|
dataDateLabel = "Data Date",
|
|
19989
|
+
projectStartLabel = "Project Start",
|
|
19990
|
+
projectEndLabel = "Project End",
|
|
19946
19991
|
showProgress = true,
|
|
19947
19992
|
hideProjectProgress = false,
|
|
19948
19993
|
progressColor,
|
|
@@ -21371,11 +21416,19 @@ const Gantt = (props) => {
|
|
|
21371
21416
|
viewMode,
|
|
21372
21417
|
showTodayLine,
|
|
21373
21418
|
showDataDateLine,
|
|
21419
|
+
showProjectStartLine,
|
|
21420
|
+
showProjectEndLine,
|
|
21374
21421
|
dataDate,
|
|
21422
|
+
projectStartDate,
|
|
21423
|
+
projectEndDate,
|
|
21375
21424
|
todayColor,
|
|
21376
21425
|
dataDateColor,
|
|
21426
|
+
projectStartColor,
|
|
21427
|
+
projectEndColor,
|
|
21377
21428
|
todayLabel,
|
|
21378
|
-
dataDateLabel
|
|
21429
|
+
dataDateLabel,
|
|
21430
|
+
projectStartLabel,
|
|
21431
|
+
projectEndLabel
|
|
21379
21432
|
}),
|
|
21380
21433
|
[
|
|
21381
21434
|
additionalLeftSpace,
|
|
@@ -21387,11 +21440,19 @@ const Gantt = (props) => {
|
|
|
21387
21440
|
viewMode,
|
|
21388
21441
|
showTodayLine,
|
|
21389
21442
|
showDataDateLine,
|
|
21443
|
+
showProjectStartLine,
|
|
21444
|
+
showProjectEndLine,
|
|
21390
21445
|
dataDate,
|
|
21446
|
+
projectStartDate,
|
|
21447
|
+
projectEndDate,
|
|
21391
21448
|
todayColor,
|
|
21392
21449
|
dataDateColor,
|
|
21450
|
+
projectStartColor,
|
|
21451
|
+
projectEndColor,
|
|
21393
21452
|
todayLabel,
|
|
21394
|
-
dataDateLabel
|
|
21453
|
+
dataDateLabel,
|
|
21454
|
+
projectStartLabel,
|
|
21455
|
+
projectEndLabel
|
|
21395
21456
|
]
|
|
21396
21457
|
);
|
|
21397
21458
|
const calendarProps = useMemo(
|