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.
@@ -11397,278 +11397,6 @@
11397
11397
  ganttToday,
11398
11398
  ganttTodayCircle
11399
11399
  };
11400
- const getDateByOffset = (startDate, offset2, viewMode) => {
11401
- switch (viewMode) {
11402
- case ViewMode.Day:
11403
- return addDays(startDate, offset2);
11404
- case ViewMode.HalfDay:
11405
- return addHours(startDate, offset2 * 12);
11406
- case ViewMode.QuarterDay:
11407
- return addHours(startDate, offset2 * 6);
11408
- case ViewMode.Hour:
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);
11416
- default:
11417
- throw new Error("Unknown view mode");
11418
- }
11419
- };
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;
11429
- };
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
11400
  const GanttTodayInner = ({
11673
11401
  additionalLeftSpace,
11674
11402
  distances: { columnWidth },
@@ -11679,133 +11407,185 @@
11679
11407
  viewMode,
11680
11408
  showTodayLine = true,
11681
11409
  showDataDateLine = false,
11682
- showProjectStartLine = false,
11683
- showProjectEndLine = false,
11684
11410
  dataDate = null,
11685
- projectStartDate = null,
11686
- projectEndDate = null,
11687
11411
  todayColor = null,
11688
11412
  dataDateColor = null,
11689
- projectStartColor = null,
11690
- projectEndColor = null,
11691
11413
  todayLabel = "Today",
11692
- dataDateLabel = "Data Date",
11693
- projectStartLabel = "Project Start",
11694
- projectEndLabel = "Project End"
11414
+ dataDateLabel = "Data Date"
11695
11415
  }) => {
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
11416
  const todayElement = React.useMemo(() => {
11715
11417
  if (isUnknownDates || !showTodayLine) {
11716
11418
  return null;
11717
11419
  }
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
11420
+ const today = /* @__PURE__ */ new Date();
11421
+ const todayIndex = getDatesDiff(today, startDate, viewMode);
11422
+ const extraMultiplier = () => {
11423
+ switch (viewMode) {
11424
+ case ViewMode.Week: {
11425
+ const percent = today.getDay() / 7;
11426
+ return 1 + percent * 0.2;
11427
+ }
11428
+ case ViewMode.Month: {
11429
+ const dayInMonth = today.getDate();
11430
+ const maxDaysInMonth = getDaysInMonth(
11431
+ today.getMonth(),
11432
+ today.getFullYear()
11433
+ );
11434
+ const percent = dayInMonth / maxDaysInMonth;
11435
+ return 1 + percent * 0.5;
11436
+ }
11437
+ case ViewMode.Year: {
11438
+ const percent = today.getMonth() / 12;
11439
+ return 1 + percent * 0.5;
11440
+ }
11441
+ default:
11442
+ return 1;
11759
11443
  }
11760
- );
11444
+ };
11445
+ const tickX = todayIndex * columnWidth * extraMultiplier();
11446
+ const x = rtl ? tickX + columnWidth : tickX;
11447
+ const color = todayColor || "var(--gantt-calendar-today-color)";
11448
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11449
+ /* @__PURE__ */ jsxRuntime.jsx(
11450
+ "rect",
11451
+ {
11452
+ x: additionalLeftSpace + x,
11453
+ y: 0,
11454
+ width: 2,
11455
+ height: ganttFullHeight,
11456
+ fill: color
11457
+ }
11458
+ ),
11459
+ /* @__PURE__ */ jsxRuntime.jsx(
11460
+ "circle",
11461
+ {
11462
+ className: styles$d.ganttTodayCircle,
11463
+ cx: x + 1,
11464
+ cy: 6,
11465
+ r: 6,
11466
+ fill: color
11467
+ }
11468
+ ),
11469
+ /* @__PURE__ */ jsxRuntime.jsx(
11470
+ "text",
11471
+ {
11472
+ x: additionalLeftSpace + x + 8,
11473
+ y: 10,
11474
+ fill: color,
11475
+ fontSize: 12,
11476
+ fontWeight: 600,
11477
+ children: todayLabel
11478
+ }
11479
+ )
11480
+ ] });
11761
11481
  }, [
11762
- showProjectStartLine,
11763
- projectStartDate,
11764
- projectStartColor,
11765
- projectStartLabel,
11766
- lineProps
11482
+ additionalLeftSpace,
11483
+ columnWidth,
11484
+ ganttFullHeight,
11485
+ isUnknownDates,
11486
+ rtl,
11487
+ startDate,
11488
+ viewMode,
11489
+ showTodayLine,
11490
+ todayColor,
11491
+ todayLabel
11767
11492
  ]);
11768
- const projectEndElement = React.useMemo(() => {
11769
- if (!showProjectEndLine || !projectEndDate) {
11493
+ const dataDateElement = React.useMemo(() => {
11494
+ if (!showDataDateLine || !dataDate) {
11770
11495
  return null;
11771
11496
  }
11772
- return /* @__PURE__ */ jsxRuntime.jsx(
11773
- DateLine,
11774
- {
11775
- config: {
11776
- date: projectEndDate,
11777
- color: projectEndColor || "#f44336",
11778
- label: projectEndLabel
11779
- },
11780
- ...lineProps
11497
+ const dataIndex = getDatesDiff(dataDate, startDate, viewMode);
11498
+ const extraMultiplier = () => {
11499
+ switch (viewMode) {
11500
+ case ViewMode.Week: {
11501
+ const percent = dataDate.getDay() / 7;
11502
+ return 1 + percent * 0.2;
11503
+ }
11504
+ case ViewMode.Month: {
11505
+ const dayInMonth = dataDate.getDate();
11506
+ const maxDaysInMonth = getDaysInMonth(
11507
+ dataDate.getMonth(),
11508
+ dataDate.getFullYear()
11509
+ );
11510
+ const percent = dayInMonth / maxDaysInMonth;
11511
+ return 1 + percent * 0.5;
11512
+ }
11513
+ case ViewMode.Year: {
11514
+ const percent = dataDate.getMonth() / 12;
11515
+ return 1 + percent * 0.5;
11516
+ }
11517
+ default:
11518
+ return 1;
11781
11519
  }
11782
- );
11520
+ };
11521
+ const tickX = dataIndex * columnWidth * extraMultiplier();
11522
+ const x = rtl ? tickX + columnWidth : tickX;
11523
+ const color = dataDateColor || "var(--gantt-calendar-today-color)";
11524
+ return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11525
+ /* @__PURE__ */ jsxRuntime.jsx(
11526
+ "rect",
11527
+ {
11528
+ x: additionalLeftSpace + x,
11529
+ y: 0,
11530
+ width: 2,
11531
+ height: ganttFullHeight,
11532
+ fill: color,
11533
+ opacity: 0.9
11534
+ }
11535
+ ),
11536
+ /* @__PURE__ */ jsxRuntime.jsx(
11537
+ "circle",
11538
+ {
11539
+ className: styles$d.ganttTodayCircle,
11540
+ cx: x + 1,
11541
+ cy: 6,
11542
+ r: 6,
11543
+ fill: color
11544
+ }
11545
+ ),
11546
+ /* @__PURE__ */ jsxRuntime.jsx(
11547
+ "text",
11548
+ {
11549
+ x: additionalLeftSpace + x + 8,
11550
+ y: 10,
11551
+ fill: color,
11552
+ fontSize: 12,
11553
+ fontWeight: 600,
11554
+ children: dataDateLabel || "Data Date"
11555
+ }
11556
+ )
11557
+ ] });
11783
11558
  }, [
11784
- showProjectEndLine,
11785
- projectEndDate,
11786
- projectEndColor,
11787
- projectEndLabel,
11788
- lineProps
11559
+ additionalLeftSpace,
11560
+ columnWidth,
11561
+ ganttFullHeight,
11562
+ rtl,
11563
+ startDate,
11564
+ viewMode,
11565
+ showDataDateLine,
11566
+ dataDate,
11567
+ dataDateColor,
11568
+ dataDateLabel
11789
11569
  ]);
11790
11570
  return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "today", children: [
11791
- projectStartElement,
11792
- projectEndElement,
11793
11571
  dataDateElement,
11794
11572
  todayElement
11795
11573
  ] });
11796
11574
  };
11797
11575
  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";
11576
+ const calendarBottomText = "_calendarBottomText_1mt8w_1";
11577
+ const calendarTopTick = "_calendarTopTick_1mt8w_31";
11578
+ const calendarTopText = "_calendarTopText_1mt8w_41";
11579
+ const calendarHeader = "_calendarHeader_1mt8w_67";
11580
+ const calendarBottomSeparator = "_calendarBottomSeparator_1mt8w_81";
11581
+ const calendar = "_calendar_1mt8w_1";
11582
+ const calendarDragging$1 = "_calendarDragging_1mt8w_103";
11804
11583
  const styles$c = {
11805
11584
  calendarBottomText,
11806
11585
  calendarTopTick,
11807
11586
  calendarTopText,
11808
11587
  calendarHeader,
11588
+ calendarBottomSeparator,
11809
11589
  calendar,
11810
11590
  calendarDragging: calendarDragging$1
11811
11591
  };
@@ -12089,6 +11869,19 @@
12089
11869
  const bottomValues2 = [];
12090
11870
  let weeksCount = 1;
12091
11871
  const topDefaultHeight = headerHeight * 0.5;
11872
+ bottomValues2.push(
11873
+ /* @__PURE__ */ jsxRuntime.jsx(
11874
+ "line",
11875
+ {
11876
+ x1: 0,
11877
+ y1: topDefaultHeight,
11878
+ x2: fullSvgWidth,
11879
+ y2: topDefaultHeight,
11880
+ className: styles$c.calendarBottomSeparator
11881
+ },
11882
+ "week-top-border"
11883
+ )
11884
+ );
12092
11885
  for (let i = endColumnIndex; i >= startColumnIndex; i--) {
12093
11886
  const date = getDate(i);
12094
11887
  const month = date.getMonth();
@@ -12098,6 +11891,19 @@
12098
11891
  topValue = renderTopHeaderByDate(date);
12099
11892
  }
12100
11893
  const bottomValue = renderBottomHeaderByDate(date, i);
11894
+ bottomValues2.push(
11895
+ /* @__PURE__ */ jsxRuntime.jsx(
11896
+ "line",
11897
+ {
11898
+ x1: additionalLeftSpace + columnWidth * i,
11899
+ y1: topDefaultHeight,
11900
+ x2: additionalLeftSpace + columnWidth * i,
11901
+ y2: headerHeight,
11902
+ className: styles$c.calendarBottomSeparator
11903
+ },
11904
+ `week-sep-${i}`
11905
+ )
11906
+ );
12101
11907
  bottomValues2.push(
12102
11908
  renderBottomText(
12103
11909
  additionalLeftSpace + columnWidth * (i + +rtl),
@@ -12133,11 +11939,37 @@
12133
11939
  const bottomValues2 = [];
12134
11940
  const topDefaultHeight = headerHeight * 0.5;
12135
11941
  const renderedMonths = /* @__PURE__ */ new Set();
11942
+ bottomValues2.push(
11943
+ /* @__PURE__ */ jsxRuntime.jsx(
11944
+ "line",
11945
+ {
11946
+ x1: 0,
11947
+ y1: topDefaultHeight,
11948
+ x2: fullSvgWidth,
11949
+ y2: topDefaultHeight,
11950
+ className: styles$c.calendarBottomSeparator
11951
+ },
11952
+ "day-top-border"
11953
+ )
11954
+ );
12136
11955
  for (let i = startColumnIndex; i <= endColumnIndex; i++) {
12137
11956
  const date = getDate(i);
12138
11957
  const bottomValue = renderBottomHeaderByDate(date, i);
12139
11958
  const month = date.getMonth();
12140
11959
  const fullYear = date.getFullYear();
11960
+ bottomValues2.push(
11961
+ /* @__PURE__ */ jsxRuntime.jsx(
11962
+ "line",
11963
+ {
11964
+ x1: additionalLeftSpace + columnWidth * i,
11965
+ y1: topDefaultHeight,
11966
+ x2: additionalLeftSpace + columnWidth * i,
11967
+ y2: headerHeight,
11968
+ className: styles$c.calendarBottomSeparator
11969
+ },
11970
+ `day-sep-${i}`
11971
+ )
11972
+ );
12141
11973
  bottomValues2.push(
12142
11974
  renderBottomText(
12143
11975
  additionalLeftSpace + columnWidth * i + columnWidth * 0.5,
@@ -12577,6 +12409,231 @@
12577
12409
  }
12578
12410
  );
12579
12411
  };
12412
+ const getDateByOffset = (startDate, offset2, viewMode) => {
12413
+ switch (viewMode) {
12414
+ case ViewMode.Day:
12415
+ return addDays(startDate, offset2);
12416
+ case ViewMode.HalfDay:
12417
+ return addHours(startDate, offset2 * 12);
12418
+ case ViewMode.QuarterDay:
12419
+ return addHours(startDate, offset2 * 6);
12420
+ case ViewMode.Hour:
12421
+ return addHours(startDate, offset2);
12422
+ case ViewMode.Month:
12423
+ return addMonths(startDate, offset2);
12424
+ case ViewMode.Week:
12425
+ return addWeeks(startDate, offset2);
12426
+ case ViewMode.Year:
12427
+ return addYears(startDate, offset2);
12428
+ default:
12429
+ throw new Error("Unknown view mode");
12430
+ }
12431
+ };
12432
+ const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
12433
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
12434
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
12435
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
12436
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
12437
+ const intervalDuration = nextDate.getTime() - currentDate.getTime();
12438
+ const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
12439
+ const result = index2 * columnWidth + percentOfInterval * columnWidth;
12440
+ return isNaN(result) || !isFinite(result) ? 0 : result;
12441
+ };
12442
+ const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
12443
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
12444
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
12445
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
12446
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
12447
+ const intervalDuration = nextDate.getTime() - currentDate.getTime();
12448
+ const percentOfInterval = intervalDuration === 0 ? 0 : remainderMillis / intervalDuration;
12449
+ const result = index2 * columnWidth + percentOfInterval * columnWidth;
12450
+ return isNaN(result) || !isFinite(result) ? 0 : result;
12451
+ };
12452
+ const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
12453
+ const safeTaskX1 = isNaN(taskX1) || !isFinite(taskX1) ? 0 : taskX1;
12454
+ const safeTaskX2 = isNaN(taskX2) || !isFinite(taskX2) ? 0 : taskX2;
12455
+ const safeProgress = isNaN(progress) || !isFinite(progress) ? 0 : progress;
12456
+ const progressWidth = Math.max(
12457
+ (safeTaskX2 - safeTaskX1) * safeProgress * 0.01,
12458
+ 0
12459
+ );
12460
+ let progressX;
12461
+ if (rtl) {
12462
+ progressX = safeTaskX2 - progressWidth;
12463
+ } else {
12464
+ progressX = safeTaskX1;
12465
+ }
12466
+ return [progressWidth, progressX];
12467
+ };
12468
+ const getProgressPoint = (progressX, taskY, taskHeight) => {
12469
+ const point = [
12470
+ progressX - 5,
12471
+ taskY + taskHeight,
12472
+ progressX + 5,
12473
+ taskY + taskHeight,
12474
+ progressX,
12475
+ taskY + taskHeight - 8.66
12476
+ ];
12477
+ return point.join(",");
12478
+ };
12479
+ const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
12480
+ const safeX = isNaN(x) || !isFinite(x) ? 0 : x;
12481
+ const safeTaskX = isNaN(taskX) || !isFinite(taskX) ? 0 : taskX;
12482
+ const safeXStep = isNaN(xStep) || !isFinite(xStep) || xStep === 0 ? 1 : xStep;
12483
+ const safeTimeStep = isNaN(timeStep) || !isFinite(timeStep) ? 0 : timeStep;
12484
+ let newDate = new Date(
12485
+ (safeX - safeTaskX) / safeXStep * safeTimeStep + taskDate.getTime()
12486
+ );
12487
+ newDate = new Date(
12488
+ newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
12489
+ );
12490
+ return newDate;
12491
+ };
12492
+ const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
12493
+ let result;
12494
+ switch (selectedTask.type) {
12495
+ case "milestone":
12496
+ result = handleTaskBySVGMouseEventForMilestone(
12497
+ action,
12498
+ selectedTask,
12499
+ initialCoordinates,
12500
+ coordinates,
12501
+ xStep,
12502
+ timeStep
12503
+ );
12504
+ break;
12505
+ default:
12506
+ result = handleTaskBySVGMouseEventForBar(
12507
+ action,
12508
+ selectedTask,
12509
+ initialCoordinates,
12510
+ coordinates,
12511
+ xStep,
12512
+ timeStep,
12513
+ rtl
12514
+ );
12515
+ break;
12516
+ }
12517
+ return result;
12518
+ };
12519
+ const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
12520
+ const changedTask = { ...selectedTask };
12521
+ let isChanged = false;
12522
+ switch (action) {
12523
+ case "progress":
12524
+ isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
12525
+ if (isChanged) {
12526
+ changedTask.progress = Math.round(
12527
+ coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
12528
+ );
12529
+ }
12530
+ break;
12531
+ case "start": {
12532
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
12533
+ if (isChanged) {
12534
+ if (rtl) {
12535
+ changedTask.end = dateByX(
12536
+ coordinates.x1,
12537
+ initialCoordinates.x1,
12538
+ selectedTask.end,
12539
+ xStep,
12540
+ timeStep
12541
+ );
12542
+ } else {
12543
+ changedTask.start = dateByX(
12544
+ coordinates.x1,
12545
+ initialCoordinates.x1,
12546
+ selectedTask.start,
12547
+ xStep,
12548
+ timeStep
12549
+ );
12550
+ }
12551
+ }
12552
+ break;
12553
+ }
12554
+ case "end": {
12555
+ isChanged = initialCoordinates.x2 !== coordinates.x2;
12556
+ if (isChanged) {
12557
+ if (rtl) {
12558
+ changedTask.start = dateByX(
12559
+ coordinates.x2,
12560
+ initialCoordinates.x2,
12561
+ selectedTask.start,
12562
+ xStep,
12563
+ timeStep
12564
+ );
12565
+ } else {
12566
+ changedTask.end = dateByX(
12567
+ coordinates.x2,
12568
+ initialCoordinates.x2,
12569
+ selectedTask.end,
12570
+ xStep,
12571
+ timeStep
12572
+ );
12573
+ }
12574
+ }
12575
+ break;
12576
+ }
12577
+ case "move": {
12578
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
12579
+ if (isChanged) {
12580
+ if (rtl) {
12581
+ changedTask.end = dateByX(
12582
+ coordinates.x1,
12583
+ initialCoordinates.x1,
12584
+ selectedTask.end,
12585
+ xStep,
12586
+ timeStep
12587
+ );
12588
+ changedTask.start = dateByX(
12589
+ coordinates.x2,
12590
+ initialCoordinates.x2,
12591
+ selectedTask.start,
12592
+ xStep,
12593
+ timeStep
12594
+ );
12595
+ } else {
12596
+ changedTask.start = dateByX(
12597
+ coordinates.x1,
12598
+ initialCoordinates.x1,
12599
+ selectedTask.start,
12600
+ xStep,
12601
+ timeStep
12602
+ );
12603
+ changedTask.end = dateByX(
12604
+ coordinates.x2,
12605
+ initialCoordinates.x2,
12606
+ selectedTask.end,
12607
+ xStep,
12608
+ timeStep
12609
+ );
12610
+ }
12611
+ }
12612
+ break;
12613
+ }
12614
+ }
12615
+ return { isChanged, changedTask };
12616
+ };
12617
+ const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
12618
+ const changedTask = { ...selectedTask };
12619
+ const isChanged = coordinates.x1 !== initialCoordinates.x1;
12620
+ if (isChanged) {
12621
+ switch (action) {
12622
+ case "move": {
12623
+ changedTask.start = dateByX(
12624
+ coordinates.x1,
12625
+ initialCoordinates.x1,
12626
+ selectedTask.start,
12627
+ xStep,
12628
+ timeStep
12629
+ );
12630
+ changedTask.end = changedTask.start;
12631
+ break;
12632
+ }
12633
+ }
12634
+ }
12635
+ return { isChanged, changedTask };
12636
+ };
12580
12637
  const barWrapper = "_barWrapper_5jhkr_1";
12581
12638
  const barHandle = "_barHandle_5jhkr_11";
12582
12639
  const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
@@ -13211,9 +13268,9 @@
13211
13268
  relationHandles
13212
13269
  ] });
13213
13270
  };
13214
- const barLabel = "_barLabel_81831_1";
13215
- const barLabelHidden = "_barLabelHidden_81831_27";
13216
- const barLabelOutside = "_barLabelOutside_81831_37";
13271
+ const barLabel = "_barLabel_5nsbb_1";
13272
+ const barLabelHidden = "_barLabelHidden_5nsbb_27";
13273
+ const barLabelOutside = "_barLabelOutside_5nsbb_37";
13217
13274
  const style = {
13218
13275
  barLabel,
13219
13276
  barLabelHidden,
@@ -13223,6 +13280,7 @@
13223
13280
  const {
13224
13281
  alwaysOutline,
13225
13282
  arrowIndent,
13283
+ forceOutside,
13226
13284
  rtl,
13227
13285
  label: label2,
13228
13286
  taskHeight,
@@ -13238,21 +13296,22 @@
13238
13296
  setIsTextInside(textRef.current.getBBox().width < width);
13239
13297
  }
13240
13298
  }, [textRef, width, viewMode]);
13299
+ const shouldBeOutside = alwaysOutline || forceOutside;
13241
13300
  const calculatedX = React.useMemo(() => {
13242
- if (isTextInside && !alwaysOutline) {
13301
+ if (isTextInside && !shouldBeOutside) {
13243
13302
  return x1 + width * 0.5;
13244
13303
  }
13245
13304
  if (rtl && textRef.current) {
13246
13305
  return x1 - textRef.current.getBBox().width - arrowIndent * 0.8;
13247
13306
  }
13248
13307
  return x1 + width + arrowIndent * 1.2;
13249
- }, [alwaysOutline, x1, width, isTextInside, rtl, arrowIndent]);
13308
+ }, [shouldBeOutside, x1, width, isTextInside, rtl, arrowIndent]);
13250
13309
  return /* @__PURE__ */ jsxRuntime.jsx(
13251
13310
  "text",
13252
13311
  {
13253
13312
  x: calculatedX,
13254
13313
  y: taskYOffset + taskHeight * 0.5,
13255
- className: isTextInside && !alwaysOutline ? style.barLabel : style.barLabelOutside,
13314
+ className: isTextInside && !shouldBeOutside ? style.barLabel : style.barLabelOutside,
13256
13315
  ref: textRef,
13257
13316
  children: label2
13258
13317
  }
@@ -13516,7 +13575,8 @@
13516
13575
  label: task.name,
13517
13576
  taskYOffset,
13518
13577
  viewMode,
13519
- alwaysOutline: task.type === "project"
13578
+ alwaysOutline: task.type === "project",
13579
+ forceOutside: props.showProgress && width > 40
13520
13580
  }
13521
13581
  )
13522
13582
  ]
@@ -13841,6 +13901,10 @@
13841
13901
  const safeComparisonY = isNaN(comparisonDates.y) || !isFinite(comparisonDates.y) ? safeLevelY : comparisonDates.y;
13842
13902
  const safeComparisonWidth = isNaN(comparisonDates.width) || !isFinite(comparisonDates.width) ? 0 : Math.max(comparisonDates.width, 0);
13843
13903
  const safeComparisonHeight = isNaN(comparisonDates.height) || !isFinite(comparisonDates.height) ? 0 : Math.max(comparisonDates.height, 0);
13904
+ const maxComparisonSvgHeight = Math.max(
13905
+ distances.rowHeight - taskYOffset - taskHeight,
13906
+ safeComparisonHeight
13907
+ );
13844
13908
  tasksRes.push(
13845
13909
  /* @__PURE__ */ jsxRuntime.jsx(
13846
13910
  "svg",
@@ -13850,7 +13914,7 @@
13850
13914
  x: Math.max(safeComparisonX + (additionalLeftSpace || 0), 0),
13851
13915
  y: safeComparisonY,
13852
13916
  width: safeComparisonWidth,
13853
- height: safeComparisonHeight * 2,
13917
+ height: Math.min(safeComparisonHeight * 2, maxComparisonSvgHeight),
13854
13918
  children: /* @__PURE__ */ jsxRuntime.jsx(
13855
13919
  BarComparison,
13856
13920
  {
@@ -14656,11 +14720,16 @@
14656
14720
  );
14657
14721
  cx1 = isNaN(cx1) || !isFinite(cx1) ? x1 : cx1;
14658
14722
  cx2 = isNaN(cx2) || !isFinite(cx2) ? x2 : cx2;
14723
+ const remainingRowSpace = distances.rowHeight - taskYOffset - taskHeight;
14724
+ const clampedHeight = Math.min(
14725
+ barComparisonTaskHeight,
14726
+ Math.max(remainingRowSpace - 2, 2)
14727
+ );
14659
14728
  comparisonDates = {
14660
14729
  x: cx1,
14661
14730
  y: y + taskHeight,
14662
14731
  width: Math.max(cx2 - cx1, 0),
14663
- height: barComparisonTaskHeight
14732
+ height: clampedHeight
14664
14733
  };
14665
14734
  }
14666
14735
  return {
@@ -19992,19 +20061,11 @@
19992
20061
  rowHeight,
19993
20062
  showTodayLine = true,
19994
20063
  showDataDateLine = false,
19995
- showProjectStartLine = false,
19996
- showProjectEndLine = false,
19997
20064
  dataDate = null,
19998
- projectStartDate = null,
19999
- projectEndDate = null,
20000
20065
  todayColor,
20001
20066
  dataDateColor,
20002
- projectStartColor,
20003
- projectEndColor,
20004
20067
  todayLabel = "Today",
20005
20068
  dataDateLabel = "Data Date",
20006
- projectStartLabel = "Project Start",
20007
- projectEndLabel = "Project End",
20008
20069
  showProgress = true,
20009
20070
  hideProjectProgress = false,
20010
20071
  progressColor,
@@ -21433,19 +21494,11 @@
21433
21494
  viewMode,
21434
21495
  showTodayLine,
21435
21496
  showDataDateLine,
21436
- showProjectStartLine,
21437
- showProjectEndLine,
21438
21497
  dataDate,
21439
- projectStartDate,
21440
- projectEndDate,
21441
21498
  todayColor,
21442
21499
  dataDateColor,
21443
- projectStartColor,
21444
- projectEndColor,
21445
21500
  todayLabel,
21446
- dataDateLabel,
21447
- projectStartLabel,
21448
- projectEndLabel
21501
+ dataDateLabel
21449
21502
  }),
21450
21503
  [
21451
21504
  additionalLeftSpace,
@@ -21457,19 +21510,11 @@
21457
21510
  viewMode,
21458
21511
  showTodayLine,
21459
21512
  showDataDateLine,
21460
- showProjectStartLine,
21461
- showProjectEndLine,
21462
21513
  dataDate,
21463
- projectStartDate,
21464
- projectEndDate,
21465
21514
  todayColor,
21466
21515
  dataDateColor,
21467
- projectStartColor,
21468
- projectEndColor,
21469
21516
  todayLabel,
21470
- dataDateLabel,
21471
- projectStartLabel,
21472
- projectEndLabel
21517
+ dataDateLabel
21473
21518
  ]
21474
21519
  );
21475
21520
  const calendarProps = React.useMemo(