gantt-task-react-v 1.6.19 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11380,278 +11380,6 @@ const styles$d = {
11380
11380
  ganttToday,
11381
11381
  ganttTodayCircle
11382
11382
  };
11383
- const getDateByOffset = (startDate, offset2, viewMode) => {
11384
- switch (viewMode) {
11385
- case ViewMode.Day:
11386
- return addDays(startDate, offset2);
11387
- case ViewMode.HalfDay:
11388
- return addHours(startDate, offset2 * 12);
11389
- case ViewMode.QuarterDay:
11390
- return addHours(startDate, offset2 * 6);
11391
- case ViewMode.Hour:
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);
11399
- default:
11400
- throw new Error("Unknown view mode");
11401
- }
11402
- };
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;
11412
- };
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
11383
  const GanttTodayInner = ({
11656
11384
  additionalLeftSpace,
11657
11385
  distances: { columnWidth },
@@ -11662,133 +11390,185 @@ const GanttTodayInner = ({
11662
11390
  viewMode,
11663
11391
  showTodayLine = true,
11664
11392
  showDataDateLine = false,
11665
- showProjectStartLine = false,
11666
- showProjectEndLine = false,
11667
11393
  dataDate = null,
11668
- projectStartDate = null,
11669
- projectEndDate = null,
11670
11394
  todayColor = null,
11671
11395
  dataDateColor = null,
11672
- projectStartColor = null,
11673
- projectEndColor = null,
11674
11396
  todayLabel = "Today",
11675
- dataDateLabel = "Data Date",
11676
- projectStartLabel = "Project Start",
11677
- projectEndLabel = "Project End"
11397
+ dataDateLabel = "Data Date"
11678
11398
  }) => {
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
11399
  const todayElement = useMemo(() => {
11698
11400
  if (isUnknownDates || !showTodayLine) {
11699
11401
  return null;
11700
11402
  }
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
11403
+ const today = /* @__PURE__ */ new Date();
11404
+ const todayIndex = getDatesDiff(today, startDate, viewMode);
11405
+ const extraMultiplier = () => {
11406
+ switch (viewMode) {
11407
+ case ViewMode.Week: {
11408
+ const percent = today.getDay() / 7;
11409
+ return 1 + percent * 0.2;
11410
+ }
11411
+ case ViewMode.Month: {
11412
+ const dayInMonth = today.getDate();
11413
+ const maxDaysInMonth = getDaysInMonth(
11414
+ today.getMonth(),
11415
+ today.getFullYear()
11416
+ );
11417
+ const percent = dayInMonth / maxDaysInMonth;
11418
+ return 1 + percent * 0.5;
11419
+ }
11420
+ case ViewMode.Year: {
11421
+ const percent = today.getMonth() / 12;
11422
+ return 1 + percent * 0.5;
11423
+ }
11424
+ default:
11425
+ return 1;
11742
11426
  }
11743
- );
11427
+ };
11428
+ const tickX = todayIndex * columnWidth * extraMultiplier();
11429
+ const x = rtl ? tickX + columnWidth : tickX;
11430
+ const color = todayColor || "var(--gantt-calendar-today-color)";
11431
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
11432
+ /* @__PURE__ */ jsx(
11433
+ "rect",
11434
+ {
11435
+ x: additionalLeftSpace + x,
11436
+ y: 0,
11437
+ width: 2,
11438
+ height: ganttFullHeight,
11439
+ fill: color
11440
+ }
11441
+ ),
11442
+ /* @__PURE__ */ jsx(
11443
+ "circle",
11444
+ {
11445
+ className: styles$d.ganttTodayCircle,
11446
+ cx: x + 1,
11447
+ cy: 6,
11448
+ r: 6,
11449
+ fill: color
11450
+ }
11451
+ ),
11452
+ /* @__PURE__ */ jsx(
11453
+ "text",
11454
+ {
11455
+ x: additionalLeftSpace + x + 8,
11456
+ y: 10,
11457
+ fill: color,
11458
+ fontSize: 12,
11459
+ fontWeight: 600,
11460
+ children: todayLabel
11461
+ }
11462
+ )
11463
+ ] });
11744
11464
  }, [
11745
- showProjectStartLine,
11746
- projectStartDate,
11747
- projectStartColor,
11748
- projectStartLabel,
11749
- lineProps
11465
+ additionalLeftSpace,
11466
+ columnWidth,
11467
+ ganttFullHeight,
11468
+ isUnknownDates,
11469
+ rtl,
11470
+ startDate,
11471
+ viewMode,
11472
+ showTodayLine,
11473
+ todayColor,
11474
+ todayLabel
11750
11475
  ]);
11751
- const projectEndElement = useMemo(() => {
11752
- if (!showProjectEndLine || !projectEndDate) {
11476
+ const dataDateElement = useMemo(() => {
11477
+ if (!showDataDateLine || !dataDate) {
11753
11478
  return null;
11754
11479
  }
11755
- return /* @__PURE__ */ jsx(
11756
- DateLine,
11757
- {
11758
- config: {
11759
- date: projectEndDate,
11760
- color: projectEndColor || "#f44336",
11761
- label: projectEndLabel
11762
- },
11763
- ...lineProps
11480
+ const dataIndex = getDatesDiff(dataDate, startDate, viewMode);
11481
+ const extraMultiplier = () => {
11482
+ switch (viewMode) {
11483
+ case ViewMode.Week: {
11484
+ const percent = dataDate.getDay() / 7;
11485
+ return 1 + percent * 0.2;
11486
+ }
11487
+ case ViewMode.Month: {
11488
+ const dayInMonth = dataDate.getDate();
11489
+ const maxDaysInMonth = getDaysInMonth(
11490
+ dataDate.getMonth(),
11491
+ dataDate.getFullYear()
11492
+ );
11493
+ const percent = dayInMonth / maxDaysInMonth;
11494
+ return 1 + percent * 0.5;
11495
+ }
11496
+ case ViewMode.Year: {
11497
+ const percent = dataDate.getMonth() / 12;
11498
+ return 1 + percent * 0.5;
11499
+ }
11500
+ default:
11501
+ return 1;
11764
11502
  }
11765
- );
11503
+ };
11504
+ const tickX = dataIndex * columnWidth * extraMultiplier();
11505
+ const x = rtl ? tickX + columnWidth : tickX;
11506
+ const color = dataDateColor || "var(--gantt-calendar-today-color)";
11507
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
11508
+ /* @__PURE__ */ jsx(
11509
+ "rect",
11510
+ {
11511
+ x: additionalLeftSpace + x,
11512
+ y: 0,
11513
+ width: 2,
11514
+ height: ganttFullHeight,
11515
+ fill: color,
11516
+ opacity: 0.9
11517
+ }
11518
+ ),
11519
+ /* @__PURE__ */ jsx(
11520
+ "circle",
11521
+ {
11522
+ className: styles$d.ganttTodayCircle,
11523
+ cx: x + 1,
11524
+ cy: 6,
11525
+ r: 6,
11526
+ fill: color
11527
+ }
11528
+ ),
11529
+ /* @__PURE__ */ jsx(
11530
+ "text",
11531
+ {
11532
+ x: additionalLeftSpace + x + 8,
11533
+ y: 10,
11534
+ fill: color,
11535
+ fontSize: 12,
11536
+ fontWeight: 600,
11537
+ children: dataDateLabel || "Data Date"
11538
+ }
11539
+ )
11540
+ ] });
11766
11541
  }, [
11767
- showProjectEndLine,
11768
- projectEndDate,
11769
- projectEndColor,
11770
- projectEndLabel,
11771
- lineProps
11542
+ additionalLeftSpace,
11543
+ columnWidth,
11544
+ ganttFullHeight,
11545
+ rtl,
11546
+ startDate,
11547
+ viewMode,
11548
+ showDataDateLine,
11549
+ dataDate,
11550
+ dataDateColor,
11551
+ dataDateLabel
11772
11552
  ]);
11773
11553
  return /* @__PURE__ */ jsxs("g", { className: "today", children: [
11774
- projectStartElement,
11775
- projectEndElement,
11776
11554
  dataDateElement,
11777
11555
  todayElement
11778
11556
  ] });
11779
11557
  };
11780
11558
  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";
11559
+ const calendarBottomText = "_calendarBottomText_1mt8w_1";
11560
+ const calendarTopTick = "_calendarTopTick_1mt8w_31";
11561
+ const calendarTopText = "_calendarTopText_1mt8w_41";
11562
+ const calendarHeader = "_calendarHeader_1mt8w_67";
11563
+ const calendarBottomSeparator = "_calendarBottomSeparator_1mt8w_81";
11564
+ const calendar = "_calendar_1mt8w_1";
11565
+ const calendarDragging$1 = "_calendarDragging_1mt8w_103";
11787
11566
  const styles$c = {
11788
11567
  calendarBottomText,
11789
11568
  calendarTopTick,
11790
11569
  calendarTopText,
11791
11570
  calendarHeader,
11571
+ calendarBottomSeparator,
11792
11572
  calendar,
11793
11573
  calendarDragging: calendarDragging$1
11794
11574
  };
@@ -12072,6 +11852,19 @@ const Calendar = ({
12072
11852
  const bottomValues2 = [];
12073
11853
  let weeksCount = 1;
12074
11854
  const topDefaultHeight = headerHeight * 0.5;
11855
+ bottomValues2.push(
11856
+ /* @__PURE__ */ jsx(
11857
+ "line",
11858
+ {
11859
+ x1: 0,
11860
+ y1: topDefaultHeight,
11861
+ x2: fullSvgWidth,
11862
+ y2: topDefaultHeight,
11863
+ className: styles$c.calendarBottomSeparator
11864
+ },
11865
+ "week-top-border"
11866
+ )
11867
+ );
12075
11868
  for (let i = endColumnIndex; i >= startColumnIndex; i--) {
12076
11869
  const date = getDate(i);
12077
11870
  const month = date.getMonth();
@@ -12081,6 +11874,19 @@ const Calendar = ({
12081
11874
  topValue = renderTopHeaderByDate(date);
12082
11875
  }
12083
11876
  const bottomValue = renderBottomHeaderByDate(date, i);
11877
+ bottomValues2.push(
11878
+ /* @__PURE__ */ jsx(
11879
+ "line",
11880
+ {
11881
+ x1: additionalLeftSpace + columnWidth * i,
11882
+ y1: topDefaultHeight,
11883
+ x2: additionalLeftSpace + columnWidth * i,
11884
+ y2: headerHeight,
11885
+ className: styles$c.calendarBottomSeparator
11886
+ },
11887
+ `week-sep-${i}`
11888
+ )
11889
+ );
12084
11890
  bottomValues2.push(
12085
11891
  renderBottomText(
12086
11892
  additionalLeftSpace + columnWidth * (i + +rtl),
@@ -12116,11 +11922,37 @@ const Calendar = ({
12116
11922
  const bottomValues2 = [];
12117
11923
  const topDefaultHeight = headerHeight * 0.5;
12118
11924
  const renderedMonths = /* @__PURE__ */ new Set();
11925
+ bottomValues2.push(
11926
+ /* @__PURE__ */ jsx(
11927
+ "line",
11928
+ {
11929
+ x1: 0,
11930
+ y1: topDefaultHeight,
11931
+ x2: fullSvgWidth,
11932
+ y2: topDefaultHeight,
11933
+ className: styles$c.calendarBottomSeparator
11934
+ },
11935
+ "day-top-border"
11936
+ )
11937
+ );
12119
11938
  for (let i = startColumnIndex; i <= endColumnIndex; i++) {
12120
11939
  const date = getDate(i);
12121
11940
  const bottomValue = renderBottomHeaderByDate(date, i);
12122
11941
  const month = date.getMonth();
12123
11942
  const fullYear = date.getFullYear();
11943
+ bottomValues2.push(
11944
+ /* @__PURE__ */ jsx(
11945
+ "line",
11946
+ {
11947
+ x1: additionalLeftSpace + columnWidth * i,
11948
+ y1: topDefaultHeight,
11949
+ x2: additionalLeftSpace + columnWidth * i,
11950
+ y2: headerHeight,
11951
+ className: styles$c.calendarBottomSeparator
11952
+ },
11953
+ `day-sep-${i}`
11954
+ )
11955
+ );
12124
11956
  bottomValues2.push(
12125
11957
  renderBottomText(
12126
11958
  additionalLeftSpace + columnWidth * i + columnWidth * 0.5,
@@ -12560,6 +12392,231 @@ const RelationLine = ({
12560
12392
  }
12561
12393
  );
12562
12394
  };
12395
+ const getDateByOffset = (startDate, offset2, viewMode) => {
12396
+ switch (viewMode) {
12397
+ case ViewMode.Day:
12398
+ return addDays(startDate, offset2);
12399
+ case ViewMode.HalfDay:
12400
+ return addHours(startDate, offset2 * 12);
12401
+ case ViewMode.QuarterDay:
12402
+ return addHours(startDate, offset2 * 6);
12403
+ case ViewMode.Hour:
12404
+ return addHours(startDate, offset2);
12405
+ case ViewMode.Month:
12406
+ return addMonths(startDate, offset2);
12407
+ case ViewMode.Week:
12408
+ return addWeeks(startDate, offset2);
12409
+ case ViewMode.Year:
12410
+ return addYears(startDate, offset2);
12411
+ default:
12412
+ throw new Error("Unknown view mode");
12413
+ }
12414
+ };
12415
+ const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
12416
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
12417
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
12418
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
12419
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
12420
+ const intervalDuration = nextDate.getTime() - currentDate.getTime();
12421
+ const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
12422
+ const result = index2 * columnWidth + percentOfInterval * columnWidth;
12423
+ return isNaN(result) || !isFinite(result) ? 0 : result;
12424
+ };
12425
+ const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
12426
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
12427
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
12428
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
12429
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
12430
+ const intervalDuration = nextDate.getTime() - currentDate.getTime();
12431
+ const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
12432
+ const result = index2 * columnWidth + percentOfInterval * columnWidth;
12433
+ return isNaN(result) || !isFinite(result) ? 0 : result;
12434
+ };
12435
+ const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
12436
+ const safeTaskX1 = isNaN(taskX1) || !isFinite(taskX1) ? 0 : taskX1;
12437
+ const safeTaskX2 = isNaN(taskX2) || !isFinite(taskX2) ? 0 : taskX2;
12438
+ const safeProgress = isNaN(progress) || !isFinite(progress) ? 0 : progress;
12439
+ const progressWidth = Math.max(
12440
+ (safeTaskX2 - safeTaskX1) * safeProgress * 0.01,
12441
+ 0
12442
+ );
12443
+ let progressX;
12444
+ if (rtl) {
12445
+ progressX = safeTaskX2 - progressWidth;
12446
+ } else {
12447
+ progressX = safeTaskX1;
12448
+ }
12449
+ return [progressWidth, progressX];
12450
+ };
12451
+ const getProgressPoint = (progressX, taskY, taskHeight) => {
12452
+ const point = [
12453
+ progressX - 5,
12454
+ taskY + taskHeight,
12455
+ progressX + 5,
12456
+ taskY + taskHeight,
12457
+ progressX,
12458
+ taskY + taskHeight - 8.66
12459
+ ];
12460
+ return point.join(",");
12461
+ };
12462
+ const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
12463
+ const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
12464
+ const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
12465
+ const safeXStep = isNaN(xStep) || !isFinite(xStep) || xStep === 0 ? 1 : xStep;
12466
+ const safeTimeStep = isNaN(timeStep) || !isFinite(timeStep) ? 0 : timeStep;
12467
+ let newDate = new Date(
12468
+ (safeX - safeTaskX) / safeXStep * safeTimeStep + taskDate.getTime()
12469
+ );
12470
+ newDate = new Date(
12471
+ newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
12472
+ );
12473
+ return newDate;
12474
+ };
12475
+ const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
12476
+ let result;
12477
+ switch (selectedTask.type) {
12478
+ case "milestone":
12479
+ result = handleTaskBySVGMouseEventForMilestone(
12480
+ action,
12481
+ selectedTask,
12482
+ initialCoordinates,
12483
+ coordinates,
12484
+ xStep,
12485
+ timeStep
12486
+ );
12487
+ break;
12488
+ default:
12489
+ result = handleTaskBySVGMouseEventForBar(
12490
+ action,
12491
+ selectedTask,
12492
+ initialCoordinates,
12493
+ coordinates,
12494
+ xStep,
12495
+ timeStep,
12496
+ rtl
12497
+ );
12498
+ break;
12499
+ }
12500
+ return result;
12501
+ };
12502
+ const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
12503
+ const changedTask = { ...selectedTask };
12504
+ let isChanged = false;
12505
+ switch (action) {
12506
+ case "progress":
12507
+ isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
12508
+ if (isChanged) {
12509
+ changedTask.progress = Math.round(
12510
+ coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
12511
+ );
12512
+ }
12513
+ break;
12514
+ case "start": {
12515
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
12516
+ if (isChanged) {
12517
+ if (rtl) {
12518
+ changedTask.end = dateByX(
12519
+ coordinates.x1,
12520
+ initialCoordinates.x1,
12521
+ selectedTask.end,
12522
+ xStep,
12523
+ timeStep
12524
+ );
12525
+ } else {
12526
+ changedTask.start = dateByX(
12527
+ coordinates.x1,
12528
+ initialCoordinates.x1,
12529
+ selectedTask.start,
12530
+ xStep,
12531
+ timeStep
12532
+ );
12533
+ }
12534
+ }
12535
+ break;
12536
+ }
12537
+ case "end": {
12538
+ isChanged = initialCoordinates.x2 !== coordinates.x2;
12539
+ if (isChanged) {
12540
+ if (rtl) {
12541
+ changedTask.start = dateByX(
12542
+ coordinates.x2,
12543
+ initialCoordinates.x2,
12544
+ selectedTask.start,
12545
+ xStep,
12546
+ timeStep
12547
+ );
12548
+ } else {
12549
+ changedTask.end = dateByX(
12550
+ coordinates.x2,
12551
+ initialCoordinates.x2,
12552
+ selectedTask.end,
12553
+ xStep,
12554
+ timeStep
12555
+ );
12556
+ }
12557
+ }
12558
+ break;
12559
+ }
12560
+ case "move": {
12561
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
12562
+ if (isChanged) {
12563
+ if (rtl) {
12564
+ changedTask.end = dateByX(
12565
+ coordinates.x1,
12566
+ initialCoordinates.x1,
12567
+ selectedTask.end,
12568
+ xStep,
12569
+ timeStep
12570
+ );
12571
+ changedTask.start = dateByX(
12572
+ coordinates.x2,
12573
+ initialCoordinates.x2,
12574
+ selectedTask.start,
12575
+ xStep,
12576
+ timeStep
12577
+ );
12578
+ } else {
12579
+ changedTask.start = dateByX(
12580
+ coordinates.x1,
12581
+ initialCoordinates.x1,
12582
+ selectedTask.start,
12583
+ xStep,
12584
+ timeStep
12585
+ );
12586
+ changedTask.end = dateByX(
12587
+ coordinates.x2,
12588
+ initialCoordinates.x2,
12589
+ selectedTask.end,
12590
+ xStep,
12591
+ timeStep
12592
+ );
12593
+ }
12594
+ }
12595
+ break;
12596
+ }
12597
+ }
12598
+ return { isChanged, changedTask };
12599
+ };
12600
+ const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
12601
+ const changedTask = { ...selectedTask };
12602
+ const isChanged = coordinates.x1 !== initialCoordinates.x1;
12603
+ if (isChanged) {
12604
+ switch (action) {
12605
+ case "move": {
12606
+ changedTask.start = dateByX(
12607
+ coordinates.x1,
12608
+ initialCoordinates.x1,
12609
+ selectedTask.start,
12610
+ xStep,
12611
+ timeStep
12612
+ );
12613
+ changedTask.end = changedTask.start;
12614
+ break;
12615
+ }
12616
+ }
12617
+ }
12618
+ return { isChanged, changedTask };
12619
+ };
12563
12620
  const barWrapper = "_barWrapper_5jhkr_1";
12564
12621
  const barHandle = "_barHandle_5jhkr_11";
12565
12622
  const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
@@ -13194,9 +13251,9 @@ const Milestone = ({
13194
13251
  relationHandles
13195
13252
  ] });
13196
13253
  };
13197
- const barLabel = "_barLabel_81831_1";
13198
- const barLabelHidden = "_barLabelHidden_81831_27";
13199
- const barLabelOutside = "_barLabelOutside_81831_37";
13254
+ const barLabel = "_barLabel_5nsbb_1";
13255
+ const barLabelHidden = "_barLabelHidden_5nsbb_27";
13256
+ const barLabelOutside = "_barLabelOutside_5nsbb_37";
13200
13257
  const style = {
13201
13258
  barLabel,
13202
13259
  barLabelHidden,
@@ -13206,6 +13263,7 @@ const TaskResponsiveLabelInner = (props) => {
13206
13263
  const {
13207
13264
  alwaysOutline,
13208
13265
  arrowIndent,
13266
+ forceOutside,
13209
13267
  rtl,
13210
13268
  label: label2,
13211
13269
  taskHeight,
@@ -13221,21 +13279,22 @@ const TaskResponsiveLabelInner = (props) => {
13221
13279
  setIsTextInside(textRef.current.getBBox().width < width);
13222
13280
  }
13223
13281
  }, [textRef, width, viewMode]);
13282
+ const shouldBeOutside = alwaysOutline || forceOutside;
13224
13283
  const calculatedX = useMemo(() => {
13225
- if (isTextInside && !alwaysOutline) {
13284
+ if (isTextInside && !shouldBeOutside) {
13226
13285
  return x1 + width * 0.5;
13227
13286
  }
13228
13287
  if (rtl && textRef.current) {
13229
13288
  return x1 - textRef.current.getBBox().width - arrowIndent * 0.8;
13230
13289
  }
13231
13290
  return x1 + width + arrowIndent * 1.2;
13232
- }, [alwaysOutline, x1, width, isTextInside, rtl, arrowIndent]);
13291
+ }, [shouldBeOutside, x1, width, isTextInside, rtl, arrowIndent]);
13233
13292
  return /* @__PURE__ */ jsx(
13234
13293
  "text",
13235
13294
  {
13236
13295
  x: calculatedX,
13237
13296
  y: taskYOffset + taskHeight * 0.5,
13238
- className: isTextInside && !alwaysOutline ? style.barLabel : style.barLabelOutside,
13297
+ className: isTextInside && !shouldBeOutside ? style.barLabel : style.barLabelOutside,
13239
13298
  ref: textRef,
13240
13299
  children: label2
13241
13300
  }
@@ -13499,7 +13558,8 @@ const TaskItemInner = (props) => {
13499
13558
  label: task.name,
13500
13559
  taskYOffset,
13501
13560
  viewMode,
13502
- alwaysOutline: task.type === "project"
13561
+ alwaysOutline: task.type === "project",
13562
+ forceOutside: props.showProgress && width > 40
13503
13563
  }
13504
13564
  )
13505
13565
  ]
@@ -13824,6 +13884,10 @@ const TaskGanttContentInner = (props) => {
13824
13884
  const safeComparisonY = isNaN(comparisonDates.y) || !isFinite(comparisonDates.y) ? safeLevelY : comparisonDates.y;
13825
13885
  const safeComparisonWidth = isNaN(comparisonDates.width) || !isFinite(comparisonDates.width) ? 0 : Math.max(comparisonDates.width, 0);
13826
13886
  const safeComparisonHeight = isNaN(comparisonDates.height) || !isFinite(comparisonDates.height) ? 0 : Math.max(comparisonDates.height, 0);
13887
+ const maxComparisonSvgHeight = Math.max(
13888
+ distances.rowHeight - taskYOffset - taskHeight,
13889
+ safeComparisonHeight
13890
+ );
13827
13891
  tasksRes.push(
13828
13892
  /* @__PURE__ */ jsx(
13829
13893
  "svg",
@@ -13833,7 +13897,7 @@ const TaskGanttContentInner = (props) => {
13833
13897
  x: Math.max(safeComparisonX + (additionalLeftSpace || 0), 0),
13834
13898
  y: safeComparisonY,
13835
13899
  width: safeComparisonWidth,
13836
- height: safeComparisonHeight * 2,
13900
+ height: Math.min(safeComparisonHeight * 2, maxComparisonSvgHeight),
13837
13901
  children: /* @__PURE__ */ jsx(
13838
13902
  BarComparison,
13839
13903
  {
@@ -14639,11 +14703,16 @@ const countTaskCoordinates = (task, taskToRowIndexMap, startDate, viewMode, rtl,
14639
14703
  );
14640
14704
  cx1 = isNaN(cx1) || !isFinite(cx1) ? x1 : cx1;
14641
14705
  cx2 = isNaN(cx2) || !isFinite(cx2) ? x2 : cx2;
14706
+ const remainingRowSpace = distances.rowHeight - taskYOffset - taskHeight;
14707
+ const clampedHeight = Math.min(
14708
+ barComparisonTaskHeight,
14709
+ Math.max(remainingRowSpace - 2, 2)
14710
+ );
14642
14711
  comparisonDates = {
14643
14712
  x: cx1,
14644
14713
  y: y + taskHeight,
14645
14714
  width: Math.max(cx2 - cx1, 0),
14646
- height: barComparisonTaskHeight
14715
+ height: clampedHeight
14647
14716
  };
14648
14717
  }
14649
14718
  return {
@@ -19975,19 +20044,11 @@ const Gantt = (props) => {
19975
20044
  rowHeight,
19976
20045
  showTodayLine = true,
19977
20046
  showDataDateLine = false,
19978
- showProjectStartLine = false,
19979
- showProjectEndLine = false,
19980
20047
  dataDate = null,
19981
- projectStartDate = null,
19982
- projectEndDate = null,
19983
20048
  todayColor,
19984
20049
  dataDateColor,
19985
- projectStartColor,
19986
- projectEndColor,
19987
20050
  todayLabel = "Today",
19988
20051
  dataDateLabel = "Data Date",
19989
- projectStartLabel = "Project Start",
19990
- projectEndLabel = "Project End",
19991
20052
  showProgress = true,
19992
20053
  hideProjectProgress = false,
19993
20054
  progressColor,
@@ -21416,19 +21477,11 @@ const Gantt = (props) => {
21416
21477
  viewMode,
21417
21478
  showTodayLine,
21418
21479
  showDataDateLine,
21419
- showProjectStartLine,
21420
- showProjectEndLine,
21421
21480
  dataDate,
21422
- projectStartDate,
21423
- projectEndDate,
21424
21481
  todayColor,
21425
21482
  dataDateColor,
21426
- projectStartColor,
21427
- projectEndColor,
21428
21483
  todayLabel,
21429
- dataDateLabel,
21430
- projectStartLabel,
21431
- projectEndLabel
21484
+ dataDateLabel
21432
21485
  }),
21433
21486
  [
21434
21487
  additionalLeftSpace,
@@ -21440,19 +21493,11 @@ const Gantt = (props) => {
21440
21493
  viewMode,
21441
21494
  showTodayLine,
21442
21495
  showDataDateLine,
21443
- showProjectStartLine,
21444
- showProjectEndLine,
21445
21496
  dataDate,
21446
- projectStartDate,
21447
- projectEndDate,
21448
21497
  todayColor,
21449
21498
  dataDateColor,
21450
- projectStartColor,
21451
- projectEndColor,
21452
21499
  todayLabel,
21453
- dataDateLabel,
21454
- projectStartLabel,
21455
- projectEndLabel
21500
+ dataDateLabel
21456
21501
  ]
21457
21502
  );
21458
21503
  const calendarProps = useMemo(