gantt-task-react-v 1.0.50 → 1.0.52

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
@@ -14,7 +14,7 @@
14
14
  ## Install
15
15
 
16
16
  ```
17
- npm install https://github.com/aguilanbon/gantt-task-react-v"
17
+ npm install gantt-task-react-v
18
18
  ```
19
19
 
20
20
  ## How to use it
@@ -10901,6 +10901,26 @@ 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
+ };
10904
10924
  const ganttToday = "_ganttToday_1oyhk_1";
10905
10925
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
10906
10926
  const styles$c = {
@@ -10928,31 +10948,12 @@ const GanttTodayInner = ({
10928
10948
  return null;
10929
10949
  }
10930
10950
  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();
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;
10956
10957
  const x = rtl ? tickX + columnWidth : tickX;
10957
10958
  const color = todayColor || "var(--gantt-calendar-today-color)";
10958
10959
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -11004,31 +11005,12 @@ const GanttTodayInner = ({
11004
11005
  if (!showDataDateLine || !dataDate) {
11005
11006
  return null;
11006
11007
  }
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();
11008
+ const index2 = getDatesDiff(dataDate, startDate, viewMode);
11009
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11010
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11011
+ const remainderMillis = dataDate.getTime() - currentDate.getTime();
11012
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11013
+ const tickX = index2 * columnWidth + percentOfInterval * columnWidth;
11032
11014
  const x = rtl ? tickX + columnWidth : tickX;
11033
11015
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11034
11016
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -11770,26 +11752,6 @@ const RelationLine = ({
11770
11752
  }
11771
11753
  );
11772
11754
  };
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
11755
  const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11794
11756
  const index2 = getDatesDiff(xDate, startDate, viewMode);
11795
11757
  const currentDate = getDateByOffset(startDate, index2, viewMode);
@@ -19910,7 +19872,7 @@ const Gantt = (props) => {
19910
19872
  viewMode,
19911
19873
  showTodayLine,
19912
19874
  showDataDateLine,
19913
- dataDate,
19875
+ dataDate: dataDate ? roundStartDate(dataDate) : null,
19914
19876
  todayColor,
19915
19877
  dataDateColor,
19916
19878
  todayLabel,
@@ -19930,7 +19892,8 @@ const Gantt = (props) => {
19930
19892
  todayColor,
19931
19893
  dataDateColor,
19932
19894
  todayLabel,
19933
- dataDateLabel
19895
+ dataDateLabel,
19896
+ roundStartDate
19934
19897
  ]
19935
19898
  );
19936
19899
  const calendarProps = useMemo(
@@ -10918,6 +10918,26 @@
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
+ };
10921
10941
  const ganttToday = "_ganttToday_1oyhk_1";
10922
10942
  const ganttTodayCircle = "_ganttTodayCircle_1oyhk_9";
10923
10943
  const styles$c = {
@@ -10945,31 +10965,12 @@
10945
10965
  return null;
10946
10966
  }
10947
10967
  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();
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;
10973
10974
  const x = rtl ? tickX + columnWidth : tickX;
10974
10975
  const color = todayColor || "var(--gantt-calendar-today-color)";
10975
10976
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -11021,31 +11022,12 @@
11021
11022
  if (!showDataDateLine || !dataDate) {
11022
11023
  return null;
11023
11024
  }
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();
11025
+ const index2 = getDatesDiff(dataDate, startDate, viewMode);
11026
+ const currentDate = getDateByOffset(startDate, index2, viewMode);
11027
+ const nextDate = getDateByOffset(startDate, index2 + 1, viewMode);
11028
+ const remainderMillis = dataDate.getTime() - currentDate.getTime();
11029
+ const percentOfInterval = remainderMillis / (nextDate.getTime() - currentDate.getTime());
11030
+ const tickX = index2 * columnWidth + percentOfInterval * columnWidth;
11049
11031
  const x = rtl ? tickX + columnWidth : tickX;
11050
11032
  const color = dataDateColor || "var(--gantt-calendar-today-color)";
11051
11033
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
@@ -11787,26 +11769,6 @@
11787
11769
  }
11788
11770
  );
11789
11771
  };
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
11772
  const taskXCoordinate = (xDate, startDate, viewMode, columnWidth) => {
11811
11773
  const index2 = getDatesDiff(xDate, startDate, viewMode);
11812
11774
  const currentDate = getDateByOffset(startDate, index2, viewMode);
@@ -19927,7 +19889,7 @@
19927
19889
  viewMode,
19928
19890
  showTodayLine,
19929
19891
  showDataDateLine,
19930
- dataDate,
19892
+ dataDate: dataDate ? roundStartDate(dataDate) : null,
19931
19893
  todayColor,
19932
19894
  dataDateColor,
19933
19895
  todayLabel,
@@ -19947,7 +19909,8 @@
19947
19909
  todayColor,
19948
19910
  dataDateColor,
19949
19911
  todayLabel,
19950
- dataDateLabel
19912
+ dataDateLabel,
19913
+ roundStartDate
19951
19914
  ]
19952
19915
  );
19953
19916
  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.50",
3
+ "version": "1.0.52",
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",