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.
@@ -10300,10 +10300,33 @@
10300
10300
  return "";
10301
10301
  if (editType === "date") {
10302
10302
  if (value instanceof Date) {
10303
- return value.toISOString().slice(0, 10);
10303
+ return Number.isNaN(value.getTime()) ? "" : value.toISOString().slice(0, 10);
10304
10304
  }
10305
- if (typeof value === "string")
10305
+ if (typeof value === "number") {
10306
+ const d = new Date(value);
10307
+ return Number.isNaN(d.getTime()) ? "" : d.toISOString().slice(0, 10);
10308
+ }
10309
+ if (typeof value === "string") {
10310
+ const d = new Date(value);
10311
+ if (!Number.isNaN(d.getTime())) {
10312
+ return d.toISOString().slice(0, 10);
10313
+ }
10306
10314
  return value.slice(0, 10);
10315
+ }
10316
+ return "";
10317
+ }
10318
+ if (editType === "number") {
10319
+ if (typeof value === "number") {
10320
+ return Number.isNaN(value) ? "" : String(value);
10321
+ }
10322
+ if (typeof value === "string") {
10323
+ const n = Number(value);
10324
+ return Number.isNaN(n) ? value : String(n);
10325
+ }
10326
+ return String(value);
10327
+ }
10328
+ if (editType === "select") {
10329
+ return String(value);
10307
10330
  }
10308
10331
  return String(value);
10309
10332
  }
@@ -10515,9 +10538,26 @@
10515
10538
  const t = columnData.task;
10516
10539
  if (c.getValueFromTask)
10517
10540
  return c.getValueFromTask(t);
10518
- if (t.type !== "empty" && t.payload && c.id in t.payload)
10519
- return t.payload[c.id];
10520
- return t[c.id];
10541
+ if (t.type !== "empty" && t.payload) {
10542
+ if (c.id in t.payload)
10543
+ return t.payload[c.id];
10544
+ }
10545
+ if (c.id in t)
10546
+ return t[c.id];
10547
+ if (t.type !== "empty") {
10548
+ const task2 = t;
10549
+ const aliasMap = {
10550
+ startDate: task2.start,
10551
+ finishDate: task2.end,
10552
+ endDate: task2.end,
10553
+ duration: task2.end && task2.start ? Math.round(
10554
+ (task2.end.getTime() - task2.start.getTime()) / (1e3 * 60 * 60 * 24)
10555
+ ) : void 0
10556
+ };
10557
+ if (c.id in aliasMap)
10558
+ return aliasMap[c.id];
10559
+ }
10560
+ return void 0;
10521
10561
  };
10522
10562
  const handleStartEdit = () => {
10523
10563
  if (col.editable && onTaskInlineEdit) {
@@ -11357,322 +11397,544 @@
11357
11397
  ganttToday,
11358
11398
  ganttTodayCircle
11359
11399
  };
11360
- const GanttTodayInner = ({
11361
- additionalLeftSpace,
11362
- distances: { columnWidth },
11363
- ganttFullHeight,
11364
- isUnknownDates,
11365
- rtl,
11366
- startDate,
11367
- viewMode,
11368
- showTodayLine = true,
11369
- showDataDateLine = false,
11370
- dataDate = null,
11371
- todayColor = null,
11372
- dataDateColor = null,
11373
- todayLabel = "Today",
11374
- dataDateLabel = "Data Date"
11375
- }) => {
11376
- const todayElement = React.useMemo(() => {
11377
- if (isUnknownDates || !showTodayLine) {
11378
- return null;
11379
- }
11380
- const today = /* @__PURE__ */ new Date();
11381
- const todayIndex = getDatesDiff(today, startDate, viewMode);
11382
- const extraMultiplier = () => {
11383
- switch (viewMode) {
11384
- case ViewMode.Week: {
11385
- const percent = today.getDay() / 7;
11386
- return 1 + percent * 0.2;
11387
- }
11388
- case ViewMode.Month: {
11389
- const dayInMonth = today.getDate();
11390
- const maxDaysInMonth = getDaysInMonth(
11391
- today.getMonth(),
11392
- today.getFullYear()
11393
- );
11394
- const percent = dayInMonth / maxDaysInMonth;
11395
- return 1 + percent * 0.5;
11396
- }
11397
- case ViewMode.Year: {
11398
- const percent = today.getMonth() / 12;
11399
- return 1 + percent * 0.5;
11400
- }
11401
- default:
11402
- return 1;
11403
- }
11404
- };
11405
- const tickX = todayIndex * columnWidth * extraMultiplier();
11406
- const x = rtl ? tickX + columnWidth : tickX;
11407
- const color = todayColor || "var(--gantt-calendar-today-color)";
11408
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11409
- /* @__PURE__ */ jsxRuntime.jsx(
11410
- "rect",
11411
- {
11412
- x: additionalLeftSpace + x,
11413
- y: 0,
11414
- width: 2,
11415
- height: ganttFullHeight,
11416
- fill: color
11417
- }
11418
- ),
11419
- /* @__PURE__ */ jsxRuntime.jsx(
11420
- "circle",
11421
- {
11422
- className: styles$d.ganttTodayCircle,
11423
- cx: x + 1,
11424
- cy: 6,
11425
- r: 6,
11426
- fill: color
11427
- }
11428
- ),
11429
- /* @__PURE__ */ jsxRuntime.jsx(
11430
- "text",
11431
- {
11432
- x: additionalLeftSpace + x + 8,
11433
- y: 10,
11434
- fill: color,
11435
- fontSize: 12,
11436
- fontWeight: 600,
11437
- children: todayLabel
11438
- }
11439
- )
11440
- ] });
11441
- }, [
11442
- additionalLeftSpace,
11443
- columnWidth,
11444
- ganttFullHeight,
11445
- isUnknownDates,
11446
- rtl,
11447
- startDate,
11448
- viewMode,
11449
- showTodayLine,
11450
- todayColor,
11451
- todayLabel
11452
- ]);
11453
- const dataDateElement = React.useMemo(() => {
11454
- if (!showDataDateLine || !dataDate) {
11455
- return null;
11456
- }
11457
- const dataIndex = getDatesDiff(dataDate, startDate, viewMode);
11458
- const extraMultiplier = () => {
11459
- switch (viewMode) {
11460
- case ViewMode.Week: {
11461
- const percent = dataDate.getDay() / 7;
11462
- return 1 + percent * 0.2;
11463
- }
11464
- case ViewMode.Month: {
11465
- const dayInMonth = dataDate.getDate();
11466
- const maxDaysInMonth = getDaysInMonth(
11467
- dataDate.getMonth(),
11468
- dataDate.getFullYear()
11469
- );
11470
- const percent = dayInMonth / maxDaysInMonth;
11471
- return 1 + percent * 0.5;
11472
- }
11473
- case ViewMode.Year: {
11474
- const percent = dataDate.getMonth() / 12;
11475
- return 1 + percent * 0.5;
11476
- }
11477
- default:
11478
- return 1;
11479
- }
11480
- };
11481
- const tickX = dataIndex * columnWidth * extraMultiplier();
11482
- const x = rtl ? tickX + columnWidth : tickX;
11483
- const color = dataDateColor || "var(--gantt-calendar-today-color)";
11484
- return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11485
- /* @__PURE__ */ jsxRuntime.jsx(
11486
- "rect",
11487
- {
11488
- x: additionalLeftSpace + x,
11489
- y: 0,
11490
- width: 2,
11491
- height: ganttFullHeight,
11492
- fill: color,
11493
- opacity: 0.9
11494
- }
11495
- ),
11496
- /* @__PURE__ */ jsxRuntime.jsx(
11497
- "circle",
11498
- {
11499
- className: styles$d.ganttTodayCircle,
11500
- cx: x + 1,
11501
- cy: 6,
11502
- r: 6,
11503
- fill: color
11504
- }
11505
- ),
11506
- /* @__PURE__ */ jsxRuntime.jsx(
11507
- "text",
11508
- {
11509
- x: additionalLeftSpace + x + 8,
11510
- y: 10,
11511
- fill: color,
11512
- fontSize: 12,
11513
- fontWeight: 600,
11514
- children: dataDateLabel || "Data Date"
11515
- }
11516
- )
11517
- ] });
11518
- }, [
11519
- additionalLeftSpace,
11520
- columnWidth,
11521
- ganttFullHeight,
11522
- rtl,
11523
- startDate,
11524
- viewMode,
11525
- showDataDateLine,
11526
- dataDate,
11527
- dataDateColor,
11528
- dataDateLabel
11529
- ]);
11530
- return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "today", children: [
11531
- dataDateElement,
11532
- todayElement
11533
- ] });
11534
- };
11535
- const GanttToday = React.memo(GanttTodayInner);
11536
- const calendarBottomText = "_calendarBottomText_15t8b_1";
11537
- const calendarTopTick = "_calendarTopTick_15t8b_25";
11538
- const calendarTopText = "_calendarTopText_15t8b_35";
11539
- const calendarHeader = "_calendarHeader_15t8b_61";
11540
- const calendar = "_calendar_15t8b_1";
11541
- const calendarDragging$1 = "_calendarDragging_15t8b_85";
11542
- const styles$c = {
11543
- calendarBottomText,
11544
- calendarTopTick,
11545
- calendarTopText,
11546
- calendarHeader,
11547
- calendar,
11548
- calendarDragging: calendarDragging$1
11549
- };
11550
- const TopPartOfCalendar = ({
11551
- value,
11552
- x1Line,
11553
- y1Line,
11554
- y2Line,
11555
- xText,
11556
- yText,
11557
- language
11558
- }) => {
11559
- const { t, i18n } = useTranslation();
11560
- React.useEffect(() => {
11561
- if (language) {
11562
- i18n.changeLanguage(language);
11563
- }
11564
- }, []);
11565
- return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "calendarTop", children: [
11566
- /* @__PURE__ */ jsxRuntime.jsx(
11567
- "line",
11568
- {
11569
- x1: x1Line,
11570
- y1: y1Line,
11571
- x2: x1Line,
11572
- y2: y2Line,
11573
- className: styles$c.calendarTopTick
11574
- }
11575
- ),
11576
- value !== null && /* @__PURE__ */ jsxRuntime.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 })
11577
- ] });
11578
- };
11579
- const defaultRenderBottomHeader = (date, viewMode, dateSetup, index2, isUnknownDates) => {
11580
- if (isUnknownDates) {
11581
- const {
11582
- dateLocale: { formatDistance: formatDistance2 },
11583
- preStepsCount
11584
- } = dateSetup;
11585
- const offsetFromStart = index2 - preStepsCount;
11586
- if (offsetFromStart === 0) {
11587
- return "0";
11588
- }
11589
- let value = "";
11590
- if (!formatDistance2) {
11591
- value = `${offsetFromStart}`;
11592
- } else {
11593
- switch (viewMode) {
11594
- case ViewMode.Year:
11595
- value = formatDistance2("xYears", offsetFromStart);
11596
- break;
11597
- case ViewMode.Month:
11598
- value = formatDistance2("xMonths", offsetFromStart);
11599
- break;
11600
- case ViewMode.Week:
11601
- value = formatDistance2("xWeeks", offsetFromStart);
11602
- break;
11603
- case ViewMode.Day:
11604
- value = formatDistance2("xDays", offsetFromStart);
11605
- break;
11606
- case ViewMode.QuarterDay:
11607
- value = formatDistance2("xHours", offsetFromStart * 6);
11608
- break;
11609
- case ViewMode.HalfDay:
11610
- value = formatDistance2("xHours", offsetFromStart * 12);
11611
- break;
11612
- case ViewMode.Hour:
11613
- value = formatDistance2("xHours", offsetFromStart);
11614
- break;
11615
- default:
11616
- throw new Error("Unknown viewMode");
11617
- }
11618
- }
11619
- if (offsetFromStart > 0) {
11620
- return `+${value}`;
11621
- }
11622
- return value;
11623
- }
11400
+ const getDateByOffset = (startDate, offset2, viewMode) => {
11624
11401
  switch (viewMode) {
11625
- case ViewMode.Year:
11626
- return date.getFullYear();
11627
- case ViewMode.Month:
11628
- try {
11629
- return format(date, dateSetup.dateFormats.monthBottomHeaderFormat, {
11630
- locale: dateSetup.dateLocale
11631
- });
11632
- } catch (e) {
11633
- return date.toLocaleString("default", { month: "long" });
11634
- }
11635
- case ViewMode.Week:
11636
- return dateSetup.dateFormats.weekBottomHeader(
11637
- date,
11638
- getWeekNumberISO8601(date),
11639
- dateSetup.dateLocale
11640
- );
11641
11402
  case ViewMode.Day:
11642
- try {
11643
- return format(date, dateSetup.dateFormats.dayBottomHeaderFormat, {
11644
- locale: dateSetup.dateLocale
11645
- });
11646
- } catch (e) {
11647
- return String(date.getDate());
11648
- }
11649
- case ViewMode.QuarterDay:
11403
+ return addDays(startDate, offset2);
11650
11404
  case ViewMode.HalfDay:
11405
+ return addHours(startDate, offset2 * 12);
11406
+ case ViewMode.QuarterDay:
11407
+ return addHours(startDate, offset2 * 6);
11651
11408
  case ViewMode.Hour:
11652
- try {
11653
- return format(date, dateSetup.dateFormats.hourBottomHeaderFormat, {
11654
- locale: dateSetup.dateLocale
11655
- });
11656
- } catch (e) {
11657
- return String(date.getDate());
11658
- }
11409
+ return addHours(startDate, offset2);
11410
+ case ViewMode.Month:
11411
+ return addMonths(startDate, offset2);
11412
+ case ViewMode.Week:
11413
+ return addWeeks(startDate, offset2);
11414
+ case ViewMode.Year:
11415
+ return addYears(startDate, offset2);
11659
11416
  default:
11660
- throw new Error("Unknown viewMode");
11417
+ throw new Error("Unknown view mode");
11661
11418
  }
11662
11419
  };
11663
- const getDayText = (date, dateSetup) => {
11664
- try {
11665
- return format(date, dateSetup.dateFormats.dayTopHeaderFormat, {
11666
- locale: dateSetup.dateLocale
11667
- });
11668
- } catch (e) {
11669
- return String(date.getDate());
11670
- }
11420
+ const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11421
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
11422
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11423
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11424
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
11425
+ const intervalDuration = nextDate.getTime() - currentDate.getTime();
11426
+ const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
11427
+ const result = index2 * columnWidth + percentOfInterval * columnWidth;
11428
+ return isNaN(result) || !isFinite(result) ? 0 : result;
11671
11429
  };
11672
- const getMonthText = (date, dateSetup) => {
11673
- try {
11674
- return format(date, dateSetup.dateFormats.monthTopHeaderFormat, {
11675
- locale: dateSetup.dateLocale
11430
+ const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11431
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
11432
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11433
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11434
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
11435
+ const intervalDuration = nextDate.getTime() - currentDate.getTime();
11436
+ const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
11437
+ const result = index2 * columnWidth + percentOfInterval * columnWidth;
11438
+ return isNaN(result) || !isFinite(result) ? 0 : result;
11439
+ };
11440
+ const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
11441
+ const safeTaskX1 = isNaN(taskX1) || !isFinite(taskX1) ? 0 : taskX1;
11442
+ const safeTaskX2 = isNaN(taskX2) || !isFinite(taskX2) ? 0 : taskX2;
11443
+ const safeProgress = isNaN(progress) || !isFinite(progress) ? 0 : progress;
11444
+ const progressWidth = Math.max(
11445
+ (safeTaskX2 - safeTaskX1) * safeProgress * 0.01,
11446
+ 0
11447
+ );
11448
+ let progressX;
11449
+ if (rtl) {
11450
+ progressX = safeTaskX2 - progressWidth;
11451
+ } else {
11452
+ progressX = safeTaskX1;
11453
+ }
11454
+ return [progressWidth, progressX];
11455
+ };
11456
+ const getProgressPoint = (progressX, taskY, taskHeight) => {
11457
+ const point = [
11458
+ progressX - 5,
11459
+ taskY + taskHeight,
11460
+ progressX + 5,
11461
+ taskY + taskHeight,
11462
+ progressX,
11463
+ taskY + taskHeight - 8.66
11464
+ ];
11465
+ return point.join(",");
11466
+ };
11467
+ const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
11468
+ const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
11469
+ const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
11470
+ const safeXStep = isNaN(xStep) || !isFinite(xStep) || xStep === 0 ? 1 : xStep;
11471
+ const safeTimeStep = isNaN(timeStep) || !isFinite(timeStep) ? 0 : timeStep;
11472
+ let newDate = new Date(
11473
+ (safeX - safeTaskX) / safeXStep * safeTimeStep + taskDate.getTime()
11474
+ );
11475
+ newDate = new Date(
11476
+ newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
11477
+ );
11478
+ return newDate;
11479
+ };
11480
+ const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11481
+ let result;
11482
+ switch (selectedTask.type) {
11483
+ case "milestone":
11484
+ result = handleTaskBySVGMouseEventForMilestone(
11485
+ action,
11486
+ selectedTask,
11487
+ initialCoordinates,
11488
+ coordinates,
11489
+ xStep,
11490
+ timeStep
11491
+ );
11492
+ break;
11493
+ default:
11494
+ result = handleTaskBySVGMouseEventForBar(
11495
+ action,
11496
+ selectedTask,
11497
+ initialCoordinates,
11498
+ coordinates,
11499
+ xStep,
11500
+ timeStep,
11501
+ rtl
11502
+ );
11503
+ break;
11504
+ }
11505
+ return result;
11506
+ };
11507
+ const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11508
+ const changedTask = { ...selectedTask };
11509
+ let isChanged = false;
11510
+ switch (action) {
11511
+ case "progress":
11512
+ isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
11513
+ if (isChanged) {
11514
+ changedTask.progress = Math.round(
11515
+ coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
11516
+ );
11517
+ }
11518
+ break;
11519
+ case "start": {
11520
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
11521
+ if (isChanged) {
11522
+ if (rtl) {
11523
+ changedTask.end = dateByX(
11524
+ coordinates.x1,
11525
+ initialCoordinates.x1,
11526
+ selectedTask.end,
11527
+ xStep,
11528
+ timeStep
11529
+ );
11530
+ } else {
11531
+ changedTask.start = dateByX(
11532
+ coordinates.x1,
11533
+ initialCoordinates.x1,
11534
+ selectedTask.start,
11535
+ xStep,
11536
+ timeStep
11537
+ );
11538
+ }
11539
+ }
11540
+ break;
11541
+ }
11542
+ case "end": {
11543
+ isChanged = initialCoordinates.x2 !== coordinates.x2;
11544
+ if (isChanged) {
11545
+ if (rtl) {
11546
+ changedTask.start = dateByX(
11547
+ coordinates.x2,
11548
+ initialCoordinates.x2,
11549
+ selectedTask.start,
11550
+ xStep,
11551
+ timeStep
11552
+ );
11553
+ } else {
11554
+ changedTask.end = dateByX(
11555
+ coordinates.x2,
11556
+ initialCoordinates.x2,
11557
+ selectedTask.end,
11558
+ xStep,
11559
+ timeStep
11560
+ );
11561
+ }
11562
+ }
11563
+ break;
11564
+ }
11565
+ case "move": {
11566
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
11567
+ if (isChanged) {
11568
+ if (rtl) {
11569
+ changedTask.end = dateByX(
11570
+ coordinates.x1,
11571
+ initialCoordinates.x1,
11572
+ selectedTask.end,
11573
+ xStep,
11574
+ timeStep
11575
+ );
11576
+ changedTask.start = dateByX(
11577
+ coordinates.x2,
11578
+ initialCoordinates.x2,
11579
+ selectedTask.start,
11580
+ xStep,
11581
+ timeStep
11582
+ );
11583
+ } else {
11584
+ changedTask.start = dateByX(
11585
+ coordinates.x1,
11586
+ initialCoordinates.x1,
11587
+ selectedTask.start,
11588
+ xStep,
11589
+ timeStep
11590
+ );
11591
+ changedTask.end = dateByX(
11592
+ coordinates.x2,
11593
+ initialCoordinates.x2,
11594
+ selectedTask.end,
11595
+ xStep,
11596
+ timeStep
11597
+ );
11598
+ }
11599
+ }
11600
+ break;
11601
+ }
11602
+ }
11603
+ return { isChanged, changedTask };
11604
+ };
11605
+ const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
11606
+ const changedTask = { ...selectedTask };
11607
+ const isChanged = coordinates.x1 !== initialCoordinates.x1;
11608
+ if (isChanged) {
11609
+ switch (action) {
11610
+ case "move": {
11611
+ changedTask.start = dateByX(
11612
+ coordinates.x1,
11613
+ initialCoordinates.x1,
11614
+ selectedTask.start,
11615
+ xStep,
11616
+ timeStep
11617
+ );
11618
+ changedTask.end = changedTask.start;
11619
+ break;
11620
+ }
11621
+ }
11622
+ }
11623
+ return { isChanged, changedTask };
11624
+ };
11625
+ const DateLine = ({
11626
+ config,
11627
+ additionalLeftSpace,
11628
+ startDate,
11629
+ viewMode,
11630
+ columnWidth,
11631
+ rtl,
11632
+ ganttFullHeight
11633
+ }) => {
11634
+ const tickX = taskXCoordinate(config.date, startDate, viewMode, columnWidth);
11635
+ const x = rtl ? tickX + columnWidth : tickX;
11636
+ const absX = additionalLeftSpace + x;
11637
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11638
+ /* @__PURE__ */ jsxRuntime.jsx(
11639
+ "rect",
11640
+ {
11641
+ x: absX,
11642
+ y: 0,
11643
+ width: 2,
11644
+ height: ganttFullHeight,
11645
+ fill: config.color,
11646
+ strokeDasharray: config.dashArray
11647
+ }
11648
+ ),
11649
+ /* @__PURE__ */ jsxRuntime.jsx(
11650
+ "circle",
11651
+ {
11652
+ className: styles$d.ganttTodayCircle,
11653
+ cx: absX + 1,
11654
+ cy: 6,
11655
+ r: 6,
11656
+ fill: config.color
11657
+ }
11658
+ ),
11659
+ /* @__PURE__ */ jsxRuntime.jsx(
11660
+ "text",
11661
+ {
11662
+ x: absX + 10,
11663
+ y: 10,
11664
+ fill: config.color,
11665
+ fontSize: 12,
11666
+ fontWeight: 600,
11667
+ children: config.label
11668
+ }
11669
+ )
11670
+ ] });
11671
+ };
11672
+ const GanttTodayInner = ({
11673
+ additionalLeftSpace,
11674
+ distances: { columnWidth },
11675
+ ganttFullHeight,
11676
+ isUnknownDates,
11677
+ rtl,
11678
+ startDate,
11679
+ viewMode,
11680
+ showTodayLine = true,
11681
+ showDataDateLine = false,
11682
+ showProjectStartLine = false,
11683
+ showProjectEndLine = false,
11684
+ dataDate = null,
11685
+ projectStartDate = null,
11686
+ projectEndDate = null,
11687
+ todayColor = null,
11688
+ dataDateColor = null,
11689
+ projectStartColor = null,
11690
+ projectEndColor = null,
11691
+ todayLabel = "Today",
11692
+ dataDateLabel = "Data Date",
11693
+ projectStartLabel = "Project Start",
11694
+ projectEndLabel = "Project End"
11695
+ }) => {
11696
+ const lineProps = React.useMemo(
11697
+ () => ({
11698
+ additionalLeftSpace,
11699
+ startDate,
11700
+ viewMode,
11701
+ columnWidth,
11702
+ rtl,
11703
+ ganttFullHeight
11704
+ }),
11705
+ [
11706
+ additionalLeftSpace,
11707
+ startDate,
11708
+ viewMode,
11709
+ columnWidth,
11710
+ rtl,
11711
+ ganttFullHeight
11712
+ ]
11713
+ );
11714
+ const todayElement = React.useMemo(() => {
11715
+ if (isUnknownDates || !showTodayLine) {
11716
+ return null;
11717
+ }
11718
+ return /* @__PURE__ */ jsxRuntime.jsx(
11719
+ DateLine,
11720
+ {
11721
+ config: {
11722
+ date: /* @__PURE__ */ new Date(),
11723
+ color: todayColor || "var(--gantt-calendar-today-color)",
11724
+ label: todayLabel
11725
+ },
11726
+ ...lineProps
11727
+ }
11728
+ );
11729
+ }, [isUnknownDates, showTodayLine, todayColor, todayLabel, lineProps]);
11730
+ const dataDateElement = React.useMemo(() => {
11731
+ if (!showDataDateLine || !dataDate) {
11732
+ return null;
11733
+ }
11734
+ return /* @__PURE__ */ jsxRuntime.jsx(
11735
+ DateLine,
11736
+ {
11737
+ config: {
11738
+ date: dataDate,
11739
+ color: dataDateColor || "#ff6600",
11740
+ label: dataDateLabel
11741
+ },
11742
+ ...lineProps
11743
+ }
11744
+ );
11745
+ }, [showDataDateLine, dataDate, dataDateColor, dataDateLabel, lineProps]);
11746
+ const projectStartElement = React.useMemo(() => {
11747
+ if (!showProjectStartLine || !projectStartDate) {
11748
+ return null;
11749
+ }
11750
+ return /* @__PURE__ */ jsxRuntime.jsx(
11751
+ DateLine,
11752
+ {
11753
+ config: {
11754
+ date: projectStartDate,
11755
+ color: projectStartColor || "#4caf50",
11756
+ label: projectStartLabel
11757
+ },
11758
+ ...lineProps
11759
+ }
11760
+ );
11761
+ }, [
11762
+ showProjectStartLine,
11763
+ projectStartDate,
11764
+ projectStartColor,
11765
+ projectStartLabel,
11766
+ lineProps
11767
+ ]);
11768
+ const projectEndElement = React.useMemo(() => {
11769
+ if (!showProjectEndLine || !projectEndDate) {
11770
+ return null;
11771
+ }
11772
+ return /* @__PURE__ */ jsxRuntime.jsx(
11773
+ DateLine,
11774
+ {
11775
+ config: {
11776
+ date: projectEndDate,
11777
+ color: projectEndColor || "#f44336",
11778
+ label: projectEndLabel
11779
+ },
11780
+ ...lineProps
11781
+ }
11782
+ );
11783
+ }, [
11784
+ showProjectEndLine,
11785
+ projectEndDate,
11786
+ projectEndColor,
11787
+ projectEndLabel,
11788
+ lineProps
11789
+ ]);
11790
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "today", children: [
11791
+ projectStartElement,
11792
+ projectEndElement,
11793
+ dataDateElement,
11794
+ todayElement
11795
+ ] });
11796
+ };
11797
+ const GanttToday = React.memo(GanttTodayInner);
11798
+ const calendarBottomText = "_calendarBottomText_15t8b_1";
11799
+ const calendarTopTick = "_calendarTopTick_15t8b_25";
11800
+ const calendarTopText = "_calendarTopText_15t8b_35";
11801
+ const calendarHeader = "_calendarHeader_15t8b_61";
11802
+ const calendar = "_calendar_15t8b_1";
11803
+ const calendarDragging$1 = "_calendarDragging_15t8b_85";
11804
+ const styles$c = {
11805
+ calendarBottomText,
11806
+ calendarTopTick,
11807
+ calendarTopText,
11808
+ calendarHeader,
11809
+ calendar,
11810
+ calendarDragging: calendarDragging$1
11811
+ };
11812
+ const TopPartOfCalendar = ({
11813
+ value,
11814
+ x1Line,
11815
+ y1Line,
11816
+ y2Line,
11817
+ xText,
11818
+ yText,
11819
+ language
11820
+ }) => {
11821
+ const { t, i18n } = useTranslation();
11822
+ React.useEffect(() => {
11823
+ if (language) {
11824
+ i18n.changeLanguage(language);
11825
+ }
11826
+ }, []);
11827
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "calendarTop", children: [
11828
+ /* @__PURE__ */ jsxRuntime.jsx(
11829
+ "line",
11830
+ {
11831
+ x1: x1Line,
11832
+ y1: y1Line,
11833
+ x2: x1Line,
11834
+ y2: y2Line,
11835
+ className: styles$c.calendarTopTick
11836
+ }
11837
+ ),
11838
+ value !== null && /* @__PURE__ */ jsxRuntime.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 })
11839
+ ] });
11840
+ };
11841
+ const defaultRenderBottomHeader = (date, viewMode, dateSetup, index2, isUnknownDates) => {
11842
+ if (isUnknownDates) {
11843
+ const {
11844
+ dateLocale: { formatDistance: formatDistance2 },
11845
+ preStepsCount
11846
+ } = dateSetup;
11847
+ const offsetFromStart = index2 - preStepsCount;
11848
+ if (offsetFromStart === 0) {
11849
+ return "0";
11850
+ }
11851
+ let value = "";
11852
+ if (!formatDistance2) {
11853
+ value = `${offsetFromStart}`;
11854
+ } else {
11855
+ switch (viewMode) {
11856
+ case ViewMode.Year:
11857
+ value = formatDistance2("xYears", offsetFromStart);
11858
+ break;
11859
+ case ViewMode.Month:
11860
+ value = formatDistance2("xMonths", offsetFromStart);
11861
+ break;
11862
+ case ViewMode.Week:
11863
+ value = formatDistance2("xWeeks", offsetFromStart);
11864
+ break;
11865
+ case ViewMode.Day:
11866
+ value = formatDistance2("xDays", offsetFromStart);
11867
+ break;
11868
+ case ViewMode.QuarterDay:
11869
+ value = formatDistance2("xHours", offsetFromStart * 6);
11870
+ break;
11871
+ case ViewMode.HalfDay:
11872
+ value = formatDistance2("xHours", offsetFromStart * 12);
11873
+ break;
11874
+ case ViewMode.Hour:
11875
+ value = formatDistance2("xHours", offsetFromStart);
11876
+ break;
11877
+ default:
11878
+ throw new Error("Unknown viewMode");
11879
+ }
11880
+ }
11881
+ if (offsetFromStart > 0) {
11882
+ return `+${value}`;
11883
+ }
11884
+ return value;
11885
+ }
11886
+ switch (viewMode) {
11887
+ case ViewMode.Year:
11888
+ return date.getFullYear();
11889
+ case ViewMode.Month:
11890
+ try {
11891
+ return format(date, dateSetup.dateFormats.monthBottomHeaderFormat, {
11892
+ locale: dateSetup.dateLocale
11893
+ });
11894
+ } catch (e) {
11895
+ return date.toLocaleString("default", { month: "long" });
11896
+ }
11897
+ case ViewMode.Week:
11898
+ return dateSetup.dateFormats.weekBottomHeader(
11899
+ date,
11900
+ getWeekNumberISO8601(date),
11901
+ dateSetup.dateLocale
11902
+ );
11903
+ case ViewMode.Day:
11904
+ try {
11905
+ return format(date, dateSetup.dateFormats.dayBottomHeaderFormat, {
11906
+ locale: dateSetup.dateLocale
11907
+ });
11908
+ } catch (e) {
11909
+ return String(date.getDate());
11910
+ }
11911
+ case ViewMode.QuarterDay:
11912
+ case ViewMode.HalfDay:
11913
+ case ViewMode.Hour:
11914
+ try {
11915
+ return format(date, dateSetup.dateFormats.hourBottomHeaderFormat, {
11916
+ locale: dateSetup.dateLocale
11917
+ });
11918
+ } catch (e) {
11919
+ return String(date.getDate());
11920
+ }
11921
+ default:
11922
+ throw new Error("Unknown viewMode");
11923
+ }
11924
+ };
11925
+ const getDayText = (date, dateSetup) => {
11926
+ try {
11927
+ return format(date, dateSetup.dateFormats.dayTopHeaderFormat, {
11928
+ locale: dateSetup.dateLocale
11929
+ });
11930
+ } catch (e) {
11931
+ return String(date.getDate());
11932
+ }
11933
+ };
11934
+ const getMonthText = (date, dateSetup) => {
11935
+ try {
11936
+ return format(date, dateSetup.dateFormats.monthTopHeaderFormat, {
11937
+ locale: dateSetup.dateLocale
11676
11938
  });
11677
11939
  } catch (e) {
11678
11940
  return date.toLocaleString("default", { month: "long" });
@@ -12315,231 +12577,6 @@
12315
12577
  }
12316
12578
  );
12317
12579
  };
12318
- const getDateByOffset = (startDate, offset2, viewMode) => {
12319
- switch (viewMode) {
12320
- case ViewMode.Day:
12321
- return addDays(startDate, offset2);
12322
- case ViewMode.HalfDay:
12323
- return addHours(startDate, offset2 * 12);
12324
- case ViewMode.QuarterDay:
12325
- return addHours(startDate, offset2 * 6);
12326
- case ViewMode.Hour:
12327
- return addHours(startDate, offset2);
12328
- case ViewMode.Month:
12329
- return addMonths(startDate, offset2);
12330
- case ViewMode.Week:
12331
- return addWeeks(startDate, offset2);
12332
- case ViewMode.Year:
12333
- return addYears(startDate, offset2);
12334
- default:
12335
- throw new Error("Unknown view mode");
12336
- }
12337
- };
12338
- const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
12339
- const index2 = getDatesDiff(xDate, startDate, viewMode);
12340
- const currentDate = getDateByOffset(startDate, index2, viewMode);
12341
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
12342
- const remainderMillis = xDate.getTime() - currentDate.getTime();
12343
- const intervalDuration = nextDate.getTime() - currentDate.getTime();
12344
- const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
12345
- const result = index2 * columnWidth + percentOfInterval * columnWidth;
12346
- return isNaN(result) || !isFinite(result) ? 0 : result;
12347
- };
12348
- const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
12349
- const index2 = getDatesDiff(xDate, startDate, viewMode);
12350
- const currentDate = getDateByOffset(startDate, index2, viewMode);
12351
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
12352
- const remainderMillis = xDate.getTime() - currentDate.getTime();
12353
- const intervalDuration = nextDate.getTime() - currentDate.getTime();
12354
- const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
12355
- const result = index2 * columnWidth + percentOfInterval * columnWidth;
12356
- return isNaN(result) || !isFinite(result) ? 0 : result;
12357
- };
12358
- const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
12359
- const safeTaskX1 = isNaN(taskX1) || !isFinite(taskX1) ? 0 : taskX1;
12360
- const safeTaskX2 = isNaN(taskX2) || !isFinite(taskX2) ? 0 : taskX2;
12361
- const safeProgress = isNaN(progress) || !isFinite(progress) ? 0 : progress;
12362
- const progressWidth = Math.max(
12363
- (safeTaskX2 - safeTaskX1) * safeProgress * 0.01,
12364
- 0
12365
- );
12366
- let progressX;
12367
- if (rtl) {
12368
- progressX = safeTaskX2 - progressWidth;
12369
- } else {
12370
- progressX = safeTaskX1;
12371
- }
12372
- return [progressWidth, progressX];
12373
- };
12374
- const getProgressPoint = (progressX, taskY, taskHeight) => {
12375
- const point = [
12376
- progressX - 5,
12377
- taskY + taskHeight,
12378
- progressX + 5,
12379
- taskY + taskHeight,
12380
- progressX,
12381
- taskY + taskHeight - 8.66
12382
- ];
12383
- return point.join(",");
12384
- };
12385
- const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
12386
- const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
12387
- const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
12388
- const safeXStep = isNaN(xStep) || !isFinite(xStep) || xStep === 0 ? 1 : xStep;
12389
- const safeTimeStep = isNaN(timeStep) || !isFinite(timeStep) ? 0 : timeStep;
12390
- let newDate = new Date(
12391
- (safeX - safeTaskX) / safeXStep * safeTimeStep + taskDate.getTime()
12392
- );
12393
- newDate = new Date(
12394
- newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
12395
- );
12396
- return newDate;
12397
- };
12398
- const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
12399
- let result;
12400
- switch (selectedTask.type) {
12401
- case "milestone":
12402
- result = handleTaskBySVGMouseEventForMilestone(
12403
- action,
12404
- selectedTask,
12405
- initialCoordinates,
12406
- coordinates,
12407
- xStep,
12408
- timeStep
12409
- );
12410
- break;
12411
- default:
12412
- result = handleTaskBySVGMouseEventForBar(
12413
- action,
12414
- selectedTask,
12415
- initialCoordinates,
12416
- coordinates,
12417
- xStep,
12418
- timeStep,
12419
- rtl
12420
- );
12421
- break;
12422
- }
12423
- return result;
12424
- };
12425
- const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
12426
- const changedTask = { ...selectedTask };
12427
- let isChanged = false;
12428
- switch (action) {
12429
- case "progress":
12430
- isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
12431
- if (isChanged) {
12432
- changedTask.progress = Math.round(
12433
- coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
12434
- );
12435
- }
12436
- break;
12437
- case "start": {
12438
- isChanged = initialCoordinates.x1 !== coordinates.x1;
12439
- if (isChanged) {
12440
- if (rtl) {
12441
- changedTask.end = dateByX(
12442
- coordinates.x1,
12443
- initialCoordinates.x1,
12444
- selectedTask.end,
12445
- xStep,
12446
- timeStep
12447
- );
12448
- } else {
12449
- changedTask.start = dateByX(
12450
- coordinates.x1,
12451
- initialCoordinates.x1,
12452
- selectedTask.start,
12453
- xStep,
12454
- timeStep
12455
- );
12456
- }
12457
- }
12458
- break;
12459
- }
12460
- case "end": {
12461
- isChanged = initialCoordinates.x2 !== coordinates.x2;
12462
- if (isChanged) {
12463
- if (rtl) {
12464
- changedTask.start = dateByX(
12465
- coordinates.x2,
12466
- initialCoordinates.x2,
12467
- selectedTask.start,
12468
- xStep,
12469
- timeStep
12470
- );
12471
- } else {
12472
- changedTask.end = dateByX(
12473
- coordinates.x2,
12474
- initialCoordinates.x2,
12475
- selectedTask.end,
12476
- xStep,
12477
- timeStep
12478
- );
12479
- }
12480
- }
12481
- break;
12482
- }
12483
- case "move": {
12484
- isChanged = initialCoordinates.x1 !== coordinates.x1;
12485
- if (isChanged) {
12486
- if (rtl) {
12487
- changedTask.end = dateByX(
12488
- coordinates.x1,
12489
- initialCoordinates.x1,
12490
- selectedTask.end,
12491
- xStep,
12492
- timeStep
12493
- );
12494
- changedTask.start = dateByX(
12495
- coordinates.x2,
12496
- initialCoordinates.x2,
12497
- selectedTask.start,
12498
- xStep,
12499
- timeStep
12500
- );
12501
- } else {
12502
- changedTask.start = dateByX(
12503
- coordinates.x1,
12504
- initialCoordinates.x1,
12505
- selectedTask.start,
12506
- xStep,
12507
- timeStep
12508
- );
12509
- changedTask.end = dateByX(
12510
- coordinates.x2,
12511
- initialCoordinates.x2,
12512
- selectedTask.end,
12513
- xStep,
12514
- timeStep
12515
- );
12516
- }
12517
- }
12518
- break;
12519
- }
12520
- }
12521
- return { isChanged, changedTask };
12522
- };
12523
- const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
12524
- const changedTask = { ...selectedTask };
12525
- const isChanged = coordinates.x1 !== initialCoordinates.x1;
12526
- if (isChanged) {
12527
- switch (action) {
12528
- case "move": {
12529
- changedTask.start = dateByX(
12530
- coordinates.x1,
12531
- initialCoordinates.x1,
12532
- selectedTask.start,
12533
- xStep,
12534
- timeStep
12535
- );
12536
- changedTask.end = changedTask.start;
12537
- break;
12538
- }
12539
- }
12540
- }
12541
- return { isChanged, changedTask };
12542
- };
12543
12580
  const barWrapper = "_barWrapper_5jhkr_1";
12544
12581
  const barHandle = "_barHandle_5jhkr_11";
12545
12582
  const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
@@ -19955,11 +19992,19 @@
19955
19992
  rowHeight,
19956
19993
  showTodayLine = true,
19957
19994
  showDataDateLine = false,
19995
+ showProjectStartLine = false,
19996
+ showProjectEndLine = false,
19958
19997
  dataDate = null,
19998
+ projectStartDate = null,
19999
+ projectEndDate = null,
19959
20000
  todayColor,
19960
20001
  dataDateColor,
20002
+ projectStartColor,
20003
+ projectEndColor,
19961
20004
  todayLabel = "Today",
19962
20005
  dataDateLabel = "Data Date",
20006
+ projectStartLabel = "Project Start",
20007
+ projectEndLabel = "Project End",
19963
20008
  showProgress = true,
19964
20009
  hideProjectProgress = false,
19965
20010
  progressColor,
@@ -21388,11 +21433,19 @@
21388
21433
  viewMode,
21389
21434
  showTodayLine,
21390
21435
  showDataDateLine,
21436
+ showProjectStartLine,
21437
+ showProjectEndLine,
21391
21438
  dataDate,
21439
+ projectStartDate,
21440
+ projectEndDate,
21392
21441
  todayColor,
21393
21442
  dataDateColor,
21443
+ projectStartColor,
21444
+ projectEndColor,
21394
21445
  todayLabel,
21395
- dataDateLabel
21446
+ dataDateLabel,
21447
+ projectStartLabel,
21448
+ projectEndLabel
21396
21449
  }),
21397
21450
  [
21398
21451
  additionalLeftSpace,
@@ -21404,11 +21457,19 @@
21404
21457
  viewMode,
21405
21458
  showTodayLine,
21406
21459
  showDataDateLine,
21460
+ showProjectStartLine,
21461
+ showProjectEndLine,
21407
21462
  dataDate,
21463
+ projectStartDate,
21464
+ projectEndDate,
21408
21465
  todayColor,
21409
21466
  dataDateColor,
21467
+ projectStartColor,
21468
+ projectEndColor,
21410
21469
  todayLabel,
21411
- dataDateLabel
21470
+ dataDateLabel,
21471
+ projectStartLabel,
21472
+ projectEndLabel
21412
21473
  ]
21413
21474
  );
21414
21475
  const calendarProps = React.useMemo(