gantt-task-react-v 1.0.56 → 1.0.57

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.
@@ -10901,6 +10901,204 @@ const TaskListInner = ({
10901
10901
  ] });
10902
10902
  };
10903
10903
  const TaskList = memo(TaskListInner);
10904
+ const getDateByOffset = (startDate, offset2, viewMode) => {
10905
+ switch (viewMode) {
10906
+ case ViewMode.Day:
10907
+ return addDays(startDate, offset2);
10908
+ case ViewMode.HalfDay:
10909
+ return addHours(startDate, offset2 * 12);
10910
+ case ViewMode.QuarterDay:
10911
+ return addHours(startDate, offset2 * 6);
10912
+ case ViewMode.Hour:
10913
+ return addHours(startDate, offset2);
10914
+ case ViewMode.Month:
10915
+ return addMonths(startDate, offset2);
10916
+ case ViewMode.Week:
10917
+ return addWeeks(startDate, offset2);
10918
+ case ViewMode.Year:
10919
+ return addYears(startDate, offset2);
10920
+ default:
10921
+ throw new Error("Unknown view mode");
10922
+ }
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
+ };
10904
11102
  const ganttToday = "_ganttToday_1oyhk_1";
10905
11103
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
10906
11104
  const styles$c = {
@@ -10928,31 +11126,7 @@ const GanttTodayInner = ({
10928
11126
  return null;
10929
11127
  }
10930
11128
  const today = /* @__PURE__ */ new Date();
10931
- const todayIndex = getDatesDiff(today, startDate, viewMode);
10932
- const extraMultiplier = () => {
10933
- switch (viewMode) {
10934
- case ViewMode.Week: {
10935
- const percent = today.getDay() / 7;
10936
- return 1 + percent * 0.2;
10937
- }
10938
- case ViewMode.Month: {
10939
- const dayInMonth = today.getDate();
10940
- const maxDaysInMonth = getDaysInMonth(
10941
- today.getMonth(),
10942
- today.getFullYear()
10943
- );
10944
- const percent = dayInMonth / maxDaysInMonth;
10945
- return 1 + percent * 0.5;
10946
- }
10947
- case ViewMode.Year: {
10948
- const percent = today.getMonth() / 12;
10949
- return 1 + percent * 0.5;
10950
- }
10951
- default:
10952
- return 1;
10953
- }
10954
- };
10955
- const tickX = todayIndex * columnWidth * extraMultiplier();
11129
+ const tickX = taskXCoordinate(today, startDate, viewMode, columnWidth);
10956
11130
  const x = rtl ? tickX + columnWidth : tickX;
10957
11131
  const color = todayColor || "var(--gantt-calendar-today-color)";
10958
11132
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -11004,31 +11178,7 @@ const GanttTodayInner = ({
11004
11178
  if (!showDataDateLine || !dataDate) {
11005
11179
  return null;
11006
11180
  }
11007
- const dataIndex = getDatesDiff(dataDate, startDate, viewMode);
11008
- const extraMultiplier = () => {
11009
- switch (viewMode) {
11010
- case ViewMode.Week: {
11011
- const percent = dataDate.getDay() / 7;
11012
- return 1 + percent * 0.2;
11013
- }
11014
- case ViewMode.Month: {
11015
- const dayInMonth = dataDate.getDate();
11016
- const maxDaysInMonth = getDaysInMonth(
11017
- dataDate.getMonth(),
11018
- dataDate.getFullYear()
11019
- );
11020
- const percent = dayInMonth / maxDaysInMonth;
11021
- return 1 + percent * 0.5;
11022
- }
11023
- case ViewMode.Year: {
11024
- const percent = dataDate.getMonth() / 12;
11025
- return 1 + percent * 0.5;
11026
- }
11027
- default:
11028
- return 1;
11029
- }
11030
- };
11031
- const tickX = dataIndex * columnWidth * extraMultiplier();
11181
+ const tickX = taskXCoordinate(dataDate, startDate, viewMode, columnWidth);
11032
11182
  const x = rtl ? tickX + columnWidth : tickX;
11033
11183
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11034
11184
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -11770,204 +11920,6 @@ const RelationLine = ({
11770
11920
  }
11771
11921
  );
11772
11922
  };
11773
- const getDateByOffset = (startDate, offset2, viewMode) => {
11774
- switch (viewMode) {
11775
- case ViewMode.Day:
11776
- return addDays(startDate, offset2);
11777
- case ViewMode.HalfDay:
11778
- return addHours(startDate, offset2 * 12);
11779
- case ViewMode.QuarterDay:
11780
- return addHours(startDate, offset2 * 6);
11781
- case ViewMode.Hour:
11782
- return addHours(startDate, offset2);
11783
- case ViewMode.Month:
11784
- return addMonths(startDate, offset2);
11785
- case ViewMode.Week:
11786
- return addWeeks(startDate, offset2);
11787
- case ViewMode.Year:
11788
- return addYears(startDate, offset2);
11789
- default:
11790
- throw new Error("Unknown view mode");
11791
- }
11792
- };
11793
- const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11794
- const index2 = getDatesDiff(xDate, startDate, viewMode);
11795
- const currentDate = getDateByOffset(startDate, index2, viewMode);
11796
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11797
- const remainderMillis = xDate.getTime() - currentDate.getTime();
11798
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11799
- return index2 * columnWidth + percentOfInterval * columnWidth;
11800
- };
11801
- const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11802
- const index2 = getDatesDiff(xDate, startDate, viewMode);
11803
- const currentDate = getDateByOffset(startDate, index2, viewMode);
11804
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11805
- const remainderMillis = xDate.getTime() - currentDate.getTime();
11806
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11807
- return index2 * columnWidth + percentOfInterval * columnWidth;
11808
- };
11809
- const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
11810
- const progressWidth = Math.max((taskX2 - taskX1) * progress * 0.01, 0);
11811
- let progressX;
11812
- if (rtl) {
11813
- progressX = taskX2 - progressWidth;
11814
- } else {
11815
- progressX = taskX1;
11816
- }
11817
- return [progressWidth, progressX];
11818
- };
11819
- const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
11820
- let newDate = new Date((x - taskX) / xStep * timeStep + taskDate.getTime());
11821
- newDate = new Date(
11822
- newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
11823
- );
11824
- return newDate;
11825
- };
11826
- const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11827
- let result;
11828
- switch (selectedTask.type) {
11829
- case "milestone":
11830
- result = handleTaskBySVGMouseEventForMilestone(
11831
- action,
11832
- selectedTask,
11833
- initialCoordinates,
11834
- coordinates,
11835
- xStep,
11836
- timeStep
11837
- );
11838
- break;
11839
- default:
11840
- result = handleTaskBySVGMouseEventForBar(
11841
- action,
11842
- selectedTask,
11843
- initialCoordinates,
11844
- coordinates,
11845
- xStep,
11846
- timeStep,
11847
- rtl
11848
- );
11849
- break;
11850
- }
11851
- return result;
11852
- };
11853
- const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11854
- const changedTask = { ...selectedTask };
11855
- let isChanged = false;
11856
- switch (action) {
11857
- case "progress":
11858
- isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
11859
- if (isChanged) {
11860
- changedTask.progress = Math.round(
11861
- coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
11862
- );
11863
- }
11864
- break;
11865
- case "start": {
11866
- isChanged = initialCoordinates.x1 !== coordinates.x1;
11867
- if (isChanged) {
11868
- if (rtl) {
11869
- changedTask.end = dateByX(
11870
- coordinates.x1,
11871
- initialCoordinates.x1,
11872
- selectedTask.end,
11873
- xStep,
11874
- timeStep
11875
- );
11876
- } else {
11877
- changedTask.start = dateByX(
11878
- coordinates.x1,
11879
- initialCoordinates.x1,
11880
- selectedTask.start,
11881
- xStep,
11882
- timeStep
11883
- );
11884
- }
11885
- }
11886
- break;
11887
- }
11888
- case "end": {
11889
- isChanged = initialCoordinates.x2 !== coordinates.x2;
11890
- if (isChanged) {
11891
- if (rtl) {
11892
- changedTask.start = dateByX(
11893
- coordinates.x2,
11894
- initialCoordinates.x2,
11895
- selectedTask.start,
11896
- xStep,
11897
- timeStep
11898
- );
11899
- } else {
11900
- changedTask.end = dateByX(
11901
- coordinates.x2,
11902
- initialCoordinates.x2,
11903
- selectedTask.end,
11904
- xStep,
11905
- timeStep
11906
- );
11907
- }
11908
- }
11909
- break;
11910
- }
11911
- case "move": {
11912
- isChanged = initialCoordinates.x1 !== coordinates.x1;
11913
- if (isChanged) {
11914
- if (rtl) {
11915
- changedTask.end = dateByX(
11916
- coordinates.x1,
11917
- initialCoordinates.x1,
11918
- selectedTask.end,
11919
- xStep,
11920
- timeStep
11921
- );
11922
- changedTask.start = dateByX(
11923
- coordinates.x2,
11924
- initialCoordinates.x2,
11925
- selectedTask.start,
11926
- xStep,
11927
- timeStep
11928
- );
11929
- } else {
11930
- changedTask.start = dateByX(
11931
- coordinates.x1,
11932
- initialCoordinates.x1,
11933
- selectedTask.start,
11934
- xStep,
11935
- timeStep
11936
- );
11937
- changedTask.end = dateByX(
11938
- coordinates.x2,
11939
- initialCoordinates.x2,
11940
- selectedTask.end,
11941
- xStep,
11942
- timeStep
11943
- );
11944
- }
11945
- }
11946
- break;
11947
- }
11948
- }
11949
- return { isChanged, changedTask };
11950
- };
11951
- const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
11952
- const changedTask = { ...selectedTask };
11953
- const isChanged = coordinates.x1 !== initialCoordinates.x1;
11954
- if (isChanged) {
11955
- switch (action) {
11956
- case "move": {
11957
- changedTask.start = dateByX(
11958
- coordinates.x1,
11959
- initialCoordinates.x1,
11960
- selectedTask.start,
11961
- xStep,
11962
- timeStep
11963
- );
11964
- changedTask.end = changedTask.start;
11965
- break;
11966
- }
11967
- }
11968
- }
11969
- return { isChanged, changedTask };
11970
- };
11971
11923
  const barWrapper = "_barWrapper_5jhkr_1";
11972
11924
  const barHandle = "_barHandle_5jhkr_11";
11973
11925
  const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
@@ -10918,6 +10918,204 @@
10918
10918
  ] });
10919
10919
  };
10920
10920
  const TaskList = React.memo(TaskListInner);
10921
+ const getDateByOffset = (startDate, offset2, viewMode) => {
10922
+ switch (viewMode) {
10923
+ case ViewMode.Day:
10924
+ return addDays(startDate, offset2);
10925
+ case ViewMode.HalfDay:
10926
+ return addHours(startDate, offset2 * 12);
10927
+ case ViewMode.QuarterDay:
10928
+ return addHours(startDate, offset2 * 6);
10929
+ case ViewMode.Hour:
10930
+ return addHours(startDate, offset2);
10931
+ case ViewMode.Month:
10932
+ return addMonths(startDate, offset2);
10933
+ case ViewMode.Week:
10934
+ return addWeeks(startDate, offset2);
10935
+ case ViewMode.Year:
10936
+ return addYears(startDate, offset2);
10937
+ default:
10938
+ throw new Error("Unknown view mode");
10939
+ }
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
+ };
10921
11119
  const ganttToday = "_ganttToday_1oyhk_1";
10922
11120
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
10923
11121
  const styles$c = {
@@ -10945,31 +11143,7 @@
10945
11143
  return null;
10946
11144
  }
10947
11145
  const today = /* @__PURE__ */ new Date();
10948
- const todayIndex = getDatesDiff(today, startDate, viewMode);
10949
- const extraMultiplier = () => {
10950
- switch (viewMode) {
10951
- case ViewMode.Week: {
10952
- const percent = today.getDay() / 7;
10953
- return 1 + percent * 0.2;
10954
- }
10955
- case ViewMode.Month: {
10956
- const dayInMonth = today.getDate();
10957
- const maxDaysInMonth = getDaysInMonth(
10958
- today.getMonth(),
10959
- today.getFullYear()
10960
- );
10961
- const percent = dayInMonth / maxDaysInMonth;
10962
- return 1 + percent * 0.5;
10963
- }
10964
- case ViewMode.Year: {
10965
- const percent = today.getMonth() / 12;
10966
- return 1 + percent * 0.5;
10967
- }
10968
- default:
10969
- return 1;
10970
- }
10971
- };
10972
- const tickX = todayIndex * columnWidth * extraMultiplier();
11146
+ const tickX = taskXCoordinate(today, startDate, viewMode, columnWidth);
10973
11147
  const x = rtl ? tickX + columnWidth : tickX;
10974
11148
  const color = todayColor || "var(--gantt-calendar-today-color)";
10975
11149
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -11021,31 +11195,7 @@
11021
11195
  if (!showDataDateLine || !dataDate) {
11022
11196
  return null;
11023
11197
  }
11024
- const dataIndex = getDatesDiff(dataDate, startDate, viewMode);
11025
- const extraMultiplier = () => {
11026
- switch (viewMode) {
11027
- case ViewMode.Week: {
11028
- const percent = dataDate.getDay() / 7;
11029
- return 1 + percent * 0.2;
11030
- }
11031
- case ViewMode.Month: {
11032
- const dayInMonth = dataDate.getDate();
11033
- const maxDaysInMonth = getDaysInMonth(
11034
- dataDate.getMonth(),
11035
- dataDate.getFullYear()
11036
- );
11037
- const percent = dayInMonth / maxDaysInMonth;
11038
- return 1 + percent * 0.5;
11039
- }
11040
- case ViewMode.Year: {
11041
- const percent = dataDate.getMonth() / 12;
11042
- return 1 + percent * 0.5;
11043
- }
11044
- default:
11045
- return 1;
11046
- }
11047
- };
11048
- const tickX = dataIndex * columnWidth * extraMultiplier();
11198
+ const tickX = taskXCoordinate(dataDate, startDate, viewMode, columnWidth);
11049
11199
  const x = rtl ? tickX + columnWidth : tickX;
11050
11200
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11051
11201
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -11787,204 +11937,6 @@
11787
11937
  }
11788
11938
  );
11789
11939
  };
11790
- const getDateByOffset = (startDate, offset2, viewMode) => {
11791
- switch (viewMode) {
11792
- case ViewMode.Day:
11793
- return addDays(startDate, offset2);
11794
- case ViewMode.HalfDay:
11795
- return addHours(startDate, offset2 * 12);
11796
- case ViewMode.QuarterDay:
11797
- return addHours(startDate, offset2 * 6);
11798
- case ViewMode.Hour:
11799
- return addHours(startDate, offset2);
11800
- case ViewMode.Month:
11801
- return addMonths(startDate, offset2);
11802
- case ViewMode.Week:
11803
- return addWeeks(startDate, offset2);
11804
- case ViewMode.Year:
11805
- return addYears(startDate, offset2);
11806
- default:
11807
- throw new Error("Unknown view mode");
11808
- }
11809
- };
11810
- const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11811
- const index2 = getDatesDiff(xDate, startDate, viewMode);
11812
- const currentDate = getDateByOffset(startDate, index2, viewMode);
11813
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11814
- const remainderMillis = xDate.getTime() - currentDate.getTime();
11815
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11816
- return index2 * columnWidth + percentOfInterval * columnWidth;
11817
- };
11818
- const taskComparisonXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11819
- const index2 = getDatesDiff(xDate, startDate, viewMode);
11820
- const currentDate = getDateByOffset(startDate, index2, viewMode);
11821
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11822
- const remainderMillis = xDate.getTime() - currentDate.getTime();
11823
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11824
- return index2 * columnWidth + percentOfInterval * columnWidth;
11825
- };
11826
- const progressWithByParams = (taskX1, taskX2, progress, rtl) => {
11827
- const progressWidth = Math.max((taskX2 - taskX1) * progress * 0.01, 0);
11828
- let progressX;
11829
- if (rtl) {
11830
- progressX = taskX2 - progressWidth;
11831
- } else {
11832
- progressX = taskX1;
11833
- }
11834
- return [progressWidth, progressX];
11835
- };
11836
- const dateByX = (x, taskX, taskDate, xStep, timeStep) => {
11837
- let newDate = new Date((x - taskX) / xStep * timeStep + taskDate.getTime());
11838
- newDate = new Date(
11839
- newDate.getTime() + (newDate.getTimezoneOffset() - taskDate.getTimezoneOffset()) * 6e4
11840
- );
11841
- return newDate;
11842
- };
11843
- const handleTaskBySVGMouseEvent = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11844
- let result;
11845
- switch (selectedTask.type) {
11846
- case "milestone":
11847
- result = handleTaskBySVGMouseEventForMilestone(
11848
- action,
11849
- selectedTask,
11850
- initialCoordinates,
11851
- coordinates,
11852
- xStep,
11853
- timeStep
11854
- );
11855
- break;
11856
- default:
11857
- result = handleTaskBySVGMouseEventForBar(
11858
- action,
11859
- selectedTask,
11860
- initialCoordinates,
11861
- coordinates,
11862
- xStep,
11863
- timeStep,
11864
- rtl
11865
- );
11866
- break;
11867
- }
11868
- return result;
11869
- };
11870
- const handleTaskBySVGMouseEventForBar = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep, rtl) => {
11871
- const changedTask = { ...selectedTask };
11872
- let isChanged = false;
11873
- switch (action) {
11874
- case "progress":
11875
- isChanged = initialCoordinates.progressWidth !== coordinates.progressWidth;
11876
- if (isChanged) {
11877
- changedTask.progress = Math.round(
11878
- coordinates.progressWidth * 100 / (coordinates.x2 - coordinates.x1)
11879
- );
11880
- }
11881
- break;
11882
- case "start": {
11883
- isChanged = initialCoordinates.x1 !== coordinates.x1;
11884
- if (isChanged) {
11885
- if (rtl) {
11886
- changedTask.end = dateByX(
11887
- coordinates.x1,
11888
- initialCoordinates.x1,
11889
- selectedTask.end,
11890
- xStep,
11891
- timeStep
11892
- );
11893
- } else {
11894
- changedTask.start = dateByX(
11895
- coordinates.x1,
11896
- initialCoordinates.x1,
11897
- selectedTask.start,
11898
- xStep,
11899
- timeStep
11900
- );
11901
- }
11902
- }
11903
- break;
11904
- }
11905
- case "end": {
11906
- isChanged = initialCoordinates.x2 !== coordinates.x2;
11907
- if (isChanged) {
11908
- if (rtl) {
11909
- changedTask.start = dateByX(
11910
- coordinates.x2,
11911
- initialCoordinates.x2,
11912
- selectedTask.start,
11913
- xStep,
11914
- timeStep
11915
- );
11916
- } else {
11917
- changedTask.end = dateByX(
11918
- coordinates.x2,
11919
- initialCoordinates.x2,
11920
- selectedTask.end,
11921
- xStep,
11922
- timeStep
11923
- );
11924
- }
11925
- }
11926
- break;
11927
- }
11928
- case "move": {
11929
- isChanged = initialCoordinates.x1 !== coordinates.x1;
11930
- if (isChanged) {
11931
- if (rtl) {
11932
- changedTask.end = dateByX(
11933
- coordinates.x1,
11934
- initialCoordinates.x1,
11935
- selectedTask.end,
11936
- xStep,
11937
- timeStep
11938
- );
11939
- changedTask.start = dateByX(
11940
- coordinates.x2,
11941
- initialCoordinates.x2,
11942
- selectedTask.start,
11943
- xStep,
11944
- timeStep
11945
- );
11946
- } else {
11947
- changedTask.start = dateByX(
11948
- coordinates.x1,
11949
- initialCoordinates.x1,
11950
- selectedTask.start,
11951
- xStep,
11952
- timeStep
11953
- );
11954
- changedTask.end = dateByX(
11955
- coordinates.x2,
11956
- initialCoordinates.x2,
11957
- selectedTask.end,
11958
- xStep,
11959
- timeStep
11960
- );
11961
- }
11962
- }
11963
- break;
11964
- }
11965
- }
11966
- return { isChanged, changedTask };
11967
- };
11968
- const handleTaskBySVGMouseEventForMilestone = (action, selectedTask, initialCoordinates, coordinates, xStep, timeStep) => {
11969
- const changedTask = { ...selectedTask };
11970
- const isChanged = coordinates.x1 !== initialCoordinates.x1;
11971
- if (isChanged) {
11972
- switch (action) {
11973
- case "move": {
11974
- changedTask.start = dateByX(
11975
- coordinates.x1,
11976
- initialCoordinates.x1,
11977
- selectedTask.start,
11978
- xStep,
11979
- timeStep
11980
- );
11981
- changedTask.end = changedTask.start;
11982
- break;
11983
- }
11984
- }
11985
- }
11986
- return { isChanged, changedTask };
11987
- };
11988
11940
  const barWrapper = "_barWrapper_5jhkr_1";
11989
11941
  const barHandle = "_barHandle_5jhkr_11";
11990
11942
  const barHandleImportantVisible = "_barHandleImportantVisible_5jhkr_37";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gantt-task-react-v",
3
- "version": "1.0.56",
3
+ "version": "1.0.57",
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",