gantt-task-react-v 1.0.54 → 1.0.56

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,26 +10901,6 @@ 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
10904
  const ganttToday = "_ganttToday_1oyhk_1";
10925
10905
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
10926
10906
  const styles$c = {
@@ -10948,15 +10928,32 @@ const GanttTodayInner = ({
10948
10928
  return null;
10949
10929
  }
10950
10930
  const today = /* @__PURE__ */ new Date();
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;
10957
- const offset2 = 5;
10958
- const adjustedTickX = tickX + (rtl ? -offset2 : offset2);
10959
- const x = rtl ? adjustedTickX + columnWidth : adjustedTickX;
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();
10956
+ const x = rtl ? tickX + columnWidth : tickX;
10960
10957
  const color = todayColor || "var(--gantt-calendar-today-color)";
10961
10958
  return /* @__PURE__ */ jsxs(Fragment, { children: [
10962
10959
  /* @__PURE__ */ jsx(
@@ -11007,15 +11004,32 @@ const GanttTodayInner = ({
11007
11004
  if (!showDataDateLine || !dataDate) {
11008
11005
  return null;
11009
11006
  }
11010
- const index2 = getDatesDiff(dataDate, startDate, viewMode);
11011
- const currentDate = getDateByOffset(startDate, index2, viewMode);
11012
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11013
- const remainderMillis = dataDate.getTime() - currentDate.getTime();
11014
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11015
- const tickX = index2 * columnWidth + percentOfInterval * columnWidth;
11016
- const offset2 = 5;
11017
- const adjustedTickX = tickX + (rtl ? -offset2 : offset2);
11018
- const x = rtl ? adjustedTickX + columnWidth : adjustedTickX;
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();
11032
+ const x = rtl ? tickX + columnWidth : tickX;
11019
11033
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11020
11034
  return /* @__PURE__ */ jsxs(Fragment, { children: [
11021
11035
  /* @__PURE__ */ jsx(
@@ -11756,6 +11770,26 @@ const RelationLine = ({
11756
11770
  }
11757
11771
  );
11758
11772
  };
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
+ };
11759
11793
  const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11760
11794
  const index2 = getDatesDiff(xDate, startDate, viewMode);
11761
11795
  const currentDate = getDateByOffset(startDate, index2, viewMode);
@@ -19876,7 +19910,7 @@ const Gantt = (props) => {
19876
19910
  viewMode,
19877
19911
  showTodayLine,
19878
19912
  showDataDateLine,
19879
- dataDate: dataDate ? roundStartDate(dataDate) : null,
19913
+ dataDate,
19880
19914
  todayColor,
19881
19915
  dataDateColor,
19882
19916
  todayLabel,
@@ -19896,8 +19930,7 @@ const Gantt = (props) => {
19896
19930
  todayColor,
19897
19931
  dataDateColor,
19898
19932
  todayLabel,
19899
- dataDateLabel,
19900
- roundStartDate
19933
+ dataDateLabel
19901
19934
  ]
19902
19935
  );
19903
19936
  const calendarProps = useMemo(
@@ -10918,26 +10918,6 @@
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
10921
  const ganttToday = "_ganttToday_1oyhk_1";
10942
10922
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
10943
10923
  const styles$c = {
@@ -10965,15 +10945,32 @@
10965
10945
  return null;
10966
10946
  }
10967
10947
  const today = /* @__PURE__ */ new Date();
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;
10974
- const offset2 = 5;
10975
- const adjustedTickX = tickX + (rtl ? -offset2 : offset2);
10976
- const x = rtl ? adjustedTickX + columnWidth : adjustedTickX;
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();
10973
+ const x = rtl ? tickX + columnWidth : tickX;
10977
10974
  const color = todayColor || "var(--gantt-calendar-today-color)";
10978
10975
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
10979
10976
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -11024,15 +11021,32 @@
11024
11021
  if (!showDataDateLine || !dataDate) {
11025
11022
  return null;
11026
11023
  }
11027
- const index2 = getDatesDiff(dataDate, startDate, viewMode);
11028
- const currentDate = getDateByOffset(startDate, index2, viewMode);
11029
- const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11030
- const remainderMillis = dataDate.getTime() - currentDate.getTime();
11031
- const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11032
- const tickX = index2 * columnWidth + percentOfInterval * columnWidth;
11033
- const offset2 = 5;
11034
- const adjustedTickX = tickX + (rtl ? -offset2 : offset2);
11035
- const x = rtl ? adjustedTickX + columnWidth : adjustedTickX;
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();
11049
+ const x = rtl ? tickX + columnWidth : tickX;
11036
11050
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11037
11051
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
11038
11052
  /* @__PURE__ */ jsxRuntime.jsx(
@@ -11773,6 +11787,26 @@
11773
11787
  }
11774
11788
  );
11775
11789
  };
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
+ };
11776
11810
  const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11777
11811
  const index2 = getDatesDiff(xDate, startDate, viewMode);
11778
11812
  const currentDate = getDateByOffset(startDate, index2, viewMode);
@@ -19893,7 +19927,7 @@
19893
19927
  viewMode,
19894
19928
  showTodayLine,
19895
19929
  showDataDateLine,
19896
- dataDate: dataDate ? roundStartDate(dataDate) : null,
19930
+ dataDate,
19897
19931
  todayColor,
19898
19932
  dataDateColor,
19899
19933
  todayLabel,
@@ -19913,8 +19947,7 @@
19913
19947
  todayColor,
19914
19948
  dataDateColor,
19915
19949
  todayLabel,
19916
- dataDateLabel,
19917
- roundStartDate
19950
+ dataDateLabel
19918
19951
  ]
19919
19952
  );
19920
19953
  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.54",
3
+ "version": "1.0.56",
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",