@thepocman/gantt-task-react 1.0.25 → 1.0.27

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.
@@ -15,5 +15,6 @@ export type GridBodyProps = {
15
15
  checkIsHoliday: (date: Date, dateExtremity: DateExtremity) => boolean;
16
16
  getDate: (index: number) => Date;
17
17
  minTaskDate: Date;
18
+ dividerColor: string;
18
19
  };
19
20
  export declare const GridBody: React.NamedExoticComponent<GridBodyProps>;
@@ -4923,6 +4923,34 @@ const Calendar = ({
4923
4923
  }
4924
4924
  ) });
4925
4925
  };
4926
+ const shouldDrawVerticalDivider = (currentDate, previousDate, viewMode, isUnknownDates, columnIndex, startColumnIndex) => {
4927
+ if (isUnknownDates)
4928
+ return false;
4929
+ if (columnIndex === startColumnIndex)
4930
+ return true;
4931
+ if (!previousDate)
4932
+ return false;
4933
+ switch (viewMode) {
4934
+ case ViewMode.Year:
4935
+ return currentDate.getFullYear() !== previousDate.getFullYear();
4936
+ case ViewMode.HalfYear:
4937
+ return currentDate.getFullYear() !== previousDate.getFullYear();
4938
+ case ViewMode.QuarterYear:
4939
+ return Math.ceil((currentDate.getMonth() + 1) / 3) !== Math.ceil((previousDate.getMonth() + 1) / 3) || currentDate.getFullYear() !== previousDate.getFullYear();
4940
+ case ViewMode.Month:
4941
+ return currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4942
+ case ViewMode.Week:
4943
+ return currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4944
+ case ViewMode.Day:
4945
+ return currentDate.getDate() !== previousDate.getDate() || currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4946
+ case ViewMode.HalfDay:
4947
+ case ViewMode.QuarterDay:
4948
+ case ViewMode.Hour:
4949
+ return currentDate.getDate() !== previousDate.getDate() || currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4950
+ default:
4951
+ return false;
4952
+ }
4953
+ };
4926
4954
  const GridBodyInner = ({
4927
4955
  additionalLeftSpace,
4928
4956
  columnWidth,
@@ -4931,7 +4959,11 @@ const GridBodyInner = ({
4931
4959
  todayColor,
4932
4960
  rtl,
4933
4961
  startDate,
4934
- viewMode
4962
+ viewMode,
4963
+ dividerColor,
4964
+ startColumnIndex,
4965
+ endColumnIndex,
4966
+ getDate
4935
4967
  }) => {
4936
4968
  const today = useMemo(() => {
4937
4969
  if (isUnknownDates) {
@@ -4960,7 +4992,57 @@ const GridBodyInner = ({
4960
4992
  todayColor,
4961
4993
  viewMode
4962
4994
  ]);
4963
- return /* @__PURE__ */ jsx("g", { className: "gridBody", children: /* @__PURE__ */ jsx("g", { className: "today", children: today }) });
4995
+ const verticalDividers = useMemo(() => {
4996
+ const dividers = [];
4997
+ for (let i2 = startColumnIndex; i2 <= endColumnIndex; i2++) {
4998
+ const currentDate = getDate(i2);
4999
+ const previousDate = i2 > startColumnIndex ? getDate(i2 - 1) : null;
5000
+ if (shouldDrawVerticalDivider(
5001
+ currentDate,
5002
+ previousDate,
5003
+ viewMode,
5004
+ isUnknownDates,
5005
+ i2,
5006
+ startColumnIndex
5007
+ )) {
5008
+ console.log("Drawing divider at column", i2, "date", currentDate);
5009
+ const x3 = additionalLeftSpace + columnWidth * i2;
5010
+ console.log("debugging x:", x3);
5011
+ console.log("divider color", dividerColor);
5012
+ dividers.push(
5013
+ /* @__PURE__ */ jsx(
5014
+ "line",
5015
+ {
5016
+ x1: x3,
5017
+ x2: x3,
5018
+ y1: 0,
5019
+ y2: ganttFullHeight,
5020
+ stroke: dividerColor,
5021
+ opacity: 0.15,
5022
+ strokeWidth: 5
5023
+ },
5024
+ `divider-${i2}`
5025
+ )
5026
+ );
5027
+ }
5028
+ }
5029
+ return dividers;
5030
+ }, [
5031
+ additionalLeftSpace,
5032
+ columnWidth,
5033
+ ganttFullHeight,
5034
+ viewMode,
5035
+ isUnknownDates,
5036
+ startColumnIndex,
5037
+ endColumnIndex,
5038
+ getDate,
5039
+ dividerColor
5040
+ ]);
5041
+ console.log("verticalDividers :>> ", verticalDividers);
5042
+ return /* @__PURE__ */ jsxs("g", { className: "gridBody", children: [
5043
+ /* @__PURE__ */ jsx("g", { className: "today", children: today }),
5044
+ /* @__PURE__ */ jsx("g", { className: "verticalDividers", children: verticalDividers })
5045
+ ] });
4964
5046
  };
4965
5047
  const GridBody = memo(GridBodyInner);
4966
5048
  function isWeekend(dirtyDate) {
@@ -6905,7 +6987,6 @@ const TaskGanttInner = (props) => {
6905
6987
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
6906
6988
  width: (ganttTaskRootRef == null ? void 0 : ganttTaskRootRef.current) ? ganttTaskRootRef.current.clientWidth + ganttTaskRootRef.current.scrollLeft : fullSvgWidth
6907
6989
  };
6908
- console.log("containerStyle:>> ", containerStyle);
6909
6990
  const gridStyle = useMemo(
6910
6991
  () => ({
6911
6992
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
@@ -11624,6 +11705,8 @@ const defaultColors = {
11624
11705
  selectedTaskBackgroundColor: "rgba(252, 248, 227, 0.5)",
11625
11706
  taskDragColor: "#7474ff",
11626
11707
  todayColor: "rgba(252, 248, 227, 0.5)",
11708
+ dividerColor: "rgba(22, 16, 14, 0.27)",
11709
+ //new color
11627
11710
  contextMenuBoxShadow: "rgb(0 0 0 / 25%) 1px 1px 5px 1px",
11628
11711
  contextMenuBgColor: "#fff",
11629
11712
  contextMenuTextColor: "inherit"
@@ -12984,6 +13067,7 @@ const Gantt = ({
12984
13067
  rtl,
12985
13068
  startDate,
12986
13069
  todayColor: colorStyles.todayColor,
13070
+ dividerColor: colorStyles.dividerColor,
12987
13071
  holidayBackgroundColor: colorStyles.holidayBackgroundColor,
12988
13072
  viewMode,
12989
13073
  startColumnIndex,
@@ -4936,6 +4936,34 @@
4936
4936
  }
4937
4937
  ) });
4938
4938
  };
4939
+ const shouldDrawVerticalDivider = (currentDate, previousDate, viewMode, isUnknownDates, columnIndex, startColumnIndex) => {
4940
+ if (isUnknownDates)
4941
+ return false;
4942
+ if (columnIndex === startColumnIndex)
4943
+ return true;
4944
+ if (!previousDate)
4945
+ return false;
4946
+ switch (viewMode) {
4947
+ case ViewMode.Year:
4948
+ return currentDate.getFullYear() !== previousDate.getFullYear();
4949
+ case ViewMode.HalfYear:
4950
+ return currentDate.getFullYear() !== previousDate.getFullYear();
4951
+ case ViewMode.QuarterYear:
4952
+ return Math.ceil((currentDate.getMonth() + 1) / 3) !== Math.ceil((previousDate.getMonth() + 1) / 3) || currentDate.getFullYear() !== previousDate.getFullYear();
4953
+ case ViewMode.Month:
4954
+ return currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4955
+ case ViewMode.Week:
4956
+ return currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4957
+ case ViewMode.Day:
4958
+ return currentDate.getDate() !== previousDate.getDate() || currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4959
+ case ViewMode.HalfDay:
4960
+ case ViewMode.QuarterDay:
4961
+ case ViewMode.Hour:
4962
+ return currentDate.getDate() !== previousDate.getDate() || currentDate.getMonth() !== previousDate.getMonth() || currentDate.getFullYear() !== previousDate.getFullYear();
4963
+ default:
4964
+ return false;
4965
+ }
4966
+ };
4939
4967
  const GridBodyInner = ({
4940
4968
  additionalLeftSpace,
4941
4969
  columnWidth,
@@ -4944,7 +4972,11 @@
4944
4972
  todayColor,
4945
4973
  rtl,
4946
4974
  startDate,
4947
- viewMode
4975
+ viewMode,
4976
+ dividerColor,
4977
+ startColumnIndex,
4978
+ endColumnIndex,
4979
+ getDate
4948
4980
  }) => {
4949
4981
  const today = React.useMemo(() => {
4950
4982
  if (isUnknownDates) {
@@ -4973,7 +5005,57 @@
4973
5005
  todayColor,
4974
5006
  viewMode
4975
5007
  ]);
4976
- return /* @__PURE__ */ jsxRuntime.jsx("g", { className: "gridBody", children: /* @__PURE__ */ jsxRuntime.jsx("g", { className: "today", children: today }) });
5008
+ const verticalDividers = React.useMemo(() => {
5009
+ const dividers = [];
5010
+ for (let i = startColumnIndex; i <= endColumnIndex; i++) {
5011
+ const currentDate = getDate(i);
5012
+ const previousDate = i > startColumnIndex ? getDate(i - 1) : null;
5013
+ if (shouldDrawVerticalDivider(
5014
+ currentDate,
5015
+ previousDate,
5016
+ viewMode,
5017
+ isUnknownDates,
5018
+ i,
5019
+ startColumnIndex
5020
+ )) {
5021
+ console.log("Drawing divider at column", i, "date", currentDate);
5022
+ const x2 = additionalLeftSpace + columnWidth * i;
5023
+ console.log("debugging x:", x2);
5024
+ console.log("divider color", dividerColor);
5025
+ dividers.push(
5026
+ /* @__PURE__ */ jsxRuntime.jsx(
5027
+ "line",
5028
+ {
5029
+ x1: x2,
5030
+ x2,
5031
+ y1: 0,
5032
+ y2: ganttFullHeight,
5033
+ stroke: dividerColor,
5034
+ opacity: 0.15,
5035
+ strokeWidth: 5
5036
+ },
5037
+ `divider-${i}`
5038
+ )
5039
+ );
5040
+ }
5041
+ }
5042
+ return dividers;
5043
+ }, [
5044
+ additionalLeftSpace,
5045
+ columnWidth,
5046
+ ganttFullHeight,
5047
+ viewMode,
5048
+ isUnknownDates,
5049
+ startColumnIndex,
5050
+ endColumnIndex,
5051
+ getDate,
5052
+ dividerColor
5053
+ ]);
5054
+ console.log("verticalDividers :>> ", verticalDividers);
5055
+ return /* @__PURE__ */ jsxRuntime.jsxs("g", { className: "gridBody", children: [
5056
+ /* @__PURE__ */ jsxRuntime.jsx("g", { className: "today", children: today }),
5057
+ /* @__PURE__ */ jsxRuntime.jsx("g", { className: "verticalDividers", children: verticalDividers })
5058
+ ] });
4977
5059
  };
4978
5060
  const GridBody = React.memo(GridBodyInner);
4979
5061
  function isWeekend(dirtyDate) {
@@ -6918,7 +7000,6 @@
6918
7000
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
6919
7001
  width: (ganttTaskRootRef == null ? void 0 : ganttTaskRootRef.current) ? ganttTaskRootRef.current.clientWidth + ganttTaskRootRef.current.scrollLeft : fullSvgWidth
6920
7002
  };
6921
- console.log("containerStyle:>> ", containerStyle);
6922
7003
  const gridStyle = React.useMemo(
6923
7004
  () => ({
6924
7005
  height: Math.max(ganttFullHeight, minimumRowDisplayed * rowHeight),
@@ -11637,6 +11718,8 @@
11637
11718
  selectedTaskBackgroundColor: "rgba(252, 248, 227, 0.5)",
11638
11719
  taskDragColor: "#7474ff",
11639
11720
  todayColor: "rgba(252, 248, 227, 0.5)",
11721
+ dividerColor: "rgba(22, 16, 14, 0.27)",
11722
+ //new color
11640
11723
  contextMenuBoxShadow: "rgb(0 0 0 / 25%) 1px 1px 5px 1px",
11641
11724
  contextMenuBgColor: "#fff",
11642
11725
  contextMenuTextColor: "inherit"
@@ -12997,6 +13080,7 @@
12997
13080
  rtl,
12998
13081
  startDate,
12999
13082
  todayColor: colorStyles.todayColor,
13083
+ dividerColor: colorStyles.dividerColor,
13000
13084
  holidayBackgroundColor: colorStyles.holidayBackgroundColor,
13001
13085
  viewMode,
13002
13086
  startColumnIndex,
@@ -0,0 +1,2 @@
1
+ import { ViewMode } from "..";
2
+ export declare const shouldDrawVerticalDivider: (currentDate: Date, previousDate: Date | null, viewMode: ViewMode, isUnknownDates: boolean, columnIndex: number, startColumnIndex: number) => boolean;
@@ -89,6 +89,7 @@ export interface ColorStyles {
89
89
  taskDragColor: string;
90
90
  selectedTaskBackgroundColor: string;
91
91
  todayColor: string;
92
+ dividerColor: string;
92
93
  contextMenuBoxShadow: string;
93
94
  contextMenuBgColor: string;
94
95
  contextMenuTextColor: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thepocman/gantt-task-react",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "Fork of gantt-task-react with support for grouped tasks on a single row when collapsed",
5
5
  "author": "Adrian Bueno <adrianlbueno@users.noreply.github.com>",
6
6
  "homepage": "https://github.com/adrianlbueno/gantt-task-react#readme",