gantt-task-react-v 1.0.51 → 1.0.53

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -8,13 +8,15 @@
8
8
  - Fixed sticky gantt header on drag
9
9
  - Fixed Tooltip should show only on gantt section current view boundaries
10
10
  - Added Tooltip for comparison bars
11
+ - Show Custom Data Date Line
12
+ - Customize Data Date Line and Today Line Color and Label
11
13
 
12
14
  ## [Live Demo In Storybook](https://661071b076b50cb537c16c19-yrsukdfefs.chromatic.com/)
13
15
 
14
16
  ## Install
15
17
 
16
18
  ```
17
- npm install https://github.com/aguilanbon/gantt-task-react-v"
19
+ npm install gantt-task-react-v
18
20
  ```
19
21
 
20
22
  ## How to use it
@@ -10921,184 +10921,6 @@ const getDateByOffset = (startDate, offset2, viewMode) => {
10921
10921
  throw new Error("Unknown view mode");
10922
10922
  }
10923
10923
  };
10924
- const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
10925
- const index2 = getDatesDiff(xDate, startDate, viewMode);
10926
- const currentDate = getDateByOffset(startDate, index2, viewMode);
10927
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
10928
- const remainderMillis = xDate.getTime() - currentDate.getTime();
10929
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
10930
- return index2 * columnWidth + percentOfInterval * columnWidth;
10931
- };
10932
- const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
10933
- const index2 = getDatesDiff(xDate, startDate, viewMode);
10934
- const currentDate = getDateByOffset(startDate, index2, viewMode);
10935
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
10936
- const remainderMillis = xDate.getTime() - currentDate.getTime();
10937
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
10938
- return index2 * columnWidth + percentOfInterval * columnWidth;
10939
- };
10940
- const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
10941
- const progressWidth = Math.max((taskX2 - taskX1) * progress * 0.01, 0);
10942
- let progressX;
10943
- if (rtl) {
10944
- progressX = taskX2 - progressWidth;
10945
- } else {
10946
- progressX = taskX1;
10947
- }
10948
- return [progressWidth, progressX];
10949
- };
10950
- const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
10951
- let newDate = new Date((x - taskX) / xStep * timeStep + taskDate.getTime());
10952
- newDate = new Date(
10953
- newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
10954
- );
10955
- return newDate;
10956
- };
10957
- const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
10958
- let result;
10959
- switch (selectedTask.type) {
10960
- case "milestone":
10961
- result = handleTaskBySVGMouseEventForMilestone(
10962
- action,
10963
- selectedTask,
10964
- initialCoordinates,
10965
- coordinates,
10966
- xStep,
10967
- timeStep
10968
- );
10969
- break;
10970
- default:
10971
- result = handleTaskBySVGMouseEventForBar(
10972
- action,
10973
- selectedTask,
10974
- initialCoordinates,
10975
- coordinates,
10976
- xStep,
10977
- timeStep,
10978
- rtl
10979
- );
10980
- break;
10981
- }
10982
- return result;
10983
- };
10984
- const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
10985
- const changedTask = { ...selectedTask };
10986
- let isChanged = false;
10987
- switch (action) {
10988
- case "progress":
10989
- isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
10990
- if (isChanged) {
10991
- changedTask.progress = Math.round(
10992
- coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
10993
- );
10994
- }
10995
- break;
10996
- case "start": {
10997
- isChanged = initialCoordinates.x1 !== coordinates.x1;
10998
- if (isChanged) {
10999
- if (rtl) {
11000
- changedTask.end = dateByX(
11001
- coordinates.x1,
11002
- initialCoordinates.x1,
11003
- selectedTask.end,
11004
- xStep,
11005
- timeStep
11006
- );
11007
- } else {
11008
- changedTask.start = dateByX(
11009
- coordinates.x1,
11010
- initialCoordinates.x1,
11011
- selectedTask.start,
11012
- xStep,
11013
- timeStep
11014
- );
11015
- }
11016
- }
11017
- break;
11018
- }
11019
- case "end": {
11020
- isChanged = initialCoordinates.x2 !== coordinates.x2;
11021
- if (isChanged) {
11022
- if (rtl) {
11023
- changedTask.start = dateByX(
11024
- coordinates.x2,
11025
- initialCoordinates.x2,
11026
- selectedTask.start,
11027
- xStep,
11028
- timeStep
11029
- );
11030
- } else {
11031
- changedTask.end = dateByX(
11032
- coordinates.x2,
11033
- initialCoordinates.x2,
11034
- selectedTask.end,
11035
- xStep,
11036
- timeStep
11037
- );
11038
- }
11039
- }
11040
- break;
11041
- }
11042
- case "move": {
11043
- isChanged = initialCoordinates.x1 !== coordinates.x1;
11044
- if (isChanged) {
11045
- if (rtl) {
11046
- changedTask.end = dateByX(
11047
- coordinates.x1,
11048
- initialCoordinates.x1,
11049
- selectedTask.end,
11050
- xStep,
11051
- timeStep
11052
- );
11053
- changedTask.start = dateByX(
11054
- coordinates.x2,
11055
- initialCoordinates.x2,
11056
- selectedTask.start,
11057
- xStep,
11058
- timeStep
11059
- );
11060
- } else {
11061
- changedTask.start = dateByX(
11062
- coordinates.x1,
11063
- initialCoordinates.x1,
11064
- selectedTask.start,
11065
- xStep,
11066
- timeStep
11067
- );
11068
- changedTask.end = dateByX(
11069
- coordinates.x2,
11070
- initialCoordinates.x2,
11071
- selectedTask.end,
11072
- xStep,
11073
- timeStep
11074
- );
11075
- }
11076
- }
11077
- break;
11078
- }
11079
- }
11080
- return { isChanged, changedTask };
11081
- };
11082
- const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
11083
- const changedTask = { ...selectedTask };
11084
- const isChanged = coordinates.x1 !== initialCoordinates.x1;
11085
- if (isChanged) {
11086
- switch (action) {
11087
- case "move": {
11088
- changedTask.start = dateByX(
11089
- coordinates.x1,
11090
- initialCoordinates.x1,
11091
- selectedTask.start,
11092
- xStep,
11093
- timeStep
11094
- );
11095
- changedTask.end = changedTask.start;
11096
- break;
11097
- }
11098
- }
11099
- }
11100
- return { isChanged, changedTask };
11101
- };
11102
10924
  const ganttToday = "_ganttToday_1oyhk_1";
11103
10925
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
11104
10926
  const styles$c = {
@@ -11126,7 +10948,12 @@ const GanttTodayInner = ({
11126
10948
  return null;
11127
10949
  }
11128
10950
  const today = /* @__PURE__ */ new Date();
11129
- const tickX = taskXCoordinate(today, startDate, viewMode, columnWidth);
10951
+ const index2 = getDatesDiff(today, startDate, viewMode);
10952
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
10953
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
10954
+ const remainderMillis = today.getTime() - currentDate.getTime();
10955
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
10956
+ const tickX = index2 * columnWidth + percentOfInterval * columnWidth;
11130
10957
  const x = rtl ? tickX + columnWidth : tickX;
11131
10958
  const color = todayColor || "var(--gantt-calendar-today-color)";
11132
10959
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -11178,7 +11005,8 @@ const GanttTodayInner = ({
11178
11005
  if (!showDataDateLine || !dataDate) {
11179
11006
  return null;
11180
11007
  }
11181
- const tickX = taskXCoordinate(dataDate, startDate, viewMode, columnWidth);
11008
+ const index2 = getDatesDiff(dataDate, startDate, viewMode);
11009
+ const tickX = (index2 + 1) * columnWidth - 0.5;
11182
11010
  const x = rtl ? tickX + columnWidth : tickX;
11183
11011
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11184
11012
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -11920,6 +11748,184 @@ const RelationLine = ({
11920
11748
  }
11921
11749
  );
11922
11750
  };
11751
+ const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11752
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
11753
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11754
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11755
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
11756
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11757
+ return index2 * columnWidth + percentOfInterval * columnWidth;
11758
+ };
11759
+ const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11760
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
11761
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11762
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11763
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
11764
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11765
+ return index2 * columnWidth + percentOfInterval * columnWidth;
11766
+ };
11767
+ const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
11768
+ const progressWidth = Math.max((taskX2 - taskX1) * progress * 0.01, 0);
11769
+ let progressX;
11770
+ if (rtl) {
11771
+ progressX = taskX2 - progressWidth;
11772
+ } else {
11773
+ progressX = taskX1;
11774
+ }
11775
+ return [progressWidth, progressX];
11776
+ };
11777
+ const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
11778
+ let newDate = new Date((x - taskX) / xStep * timeStep + taskDate.getTime());
11779
+ newDate = new Date(
11780
+ newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
11781
+ );
11782
+ return newDate;
11783
+ };
11784
+ const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11785
+ let result;
11786
+ switch (selectedTask.type) {
11787
+ case "milestone":
11788
+ result = handleTaskBySVGMouseEventForMilestone(
11789
+ action,
11790
+ selectedTask,
11791
+ initialCoordinates,
11792
+ coordinates,
11793
+ xStep,
11794
+ timeStep
11795
+ );
11796
+ break;
11797
+ default:
11798
+ result = handleTaskBySVGMouseEventForBar(
11799
+ action,
11800
+ selectedTask,
11801
+ initialCoordinates,
11802
+ coordinates,
11803
+ xStep,
11804
+ timeStep,
11805
+ rtl
11806
+ );
11807
+ break;
11808
+ }
11809
+ return result;
11810
+ };
11811
+ const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11812
+ const changedTask = { ...selectedTask };
11813
+ let isChanged = false;
11814
+ switch (action) {
11815
+ case "progress":
11816
+ isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
11817
+ if (isChanged) {
11818
+ changedTask.progress = Math.round(
11819
+ coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
11820
+ );
11821
+ }
11822
+ break;
11823
+ case "start": {
11824
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
11825
+ if (isChanged) {
11826
+ if (rtl) {
11827
+ changedTask.end = dateByX(
11828
+ coordinates.x1,
11829
+ initialCoordinates.x1,
11830
+ selectedTask.end,
11831
+ xStep,
11832
+ timeStep
11833
+ );
11834
+ } else {
11835
+ changedTask.start = dateByX(
11836
+ coordinates.x1,
11837
+ initialCoordinates.x1,
11838
+ selectedTask.start,
11839
+ xStep,
11840
+ timeStep
11841
+ );
11842
+ }
11843
+ }
11844
+ break;
11845
+ }
11846
+ case "end": {
11847
+ isChanged = initialCoordinates.x2 !== coordinates.x2;
11848
+ if (isChanged) {
11849
+ if (rtl) {
11850
+ changedTask.start = dateByX(
11851
+ coordinates.x2,
11852
+ initialCoordinates.x2,
11853
+ selectedTask.start,
11854
+ xStep,
11855
+ timeStep
11856
+ );
11857
+ } else {
11858
+ changedTask.end = dateByX(
11859
+ coordinates.x2,
11860
+ initialCoordinates.x2,
11861
+ selectedTask.end,
11862
+ xStep,
11863
+ timeStep
11864
+ );
11865
+ }
11866
+ }
11867
+ break;
11868
+ }
11869
+ case "move": {
11870
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
11871
+ if (isChanged) {
11872
+ if (rtl) {
11873
+ changedTask.end = dateByX(
11874
+ coordinates.x1,
11875
+ initialCoordinates.x1,
11876
+ selectedTask.end,
11877
+ xStep,
11878
+ timeStep
11879
+ );
11880
+ changedTask.start = dateByX(
11881
+ coordinates.x2,
11882
+ initialCoordinates.x2,
11883
+ selectedTask.start,
11884
+ xStep,
11885
+ timeStep
11886
+ );
11887
+ } else {
11888
+ changedTask.start = dateByX(
11889
+ coordinates.x1,
11890
+ initialCoordinates.x1,
11891
+ selectedTask.start,
11892
+ xStep,
11893
+ timeStep
11894
+ );
11895
+ changedTask.end = dateByX(
11896
+ coordinates.x2,
11897
+ initialCoordinates.x2,
11898
+ selectedTask.end,
11899
+ xStep,
11900
+ timeStep
11901
+ );
11902
+ }
11903
+ }
11904
+ break;
11905
+ }
11906
+ }
11907
+ return { isChanged, changedTask };
11908
+ };
11909
+ const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
11910
+ const changedTask = { ...selectedTask };
11911
+ const isChanged = coordinates.x1 !== initialCoordinates.x1;
11912
+ if (isChanged) {
11913
+ switch (action) {
11914
+ case "move": {
11915
+ changedTask.start = dateByX(
11916
+ coordinates.x1,
11917
+ initialCoordinates.x1,
11918
+ selectedTask.start,
11919
+ xStep,
11920
+ timeStep
11921
+ );
11922
+ changedTask.end = changedTask.start;
11923
+ break;
11924
+ }
11925
+ }
11926
+ }
11927
+ return { isChanged, changedTask };
11928
+ };
11923
11929
  const barWrapper = "_barWrapper_5jhkr_1";
11924
11930
  const barHandle = "_barHandle_5jhkr_11";
11925
11931
  const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
@@ -19862,7 +19868,7 @@ const Gantt = (props) => {
19862
19868
  viewMode,
19863
19869
  showTodayLine,
19864
19870
  showDataDateLine,
19865
- dataDate,
19871
+ dataDate: dataDate ? roundStartDate(dataDate) : null,
19866
19872
  todayColor,
19867
19873
  dataDateColor,
19868
19874
  todayLabel,
@@ -19882,7 +19888,8 @@ const Gantt = (props) => {
19882
19888
  todayColor,
19883
19889
  dataDateColor,
19884
19890
  todayLabel,
19885
- dataDateLabel
19891
+ dataDateLabel,
19892
+ roundStartDate
19886
19893
  ]
19887
19894
  );
19888
19895
  const calendarProps = useMemo(
@@ -10938,184 +10938,6 @@
10938
10938
  throw new Error("Unknown view mode");
10939
10939
  }
10940
10940
  };
10941
- const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
10942
- const index2 = getDatesDiff(xDate, startDate, viewMode);
10943
- const currentDate = getDateByOffset(startDate, index2, viewMode);
10944
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
10945
- const remainderMillis = xDate.getTime() - currentDate.getTime();
10946
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
10947
- return index2 * columnWidth + percentOfInterval * columnWidth;
10948
- };
10949
- const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
10950
- const index2 = getDatesDiff(xDate, startDate, viewMode);
10951
- const currentDate = getDateByOffset(startDate, index2, viewMode);
10952
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
10953
- const remainderMillis = xDate.getTime() - currentDate.getTime();
10954
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
10955
- return index2 * columnWidth + percentOfInterval * columnWidth;
10956
- };
10957
- const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
10958
- const progressWidth = Math.max((taskX2 - taskX1) * progress * 0.01, 0);
10959
- let progressX;
10960
- if (rtl) {
10961
- progressX = taskX2 - progressWidth;
10962
- } else {
10963
- progressX = taskX1;
10964
- }
10965
- return [progressWidth, progressX];
10966
- };
10967
- const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
10968
- let newDate = new Date((x - taskX) / xStep * timeStep + taskDate.getTime());
10969
- newDate = new Date(
10970
- newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
10971
- );
10972
- return newDate;
10973
- };
10974
- const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
10975
- let result;
10976
- switch (selectedTask.type) {
10977
- case "milestone":
10978
- result = handleTaskBySVGMouseEventForMilestone(
10979
- action,
10980
- selectedTask,
10981
- initialCoordinates,
10982
- coordinates,
10983
- xStep,
10984
- timeStep
10985
- );
10986
- break;
10987
- default:
10988
- result = handleTaskBySVGMouseEventForBar(
10989
- action,
10990
- selectedTask,
10991
- initialCoordinates,
10992
- coordinates,
10993
- xStep,
10994
- timeStep,
10995
- rtl
10996
- );
10997
- break;
10998
- }
10999
- return result;
11000
- };
11001
- const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11002
- const changedTask = { ...selectedTask };
11003
- let isChanged = false;
11004
- switch (action) {
11005
- case "progress":
11006
- isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
11007
- if (isChanged) {
11008
- changedTask.progress = Math.round(
11009
- coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
11010
- );
11011
- }
11012
- break;
11013
- case "start": {
11014
- isChanged = initialCoordinates.x1 !== coordinates.x1;
11015
- if (isChanged) {
11016
- if (rtl) {
11017
- changedTask.end = dateByX(
11018
- coordinates.x1,
11019
- initialCoordinates.x1,
11020
- selectedTask.end,
11021
- xStep,
11022
- timeStep
11023
- );
11024
- } else {
11025
- changedTask.start = dateByX(
11026
- coordinates.x1,
11027
- initialCoordinates.x1,
11028
- selectedTask.start,
11029
- xStep,
11030
- timeStep
11031
- );
11032
- }
11033
- }
11034
- break;
11035
- }
11036
- case "end": {
11037
- isChanged = initialCoordinates.x2 !== coordinates.x2;
11038
- if (isChanged) {
11039
- if (rtl) {
11040
- changedTask.start = dateByX(
11041
- coordinates.x2,
11042
- initialCoordinates.x2,
11043
- selectedTask.start,
11044
- xStep,
11045
- timeStep
11046
- );
11047
- } else {
11048
- changedTask.end = dateByX(
11049
- coordinates.x2,
11050
- initialCoordinates.x2,
11051
- selectedTask.end,
11052
- xStep,
11053
- timeStep
11054
- );
11055
- }
11056
- }
11057
- break;
11058
- }
11059
- case "move": {
11060
- isChanged = initialCoordinates.x1 !== coordinates.x1;
11061
- if (isChanged) {
11062
- if (rtl) {
11063
- changedTask.end = dateByX(
11064
- coordinates.x1,
11065
- initialCoordinates.x1,
11066
- selectedTask.end,
11067
- xStep,
11068
- timeStep
11069
- );
11070
- changedTask.start = dateByX(
11071
- coordinates.x2,
11072
- initialCoordinates.x2,
11073
- selectedTask.start,
11074
- xStep,
11075
- timeStep
11076
- );
11077
- } else {
11078
- changedTask.start = dateByX(
11079
- coordinates.x1,
11080
- initialCoordinates.x1,
11081
- selectedTask.start,
11082
- xStep,
11083
- timeStep
11084
- );
11085
- changedTask.end = dateByX(
11086
- coordinates.x2,
11087
- initialCoordinates.x2,
11088
- selectedTask.end,
11089
- xStep,
11090
- timeStep
11091
- );
11092
- }
11093
- }
11094
- break;
11095
- }
11096
- }
11097
- return { isChanged, changedTask };
11098
- };
11099
- const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
11100
- const changedTask = { ...selectedTask };
11101
- const isChanged = coordinates.x1 !== initialCoordinates.x1;
11102
- if (isChanged) {
11103
- switch (action) {
11104
- case "move": {
11105
- changedTask.start = dateByX(
11106
- coordinates.x1,
11107
- initialCoordinates.x1,
11108
- selectedTask.start,
11109
- xStep,
11110
- timeStep
11111
- );
11112
- changedTask.end = changedTask.start;
11113
- break;
11114
- }
11115
- }
11116
- }
11117
- return { isChanged, changedTask };
11118
- };
11119
10941
  const ganttToday = "_ganttToday_1oyhk_1";
11120
10942
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
11121
10943
  const styles$c = {
@@ -11143,7 +10965,12 @@
11143
10965
  return null;
11144
10966
  }
11145
10967
  const today = /* @__PURE__ */ new Date();
11146
- const tickX = taskXCoordinate(today, startDate, viewMode, columnWidth);
10968
+ const index2 = getDatesDiff(today, startDate, viewMode);
10969
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
10970
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
10971
+ const remainderMillis = today.getTime() - currentDate.getTime();
10972
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
10973
+ const tickX = index2 * columnWidth + percentOfInterval * columnWidth;
11147
10974
  const x = rtl ? tickX + columnWidth : tickX;
11148
10975
  const color = todayColor || "var(--gantt-calendar-today-color)";
11149
10976
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -11195,7 +11022,8 @@
11195
11022
  if (!showDataDateLine || !dataDate) {
11196
11023
  return null;
11197
11024
  }
11198
- const tickX = taskXCoordinate(dataDate, startDate, viewMode, columnWidth);
11025
+ const index2 = getDatesDiff(dataDate, startDate, viewMode);
11026
+ const tickX = (index2 + 1) * columnWidth - 0.5;
11199
11027
  const x = rtl ? tickX + columnWidth : tickX;
11200
11028
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11201
11029
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -11937,6 +11765,184 @@
11937
11765
  }
11938
11766
  );
11939
11767
  };
11768
+ const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11769
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
11770
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11771
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11772
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
11773
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11774
+ return index2 * columnWidth + percentOfInterval * columnWidth;
11775
+ };
11776
+ const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11777
+ const index2 = getDatesDiff(xDate, startDate, viewMode);
11778
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11779
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11780
+ const remainderMillis = xDate.getTime() - currentDate.getTime();
11781
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11782
+ return index2 * columnWidth + percentOfInterval * columnWidth;
11783
+ };
11784
+ const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
11785
+ const progressWidth = Math.max((taskX2 - taskX1) * progress * 0.01, 0);
11786
+ let progressX;
11787
+ if (rtl) {
11788
+ progressX = taskX2 - progressWidth;
11789
+ } else {
11790
+ progressX = taskX1;
11791
+ }
11792
+ return [progressWidth, progressX];
11793
+ };
11794
+ const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
11795
+ let newDate = new Date((x - taskX) / xStep * timeStep + taskDate.getTime());
11796
+ newDate = new Date(
11797
+ newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
11798
+ );
11799
+ return newDate;
11800
+ };
11801
+ const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11802
+ let result;
11803
+ switch (selectedTask.type) {
11804
+ case "milestone":
11805
+ result = handleTaskBySVGMouseEventForMilestone(
11806
+ action,
11807
+ selectedTask,
11808
+ initialCoordinates,
11809
+ coordinates,
11810
+ xStep,
11811
+ timeStep
11812
+ );
11813
+ break;
11814
+ default:
11815
+ result = handleTaskBySVGMouseEventForBar(
11816
+ action,
11817
+ selectedTask,
11818
+ initialCoordinates,
11819
+ coordinates,
11820
+ xStep,
11821
+ timeStep,
11822
+ rtl
11823
+ );
11824
+ break;
11825
+ }
11826
+ return result;
11827
+ };
11828
+ const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11829
+ const changedTask = { ...selectedTask };
11830
+ let isChanged = false;
11831
+ switch (action) {
11832
+ case "progress":
11833
+ isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
11834
+ if (isChanged) {
11835
+ changedTask.progress = Math.round(
11836
+ coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
11837
+ );
11838
+ }
11839
+ break;
11840
+ case "start": {
11841
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
11842
+ if (isChanged) {
11843
+ if (rtl) {
11844
+ changedTask.end = dateByX(
11845
+ coordinates.x1,
11846
+ initialCoordinates.x1,
11847
+ selectedTask.end,
11848
+ xStep,
11849
+ timeStep
11850
+ );
11851
+ } else {
11852
+ changedTask.start = dateByX(
11853
+ coordinates.x1,
11854
+ initialCoordinates.x1,
11855
+ selectedTask.start,
11856
+ xStep,
11857
+ timeStep
11858
+ );
11859
+ }
11860
+ }
11861
+ break;
11862
+ }
11863
+ case "end": {
11864
+ isChanged = initialCoordinates.x2 !== coordinates.x2;
11865
+ if (isChanged) {
11866
+ if (rtl) {
11867
+ changedTask.start = dateByX(
11868
+ coordinates.x2,
11869
+ initialCoordinates.x2,
11870
+ selectedTask.start,
11871
+ xStep,
11872
+ timeStep
11873
+ );
11874
+ } else {
11875
+ changedTask.end = dateByX(
11876
+ coordinates.x2,
11877
+ initialCoordinates.x2,
11878
+ selectedTask.end,
11879
+ xStep,
11880
+ timeStep
11881
+ );
11882
+ }
11883
+ }
11884
+ break;
11885
+ }
11886
+ case "move": {
11887
+ isChanged = initialCoordinates.x1 !== coordinates.x1;
11888
+ if (isChanged) {
11889
+ if (rtl) {
11890
+ changedTask.end = dateByX(
11891
+ coordinates.x1,
11892
+ initialCoordinates.x1,
11893
+ selectedTask.end,
11894
+ xStep,
11895
+ timeStep
11896
+ );
11897
+ changedTask.start = dateByX(
11898
+ coordinates.x2,
11899
+ initialCoordinates.x2,
11900
+ selectedTask.start,
11901
+ xStep,
11902
+ timeStep
11903
+ );
11904
+ } else {
11905
+ changedTask.start = dateByX(
11906
+ coordinates.x1,
11907
+ initialCoordinates.x1,
11908
+ selectedTask.start,
11909
+ xStep,
11910
+ timeStep
11911
+ );
11912
+ changedTask.end = dateByX(
11913
+ coordinates.x2,
11914
+ initialCoordinates.x2,
11915
+ selectedTask.end,
11916
+ xStep,
11917
+ timeStep
11918
+ );
11919
+ }
11920
+ }
11921
+ break;
11922
+ }
11923
+ }
11924
+ return { isChanged, changedTask };
11925
+ };
11926
+ const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
11927
+ const changedTask = { ...selectedTask };
11928
+ const isChanged = coordinates.x1 !== initialCoordinates.x1;
11929
+ if (isChanged) {
11930
+ switch (action) {
11931
+ case "move": {
11932
+ changedTask.start = dateByX(
11933
+ coordinates.x1,
11934
+ initialCoordinates.x1,
11935
+ selectedTask.start,
11936
+ xStep,
11937
+ timeStep
11938
+ );
11939
+ changedTask.end = changedTask.start;
11940
+ break;
11941
+ }
11942
+ }
11943
+ }
11944
+ return { isChanged, changedTask };
11945
+ };
11940
11946
  const barWrapper = "_barWrapper_5jhkr_1";
11941
11947
  const barHandle = "_barHandle_5jhkr_11";
11942
11948
  const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
@@ -19879,7 +19885,7 @@
19879
19885
  viewMode,
19880
19886
  showTodayLine,
19881
19887
  showDataDateLine,
19882
- dataDate,
19888
+ dataDate: dataDate ? roundStartDate(dataDate) : null,
19883
19889
  todayColor,
19884
19890
  dataDateColor,
19885
19891
  todayLabel,
@@ -19899,7 +19905,8 @@
19899
19905
  todayColor,
19900
19906
  dataDateColor,
19901
19907
  todayLabel,
19902
- dataDateLabel
19908
+ dataDateLabel,
19909
+ roundStartDate
19903
19910
  ]
19904
19911
  );
19905
19912
  const calendarProps = React.useMemo(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.0.51",
3
+ "version": "1.0.53",
4
4
  "description": "Interactive Gantt Chart for React with TypeScript.",
5
5
  "author": "aguilanbon",
6
6
  "homepage": "https://github.com/aguilanbon/gantt-task-react-v",